Skip to content

Commit

Permalink
Change to language selection menu
Browse files Browse the repository at this point in the history
  • Loading branch information
GravityDarkLab committed Jan 30, 2024
1 parent 0a5d264 commit 6544663
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lib/views/settings_view/settings_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
ref: ref,
),
_buildThemeSelectionTile(context, ref),
_builLanguageSelectionTile(context, ref),
_buildLanguageSelectionTile(context, ref),
_buildSwitchListTile(
title: AppLocalizations.of(context)!.download_over_wifi_only,
value: settingState.isDownloadWithWifiOnly,
Expand Down Expand Up @@ -136,31 +136,32 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
);
}

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<String>(
final selectedLanguage = await showModalBottomSheet<String>(
context: context,
builder: (BuildContext context) {
return SimpleDialog(
title: Text(AppLocalizations.of(context)!.language_selection_description),
children: <String>['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: <String>['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);
}
},
Expand Down

0 comments on commit 6544663

Please sign in to comment.