Revert "re-write localization service and add translation extension"
This reverts commit fdd7386020.
This commit is contained in:
@@ -2,9 +2,9 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:immich_mobile/constants/locales.dart';
|
||||
import 'package:immich_mobile/services/localization.service.dart';
|
||||
import 'package:immich_mobile/extensions/translation_extensions.dart';
|
||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/widgets/common/search_field.dart';
|
||||
|
||||
@@ -12,14 +12,15 @@ class LanguageSettings extends HookConsumerWidget {
|
||||
const LanguageSettings({super.key});
|
||||
|
||||
Future<void> _applyLanguageChange(
|
||||
BuildContext context,
|
||||
ValueNotifier<Locale> selectedLocale,
|
||||
ValueNotifier<bool> isLoading,
|
||||
) async {
|
||||
isLoading.value = true;
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
try {
|
||||
await EasyLocalizationService().changeLocale(selectedLocale.value);
|
||||
await EasyLocalizationService().loadTranslations();
|
||||
await context.setLocale(selectedLocale.value);
|
||||
await loadTranslations();
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
@@ -28,7 +29,7 @@ class LanguageSettings extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final localeEntries = useMemoized(() => locales.entries.toList(), const []);
|
||||
final currentLocale = EasyLocalizationService().currentLocale;
|
||||
final currentLocale = context.locale;
|
||||
final filteredLocaleEntries =
|
||||
useState<List<MapEntry<String, Locale>>>(localeEntries);
|
||||
final selectedLocale = useState<Locale>(currentLocale);
|
||||
@@ -114,6 +115,7 @@ class LanguageSettings extends HookConsumerWidget {
|
||||
isDisabled: isButtonDisabled,
|
||||
isLoading: isLoading.value,
|
||||
onPressed: () => _applyLanguageChange(
|
||||
context,
|
||||
selectedLocale,
|
||||
isLoading,
|
||||
),
|
||||
@@ -160,7 +162,7 @@ class _LanguageSearchBar extends StatelessWidget {
|
||||
child: SearchField(
|
||||
autofocus: false,
|
||||
contentPadding: const EdgeInsets.all(12),
|
||||
hintText: 'language_search_hint'.t(),
|
||||
hintText: 'language_search_hint'.tr(),
|
||||
prefixIcon: const Icon(Icons.search_rounded),
|
||||
suffixIcon: controller.text.isNotEmpty
|
||||
? IconButton(
|
||||
@@ -194,14 +196,14 @@ class _LanguageNotFound extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'language_no_results_title'.t(),
|
||||
'language_no_results_title'.tr(),
|
||||
style: context.textTheme.titleMedium?.copyWith(
|
||||
color: context.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'language_no_results_subtitle'.t(),
|
||||
'language_no_results_subtitle'.tr(),
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: context.colorScheme.onSurface.withValues(alpha: 0.8),
|
||||
),
|
||||
@@ -244,7 +246,7 @@ class _LanguageApplyButton extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'setting_languages_apply'.t(),
|
||||
'setting_languages_apply'.tr(),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16.0,
|
||||
|
||||
Reference in New Issue
Block a user