Browse Source

refactor(neon): Rename nextcloud theme option

Signed-off-by: jld3103 <jld3103yt@gmail.com>
pull/1064/head
jld3103 1 year ago
parent
commit
aec30754e7
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 2
      packages/neon/neon/lib/l10n/en.arb
  2. 6
      packages/neon/neon/lib/l10n/localizations.dart
  3. 2
      packages/neon/neon/lib/l10n/localizations_en.dart
  4. 2
      packages/neon/neon/lib/src/app.dart
  5. 2
      packages/neon/neon/lib/src/pages/settings.dart
  6. 19
      packages/neon/neon/lib/src/theme/theme.dart
  7. 16
      packages/neon/neon/lib/src/utils/global_options.dart

2
packages/neon/neon/lib/l10n/en.arb

@ -131,7 +131,7 @@
"globalOptionsThemeModeDark": "Dark", "globalOptionsThemeModeDark": "Dark",
"globalOptionsThemeModeAutomatic": "Automatic", "globalOptionsThemeModeAutomatic": "Automatic",
"globalOptionsThemeOLEDAsDark": "OLED theme as dark theme", "globalOptionsThemeOLEDAsDark": "OLED theme as dark theme",
"globalOptionsThemeKeepOriginalAccentColor": "Keep the original accent color", "globalOptionsThemeUseNextcloudTheme": "Use Nextcloud theme",
"globalOptionsPushNotificationsEnabled": "Enabled", "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", "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", "globalOptionsPushNotificationsDistributor": "UnifiedPush Distributor",

6
packages/neon/neon/lib/l10n/localizations.dart

