From 3af3f78d938faadb5dc07c9e6402cd18c917fa1d Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:24:30 -0500 Subject: [PATCH] chore: reduce padding in learning setting dropdowns (#1772) --- .../pages/settings_learning_view.dart | 6 +- .../widgets/country_picker_tile.dart | 57 +++++++++++-------- .../widgets/p_language_dropdown.dart | 3 +- .../widgets/p_settings_switch_list_tile.dart | 1 + 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/lib/pangea/learning_settings/pages/settings_learning_view.dart b/lib/pangea/learning_settings/pages/settings_learning_view.dart index 5aeb99f1a..615e8c873 100644 --- a/lib/pangea/learning_settings/pages/settings_learning_view.dart +++ b/lib/pangea/learning_settings/pages/settings_learning_view.dart @@ -47,7 +47,10 @@ class SettingsLearningView extends StatelessWidget { child: Form( key: controller.formKey, child: Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.symmetric( + vertical: 16.0, + horizontal: 8.0, + ), child: Column( children: [ Expanded( @@ -186,6 +189,7 @@ class SettingsLearningView extends StatelessWidget { L10n.of(context).publicProfileDesc, ), activeColor: AppConfig.activeToggleColor, + contentPadding: EdgeInsets.zero, ), ], ), diff --git a/lib/pangea/learning_settings/widgets/country_picker_tile.dart b/lib/pangea/learning_settings/widgets/country_picker_tile.dart index 63235a074..de3ae56ae 100644 --- a/lib/pangea/learning_settings/widgets/country_picker_tile.dart +++ b/lib/pangea/learning_settings/widgets/country_picker_tile.dart @@ -30,13 +30,19 @@ class CountryPickerDropdownState extends State { @override Widget build(BuildContext context) { + final countries = CountryService().getAll(); return DropdownButtonFormField2( - customButton: widget.learningController.country != null + customButton: widget.learningController.country != null && + countries.any( + (country) => + country.name == widget.learningController.country!.name, + ) ? CountryPickerTile( widget.learningController.country!, isDropdown: true, ) : null, + isExpanded: true, decoration: InputDecoration( labelText: L10n.of(context).countryInformation, ), @@ -44,12 +50,12 @@ class CountryPickerDropdownState extends State { maxHeight: 300, ), items: [ - ...CountryService().getAll().map( - (country) => DropdownMenuItem( - value: country, - child: CountryPickerTile(country), - ), - ), + ...countries.map( + (country) => DropdownMenuItem( + value: country, + child: CountryPickerTile(country), + ), + ), ], onChanged: widget.learningController.changeCountry, value: widget.learningController.country, @@ -94,23 +100,28 @@ class CountryPickerTile extends StatelessWidget { @override Widget build(BuildContext context) { return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - CountryDisplayUtil.flagEmoji(country.name), - style: const TextStyle(fontSize: 25), - ), - const SizedBox(width: 10), - Text( - CountryDisplayUtil.countryDisplayName( - country.name, - context, - ) ?? - '', - style: const TextStyle().copyWith( - color: Theme.of(context).textTheme.bodyLarge!.color, - fontSize: 14, - ), - overflow: TextOverflow.ellipsis, + Row( + children: [ + Text( + CountryDisplayUtil.flagEmoji(country.name), + style: const TextStyle(fontSize: 25), + ), + const SizedBox(width: 10), + Text( + CountryDisplayUtil.countryDisplayName( + country.name, + context, + ) ?? + '', + style: const TextStyle().copyWith( + color: Theme.of(context).textTheme.bodyLarge!.color, + fontSize: 14, + ), + overflow: TextOverflow.ellipsis, + ), + ], ), if (isDropdown) Icon( diff --git a/lib/pangea/learning_settings/widgets/p_language_dropdown.dart b/lib/pangea/learning_settings/widgets/p_language_dropdown.dart index 686a857ec..713ca48ce 100644 --- a/lib/pangea/learning_settings/widgets/p_language_dropdown.dart +++ b/lib/pangea/learning_settings/widgets/p_language_dropdown.dart @@ -80,7 +80,8 @@ class PLanguageDropdownState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ DropdownButtonFormField2( - customButton: widget.initialLanguage != null + customButton: widget.initialLanguage != null && + sortedLanguages.contains(widget.initialLanguage) ? LanguageDropDownEntry( languageModel: widget.initialLanguage!, isL2List: widget.isL2List, diff --git a/lib/pangea/learning_settings/widgets/p_settings_switch_list_tile.dart b/lib/pangea/learning_settings/widgets/p_settings_switch_list_tile.dart index 2916e7ab2..e605eae90 100644 --- a/lib/pangea/learning_settings/widgets/p_settings_switch_list_tile.dart +++ b/lib/pangea/learning_settings/widgets/p_settings_switch_list_tile.dart @@ -44,6 +44,7 @@ class PSettingsSwitchListTileState @override Widget build(BuildContext context) { return SwitchListTile.adaptive( + contentPadding: EdgeInsets.zero, value: currentValue, title: Text(widget.title), activeColor: AppConfig.activeToggleColor,