Skip to content

Commit

Permalink
revert: mobile magnifier feature (#2026)
Browse files Browse the repository at this point in the history
This reverts commit af691e6.
  • Loading branch information
EchoEllet committed Jan 7, 2025
1 parent 3ca00f6 commit cfeac28
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 277 deletions.
20 changes: 1 addition & 19 deletions lib/src/editor/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:math' as math;

import 'package:flutter/cupertino.dart'
show CupertinoTheme, cupertinoTextSelectionControls;
import 'package:flutter/foundation.dart' show ValueListenable, kIsWeb;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
Expand All @@ -16,7 +16,6 @@ import '../document/nodes/container.dart' as container_node;
import '../document/nodes/leaf.dart';
import 'config/editor_config.dart';
import 'embed/embed_editor_builder.dart';
import 'magnifier/magnifier_platform_support.dart';
import 'raw_editor/config/raw_editor_config.dart';
import 'raw_editor/raw_editor.dart';
import 'widgets/box.dart';
Expand Down Expand Up @@ -320,7 +319,6 @@ class QuillEditorState extends State<QuillEditor>
onScribbleActivated: configurations.onScribbleActivated,
scribbleAreaInsets: configurations.scribbleAreaInsets,
readOnlyMouseCursor: configurations.readOnlyMouseCursor,
magnifierConfiguration: configurations.magnifierConfiguration,
textInputAction: configurations.textInputAction,
onPerformAction: configurations.onPerformAction,
),
Expand Down Expand Up @@ -448,7 +446,6 @@ class _QuillEditorSelectionGestureDetectorBuilder
SelectionChangedCause.longPress,
);
}
editor?.updateMagnifier(details.globalPosition);
}

bool _isPositionSelected(TapDragUpDetails details) {
Expand Down Expand Up @@ -582,8 +579,6 @@ class _QuillEditorSelectionGestureDetectorBuilder
Feedback.forLongPress(_state.context);
}
}

_showMagnifierIfSupported(details.globalPosition);
}

@override
Expand All @@ -602,21 +597,8 @@ class _QuillEditorSelectionGestureDetectorBuilder
}
}
}
_hideMagnifierIfSupported();
super.onSingleLongTapEnd(details);
}

void _showMagnifierIfSupported(Offset positionToShow) {
if (magnifierSupported) {
editor?.showMagnifier(positionToShow);
}
}

void _hideMagnifierIfSupported() {
if (magnifierSupported) {
editor?.hideMagnifier();
}
}
}

/// Signature for the callback that reports when the user changes the selection
Expand Down
4 changes: 0 additions & 4 deletions lib/src/editor/magnifier/magnifier_platform_support.dart

This file was deleted.

106 changes: 0 additions & 106 deletions lib/src/editor/magnifier/text_selection_magnifier_ext.dart

This file was deleted.

6 changes: 0 additions & 6 deletions lib/src/editor/raw_editor/config/raw_editor_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class QuillRawEditorConfig {
this.onScribbleActivated,
this.scribbleAreaInsets,
this.readOnlyMouseCursor = SystemMouseCursors.text,
@experimental this.magnifierConfiguration,
this.onPerformAction,
@experimental this.customLeadingBuilder,
});
Expand Down Expand Up @@ -402,11 +401,6 @@ class QuillRawEditorConfig {
/// Optional insets for the scribble area.
final EdgeInsets? scribbleAreaInsets;

/// This feature is currently experimental and only supported
/// on **Android** and **iOS**.
@experimental
final TextMagnifierConfiguration? magnifierConfiguration;

/// Called when a text input action is performed.
final void Function(TextInputAction action)? onPerformAction;
}
12 changes: 0 additions & 12 deletions lib/src/editor/raw_editor/raw_editor.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/widgets.dart';
import 'package:meta/meta.dart';

import '../../common/structs/offset_value.dart';
import '../../controller/quill_controller.dart';
Expand Down Expand Up @@ -77,15 +76,4 @@ abstract class EditorState extends State<QuillRawEditor>
bool showToolbar();

void requestKeyboard();

@experimental
void showMagnifier(Offset positionToShow);

@experimental
void updateMagnifier(Offset positionToShow);

@experimental
void hideMagnifier();

void toggleToolbar([bool hideHandles = true]);
}
74 changes: 18 additions & 56 deletions lib/src/editor/raw_editor/raw_editor_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show RenderAbstractViewport;
import 'package:flutter/scheduler.dart' show SchedulerBinding;
import 'package:flutter/services.dart'
show Clipboard, HardwareKeyboard, SystemChannels, TextInputControl;
import 'package:flutter/services.dart';
import 'package:flutter_keyboard_visibility_temp_fork/flutter_keyboard_visibility_temp_fork.dart'
show KeyboardVisibilityController;

