mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #1089 from sunny7dusk/fix_language_when_reopening_700
fix: Fixed locale bug when oppening -
This commit is contained in:
commit
3119759c92
@ -16,7 +16,8 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
|
|||||||
|
|
||||||
AppearanceSettingModel(this.setting)
|
AppearanceSettingModel(this.setting)
|
||||||
: _theme = AppTheme.fromName(name: setting.theme),
|
: _theme = AppTheme.fromName(name: setting.theme),
|
||||||
_locale = Locale(setting.locale.languageCode, setting.locale.countryCode);
|
_locale =
|
||||||
|
Locale(setting.locale.languageCode, setting.locale.countryCode);
|
||||||
|
|
||||||
AppTheme get theme => _theme;
|
AppTheme get theme => _theme;
|
||||||
Locale get locale => _locale;
|
Locale get locale => _locale;
|
||||||
@ -34,7 +35,8 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void swapTheme() {
|
void swapTheme() {
|
||||||
final themeType = (_theme.ty == ThemeType.light ? ThemeType.dark : ThemeType.light);
|
final themeType =
|
||||||
|
(_theme.ty == ThemeType.light ? ThemeType.dark : ThemeType.light);
|
||||||
|
|
||||||
if (_theme.ty != themeType) {
|
if (_theme.ty != themeType) {
|
||||||
_theme = AppTheme.fromType(themeType);
|
_theme = AppTheme.fromType(themeType);
|
||||||
@ -45,7 +47,6 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setLocale(BuildContext context, Locale newLocale) {
|
void setLocale(BuildContext context, Locale newLocale) {
|
||||||
if (_locale != newLocale) {
|
|
||||||
if (!context.supportedLocales.contains(newLocale)) {
|
if (!context.supportedLocales.contains(newLocale)) {
|
||||||
Log.warn("Unsupported locale: $newLocale");
|
Log.warn("Unsupported locale: $newLocale");
|
||||||
newLocale = const Locale('en');
|
newLocale = const Locale('en');
|
||||||
@ -53,6 +54,8 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
context.setLocale(newLocale);
|
context.setLocale(newLocale);
|
||||||
|
|
||||||
|
if (_locale != newLocale) {
|
||||||
_locale = newLocale;
|
_locale = newLocale;
|
||||||
setting.locale.languageCode = _locale.languageCode;
|
setting.locale.languageCode = _locale.languageCode;
|
||||||
setting.locale.countryCode = _locale.countryCode ?? "";
|
setting.locale.countryCode = _locale.countryCode ?? "";
|
||||||
@ -67,6 +70,10 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
|
|||||||
save();
|
save();
|
||||||
|
|
||||||
setLocale(context, context.deviceLocale);
|
setLocale(context, context.deviceLocale);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// when opening app the first time
|
||||||
|
setLocale(context, _locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user