diff --git a/lib/features/settings/widgets/settings_input_dialog.dart b/lib/features/settings/widgets/settings_input_dialog.dart index 96c93499c..cdade2a46 100644 --- a/lib/features/settings/widgets/settings_input_dialog.dart +++ b/lib/features/settings/widgets/settings_input_dialog.dart @@ -48,7 +48,47 @@ class SettingsInputDialog extends HookConsumerWidget with PresLogger { mainAxisSize: MainAxisSize.min, children: [ if (possibleValues != null) - AutocompleteField(initialValue: initialValue.toString(), options: possibleValues!.map((e) => e.toString()).toList()) + // AutocompleteField(initialValue: initialValue.toString(), options: possibleValues!.map((e) => e.toString()).toList()) + TypeAheadField( + controller: textController, + builder: (context, controller, focusNode) { + return TextField( + controller: controller, + focusNode: focusNode, + textDirection: TextDirection.ltr, + autofocus: true, + // decoration: InputDecoration( + // // border: OutlineInputBorder(), + // // labelText: 'City', + // ) + ); + }, + // Callback to fetch suggestions based on user input + suggestionsCallback: (pattern) async { + final items = possibleValues!.map((p) => p.toString()); + var res = items.where((suggestion) => suggestion.toLowerCase().contains(pattern.toLowerCase())).toList(); + if (res.length <= 1) res = [pattern, ...items.where((s) => s != pattern)]; + return res; + }, + // Widget to build each suggestion in the list + itemBuilder: (context, suggestion) { + return ListTile( + contentPadding: const EdgeInsets.symmetric(vertical: 3, horizontal: 10), // Minimize ListTile padding + minTileHeight: 0, + title: Text( + suggestion, + textDirection: TextDirection.ltr, + style: Theme.of(context).textTheme.bodySmall, + ), + ); + }, + // Callback when a suggestion is selected + onSelected: (suggestion) { + // Handle the selected suggestion + print('Selected: $suggestion'); + textController.text = suggestion.toString(); + }, + ) else CustomTextFormField( controller: textController, diff --git a/pubspec.lock b/pubspec.lock index 64df3b569..bd665d1af 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -630,6 +630,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + flutter_typeahead: + dependency: "direct main" + description: + name: flutter_typeahead + sha256: d64712c65db240b1057559b952398ebb6e498077baeebf9b0731dade62438a6d + url: "https://pub.dev" + source: hosted + version: "5.2.0" flutter_web_plugins: dependency: transitive description: flutter @@ -1188,6 +1196,38 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + pointer_interceptor: + dependency: transitive + description: + name: pointer_interceptor + sha256: "57210410680379aea8b1b7ed6ae0c3ad349bfd56fe845b8ea934a53344b9d523" + url: "https://pub.dev" + source: hosted + version: "0.10.1+2" + pointer_interceptor_ios: + dependency: transitive + description: + name: pointer_interceptor_ios + sha256: a6906772b3205b42c44614fcea28f818b1e5fdad73a4ca742a7bd49818d9c917 + url: "https://pub.dev" + source: hosted + version: "0.10.1" + 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: "7a7087782110f8c1827170660b09f8aa893e0e9a61431dbbe2ac3fc482e8c044" + url: "https://pub.dev" + source: hosted + version: "0.10.2+1" pool: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 257243fe5..c9f275dfa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -95,6 +95,7 @@ dependencies: protobuf: ^3.1.0 grpc: ^3.2.4 dynamic_color: ^1.7.0 + flutter_typeahead: ^5.0.1 dev_dependencies: flutter_test: sdk: flutter