diff --git a/mobile/lib/modules/settings/ui/language_settings.dart b/mobile/lib/modules/settings/ui/language_settings.dart new file mode 100644 index 0000000000..c3cdde6859 --- /dev/null +++ b/mobile/lib/modules/settings/ui/language_settings.dart @@ -0,0 +1,71 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/constants/locales.dart'; +import 'package:immich_mobile/extensions/build_context_extensions.dart'; +import 'package:immich_mobile/modules/backup/background_service/localization.dart'; + +class LanguageSettings extends HookConsumerWidget { + const LanguageSettings({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final currentLocale = context.locale; + final textController = useTextEditingController( + text: locales.keys.firstWhere( + (countryName) => locales[countryName] == currentLocale, + ), + ); + + final selectedLocale = useState<Locale>(currentLocale); + + return ListView( + padding: const EdgeInsets.all(16), + children: [ + DropdownMenu( + inputDecorationTheme: InputDecorationTheme( + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(20), + ), + contentPadding: const EdgeInsets.only(left: 16), + ), + menuStyle: MenuStyle( + shape: MaterialStatePropertyAll<OutlinedBorder>( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15), + ), + ), + ), + menuHeight: context.height * 0.5, + hintText: "Languages", + label: const Text('Languages'), + dropdownMenuEntries: locales.keys + .map( + (countryName) => DropdownMenuEntry( + value: locales[countryName], + label: countryName, + ), + ) + .toList(), + controller: textController, + onSelected: (value) { + if (value != null) { + selectedLocale.value = value; + } + }, + ), + const SizedBox(height: 16), + ElevatedButton( + onPressed: selectedLocale.value == currentLocale + ? null + : () { + context.setLocale(selectedLocale.value); + loadTranslations(); + }, + child: const Text('setting_languages_apply').tr(), + ), + ], + ); + } +} diff --git a/mobile/lib/modules/settings/views/settings_page.dart b/mobile/lib/modules/settings/views/settings_page.dart index bfe8899924..3ca723e921 100644 --- a/mobile/lib/modules/settings/views/settings_page.dart +++ b/mobile/lib/modules/settings/views/settings_page.dart @@ -2,14 +2,12 @@ import 'package:auto_route/auto_route.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:immich_mobile/constants/locales.dart'; import 'package:immich_mobile/extensions/build_context_extensions.dart'; -import 'package:immich_mobile/modules/backup/background_service/localization.dart'; import 'package:immich_mobile/modules/settings/ui/advanced_settings.dart'; import 'package:immich_mobile/modules/settings/ui/asset_list_settings/asset_list_settings.dart'; import 'package:immich_mobile/modules/settings/ui/backup_settings/backup_settings.dart'; import 'package:immich_mobile/modules/settings/ui/image_viewer_quality_setting.dart'; +import 'package:immich_mobile/modules/settings/ui/language_settings.dart'; import 'package:immich_mobile/modules/settings/ui/notification_setting.dart'; import 'package:immich_mobile/modules/settings/ui/preference_settings/preference_setting.dart'; import 'package:immich_mobile/routing/router.dart'; @@ -42,70 +40,6 @@ enum SettingSection { const SettingSection(this.title, this.icon); } -class LanguageSettings extends HookConsumerWidget { - const LanguageSettings({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final currentLocale = context.locale; - final textController = useTextEditingController( - text: locales.keys.firstWhere( - (countryName) => locales[countryName] == currentLocale, - ), - ); - - final selectedLocale = useState<Locale>(currentLocale); - - return ListView( - padding: const EdgeInsets.all(16), - children: [ - DropdownMenu( - inputDecorationTheme: InputDecorationTheme( - border: OutlineInputBorder( - borderRadius: BorderRadius.circular(20), - ), - contentPadding: const EdgeInsets.only(left: 16), - ), - menuStyle: MenuStyle( - shape: MaterialStatePropertyAll<OutlinedBorder>( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(15), - ), - ), - ), - menuHeight: context.height * 0.5, - hintText: "Languages", - label: const Text('Languages'), - dropdownMenuEntries: locales.keys - .map( - (countryName) => DropdownMenuEntry( - value: locales[countryName], - label: countryName, - ), - ) - .toList(), - controller: textController, - onSelected: (value) { - if (value != null) { - selectedLocale.value = value; - } - }, - ), - const SizedBox(height: 16), - ElevatedButton( - onPressed: selectedLocale.value == currentLocale - ? null - : () { - context.setLocale(selectedLocale.value); - loadTranslations(); - }, - child: const Text('setting_languages_apply').tr(), - ), - ], - ); - } -} - @RoutePage() class SettingsPage extends StatelessWidget { const SettingsPage({super.key});