Expand Down Expand Up @@ -509,13 +508,7 @@ class QuillRawEditorState extends EditorState
final oldSelection = controller.selection;
controller.updateSelection(selection, ChangeSource.local);

if (_selectionOverlay == null) {
_selectionOverlay = _createSelectionOverlay();
} else {
_selectionOverlay!.update(textEditingValue);
}
_selectionOverlay?.handlesVisible = _shouldShowSelectionHandles();
_selectionOverlay?.showHandles();

if (!_hasFocus) {
// This will show the keyboard for all selection changes on the
Expand Down Expand Up @@ -938,7 +931,6 @@ class QuillRawEditorState extends EditorState

@override
void dispose() {
hideMagnifier();
closeConnectionIfNeeded();
_keyboardVisibilitySubscription?.cancel();
HardwareKeyboard.instance.removeHandler(_hardwareKeyboardEvent);
Expand Down Expand Up @@ -1039,38 +1031,32 @@ class QuillRawEditorState extends EditorState

void _updateOrDisposeSelectionOverlayIfNeeded() {
if (_selectionOverlay != null) {
if (_hasFocus) {
_selectionOverlay!.update(textEditingValue);
} else {
if (!_hasFocus || textEditingValue.selection.isCollapsed) {
_selectionOverlay!.dispose();
_selectionOverlay = null;
} else {
_selectionOverlay!.update(textEditingValue);
}
} else if (_hasFocus) {
_selectionOverlay = _createSelectionOverlay();
_selectionOverlay = EditorTextSelectionOverlay(
value: textEditingValue,
context: context,
debugRequiredFor: widget,
startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink,
renderObject: renderEditor,
selectionCtrls: widget.config.selectionCtrls,
selectionDelegate: this,
clipboardStatus: _clipboardStatus,
contextMenuBuilder: widget.config.contextMenuBuilder == null
? null
: (context) => widget.config.contextMenuBuilder!(context, this),
);
_selectionOverlay!.handlesVisible = _shouldShowSelectionHandles();
_selectionOverlay!.showHandles();
}
}

EditorTextSelectionOverlay _createSelectionOverlay() {
return EditorTextSelectionOverlay(
value: textEditingValue,
context: context,
debugRequiredFor: widget,
startHandleLayerLink: _startHandleLayerLink,
endHandleLayerLink: _endHandleLayerLink,
renderObject: renderEditor,
selectionCtrls: widget.config.selectionCtrls,
selectionDelegate: this,
clipboardStatus: _clipboardStatus,
contextMenuBuilder: widget.config.contextMenuBuilder == null
? null
: (context) => widget.config.contextMenuBuilder!(context, this),
magnifierConfiguration: widget.config.magnifierConfiguration ??
TextMagnifier.adaptiveMagnifierConfiguration,
);
}

void _handleFocusChanged() {
if (dirty) {
requestKeyboard();
Expand Down Expand Up @@ -1288,28 +1274,4 @@ class QuillRawEditorState extends EditorState

@override
bool get shareEnabled => false;

@override
void hideMagnifier() {
if (_selectionOverlay == null) return;
_selectionOverlay?.hideMagnifier();
}

@override
void showMagnifier(ui.Offset positionToShow) {
if (_hasFocus == false) return;
if (_selectionOverlay == null) return;
final position = renderEditor.getPositionForOffset(positionToShow);
if (_selectionOverlay!.isMagnifierVisible) {
_selectionOverlay!
.updateMagnifier(position, positionToShow, renderEditor);
} else {
_selectionOverlay!.showMagnifier(position, positionToShow, renderEditor);
}
}

@override
void updateMagnifier(ui.Offset positionToShow) {
showMagnifier(positionToShow);
}
}
4 changes: 0 additions & 4 deletions lib/src/editor/widgets/text/text_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -984,10 +984,6 @@ class RenderEditableTextLine extends RenderEditableBox {
_getBoxes(TextSelection(baseOffset: 0, extentOffset: line.length - 1))
.where((element) => element.top < lineDy && element.bottom > lineDy)
.toList(growable: false);
if (lineBoxes.isEmpty) {
// Empty line, line box is empty
return TextRange.collapsed(position.offset);
}
return TextRange(
start: getPositionForOffset(
Offset(lineBoxes.first.left, lineDy),
Expand Down
Loading

0 comments on commit cfeac28

Please sign in to comment.