@ -509,11 +509,11 @@ abstract class NeonLocalizations {
/// **'OLED theme as dark theme'** /// **'OLED theme as dark theme'**
String get globalOptionsThemeOLEDAsDark; String get globalOptionsThemeOLEDAsDark;
/// No description provided for @globalOptionsThemeKeepOriginalAccentColor. /// No description provided for @globalOptionsThemeUseNextcloudTheme.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'Keep the original accent color'** /// **'Use Nextcloud theme'**
String get globalOptionsThemeKeepOriginalAccentColor; String get globalOptionsThemeUseNextcloudTheme;
/// No description provided for @globalOptionsPushNotificationsEnabled. /// No description provided for @globalOptionsPushNotificationsEnabled.
/// ///

2
packages/neon/neon/lib/l10n/localizations_en.dart

@ -252,7 +252,7 @@ class NeonLocalizationsEn extends NeonLocalizations {
String get globalOptionsThemeOLEDAsDark => 'OLED theme as dark theme'; String get globalOptionsThemeOLEDAsDark => 'OLED theme as dark theme';
@override @override
String get globalOptionsThemeKeepOriginalAccentColor => 'Keep the original accent color'; String get globalOptionsThemeUseNextcloudTheme => 'Use Nextcloud theme';
@override @override
String get globalOptionsPushNotificationsEnabled => 'Enabled'; String get globalOptionsPushNotificationsEnabled => 'Enabled';

2
packages/neon/neon/lib/src/app.dart

@ -297,7 +297,7 @@ class _NeonAppState extends State<NeonApp> with WidgetsBindingObserver, tray.Tra
builder: (final context, final capabilitiesSnapshot) { builder: (final context, final capabilitiesSnapshot) {
final appTheme = AppTheme( final appTheme = AppTheme(
capabilitiesSnapshot.data?.capabilities.themingPublicCapabilities?.theming, capabilitiesSnapshot.data?.capabilities.themingPublicCapabilities?.theming,
keepOriginalAccentColor: options.themeKeepOriginalAccentColor.value, useNextcloudTheme: options.themeUseNextcloudTheme.value,
oledAsDark: options.themeOLEDAsDark.value, oledAsDark: options.themeOLEDAsDark.value,
appThemes: _appImplementations.map((final a) => a.theme).whereNotNull(), appThemes: _appImplementations.map((final a) => a.theme).whereNotNull(),
neonTheme: widget.neonTheme, neonTheme: widget.neonTheme,

2
packages/neon/neon/lib/src/pages/settings.dart

@ -157,7 +157,7 @@ class _SettingsPageState extends State<SettingsPage> {
option: globalOptions.themeOLEDAsDark, option: globalOptions.themeOLEDAsDark,
), ),
ToggleSettingsTile( ToggleSettingsTile(
option: globalOptions.themeKeepOriginalAccentColor, option: globalOptions.themeUseNextcloudTheme,
), ),
], ],
), ),

19
packages/neon/neon/lib/src/theme/theme.dart

@ -13,16 +13,16 @@ class AppTheme {
const AppTheme( const AppTheme(
this.nextcloudTheme, { this.nextcloudTheme, {
required this.neonTheme, required this.neonTheme,
final bool keepOriginalAccentColor = false, final bool useNextcloudTheme = false,
this.oledAsDark = false, this.oledAsDark = false,
this.appThemes, this.appThemes,
}) : keepOriginalAccentColor = nextcloudTheme == null || keepOriginalAccentColor; }) : useNextcloudTheme = nextcloudTheme == null || useNextcloudTheme;
/// The theme provided by the Nextcloud server. /// The theme provided by the Nextcloud server.
final core.ThemingPublicCapabilities_Theming? nextcloudTheme; final core.ThemingPublicCapabilities_Theming? nextcloudTheme;
/// Whether to force the use of the Nextcloud accent color. /// Whether to use of the Nextcloud theme.
final bool keepOriginalAccentColor; final bool useNextcloudTheme;
/// Whether to use [NcColors.oledBackground] in the dark theme. /// Whether to use [NcColors.oledBackground] in the dark theme.
final bool oledAsDark; final bool oledAsDark;
@ -34,17 +34,18 @@ class AppTheme {
final NeonTheme neonTheme; final NeonTheme neonTheme;
ColorScheme _buildColorScheme(final Brightness brightness) { ColorScheme _buildColorScheme(final Brightness brightness) {
final primary = nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color) : neonTheme.colorScheme.primary; final primaryColor =
final keepOriginalAccentColorOverride = keepOriginalAccentColor ? primary : null; nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color) : neonTheme.colorScheme.primary;
final primaryColorOverride = useNextcloudTheme ? primaryColor : null;
final oledBackgroundOverride = oledAsDark && brightness == Brightness.dark ? NcColors.oledBackground : null; final oledBackgroundOverride = oledAsDark && brightness == Brightness.dark ? NcColors.oledBackground : null;
return ColorScheme.fromSeed( return ColorScheme.fromSeed(
seedColor: primary, seedColor: primaryColor,
brightness: brightness, brightness: brightness,
).copyWith( ).copyWith(
background: oledBackgroundOverride, background: oledBackgroundOverride,
primary: keepOriginalAccentColorOverride, primary: primaryColorOverride,
secondary: keepOriginalAccentColorOverride, secondary: primaryColorOverride,
); );
} }

16
packages/neon/neon/lib/src/utils/global_options.dart

@ -72,7 +72,7 @@ class GlobalOptions extends OptionsCollection {
late final List<Option<dynamic>> options = [ late final List<Option<dynamic>> options = [
themeMode, themeMode,
themeOLEDAsDark, themeOLEDAsDark,
themeKeepOriginalAccentColor, themeUseNextcloudTheme,
pushNotificationsEnabled, pushNotificationsEnabled,
pushNotificationsDistributor, pushNotificationsDistributor,
startupMinimized, startupMinimized,
@ -150,14 +150,14 @@ class GlobalOptions extends OptionsCollection {
defaultValue: false, 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. /// Defaults to `false` generating a Material 3 style color.
late final themeKeepOriginalAccentColor = ToggleOption( late final themeUseNextcloudTheme = ToggleOption(
storage: storage, storage: storage,
key: GlobalOptionKeys.themeKeepOriginalAccentColor, key: GlobalOptionKeys.themeUseNextcloudTheme,
label: (final context) => NeonLocalizations.of(context).globalOptionsThemeKeepOriginalAccentColor, label: (final context) => NeonLocalizations.of(context).globalOptionsThemeUseNextcloudTheme,
defaultValue: false, defaultValue: true,
); );
/// Whether to enable the push notifications plugin. /// Whether to enable the push notifications plugin.
@ -286,8 +286,8 @@ enum GlobalOptionKeys implements Storable {
/// The storage key for [GlobalOptions.themeOLEDAsDark] /// The storage key for [GlobalOptions.themeOLEDAsDark]
themeOLEDAsDark._('theme-oled-as-dark'), themeOLEDAsDark._('theme-oled-as-dark'),
/// The storage key for [GlobalOptions.themeKeepOriginalAccentColor] /// The storage key for [GlobalOptions.themeUseNextcloudTheme]
themeKeepOriginalAccentColor._('theme-keep-original-accent-color'), themeUseNextcloudTheme._('theme-use-nextcloud-theme'),
/// The storage key for [GlobalOptions.pushNotificationsEnabled] /// The storage key for [GlobalOptions.pushNotificationsEnabled]
pushNotificationsEnabled._('push-notifications-enabled'), pushNotificationsEnabled._('push-notifications-enabled'),

Loading…
Cancel
Save