mirror of
https://github.com/git-touch/git-touch
synced 2025-03-10 00:00:20 +01:00
fix: set locale null
This commit is contained in:
parent
e2f103a807
commit
9b3a6fce07
lib
@ -166,10 +166,14 @@ class ThemeModel with ChangeNotifier {
|
|||||||
String? _locale;
|
String? _locale;
|
||||||
String? get locale => _locale;
|
String? get locale => _locale;
|
||||||
|
|
||||||
Future<void> setLocale(String v) async {
|
Future<void> setLocale(String? v) async {
|
||||||
_locale = v;
|
_locale = v;
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setString(StorageKeys.locale, v);
|
if (v == null) {
|
||||||
|
await prefs.remove(StorageKeys.locale);
|
||||||
|
} else {
|
||||||
|
await prefs.setString(StorageKeys.locale, v);
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,13 +86,13 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
? AppLocalizations.of(context)!.followSystem
|
? AppLocalizations.of(context)!.followSystem
|
||||||
: localeNameMap[key],
|
: localeNameMap[key],
|
||||||
onTap: (_) async {
|
onTap: (_) async {
|
||||||
final res = await (theme.showConfirm(
|
final res = await theme.showConfirm(
|
||||||
context,
|
context,
|
||||||
Text(
|
Text(
|
||||||
'The app will reload to make the language setting take effect'),
|
'The app will reload to make the language setting take effect'),
|
||||||
) as Future<bool>);
|
);
|
||||||
if (res && theme.locale != key) {
|
if (res == true && theme.locale != key) {
|
||||||
await theme.setLocale(key!);
|
await theme.setLocale(key);
|
||||||
auth.reloadApp();
|
auth.reloadApp();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user