diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7916f12d8..975eafce7 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -151,6 +151,8 @@ PODS: - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS + - pointer_interceptor_ios (0.0.1): + - Flutter - PromisesObjC (2.4.0) - share_plus (0.0.1): - Flutter @@ -206,6 +208,7 @@ DEPENDENCIES: - mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) + - pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`) - share_plus (from `.symlinks/plugins/share_plus/ios`) - shared_preference_app_group (from `.symlinks/plugins/shared_preference_app_group/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) @@ -282,6 +285,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/package_info_plus/ios" path_provider_foundation: :path: ".symlinks/plugins/path_provider_foundation/darwin" + pointer_interceptor_ios: + :path: ".symlinks/plugins/pointer_interceptor_ios/ios" share_plus: :path: ".symlinks/plugins/share_plus/ios" shared_preference_app_group: @@ -336,6 +341,7 @@ SPEC CHECKSUMS: OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 + pointer_interceptor_ios: 9280618c0b2eeb80081a343924aa8ad756c21375 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad shared_preference_app_group: 46aee3873e1da581d4904bece9876596d7f66725 diff --git a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart index 5d000c19d..2d0a8c0c0 100644 --- a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart +++ b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart @@ -9,14 +9,12 @@ import 'package:flutter_typeahead/flutter_typeahead.dart'; class RestoreForm extends StatefulWidget { final GlobalKey formKey; final int currentPage; - final int lastPage; final List textEditingControllers; final AutovalidateMode autoValidateMode; const RestoreForm({ required this.formKey, required this.currentPage, - required this.lastPage, required this.textEditingControllers, required this.autoValidateMode, }); @@ -46,37 +44,47 @@ class RestoreFormPageState extends State { mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: List.generate(6, (index) { - final itemIndex = index + (6 * (widget.currentPage - 1)); - return TypeAheadFormField( - textFieldConfiguration: TextFieldConfiguration( - controller: widget.textEditingControllers[itemIndex], - textInputAction: TextInputAction.next, - onSubmitted: (text) { - widget.textEditingControllers[itemIndex].text = text; - if (itemIndex + 1 < focusNodes.length) { - focusNodes[itemIndex + 1].requestFocus(); - } - }, - focusNode: focusNodes[itemIndex], - decoration: InputDecoration( - labelText: "${itemIndex + 1}", - ), - style: theme.FieldTextStyle.textStyle, - ), - autovalidateMode: _autoValidateMode, - validator: (text) => _onValidate(context, text!), + final itemIndex = index + ((widget.currentPage - 1) * 6); + return TypeAheadField( + builder: (context, controller, focusNode) { + return TextFormField( + controller: widget.textEditingControllers[itemIndex], + textInputAction: TextInputAction.next, + focusNode: focusNodes[itemIndex], + decoration: InputDecoration( + labelText: "${itemIndex + 1}", + ), + onFieldSubmitted: (text) => _onSelected(itemIndex, text), + style: theme.FieldTextStyle.textStyle, + autovalidateMode: _autoValidateMode, + validator: (text) => _onValidate(context, text!), + ); + }, + controller: widget.textEditingControllers[itemIndex], + focusNode: focusNodes[itemIndex], suggestionsCallback: _getSuggestions, hideOnEmpty: true, hideOnLoading: true, - autoFlipDirection: true, - suggestionsBoxDecoration: const SuggestionsBoxDecoration( - color: Colors.white, - constraints: BoxConstraints( - minWidth: 180, - maxWidth: 180, - maxHeight: 180, - ), - ), + decorationBuilder: (context, child) { + return Row( + children: [ + Material( + type: MaterialType.card, + elevation: 4, + color: Colors.white, + borderRadius: BorderRadius.circular(8), + child: ConstrainedBox( + constraints: const BoxConstraints( + minWidth: 180, + maxWidth: 180, + maxHeight: 180, + ), + child: child, + ), + ), + ], + ); + }, itemBuilder: (context, suggestion) { return Container( decoration: const BoxDecoration( @@ -96,12 +104,9 @@ class RestoreFormPageState extends State { ), ); }, - onSuggestionSelected: (suggestion) { - widget.textEditingControllers[itemIndex].text = suggestion; - if (itemIndex + 1 < focusNodes.length) { - focusNodes[itemIndex + 1].requestFocus(); - } - }, + autoFlipDirection: true, + autoFlipMinHeight: 180, + onSelected: (suggestion) => _onSelected(itemIndex, suggestion), ); }), ), @@ -109,6 +114,18 @@ class RestoreFormPageState extends State { ); } + void _onSelected(int itemIndex, String text) { + final currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus && currentFocus.hasFocus) { + FocusManager.instance.primaryFocus?.unfocus(); + } + + widget.textEditingControllers[itemIndex + ((widget.currentPage - 1) * 6)].text = text; + if (itemIndex + 1 < focusNodes.length / 2) { + focusNodes[itemIndex + ((widget.currentPage - 1) * 6) + 1].requestFocus(); + } + } + String? _onValidate(BuildContext context, String text) { final texts = context.texts(); if (text.isEmpty) { diff --git a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form_page.dart b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form_page.dart index 269911a48..9f9bc45be 100644 --- a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form_page.dart +++ b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form_page.dart @@ -53,7 +53,6 @@ class RestoreFormPageState extends State { RestoreForm( formKey: _formKey, currentPage: widget.currentPage, - lastPage: widget.lastPage, textEditingControllers: textEditingControllers, autoValidateMode: _autoValidateMode, ), diff --git a/pubspec.lock b/pubspec.lock index 9d0c86b68..c7d633e98 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -577,10 +577,10 @@ packages: dependency: transitive description: name: flutter_keyboard_visibility - sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" + sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "6.0.0" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -714,12 +714,11 @@ packages: flutter_typeahead: dependency: "direct main" description: - path: "." - ref: a16aa4deeff1c5e96c6da46da31cb0533f838d8d - resolved-ref: a16aa4deeff1c5e96c6da46da31cb0533f838d8d - url: "https://github.com/breez/flutter_typeahead.git" - source: git - version: "4.0.0" + name: flutter_typeahead + sha256: d64712c65db240b1057559b952398ebb6e498077baeebf9b0731dade62438a6d + url: "https://pub.dev" + source: hosted + version: "5.2.0" flutter_web_plugins: dependency: transitive description: flutter @@ -1239,6 +1238,38 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + pointer_interceptor: + dependency: transitive + description: + name: pointer_interceptor + sha256: d0a8e660d1204eaec5bd34b34cc92174690e076d2e4f893d9d68c486a13b07c4 + url: "https://pub.dev" + source: hosted + version: "0.10.1+1" + pointer_interceptor_ios: + dependency: transitive + description: + name: pointer_interceptor_ios + sha256: "2e73c39452830adc4695757130676a39412a3b7f3c34e3f752791b5384770877" + url: "https://pub.dev" + source: hosted + version: "0.10.0+2" + pointer_interceptor_platform_interface: + dependency: transitive + description: + name: pointer_interceptor_platform_interface + sha256: "0597b0560e14354baeb23f8375cd612e8bd4841bf8306ecb71fcd0bb78552506" + url: "https://pub.dev" + source: hosted + version: "0.10.0+1" + pointer_interceptor_web: + dependency: transitive + description: + name: pointer_interceptor_web + sha256: a6237528b46c411d8d55cdfad8fcb3269fc4cbb26060b14bff94879165887d1e + url: "https://pub.dev" + source: hosted + version: "0.10.2" pointycastle: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f55e6b339..84b81f775 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,10 +54,7 @@ dependencies: flutter_rust_bridge: ^1.82.6 flutter_secure_storage: ^9.1.1 flutter_svg: ^2.0.10+1 - flutter_typeahead: - git: - url: https://github.com/breez/flutter_typeahead.git - ref: a16aa4deeff1c5e96c6da46da31cb0533f838d8d + flutter_typeahead: ^5.2.0 git_info: ^1.1.2 hex: ^0.2.0 http: ^1.2.1