Skip to content

Commit

Permalink
Fixes for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
angelosilvestre committed Oct 29, 2024
1 parent 9a56415 commit ec6830d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ class SuperEditorAndroidHandlesDocumentLayerBuilder implements SuperEditorLayerB
]);
},
caretWidth: caretWidth,
areSelectionHandlesAllowed: SuperEditorAndroidControlsScope.rootOf(context).areSelectionHandlesAllowed,
caretColor: caretColor,
);
}
Expand Down Expand Up @@ -1760,6 +1759,7 @@ class SuperEditorAndroidControlsOverlayManagerState extends State<SuperEditorAnd
link: _controlsController!.collapsedHandleFocalPoint,
leaderAnchor: Alignment.bottomCenter,
followerAnchor: Alignment.topCenter,
showWhenUnlinked: false,
// Use the offset to account for the invisible expanded touch region around the handle.
offset: -Offset(0, AndroidSelectionHandle.defaultTouchRegionExpansion.top) *
MediaQuery.devicePixelRatioOf(context),
Expand Down Expand Up @@ -1810,6 +1810,7 @@ class SuperEditorAndroidControlsOverlayManagerState extends State<SuperEditorAnd
link: _controlsController!.upstreamHandleFocalPoint,
leaderAnchor: Alignment.bottomLeft,
followerAnchor: Alignment.topRight,
showWhenUnlinked: false,
// Use the offset to account for the invisible expanded touch region around the handle.
offset:
-AndroidSelectionHandle.defaultTouchRegionExpansion.topRight * MediaQuery.devicePixelRatioOf(context),
Expand Down Expand Up @@ -1842,6 +1843,7 @@ class SuperEditorAndroidControlsOverlayManagerState extends State<SuperEditorAnd
link: _controlsController!.downstreamHandleFocalPoint,
leaderAnchor: Alignment.bottomRight,
followerAnchor: Alignment.topLeft,
showWhenUnlinked: false,
// Use the offset to account for the invisible expanded touch region around the handle.
offset:
-AndroidSelectionHandle.defaultTouchRegionExpansion.topLeft * MediaQuery.devicePixelRatioOf(context),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class AndroidHandlesDocumentLayer extends DocumentLayoutLayerStatefulWidget {
required this.changeSelection,
this.caretWidth = 2,
this.caretColor,
this.areSelectionHandlesAllowed,
this.showDebugPaint = false,
});

Expand All @@ -174,9 +173,6 @@ class AndroidHandlesDocumentLayer extends DocumentLayoutLayerStatefulWidget {
/// is retrieved from the root [SuperEditorAndroidControlsController].
final Color? caretColor;

/// {@macro are_selection_handles_allowed}
final ValueListenable<bool>? areSelectionHandlesAllowed;

final bool showDebugPaint;

@override
Expand Down Expand Up @@ -211,11 +207,13 @@ class AndroidControlsDocumentLayerState
_controlsController!.shouldCaretBlink.removeListener(_onBlinkModeChange);
_controlsController!.caretJumpToOpaqueSignal.removeListener(_caretJumpToOpaque);
_controlsController!.shouldShowCollapsedHandle.removeListener(_onShouldShowCollapsedHandleChange);
_controlsController!.areSelectionHandlesAllowed.removeListener(_onSelectionHandlesAllowedChange);
}

_controlsController = SuperEditorAndroidControlsScope.rootOf(context);
_controlsController!.shouldCaretBlink.addListener(_onBlinkModeChange);
_controlsController!.caretJumpToOpaqueSignal.addListener(_caretJumpToOpaque);
_controlsController!.areSelectionHandlesAllowed.addListener(_onSelectionHandlesAllowedChange);

/// Listen for changes about whether we want to show the collapsed handle
/// or whether we want to show expanded handles for a selection. We listen to
Expand All @@ -242,6 +240,7 @@ class AndroidControlsDocumentLayerState
widget.selection.removeListener(_onSelectionChange);
_controlsController?.shouldCaretBlink.removeListener(_onBlinkModeChange);
_controlsController!.shouldShowCollapsedHandle.removeListener(_onShouldShowCollapsedHandleChange);
_controlsController!.areSelectionHandlesAllowed.removeListener(_onSelectionHandlesAllowedChange);

_caretBlinkController.dispose();
super.dispose();
Expand Down Expand Up @@ -315,6 +314,12 @@ class AndroidControlsDocumentLayerState
});
}

void _onSelectionHandlesAllowedChange() {
setState(() {
//
});
}

@override
DocumentSelectionLayout? computeLayoutDataWithDocumentLayout(
BuildContext contentLayersContext, BuildContext documentContext, DocumentLayout documentLayout) {
Expand All @@ -323,7 +328,7 @@ class AndroidControlsDocumentLayerState
return null;
}

if (widget.areSelectionHandlesAllowed?.value == false) {
if (_controlsController!.areSelectionHandlesAllowed.value == false) {
// We don't want to show any selection handles.
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ extension SpellingAndGrammarEditorExtensions on Editor {
),
),
),
const ClearComposingRegionRequest(),
]);
}
}
Expand Down

0 comments on commit ec6830d

Please sign in to comment.