|
|
@ -26,7 +26,7 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
void _rememberLastUsedAccountListener() { |
|
|
|
void _rememberLastUsedAccountListener() { |
|
|
|
initialAccount.enabled = !rememberLastUsedAccount.value; |
|
|
|
initialAccount.enabled = !rememberLastUsedAccount.value; |
|
|
|
if (rememberLastUsedAccount.value) { |
|
|
|
if (rememberLastUsedAccount.value) { |
|
|
|
initialAccount.value = null; |
|
|
|
initialAccount.reset(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Only override the initial account if there already has been a value, |
|
|
|
// Only override the initial account if there already has been a value, |
|
|
|
// which means it's not the initial emit from rememberLastUsedAccount |
|
|
|
// which means it's not the initial emit from rememberLastUsedAccount |
|
|
@ -44,7 +44,7 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
pushNotificationsEnabled.value = false; |
|
|
|
pushNotificationsEnabled.value = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
pushNotificationsDistributor.value = null; |
|
|
|
pushNotificationsDistributor.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -91,26 +91,29 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void updateAccounts(final List<Account> accounts) { |
|
|
|
void updateAccounts(final List<Account> accounts) { |
|
|
|
initialAccount.values = { |
|
|
|
initialAccount.values = Map.fromEntries( |
|
|
|
for (final account in accounts) account.id: (final context) => account.humanReadableID, |
|
|
|
accounts.map( |
|
|
|
}; |
|
|
|
(final account) => MapEntry(account.id, (final context) => account.humanReadableID), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (accounts.tryFind(initialAccount.value) == null) { |
|
|
|
if (!initialAccount.values.containsKey(initialAccount.value)) { |
|
|
|
initialAccount.reset(); |
|
|
|
initialAccount.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Future<void> updateDistributors(final List<String> distributors) async { |
|
|
|
void updateDistributors(final List<String> distributors) { |
|
|
|
pushNotificationsDistributor.values = { |
|
|
|
pushNotificationsDistributor.values = Map.fromEntries( |
|
|
|
for (final distributor in distributors) ...{ |
|
|
|
distributors.map( |
|
|
|
distributor: _distributorsMap[distributor] ?? (final _) => distributor, |
|
|
|
(final distributor) => MapEntry(distributor, _distributorsMap[distributor] ?? (final _) => distributor), |
|
|
|
}, |
|
|
|
), |
|
|
|
}; |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
final allowed = distributors.isNotEmpty; |
|
|
|
final allowed = pushNotificationsDistributor.values.containsKey(pushNotificationsDistributor.value); |
|
|
|
pushNotificationsEnabled.enabled = allowed; |
|
|
|
pushNotificationsEnabled.enabled = allowed; |
|
|
|
if (!allowed) { |
|
|
|
if (!allowed) { |
|
|
|
pushNotificationsEnabled.value = false; |
|
|
|
pushNotificationsDistributor.reset(); |
|
|
|
|
|
|
|
pushNotificationsEnabled.reset(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -128,7 +131,7 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
|
|
|
|
|
|
|
|
late final themeOLEDAsDark = ToggleOption( |
|
|
|
late final themeOLEDAsDark = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.themeOledAsDark, |
|
|
|
key: GlobalOptionKeys.themeOLEDAsDark, |
|
|
|
label: (final context) => AppLocalizations.of(context).globalOptionsThemeOLEDAsDark, |
|
|
|
label: (final context) => AppLocalizations.of(context).globalOptionsThemeOLEDAsDark, |
|
|
|
defaultValue: false, |
|
|
|
defaultValue: false, |
|
|
|
); |
|
|
|
); |
|
|
@ -209,20 +212,17 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
defaultValue: Platform.isAndroid || Platform.isIOS ? NavigationMode.drawer : NavigationMode.drawerAlwaysVisible, |
|
|
|
defaultValue: Platform.isAndroid || Platform.isIOS ? NavigationMode.drawer : NavigationMode.drawerAlwaysVisible, |
|
|
|
values: { |
|
|
|
values: { |
|
|
|
NavigationMode.drawer: (final context) => AppLocalizations.of(context).globalOptionsNavigationModeDrawer, |
|
|
|
NavigationMode.drawer: (final context) => AppLocalizations.of(context).globalOptionsNavigationModeDrawer, |
|
|
|
if (!Platform.isAndroid && !Platform.isIOS) ...{ |
|
|
|
if (!Platform.isAndroid && !Platform.isIOS) |
|
|
|
NavigationMode.drawerAlwaysVisible: (final context) => |
|
|
|
NavigationMode.drawerAlwaysVisible: (final context) => |
|
|
|
AppLocalizations.of(context).globalOptionsNavigationModeDrawerAlwaysVisible, |
|
|
|
AppLocalizations.of(context).globalOptionsNavigationModeDrawerAlwaysVisible, |
|
|
|
}, |
|
|
|
}, |
|
|
|
// ignore: deprecated_member_use_from_same_package |
|
|
|
|
|
|
|
NavigationMode.quickBar: (final context) => AppLocalizations.of(context).globalOptionsNavigationModeQuickBar, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@internal |
|
|
|
@internal |
|
|
|
enum GlobalOptionKeys implements Storable { |
|
|
|
enum GlobalOptionKeys implements Storable { |
|
|
|
themeMode._('theme-mode'), |
|
|
|
themeMode._('theme-mode'), |
|
|
|
themeOledAsDark._('theme-oled-as-dark'), |
|
|
|
themeOLEDAsDark._('theme-oled-as-dark'), |
|
|
|
themeKeepOriginalAccentColor._('theme-keep-original-accent-color'), |
|
|
|
themeKeepOriginalAccentColor._('theme-keep-original-accent-color'), |
|
|
|
pushNotificationsEnabled._('push-notifications-enabled'), |
|
|
|
pushNotificationsEnabled._('push-notifications-enabled'), |
|
|
|
pushNotificationsDistributor._('push-notifications-distributor'), |
|
|
|
pushNotificationsDistributor._('push-notifications-distributor'), |
|
|
@ -244,6 +244,4 @@ enum GlobalOptionKeys implements Storable { |
|
|
|
enum NavigationMode { |
|
|
|
enum NavigationMode { |
|
|
|
drawer, |
|
|
|
drawer, |
|
|
|
drawerAlwaysVisible, |
|
|
|
drawerAlwaysVisible, |
|
|
|
@Deprecated("The new design won't use this anymore") |
|
|
|
|
|
|
|
quickBar, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|