Skip to content

Commit

Permalink
Use SystemContextMenu for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mono0926 committed Nov 27, 2024
1 parent 221717e commit 6b32f75
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.3.0

- Use SystemContextMenu for iOS

## 2.2.1

- Changed to Flutter 3.24.0 and Dart 3.5 or higher
Expand Down
17 changes: 17 additions & 0 deletions lib/src/text_input_dialog/ios_text_input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class _IOSTextInputDialogState extends State<IOSTextInputDialog> {
final prefixText = field.prefixText;
final suffixText = field.suffixText;
return CupertinoTextField(
contextMenuBuilder: _contextMenuBuilder,
controller: c,
autofocus: i == 0,
placeholder: field.hintText,
Expand Down Expand Up @@ -210,3 +211,19 @@ class _IOSTextInputDialogState extends State<IOSTextInputDialog> {
return validations.isEmpty;
}
}

/// SystemContextMenu対応のcontextMenuBuilder
///
/// SystemContextMenuがサポートされている場合はそれを利用したネイティブUIで、
/// それ以外の時は無指定の時と同じ挙動
Widget _contextMenuBuilder(
BuildContext context,
EditableTextState editableTextState,
) =>
SystemContextMenu.isSupported(context)
? SystemContextMenu.editableText(
editableTextState: editableTextState,
)
: AdaptiveTextSelectionToolbar.editableText(
editableTextState: editableTextState,
);
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: adaptive_dialog
description: Show alert dialog or modal action sheet adaptively according to platform.
version: 2.2.1+2
version: 2.3.0
repository: https://github.com/mono0926/adaptive_dialog
funding:
- https://github.com/sponsors/mono0926
Expand Down

0 comments on commit 6b32f75

Please sign in to comment.