Skip to content

Commit

Permalink
revert: Copying TapAndPanGestureRecognizer from TextField (#2128)
Browse files Browse the repository at this point in the history
This reverts commit 2937dc8.
  • Loading branch information
EchoEllet committed Dec 11, 2024
1 parent 1f6f749 commit 4d1cbf8
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 862 deletions.
6 changes: 2 additions & 4 deletions lib/src/editor/config/editor_config.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:ui' as ui;

import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:meta/meta.dart' show experimental;

Expand Down Expand Up @@ -338,12 +337,11 @@ class QuillEditorConfig {

// Returns whether gesture is handled
final bool Function(
TapDragDownDetails details, TextPosition Function(Offset offset))?
onTapDown;
TapDownDetails details, TextPosition Function(Offset offset))? onTapDown;

// Returns whether gesture is handled
final bool Function(
TapDragUpDetails details, TextPosition Function(Offset offset))? onTapUp;
TapUpDetails details, TextPosition Function(Offset offset))? onTapUp;

// Returns whether gesture is handled
final bool Function(
Expand Down
19 changes: 5 additions & 14 deletions lib/src/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
}
}

bool _isPositionSelected(TapDragUpDetails details) {
bool _isPositionSelected(TapUpDetails details) {
if (_state.controller.document.isEmpty()) {
return false;
}
Expand All @@ -471,7 +471,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
}

@override
void onTapDown(TapDragDownDetails details) {
void onTapDown(TapDownDetails details) {
if (_state.configurations.onTapDown != null) {
if (renderEditor != null &&
_state.configurations.onTapDown!(
Expand All @@ -492,7 +492,7 @@ class _QuillEditorSelectionGestureDetectorBuilder
}

@override
void onSingleTapUp(TapDragUpDetails details) {
void onSingleTapUp(TapUpDetails details) {
if (_state.configurations.onTapUp != null &&
renderEditor != null &&
_state.configurations.onTapUp!(
Expand Down Expand Up @@ -671,7 +671,6 @@ class RenderEditor extends RenderEditableContainerBox
Document document;
TextSelection selection;
bool _hasFocus = false;
bool get hasFocus => _hasFocus;
LayerLink _startHandleLayerLink;
LayerLink _endHandleLayerLink;

Expand Down Expand Up @@ -878,28 +877,20 @@ class RenderEditor extends RenderEditableContainerBox
}

Offset? _lastTapDownPosition;
Offset? _lastSecondaryTapDownPosition;

Offset? get lastSecondaryTapDownPosition => _lastSecondaryTapDownPosition;

// Used on Desktop (mouse and keyboard enabled platforms) as base offset
// for extending selection, either with combination of `Shift` + Click or
// by dragging
TextSelection? _extendSelectionOrigin;

void handleSecondaryTapDown(TapDownDetails details) {
_lastTapDownPosition = details.globalPosition;
_lastSecondaryTapDownPosition = details.globalPosition;
}

@override
void handleTapDown(TapDownDetails details) {
_lastTapDownPosition = details.globalPosition;
}

bool _isDragging = false;

void handleDragStart(TapDragStartDetails details) {
void handleDragStart(DragStartDetails details) {
_isDragging = true;

final newSelection = selectPositionAt(
Expand All @@ -912,7 +903,7 @@ class RenderEditor extends RenderEditableContainerBox
_extendSelectionOrigin = newSelection;
}

void handleDragEnd(TapDragEndDetails details) {
void handleDragEnd(DragEndDetails details) {
_isDragging = false;
onSelectionCompleted();
}
Expand Down
16 changes: 7 additions & 9 deletions lib/src/editor/raw_editor/raw_editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ class QuillRawEditorState extends EditorState

_selectionOverlay?.handlesVisible = _shouldShowSelectionHandles();

if (!_hasFocus) {
if (!_keyboardVisible) {
// This will show the keyboard for all selection changes on the
// editor, not just changes triggered by user gestures.
requestKeyboard();
Expand Down Expand Up @@ -1209,14 +1209,12 @@ class QuillRawEditorState extends EditorState
return true;
}

@override
void toggleToolbar([bool hideHandles = true]) {
final selectionOverlay = _selectionOverlay ??= _createSelectionOverlay();
if (selectionOverlay.handlesVisible) {
hideToolbar(hideHandles);
} else {
showToolbar();
}
void _replaceText(ReplaceTextIntent intent) {
userUpdateTextEditingValue(
intent.currentTextEditingValue
.replaced(intent.replacementRange, intent.replacementText),
intent.cause,
);
}

@override
Expand Down
Loading

0 comments on commit 4d1cbf8

Please sign in to comment.