|
|
@ -10,11 +10,14 @@ import 'package:package_info_plus/package_info_plus.dart'; |
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
import 'package:universal_io/io.dart'; |
|
|
|
import 'package:universal_io/io.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The package id of the NextPush UnifiedPush distributor. |
|
|
|
const unifiedPushNextPushID = 'org.unifiedpush.distributor.nextpush'; |
|
|
|
const unifiedPushNextPushID = 'org.unifiedpush.distributor.nextpush'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Global options for the Neon framework. |
|
|
|
@internal |
|
|
|
@internal |
|
|
|
@immutable |
|
|
|
@immutable |
|
|
|
class GlobalOptions extends OptionsCollection { |
|
|
|
class GlobalOptions extends OptionsCollection { |
|
|
|
|
|
|
|
/// Creates a new global options collection. |
|
|
|
GlobalOptions( |
|
|
|
GlobalOptions( |
|
|
|
this._packageInfo, |
|
|
|
this._packageInfo, |
|
|
|
) : super(const AppStorage(StorageKeys.global)) { |
|
|
|
) : super(const AppStorage(StorageKeys.global)) { |
|
|
@ -89,6 +92,9 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
rememberLastUsedAccount.removeListener(_rememberLastUsedAccountListener); |
|
|
|
rememberLastUsedAccount.removeListener(_rememberLastUsedAccountListener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Updates the available values of [initialAccount]. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// If the current `initialAccount` is not supported anymore the option will be reset. |
|
|
|
void updateAccounts(final List<Account> accounts) { |
|
|
|
void updateAccounts(final List<Account> accounts) { |
|
|
|
initialAccount.values = Map.fromEntries( |
|
|
|
initialAccount.values = Map.fromEntries( |
|
|
|
accounts.map( |
|
|
|
accounts.map( |
|
|
@ -101,6 +107,10 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Updates the values of [pushNotificationsDistributor]. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// If the new `distributors` does not contain the currently active one |
|
|
|
|
|
|
|
/// both [pushNotificationsDistributor] and [pushNotificationsEnabled] will be reset. |
|
|
|
void updateDistributors(final List<String> distributors) { |
|
|
|
void updateDistributors(final List<String> distributors) { |
|
|
|
pushNotificationsDistributor.values = Map.fromEntries( |
|
|
|
pushNotificationsDistributor.values = Map.fromEntries( |
|
|
|
distributors.map( |
|
|
|
distributors.map( |
|
|
@ -116,6 +126,7 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The theme mode of the app implementing the Neon framework. |
|
|
|
late final themeMode = SelectOption( |
|
|
|
late final themeMode = SelectOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.themeMode, |
|
|
|
key: GlobalOptionKeys.themeMode, |
|
|
@ -128,6 +139,10 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether the [ThemeMode.dark] should use a plain black background. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// This is commonly used for OLED screens. |
|
|
|
|
|
|
|
/// Defaults to `false`. |
|
|
|
late final themeOLEDAsDark = ToggleOption( |
|
|
|
late final themeOLEDAsDark = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.themeOLEDAsDark, |
|
|
|
key: GlobalOptionKeys.themeOLEDAsDark, |
|
|
@ -135,6 +150,9 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
defaultValue: false, |
|
|
|
defaultValue: false, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether the `ColorScheme` should keep the accent color provided by the Nextcloud server. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Defaults to `false` generating a Material 3 style color. |
|
|
|
late final themeKeepOriginalAccentColor = ToggleOption( |
|
|
|
late final themeKeepOriginalAccentColor = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.themeKeepOriginalAccentColor, |
|
|
|
key: GlobalOptionKeys.themeKeepOriginalAccentColor, |
|
|
@ -142,6 +160,12 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
defaultValue: false, |
|
|
|
defaultValue: false, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether to enable the push notifications plugin. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Setting this option to true will request the permission to show notifications. |
|
|
|
|
|
|
|
/// Disabling this option will reset [pushNotificationsDistributor]. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Defaults to `false`. |
|
|
|
late final pushNotificationsEnabled = ToggleOption( |
|
|
|
late final pushNotificationsEnabled = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.pushNotificationsEnabled, |
|
|
|
key: GlobalOptionKeys.pushNotificationsEnabled, |
|
|
@ -149,6 +173,7 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
defaultValue: false, |
|
|
|
defaultValue: false, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The registered distributor for push notifications. |
|
|
|
late final pushNotificationsDistributor = SelectOption<String?>.depend( |
|
|
|
late final pushNotificationsDistributor = SelectOption<String?>.depend( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.pushNotificationsDistributor, |
|
|
|
key: GlobalOptionKeys.pushNotificationsDistributor, |
|
|
@ -158,6 +183,13 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
enabled: pushNotificationsEnabled, |
|
|
|
enabled: pushNotificationsEnabled, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether to start the app minimized. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Defaults to `false`. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// See: |
|
|
|
|
|
|
|
/// * [minimizeInsteadOfExit]: for an option to minimize instead of closing the app. |
|
|
|
|
|
|
|
/// * [systemTrayHideToTrayWhenMinimized]: to minimize the app to system tray. |
|
|
|
late final startupMinimized = ToggleOption( |
|
|
|
late final startupMinimized = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.startupMinimized, |
|
|
|
key: GlobalOptionKeys.startupMinimized, |
|
|
@ -165,6 +197,13 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
defaultValue: false, |
|
|
|
defaultValue: false, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether to minimize app instead of closing it. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Defaults to `false`. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// See: |
|
|
|
|
|
|
|
/// * [startupMinimized]: for an option to startup in the minimized state. |
|
|
|
|
|
|
|
/// * [systemTrayHideToTrayWhenMinimized]: to minimize the app to system tray. |
|
|
|
late final startupMinimizeInsteadOfExit = ToggleOption( |
|
|
|
late final startupMinimizeInsteadOfExit = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.startupMinimizeInsteadOfExit, |
|
|
|
key: GlobalOptionKeys.startupMinimizeInsteadOfExit, |
|
|
@ -174,6 +213,12 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Autostart option |
|
|
|
// TODO: Autostart option |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether to enable the system tray. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Defaults to `false`. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// See: |
|
|
|
|
|
|
|
/// * [systemTrayHideToTrayWhenMinimized]: to minimize the app to system tray. |
|
|
|
late final systemTrayEnabled = ToggleOption( |
|
|
|
late final systemTrayEnabled = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.systemTrayEnabled, |
|
|
|
key: GlobalOptionKeys.systemTrayEnabled, |
|
|
@ -181,6 +226,15 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
defaultValue: false, |
|
|
|
defaultValue: false, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether to minimize to the system tray or not. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Requires [systemTrayEnabled] to be true. |
|
|
|
|
|
|
|
/// Defaults to `true`. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// See: |
|
|
|
|
|
|
|
/// * [systemTrayEnabled]: to enable the system tray. |
|
|
|
|
|
|
|
/// * [startupMinimized]: for an option to startup in the minimized state. |
|
|
|
|
|
|
|
/// * [minimizeInsteadOfExit]: for an option to minimize instead of closing the app. |
|
|
|
late final systemTrayHideToTrayWhenMinimized = ToggleOption.depend( |
|
|
|
late final systemTrayHideToTrayWhenMinimized = ToggleOption.depend( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.systemTrayHideToTrayWhenMinimized, |
|
|
|
key: GlobalOptionKeys.systemTrayHideToTrayWhenMinimized, |
|
|
@ -189,6 +243,10 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
enabled: systemTrayEnabled, |
|
|
|
enabled: systemTrayEnabled, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Whether to remember the last active account. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// Enabling this option will reset the [initialAccount]. |
|
|
|
|
|
|
|
/// Defaults to `true`. |
|
|
|
late final rememberLastUsedAccount = ToggleOption( |
|
|
|
late final rememberLastUsedAccount = ToggleOption( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.rememberLastUsedAccount, |
|
|
|
key: GlobalOptionKeys.rememberLastUsedAccount, |
|
|
@ -196,6 +254,7 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
defaultValue: true, |
|
|
|
defaultValue: true, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The initial account to use when opening the app. |
|
|
|
late final initialAccount = SelectOption<String?>( |
|
|
|
late final initialAccount = SelectOption<String?>( |
|
|
|
storage: storage, |
|
|
|
storage: storage, |
|
|
|
key: GlobalOptionKeys.initialAccount, |
|
|
|
key: GlobalOptionKeys.initialAccount, |
|
|
@ -218,19 +277,43 @@ class GlobalOptions extends OptionsCollection { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage keys for the [GlobalOptions]. |
|
|
|
@internal |
|
|
|
@internal |
|
|
|
enum GlobalOptionKeys implements Storable { |
|
|
|
enum GlobalOptionKeys implements Storable { |
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.themeMode] |
|
|
|
themeMode._('theme-mode'), |
|
|
|
themeMode._('theme-mode'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.themeOLEDAsDark] |
|
|
|
themeOLEDAsDark._('theme-oled-as-dark'), |
|
|
|
themeOLEDAsDark._('theme-oled-as-dark'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.themeKeepOriginalAccentColor] |
|
|
|
themeKeepOriginalAccentColor._('theme-keep-original-accent-color'), |
|
|
|
themeKeepOriginalAccentColor._('theme-keep-original-accent-color'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.pushNotificationsEnabled] |
|
|
|
pushNotificationsEnabled._('push-notifications-enabled'), |
|
|
|
pushNotificationsEnabled._('push-notifications-enabled'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.pushNotificationsDistributor] |
|
|
|
pushNotificationsDistributor._('push-notifications-distributor'), |
|
|
|
pushNotificationsDistributor._('push-notifications-distributor'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.startupMinimized] |
|
|
|
startupMinimized._('startup-minimized'), |
|
|
|
startupMinimized._('startup-minimized'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.startupMinimizeInsteadOfExit] |
|
|
|
startupMinimizeInsteadOfExit._('startup-minimize-instead-of-exit'), |
|
|
|
startupMinimizeInsteadOfExit._('startup-minimize-instead-of-exit'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.systemTrayEnabled] |
|
|
|
systemTrayEnabled._('system-tray-enabled'), |
|
|
|
systemTrayEnabled._('system-tray-enabled'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.systemTrayHideToTrayWhenMinimized] |
|
|
|
systemTrayHideToTrayWhenMinimized._('system-tray-hide-to-tray-when-minimized'), |
|
|
|
systemTrayHideToTrayWhenMinimized._('system-tray-hide-to-tray-when-minimized'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.rememberLastUsedAccount] |
|
|
|
rememberLastUsedAccount._('remember-last-used-account'), |
|
|
|
rememberLastUsedAccount._('remember-last-used-account'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.initialAccount] |
|
|
|
initialAccount._('initial-account'), |
|
|
|
initialAccount._('initial-account'), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The storage key for [GlobalOptions.navigationMode] |
|
|
|
navigationMode._('navigation-mode'); |
|
|
|
navigationMode._('navigation-mode'); |
|
|
|
|
|
|
|
|
|
|
|
const GlobalOptionKeys._(this.value); |
|
|
|
const GlobalOptionKeys._(this.value); |
|
|
@ -239,8 +322,16 @@ enum GlobalOptionKeys implements Storable { |
|
|
|
final String value; |
|
|
|
final String value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// App navigation modes. |
|
|
|
@internal |
|
|
|
@internal |
|
|
|
enum NavigationMode { |
|
|
|
enum NavigationMode { |
|
|
|
|
|
|
|
/// Drawer behind a hamburger menu. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// The default for small screen sizes. |
|
|
|
drawer, |
|
|
|
drawer, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Persistent drawer on the leading edge. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// The default on large screen sizes. |
|
|
|
drawerAlwaysVisible, |
|
|
|
drawerAlwaysVisible, |
|
|
|
} |
|
|
|
} |
|
|
|