forked from flutter/packages
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverts "Native ios context menu (#143002)" (#148237)
Reverts: flutter/flutter#143002 Initiated by: cbracken Reason for reverting: unresolved docs links. See failure here: https://ci.chromium.org/ui/p/flutter/builders/prod/Linux%20docs_test/16540/overview ``` dartdoc:stdout: Generating docs for package flutter... dartdoc:stderr: error: unresolved doc reference [TextInput.showSystemContextMenu] dartdoc:stderr: from widgets.MediaQueryData.supportsShowingSystemContextMenu: (file:///b/s/w/ir/x/w/flutter/packages/flutt Original PR Author: justinmc Reviewed By: {Renzo-Olivares, hellohuanlin} This change reverts the following previous change: In order to work around the fact that iOS 15 shows a notification on pressing Flutter's paste button (flutter/flutter#103163), this PR allows showing the iOS system context menu in text fields. <img width="385" alt="Screenshot 2024-02-06 at 11 52 25 AM" src="https://github.com/flutter/flutter/assets/389558/d82e18ee-b8a3-4082-9225-cf47fa7f3674"> It is currently opt-in, which a user would typically do like this (also in example system_context_menu.0.dart): ```dart contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) { // If supported, show the system context menu. if (SystemContextMenu.isSupported(context)) { return SystemContextMenu.editableText( editableTextState: editableTextState, ); } // Otherwise, show the flutter-rendered context menu for the current // platform. return AdaptiveTextSelectionToolbar.editableText( editableTextState: editableTextState, ); }, ``` Requires engine PR flutter/engine#50095. ## API changes ### SystemContextMenu A widget that shows the system context menu when built, and removes it when disposed. The main high-level way that most users would use this PR. Only works on later versions of iOS. ### SystemContextMenuController Used under the hood to hide and show a system context menu. There can only be one visible at a time. ### MediaQuery.supportsShowingSystemContextMenu Sent by the iOS embedder to tell the framework whether or not the platform supports showing the system context menu. That way the framework, or Flutter developers, can decide to show a different menu. ### `flutter/platform ContextMenu.showSystemContextMenu` Sent by the framework to show the menu at a given `targetRect`, which is the current selection rect. ### `flutter/platform ContextMenu.hideSystemContextMenu` Sent by the framework to hide the menu. Typically not needed, because the platform will hide the menu when the user taps outside of it and after the user presses a button, but it handles edge cases where the user programmatically rebuilds the context menu, for example. ### `flutter/platform System.onDismissSystemContextMenu` Sent by the iOS embedder to indicate that the system context menu has been hidden by the system, such as when the user taps outside of the menu. This is useful when there are multiple instances of SystemContextMenu, such as with multiple text fields.
- Loading branch information
1 parent
1255435
commit 14d88ee
Showing
13 changed files
with
43 additions
and
1,321 deletions.
There are no files selected for viewing
41 changes: 0 additions & 41 deletions
41
examples/api/lib/widgets/system_context_menu/system_context_menu.0.dart
This file was deleted.
Oops, something went wrong.
67 changes: 0 additions & 67 deletions
67
examples/api/test/widgets/system_context_menu/system_context_menu.0_test.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.