From aec30754e7dbc8e8c620dea96e93dd3a4fb53df3 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Tue, 31 Oct 2023 16:08:23 +0100 Subject: [PATCH] refactor(neon): Rename nextcloud theme option Signed-off-by: jld3103 --- packages/neon/neon/lib/l10n/en.arb | 2 +- .../neon/neon/lib/l10n/localizations.dart | 6 +++--- .../neon/neon/lib/l10n/localizations_en.dart | 2 +- packages/neon/neon/lib/src/app.dart | 2 +- .../neon/neon/lib/src/pages/settings.dart | 2 +- packages/neon/neon/lib/src/theme/theme.dart | 19 ++++++++++--------- .../neon/lib/src/utils/global_options.dart | 16 ++++++++-------- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/packages/neon/neon/lib/l10n/en.arb b/packages/neon/neon/lib/l10n/en.arb index 53515aa9..cfc0f28e 100644 --- a/packages/neon/neon/lib/l10n/en.arb +++ b/packages/neon/neon/lib/l10n/en.arb @@ -131,7 +131,7 @@ "globalOptionsThemeModeDark": "Dark", "globalOptionsThemeModeAutomatic": "Automatic", "globalOptionsThemeOLEDAsDark": "OLED theme as dark theme", - "globalOptionsThemeKeepOriginalAccentColor": "Keep the original accent color", + "globalOptionsThemeUseNextcloudTheme": "Use Nextcloud theme", "globalOptionsPushNotificationsEnabled": "Enabled", "globalOptionsPushNotificationsEnabledDisabledNotice": "No UnifiedPush distributor could be found or you denied the permission for showing notifications. Please go to the app settings and allow notifications and go to https://unifiedpush.org/users/distributors and setup any of the listed distributors. Then re-open this app and you should be able to enable notifications", "globalOptionsPushNotificationsDistributor": "UnifiedPush Distributor", diff --git a/packages/neon/neon/lib/l10n/localizations.dart b/packages/neon/neon/lib/l10n/localizations.dart index ce9f982a..b588aaf2 100644 --- a/packages/neon/neon/lib/l10n/localizations.dart +++ b/packages/neon/neon/lib/l10n/localizations.dart @@ -509,11 +509,11 @@ abstract class NeonLocalizations { /// **'OLED theme as dark theme'** String get globalOptionsThemeOLEDAsDark; - /// No description provided for @globalOptionsThemeKeepOriginalAccentColor. + /// No description provided for @globalOptionsThemeUseNextcloudTheme. /// /// In en, this message translates to: - /// **'Keep the original accent color'** - String get globalOptionsThemeKeepOriginalAccentColor; + /// **'Use Nextcloud theme'** + String get globalOptionsThemeUseNextcloudTheme; /// No description provided for @globalOptionsPushNotificationsEnabled. /// diff --git a/packages/neon/neon/lib/l10n/localizations_en.dart b/packages/neon/neon/lib/l10n/localizations_en.dart index e1aba5d6..e8df967a 100644 --- a/packages/neon/neon/lib/l10n/localizations_en.dart +++ b/packages/neon/neon/lib/l10n/localizations_en.dart @@ -252,7 +252,7 @@ class NeonLocalizationsEn extends NeonLocalizations { String get globalOptionsThemeOLEDAsDark => 'OLED theme as dark theme'; @override - String get globalOptionsThemeKeepOriginalAccentColor => 'Keep the original accent color'; + String get globalOptionsThemeUseNextcloudTheme => 'Use Nextcloud theme'; @override String get globalOptionsPushNotificationsEnabled => 'Enabled'; diff --git a/packages/neon/neon/lib/src/app.dart b/packages/neon/neon/lib/src/app.dart index 6ecc891c..149f0f96 100644 --- a/packages/neon/neon/lib/src/app.dart +++ b/packages/neon/neon/lib/src/app.dart @@ -297,7 +297,7 @@ class _NeonAppState extends State with WidgetsBindingObserver, tray.Tra builder: (final context, final capabilitiesSnapshot) { final appTheme = AppTheme( capabilitiesSnapshot.data?.capabilities.themingPublicCapabilities?.theming, - keepOriginalAccentColor: options.themeKeepOriginalAccentColor.value, + useNextcloudTheme: options.themeUseNextcloudTheme.value, oledAsDark: options.themeOLEDAsDark.value, appThemes: _appImplementations.map((final a) => a.theme).whereNotNull(), neonTheme: widget.neonTheme, diff --git a/packages/neon/neon/lib/src/pages/settings.dart b/packages/neon/neon/lib/src/pages/settings.dart index 0d842b73..14e99757 100644 --- a/packages/neon/neon/lib/src/pages/settings.dart +++ b/packages/neon/neon/lib/src/pages/settings.dart @@ -157,7 +157,7 @@ class _SettingsPageState extends State { option: globalOptions.themeOLEDAsDark, ), ToggleSettingsTile( - option: globalOptions.themeKeepOriginalAccentColor, + option: globalOptions.themeUseNextcloudTheme, ), ], ), diff --git a/packages/neon/neon/lib/src/theme/theme.dart b/packages/neon/neon/lib/src/theme/theme.dart index 81ac674f..4fbc761d 100644 --- a/packages/neon/neon/lib/src/theme/theme.dart +++ b/packages/neon/neon/lib/src/theme/theme.dart @@ -13,16 +13,16 @@ class AppTheme { const AppTheme( this.nextcloudTheme, { required this.neonTheme, - final bool keepOriginalAccentColor = false, + final bool useNextcloudTheme = false, this.oledAsDark = false, this.appThemes, - }) : keepOriginalAccentColor = nextcloudTheme == null || keepOriginalAccentColor; + }) : useNextcloudTheme = nextcloudTheme == null || useNextcloudTheme; /// The theme provided by the Nextcloud server. final core.ThemingPublicCapabilities_Theming? nextcloudTheme; - /// Whether to force the use of the Nextcloud accent color. - final bool keepOriginalAccentColor; + /// Whether to use of the Nextcloud theme. + final bool useNextcloudTheme; /// Whether to use [NcColors.oledBackground] in the dark theme. final bool oledAsDark; @@ -34,17 +34,18 @@ class AppTheme { final NeonTheme neonTheme; ColorScheme _buildColorScheme(final Brightness brightness) { - final primary = nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color) : neonTheme.colorScheme.primary; - final keepOriginalAccentColorOverride = keepOriginalAccentColor ? primary : null; + final primaryColor = + nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color) : neonTheme.colorScheme.primary; + final primaryColorOverride = useNextcloudTheme ? primaryColor : null; final oledBackgroundOverride = oledAsDark && brightness == Brightness.dark ? NcColors.oledBackground : null; return ColorScheme.fromSeed( - seedColor: primary, + seedColor: primaryColor, brightness: brightness, ).copyWith( background: oledBackgroundOverride, - primary: keepOriginalAccentColorOverride, - secondary: keepOriginalAccentColorOverride, + primary: primaryColorOverride, + secondary: primaryColorOverride, ); } diff --git a/packages/neon/neon/lib/src/utils/global_options.dart b/packages/neon/neon/lib/src/utils/global_options.dart index 075a3439..e5d57616 100644 --- a/packages/neon/neon/lib/src/utils/global_options.dart +++ b/packages/neon/neon/lib/src/utils/global_options.dart @@ -72,7 +72,7 @@ class GlobalOptions extends OptionsCollection { late final List> options = [ themeMode, themeOLEDAsDark, - themeKeepOriginalAccentColor, + themeUseNextcloudTheme, pushNotificationsEnabled, pushNotificationsDistributor, startupMinimized, @@ -150,14 +150,14 @@ class GlobalOptions extends OptionsCollection { defaultValue: false, ); - /// Whether the `ColorScheme` should keep the accent color provided by the Nextcloud server. + /// Whether the `ColorScheme` should keep the colors provided by the Nextcloud server. /// /// Defaults to `false` generating a Material 3 style color. - late final themeKeepOriginalAccentColor = ToggleOption( + late final themeUseNextcloudTheme = ToggleOption( storage: storage, - key: GlobalOptionKeys.themeKeepOriginalAccentColor, - label: (final context) => NeonLocalizations.of(context).globalOptionsThemeKeepOriginalAccentColor, - defaultValue: false, + key: GlobalOptionKeys.themeUseNextcloudTheme, + label: (final context) => NeonLocalizations.of(context).globalOptionsThemeUseNextcloudTheme, + defaultValue: true, ); /// Whether to enable the push notifications plugin. @@ -286,8 +286,8 @@ enum GlobalOptionKeys implements Storable { /// The storage key for [GlobalOptions.themeOLEDAsDark] themeOLEDAsDark._('theme-oled-as-dark'), - /// The storage key for [GlobalOptions.themeKeepOriginalAccentColor] - themeKeepOriginalAccentColor._('theme-keep-original-accent-color'), + /// The storage key for [GlobalOptions.themeUseNextcloudTheme] + themeUseNextcloudTheme._('theme-use-nextcloud-theme'), /// The storage key for [GlobalOptions.pushNotificationsEnabled] pushNotificationsEnabled._('push-notifications-enabled'),