Skip to content

Commit

Permalink
Handle dragging the base handle that makes it the extent on Apple pla…
Browse files Browse the repository at this point in the history
…tforms
  • Loading branch information
amantoux committed Dec 28, 2023
1 parent 182d80b commit 7a8b795
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/fleather/lib/src/widgets/text_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ class EditorTextSelectionOverlay {
}

void _updateSelectionOverlay() {
// Swap occurs when dragging start handle on Apple systems
final isAppleSwapped =
selectionDelegate.textEditingValue.selection.baseOffset >
selectionDelegate.textEditingValue.selection.extentOffset;
_selectionOverlay
// Update selection handle metrics.
..startHandleType = _chooseType(
Expand All @@ -210,16 +214,18 @@ class EditorTextSelectionOverlay {
TextSelectionHandleType.right,
)
// TODO: use _getStartGlyphHeight when adapted from flutter
..lineHeightAtStart = renderObject.preferredLineHeight(
selectionDelegate.textEditingValue.selection.base)
..lineHeightAtStart = renderObject.preferredLineHeight(isAppleSwapped
? selectionDelegate.textEditingValue.selection.extent
: selectionDelegate.textEditingValue.selection.base)
..endHandleType = _chooseType(
renderObject.textDirection,
TextSelectionHandleType.right,
TextSelectionHandleType.left,
)
// TODO: use _getEndGlyphHeight when adapted from flutter
..lineHeightAtEnd = renderObject.preferredLineHeight(
selectionDelegate.textEditingValue.selection.extent)
..lineHeightAtEnd = renderObject.preferredLineHeight(isAppleSwapped
? selectionDelegate.textEditingValue.selection.base
: selectionDelegate.textEditingValue.selection.extent)
// Update selection toolbar metrics.
..selectionEndpoints = renderObject.getEndpointsForSelection(_selection)
..toolbarLocation = renderObject.lastSecondaryTapDownPosition;
Expand Down

0 comments on commit 7a8b795

Please sign in to comment.