From 6544663353537309f3ac1d472f18a88fef0fba46 Mon Sep 17 00:00:00 2001 From: Achraf Labidi Date: Tue, 30 Jan 2024 10:20:44 +0100 Subject: [PATCH] Change to language selection menu --- .../settings_view/settings_screen_view.dart | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/views/settings_view/settings_screen_view.dart b/lib/views/settings_view/settings_screen_view.dart index e7ecef4..074a01e 100644 --- a/lib/views/settings_view/settings_screen_view.dart +++ b/lib/views/settings_view/settings_screen_view.dart @@ -72,7 +72,7 @@ class _SettingsScreenState extends ConsumerState { ref: ref, ), _buildThemeSelectionTile(context, ref), - _builLanguageSelectionTile(context, ref), + _buildLanguageSelectionTile(context, ref), _buildSwitchListTile( title: AppLocalizations.of(context)!.download_over_wifi_only, value: settingState.isDownloadWithWifiOnly, @@ -136,31 +136,32 @@ class _SettingsScreenState extends ConsumerState { ); } - ListTile _builLanguageSelectionTile(BuildContext context, WidgetRef ref) { + ListTile _buildLanguageSelectionTile(BuildContext context, WidgetRef ref) { return ListTile( title: Text(AppLocalizations.of(context)!.language_selection), subtitle: Text(UserPreferences.getLanguageName(UserPreferences.getLanguage())), trailing: const Icon(Icons.arrow_forward_ios), onTap: () async { - String? selectedLanguage = await showDialog( + final selectedLanguage = await showModalBottomSheet( context: context, builder: (BuildContext context) { - return SimpleDialog( - title: Text(AppLocalizations.of(context)!.language_selection_description), - children: ['en', 'fr', 'de', 'es'] - .map((String lang) => SimpleDialogOption( - onPressed: () { - Navigator.pop(context, lang); - }, - child: Text(UserPreferences.getLanguageName(lang)), // Assuming you have a method to get the language name - )) - .toList(), + return SafeArea( + child: Column( + mainAxisSize: MainAxisSize.min, + children: ['en', 'fr', 'de', 'es'] + .map((String lang) => ListTile( + title: Text(UserPreferences.getLanguageName(lang)), + onTap: () => Navigator.pop(context, lang), + )) + .toList(), + ), ); }, ); + if (selectedLanguage != null) { await UserPreferences.setLanguage(selectedLanguage); - //to rebuild the app + // To rebuild the app ref.read(settingViewModelProvider.notifier).setLoading(false); } },