opt dyn/reply text menu

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-07-16 20:25:21 +08:00
parent f7cd1aa502
commit 177493fe38
31 changed files with 550 additions and 268 deletions

View File

@@ -0,0 +1,45 @@
diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart
index b1ae878f2cc..8a7540350ef 100644
--- a/packages/flutter/lib/src/widgets/editable_text.dart
+++ b/packages/flutter/lib/src/widgets/editable_text.dart
@@ -5046,7 +5046,9 @@ class EditableTextState extends State<EditableText>
void userUpdateTextEditingValue(TextEditingValue value, SelectionChangedCause? cause) {
// Compare the current TextEditingValue with the pre-format new
// TextEditingValue value, in case the formatter would reject the change.
- final shouldShowCaret = widget.readOnly ? _value.selection != value.selection : _value != value;
+ final shouldShowCaret =
+ cause != SelectionChangedCause.drag &&
+ (widget.readOnly ? _value.selection != value.selection : _value != value);
if (shouldShowCaret) {
_scheduleShowCaretOnScreen(withAnimation: true);
}
@@ -5709,7 +5711,7 @@ class EditableTextState extends State<EditableText>
PasteTextIntent: _makeOverridable(_PasteSelectionAction(this)),
TransposeCharactersIntent: _makeOverridable(_transposeCharactersAction),
- EditableTextTapOutsideIntent: _makeOverridable(_EditableTextTapOutsideAction()),
+ EditableTextTapOutsideIntent: _makeOverridable(_EditableTextTapOutsideAction(this)),
EditableTextTapUpOutsideIntent: _makeOverridable(_EditableTextTapUpOutsideAction()),
};
@@ -6775,10 +6777,19 @@ class _WebClipboardStatusNotifier extends ClipboardStatusNotifier {
}
class _EditableTextTapOutsideAction extends ContextAction<EditableTextTapOutsideIntent> {
- _EditableTextTapOutsideAction();
+ _EditableTextTapOutsideAction(this.state);
+
+ final EditableTextState state;
@override
void invoke(EditableTextTapOutsideIntent intent, [BuildContext? context]) {
+ state.hideToolbar();
+ final controller = state.widget.controller;
+ final selection = controller.value.selection;
+ if (!selection.isCollapsed) {
+ controller.selection = TextSelection.collapsed(offset: selection.end);
+ }
+ return;
// The focus dropping behavior is only present on desktop platforms.
switch (defaultTargetPlatform) {
case TargetPlatform.android:

View File

@@ -35,6 +35,8 @@ $FABPatch = "lib/scripts/fab.patch"
$SelectableRegionSelectionPatch = "lib/scripts/selectable_region.patch"
$EditableTextPatch = "lib/scripts/editable_text.patch"
# TODO: remove
# https://github.com/flutter/flutter/pull/183261
$SelectableRegionPatch = "lib/scripts/null_safety_for_selectable_region.patch"
@@ -66,7 +68,8 @@ $picks = @()
$reverts = @()
$patches = @($ModalBarrierPatch, $TextSelectionPatch, $MouseCursorPatch,
$ImageAnimPatch, $LayoutBuilderPatch, $NavigationDrawerPatch,
$PopupMenuPatch, $FABPatch, $SelectableRegionPatch, $SelectableRegionSelectionPatch)
$PopupMenuPatch, $FABPatch, $SelectableRegionPatch, $SelectableRegionSelectionPatch,
$EditableTextPatch)
switch ($platform.ToLower()) {
"android" {

View File

@@ -1,8 +1,17 @@
diff --git a/packages/flutter/lib/src/widgets/selectable_region.dart b/packages/flutter/lib/src/widgets/selectable_region.dart
index 59de8bae20b..07ac6981c78 100644
index 59de8bae20b..a1b6ea5651e 100644
--- a/packages/flutter/lib/src/widgets/selectable_region.dart
+++ b/packages/flutter/lib/src/widgets/selectable_region.dart
@@ -2822,7 +2822,10 @@ abstract class MultiSelectableSelectionContainerDelegate extends SelectionContai
@@ -1957,6 +1957,8 @@ class SelectableRegionState extends State<SelectableRegion>
// the region on non-web platforms.
if (kIsWeb) {
_focusNode.unfocus();
+ } else {
+ clearSelection();
}
},
child: CompositedTransformTarget(
@@ -2822,7 +2824,10 @@ abstract class MultiSelectableSelectionContainerDelegate extends SelectionContai
return null;
}
final buffer = StringBuffer();