Added backsupport for old saved themes

This commit is contained in:
M 2020-12-18 21:30:43 +02:00
parent 89c240091b
commit bd2bab997f
2 changed files with 10 additions and 3 deletions

View file

@ -10,6 +10,7 @@ class PreferencesKey {
static const allowBiometricalAuthenticationKey =
'allow_biometrical_authentication';
static const currentTheme = 'current_theme';
static const isDarkThemeLegacy = 'dark_theme';
static const displayActionListModeKey = 'display_list_mode';
static const currentPinLength = 'current_pin_length';
static const currentLanguageCode = 'language_code';

View file

@ -66,8 +66,8 @@ abstract class SettingsStoreBase with Store {
reaction(
(_) => currentTheme,
(ThemeBase theme) => sharedPreferences.setInt(
PreferencesKey.currentTheme, theme.raw));
(ThemeBase theme) =>
sharedPreferences.setInt(PreferencesKey.currentTheme, theme.raw));
reaction(
(_) => allowBiometricalAuthentication,
@ -152,8 +152,14 @@ abstract class SettingsStoreBase with Store {
final allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
false;
final legacyTheme =
sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy)
? ThemeType.dark.index
: ThemeType.bright.index;
final savedTheme = ThemeList.deserialize(
raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ?? 0);
raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ??
legacyTheme ??
0);
final actionListDisplayMode = ObservableList<ActionListDisplayMode>();
actionListDisplayMode.addAll(deserializeActionlistDisplayModes(
sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ??