From 0146436cb3c9bd216f883b2c65f9d79baab0eb2e Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Fri, 29 Apr 2022 09:56:56 -0700 Subject: [PATCH] Fix maximum width of dropdown boxes in settings --- lib/views/globalsettingsview.dart | 156 ++++++++++++++++-------------- 1 file changed, 83 insertions(+), 73 deletions(-) diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index b96a70d3..a023bae5 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -107,20 +107,22 @@ class _GlobalSettingsViewState extends State { ListTile( title: Text(AppLocalizations.of(context)!.settingLanguage, style: TextStyle(color: settings.current().mainTextColor)), leading: Icon(CwtchIcons.change_language, color: settings.current().mainTextColor), - trailing: DropdownButton( - value: Provider.of(context).locale.languageCode, - onChanged: (String? newValue) { - setState(() { - settings.switchLocale(Locale(newValue!)); - saveSettings(context); - }); - }, - items: AppLocalizations.supportedLocales.map>((Locale value) { - return DropdownMenuItem( - value: value.languageCode, - child: Text(getLanguageFull(context, value.languageCode)), - ); - }).toList())), + trailing: Container( + width: MediaQuery.of(context).size.width / 4, + child: DropdownButton( + value: Provider.of(context).locale.languageCode, + onChanged: (String? newValue) { + setState(() { + settings.switchLocale(Locale(newValue!)); + saveSettings(context); + }); + }, + items: AppLocalizations.supportedLocales.map>((Locale value) { + return DropdownMenuItem( + value: value.languageCode, + child: Text(getLanguageFull(context, value.languageCode)), + ); + }).toList()))), SwitchListTile( title: Text(AppLocalizations.of(context)!.settingTheme, style: TextStyle(color: settings.current().mainTextColor)), value: settings.current().mode == mode_light, @@ -140,39 +142,43 @@ class _GlobalSettingsViewState extends State { ), ListTile( title: Text(AppLocalizations.of(context)!.themeColorLabel), - trailing: DropdownButton( - key: Key("DropdownTheme"), - isDense: true, - value: Provider.of(context).theme.theme, - onChanged: (String? newValue) { - setState(() { - settings.setTheme(newValue!, settings.theme.mode); - saveSettings(context); - }); - }, - items: themes.keys.map>((String themeId) { - return DropdownMenuItem( - value: themeId, - child: Text(getThemeName(context, themeId)), //"ddi_$themeId", key: Key("ddi_$themeId")), - ); - }).toList()), + trailing: Container( + width: MediaQuery.of(context).size.width / 4, + child: DropdownButton( + key: Key("DropdownTheme"), + isDense: true, + value: Provider.of(context).theme.theme, + onChanged: (String? newValue) { + setState(() { + settings.setTheme(newValue!, settings.theme.mode); + saveSettings(context); + }); + }, + items: themes.keys.map>((String themeId) { + return DropdownMenuItem( + value: themeId, + child: Text(getThemeName(context, themeId)), //"ddi_$themeId", key: Key("ddi_$themeId")), + ); + }).toList())), leading: Icon(CwtchIcons.change_theme, color: settings.current().mainTextColor), ), ListTile( title: Text(AppLocalizations.of(context)!.settingUIColumnPortrait, style: TextStyle(color: settings.current().mainTextColor)), leading: Icon(Icons.table_chart, color: settings.current().mainTextColor), - trailing: DropdownButton( - value: settings.uiColumnModePortrait.toString(), - onChanged: (String? newValue) { - settings.uiColumnModePortrait = Settings.uiColumnModeFromString(newValue!); - saveSettings(context); - }, - items: Settings.uiColumnModeOptions(false).map>((DualpaneMode value) { - return DropdownMenuItem( - value: value.toString(), - child: Text(Settings.uiColumnModeToString(value, context)), - ); - }).toList())), + trailing: Container( + width: MediaQuery.of(context).size.width / 4, + child: DropdownButton( + value: settings.uiColumnModePortrait.toString(), + onChanged: (String? newValue) { + settings.uiColumnModePortrait = Settings.uiColumnModeFromString(newValue!); + saveSettings(context); + }, + items: Settings.uiColumnModeOptions(false).map>((DualpaneMode value) { + return DropdownMenuItem( + value: value.toString(), + child: Text(Settings.uiColumnModeToString(value, context)), + ); + }).toList()))), ListTile( title: Text( AppLocalizations.of(context)!.settingUIColumnLandscape, @@ -183,22 +189,24 @@ class _GlobalSettingsViewState extends State { leading: Icon(Icons.table_chart, color: settings.current().mainTextColor), trailing: Container( width: MediaQuery.of(context).size.width / 4, - child: DropdownButton( - isExpanded: true, - value: settings.uiColumnModeLandscape.toString(), - onChanged: (String? newValue) { - settings.uiColumnModeLandscape = Settings.uiColumnModeFromString(newValue!); - saveSettings(context); - }, - items: Settings.uiColumnModeOptions(true).map>((DualpaneMode value) { - return DropdownMenuItem( - value: value.toString(), - child: Text( - Settings.uiColumnModeToString(value, context), - overflow: TextOverflow.ellipsis, - ), - ); - }).toList()))), + child: Container( + width: MediaQuery.of(context).size.width / 4, + child: DropdownButton( + isExpanded: true, + value: settings.uiColumnModeLandscape.toString(), + onChanged: (String? newValue) { + settings.uiColumnModeLandscape = Settings.uiColumnModeFromString(newValue!); + saveSettings(context); + }, + items: Settings.uiColumnModeOptions(true).map>((DualpaneMode value) { + return DropdownMenuItem( + value: value.toString(), + child: Text( + Settings.uiColumnModeToString(value, context), + overflow: TextOverflow.ellipsis, + ), + ); + }).toList())))), SwitchListTile( title: Text(AppLocalizations.of(context)!.streamerModeLabel, style: TextStyle(color: settings.current().mainTextColor)), subtitle: Text(AppLocalizations.of(context)!.descriptionStreamerMode), @@ -238,21 +246,23 @@ class _GlobalSettingsViewState extends State { ListTile( title: Text(AppLocalizations.of(context)!.notificationPolicySettingLabel), subtitle: Text(AppLocalizations.of(context)!.notificationPolicySettingDescription), - trailing: DropdownButton( - value: settings.notificationPolicy, - onChanged: (NotificationPolicy? newValue) { - settings.notificationPolicy = newValue!; - saveSettings(context); - }, - items: NotificationPolicy.values.map>((NotificationPolicy value) { - return DropdownMenuItem( - value: value, - child: Text( - Settings.notificationPolicyToString(value, context), - overflow: TextOverflow.ellipsis, - ), - ); - }).toList()), + trailing: Container( + width: MediaQuery.of(context).size.width / 4, + child: DropdownButton( + value: settings.notificationPolicy, + onChanged: (NotificationPolicy? newValue) { + settings.notificationPolicy = newValue!; + saveSettings(context); + }, + items: NotificationPolicy.values.map>((NotificationPolicy value) { + return DropdownMenuItem( + value: value, + child: Text( + Settings.notificationPolicyToString(value, context), + overflow: TextOverflow.ellipsis, + ), + ); + }).toList())), leading: Icon(CwtchIcons.chat_bubble_empty_24px, color: settings.current().mainTextColor), ), ListTile(