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",
"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",

6
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.
///

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';
@override
String get globalOptionsThemeKeepOriginalAccentColor => 'Keep the original accent color';
String get globalOptionsThemeUseNextcloudTheme => 'Use Nextcloud theme';
@override
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) {
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,

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

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

19
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,
);
}

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

@ -72,7 +72,7 @@ class GlobalOptions extends OptionsCollection {
late final List<Option<dynamic>> 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'),

Loading…
Cancel
Save