Skip to content

Commit 6b32f75

Browse files
committed
Use SystemContextMenu for iOS
1 parent 221717e commit 6b32f75

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.3.0
2+
3+
- Use SystemContextMenu for iOS
4+
15
## 2.2.1
26

37
- Changed to Flutter 3.24.0 and Dart 3.5 or higher

lib/src/text_input_dialog/ios_text_input_dialog.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class _IOSTextInputDialogState extends State<IOSTextInputDialog> {
129129
final prefixText = field.prefixText;
130130
final suffixText = field.suffixText;
131131
return CupertinoTextField(
132+
contextMenuBuilder: _contextMenuBuilder,
132133
controller: c,
133134
autofocus: i == 0,
134135
placeholder: field.hintText,
@@ -210,3 +211,19 @@ class _IOSTextInputDialogState extends State<IOSTextInputDialog> {
210211
return validations.isEmpty;
211212
}
212213
}
214+
215+
/// SystemContextMenu対応のcontextMenuBuilder
216+
///
217+
/// SystemContextMenuがサポートされている場合はそれを利用したネイティブUIで、
218+
/// それ以外の時は無指定の時と同じ挙動
219+
Widget _contextMenuBuilder(
220+
BuildContext context,
221+
EditableTextState editableTextState,
222+
) =>
223+
SystemContextMenu.isSupported(context)
224+
? SystemContextMenu.editableText(
225+
editableTextState: editableTextState,
226+
)
227+
: AdaptiveTextSelectionToolbar.editableText(
228+
editableTextState: editableTextState,
229+
);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: adaptive_dialog
22
description: Show alert dialog or modal action sheet adaptively according to platform.
3-
version: 2.2.1+2
3+
version: 2.3.0
44
repository: https://github.com/mono0926/adaptive_dialog
55
funding:
66
- https://github.com/sponsors/mono0926

0 commit comments

Comments
 (0)