From a7a7f4c252c1257fbf4ae1aae4d52b2fa963b3fe Mon Sep 17 00:00:00 2001 From: ggurdin Date: Wed, 23 Oct 2024 12:40:38 -0400 Subject: [PATCH] switch form dropdowns to new wigget type to make options appear below the dropdown --- assets/l10n/intl_en.arb | 7 ++++--- .../conversation_bot_mode_dynamic_zone.dart | 4 ++++ .../conversation_bot_mode_select.dart | 20 +++---------------- .../conversation_bot_settings_form.dart | 12 +++++------ .../space/language_level_dropdown.dart | 8 ++------ pubspec.lock | 18 ++++++++--------- pubspec.yaml | 1 + 7 files changed, 29 insertions(+), 41 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 51ab9d1d7..d7eb4b149 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4016,9 +4016,9 @@ "conversationBotModeSelectOption_storyGame": "Story Game", "conversationBotDiscussionZone_title": "Discussion Settings", "conversationBotDiscussionZone_discussionTopicLabel": "Discussion Topic", - "conversationBotDiscussionZone_discussionTopicPlaceholder": "Set Discussion Topic", + "conversationBotDiscussionZone_discussionTopicPlaceholder": "Set discussion topic", "conversationBotDiscussionZone_discussionKeywordsLabel": "Discussion Keywords", - "conversationBotDiscussionZone_discussionKeywordsPlaceholder": "Set Discussion Keywords", + "conversationBotDiscussionZone_discussionKeywordsPlaceholder": "Set discussion keywords", "conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion", "conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Send discussion prompt on a schedule", "conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts", @@ -4364,5 +4364,6 @@ "selectBotLanguage": "Select bot language", "chooseVoice": "Choose a voice", "enterLanguageLevel": "Please enter a language level", - "enterDiscussionTopic": "Please enter a discussion topic" + "enterDiscussionTopic": "Please enter a discussion topic", + "selectBotChatMode": "Select chat mode" } \ No newline at end of file diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart index e8f33fe3d..5a3082610 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart @@ -27,6 +27,8 @@ class ConversationBotModeDynamicZone extends StatelessWidget { decoration: InputDecoration( hintText: L10n.of(context)! .conversationBotDiscussionZone_discussionTopicPlaceholder, + contentPadding: + const EdgeInsets.symmetric(horizontal: 28.0, vertical: 12.0), ), controller: discussionTopicController, validator: (value) => enabled && @@ -44,6 +46,7 @@ class ConversationBotModeDynamicZone extends StatelessWidget { decoration: InputDecoration( hintText: L10n.of(context)! .conversationBotDiscussionZone_discussionKeywordsPlaceholder, + contentPadding: const EdgeInsets.symmetric(horizontal: 28.0), ), controller: discussionKeywordsController, enabled: enabled, @@ -58,6 +61,7 @@ class ConversationBotModeDynamicZone extends StatelessWidget { decoration: InputDecoration( hintText: L10n.of(context)! .conversationBotCustomZone_customSystemPromptPlaceholder, + contentPadding: const EdgeInsets.symmetric(horizontal: 28.0), ), validator: (value) => enabled && botOptions.mode == BotMode.custom && diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart index 3d893f078..408e6560e 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart @@ -1,3 +1,4 @@ +import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:fluffychat/pangea/constants/bot_mode.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -26,23 +27,8 @@ class ConversationBotModeSelect extends StatelessWidget { // L10n.of(context)!.conversationBotModeSelectOption_storyGame, }; - String? mode = initialMode; - if (!options.containsKey(initialMode)) { - mode = null; - } - - return DropdownButtonFormField( - // Initial Value - hint: Text( - options[mode ?? BotMode.discussion]!, - overflow: TextOverflow.clip, - textAlign: TextAlign.center, - ), - // ), - isExpanded: true, - // Down Arrow Icon - icon: const Icon(Icons.keyboard_arrow_down), - // Array list of items + return DropdownButtonFormField2( + hint: Text(L10n.of(context)!.selectBotChatMode), items: [ for (final entry in options.entries) DropdownMenuItem( diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_settings_form.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_settings_form.dart index 195d35801..6b5535bc4 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_settings_form.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_settings_form.dart @@ -1,3 +1,4 @@ +import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:fluffychat/pangea/models/bot_options_model.dart'; import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart'; import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_mode_select.dart'; @@ -36,8 +37,10 @@ class ConversationBotSettingsForm extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - DropdownButtonFormField( - // Initial Value + DropdownButtonFormField2( + dropdownStyleData: const DropdownStyleData( + padding: EdgeInsets.zero, + ), hint: Text( L10n.of(context)!.selectBotLanguage, overflow: TextOverflow.clip, @@ -45,7 +48,6 @@ class ConversationBotSettingsForm extends StatelessWidget { ), value: botOptions.targetLanguage, isExpanded: true, - icon: const Icon(Icons.keyboard_arrow_down), items: MatrixState.pangeaController.pLanguageStore.targetOptions .map((language) { return DropdownMenuItem( @@ -60,8 +62,7 @@ class ConversationBotSettingsForm extends StatelessWidget { onChanged: enabled ? onUpdateBotLanguage : null, ), const SizedBox(height: 12), - DropdownButtonFormField( - // Initial Value + DropdownButtonFormField2( hint: Text( L10n.of(context)!.chooseVoice, overflow: TextOverflow.clip, @@ -69,7 +70,6 @@ class ConversationBotSettingsForm extends StatelessWidget { ), value: botOptions.targetVoice, isExpanded: true, - icon: const Icon(Icons.keyboard_arrow_down), items: const [], onChanged: enabled ? onUpdateBotVoice : null, ), diff --git a/lib/pangea/widgets/space/language_level_dropdown.dart b/lib/pangea/widgets/space/language_level_dropdown.dart index 0b238485a..a8c618bc1 100644 --- a/lib/pangea/widgets/space/language_level_dropdown.dart +++ b/lib/pangea/widgets/space/language_level_dropdown.dart @@ -1,3 +1,4 @@ +import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:fluffychat/pangea/constants/language_constants.dart'; import 'package:fluffychat/pangea/utils/language_level_copy.dart'; import 'package:flutter/material.dart'; @@ -19,18 +20,13 @@ class LanguageLevelDropdown extends StatelessWidget { @override Widget build(BuildContext context) { - return DropdownButtonFormField( - // Initial Value + return DropdownButtonFormField2( hint: Text( L10n.of(context)!.selectLanguageLevel, overflow: TextOverflow.clip, textAlign: TextAlign.center, ), value: initialLevel, - isExpanded: true, - // Down Arrow Icon - icon: const Icon(Icons.keyboard_arrow_down), - // Array list of items items: LanguageLevelType.allInts.map((int levelOption) { return DropdownMenuItem( value: levelOption, diff --git a/pubspec.lock b/pubspec.lock index 0a0e1ed23..99543db43 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -345,6 +345,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + dropdown_button2: + dependency: "direct main" + description: + name: dropdown_button2 + sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1 + url: "https://pub.dev" + source: hosted + version: "2.3.9" dynamic_color: dependency: "direct main" description: @@ -2642,14 +2650,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.1" - visibility_detector: - dependency: transitive - description: - name: visibility_detector - sha256: "15c54a459ec2c17b4705450483f3d5a2858e733aee893dcee9d75fd04814940d" - url: "https://pub.dev" - source: hosted - version: "0.3.3" vm_service: dependency: transitive description: @@ -2723,7 +2723,7 @@ packages: source: hosted version: "1.2.0" win32: - dependency: "direct overridden" + dependency: transitive description: name: win32 sha256: "015002c060f1ae9f41a818f2d5640389cc05283e368be19dc8d77cecb43c40c9" diff --git a/pubspec.yaml b/pubspec.yaml index 1af58cbb5..1dc0fcc8f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -113,6 +113,7 @@ dependencies: android_intent_plus: ^5.2.0 country_picker: ^2.0.25 csv: ^6.0.0 + dropdown_button2: ^2.3.9 fl_chart: ^0.67.0 firebase_analytics: ^11.0.1 firebase_core: ^3.1.0