Added backsupport for old saved themes

M committed Dec 18, 2020 at 21:30 UTC bd2bab997fec1704db84c39819716d2a450f8607
2 files changed +10 -3
lib/entities/preferences_key.dart
+1
@@ -10,6 +10,7 @@ class PreferencesKey {
10 static const allowBiometricalAuthenticationKey =
11 'allow_biometrical_authentication';
12 static const currentTheme = 'current_theme';
13 + static const isDarkThemeLegacy = 'dark_theme';
14 static const displayActionListModeKey = 'display_list_mode';
15 static const currentPinLength = 'current_pin_length';
16 static const currentLanguageCode = 'language_code';
lib/store/settings_store.dart
+9 -3
@@ -66,8 +66,8 @@ abstract class SettingsStoreBase with Store {
66
67 reaction(
68 (_) => currentTheme,
69 - (ThemeBase theme) => sharedPreferences.setInt(
70 - PreferencesKey.currentTheme, theme.raw));
69 + (ThemeBase theme) =>
70 + sharedPreferences.setInt(PreferencesKey.currentTheme, theme.raw));
71
72 reaction(
73 (_) => allowBiometricalAuthentication,
@@ -152,8 +152,14 @@ abstract class SettingsStoreBase with Store {
152 final allowBiometricalAuthentication = sharedPreferences
153 .getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
154 false;
155 + final legacyTheme =
156 + sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy)
157 + ? ThemeType.dark.index
158 + : ThemeType.bright.index;
159 final savedTheme = ThemeList.deserialize(
156 - raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ?? 0);
160 + raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ??
161 + legacyTheme ??
162 + 0);
163 final actionListDisplayMode = ObservableList<ActionListDisplayMode>();
164 actionListDisplayMode.addAll(deserializeActionlistDisplayModes(
165 sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ??