|
|
@ -10,8 +10,10 @@ import 'package:nextcloud/core.dart' as core; |
|
|
|
@immutable |
|
|
|
@immutable |
|
|
|
class AppTheme { |
|
|
|
class AppTheme { |
|
|
|
/// Creates a new Neon app theme. |
|
|
|
/// Creates a new Neon app theme. |
|
|
|
const AppTheme( |
|
|
|
const AppTheme({ |
|
|
|
this.nextcloudTheme, { |
|
|
|
required this.nextcloudTheme, |
|
|
|
|
|
|
|
required this.deviceThemeLight, |
|
|
|
|
|
|
|
required this.deviceThemeDark, |
|
|
|
required this.neonTheme, |
|
|
|
required this.neonTheme, |
|
|
|
final bool useNextcloudTheme = false, |
|
|
|
final bool useNextcloudTheme = false, |
|
|
|
this.oledAsDark = false, |
|
|
|
this.oledAsDark = false, |
|
|
@ -24,6 +26,12 @@ class AppTheme { |
|
|
|
/// Whether to use of the Nextcloud theme. |
|
|
|
/// Whether to use of the Nextcloud theme. |
|
|
|
final bool useNextcloudTheme; |
|
|
|
final bool useNextcloudTheme; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The light theme provided by the device. |
|
|
|
|
|
|
|
final ColorScheme? deviceThemeLight; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The dark theme provided by the device. |
|
|
|
|
|
|
|
final ColorScheme? deviceThemeDark; |
|
|
|
|
|
|
|
|
|
|
|
/// 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,19 +42,39 @@ class AppTheme { |
|
|
|
final NeonTheme neonTheme; |
|
|
|
final NeonTheme neonTheme; |
|
|
|
|
|
|
|
|
|
|
|
ColorScheme _buildColorScheme(final Brightness brightness) { |
|
|
|
ColorScheme _buildColorScheme(final Brightness brightness) { |
|
|
|
final primaryColor = |
|
|
|
ColorScheme? colorScheme; |
|
|
|
nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color) : neonTheme.colorScheme.primary; |
|
|
|
|
|
|
|
final primaryColorOverride = useNextcloudTheme ? primaryColor : null; |
|
|
|
if (nextcloudTheme != null && useNextcloudTheme) { |
|
|
|
final oledBackgroundOverride = oledAsDark && brightness == Brightness.dark ? NcColors.oledBackground : null; |
|
|
|
final primaryColor = HexColor(nextcloudTheme!.color); |
|
|
|
|
|
|
|
final onPrimaryColor = HexColor(nextcloudTheme!.colorText); |
|
|
|
|
|
|
|
|
|
|
|
return ColorScheme.fromSeed( |
|
|
|
colorScheme = ColorScheme.fromSeed( |
|
|
|
seedColor: primaryColor, |
|
|
|
seedColor: primaryColor, |
|
|
|
brightness: brightness, |
|
|
|
brightness: brightness, |
|
|
|
).copyWith( |
|
|
|
).copyWith( |
|
|
|
background: oledBackgroundOverride, |
|
|
|
primary: primaryColor, |
|
|
|
primary: primaryColorOverride, |
|
|
|
onPrimary: onPrimaryColor, |
|
|
|
secondary: primaryColorOverride, |
|
|
|
secondary: primaryColor, |
|
|
|
|
|
|
|
onSecondary: onPrimaryColor, |
|
|
|
|
|
|
|
tertiary: primaryColor, |
|
|
|
|
|
|
|
onTertiary: onPrimaryColor, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
colorScheme = brightness == Brightness.dark ? deviceThemeDark : deviceThemeLight; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
colorScheme ??= ColorScheme.fromSeed( |
|
|
|
|
|
|
|
seedColor: NcColors.primary, |
|
|
|
|
|
|
|
brightness: brightness, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (oledAsDark && brightness == Brightness.dark) { |
|
|
|
|
|
|
|
colorScheme = colorScheme.copyWith( |
|
|
|
|
|
|
|
background: NcColors.oledBackground, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return colorScheme; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ThemeData _getTheme(final Brightness brightness) { |
|
|
|
ThemeData _getTheme(final Brightness brightness) { |
|
|
@ -56,7 +84,8 @@ class AppTheme { |
|
|
|
useMaterial3: true, |
|
|
|
useMaterial3: true, |
|
|
|
colorScheme: colorScheme, |
|
|
|
colorScheme: colorScheme, |
|
|
|
scaffoldBackgroundColor: colorScheme.background, |
|
|
|
scaffoldBackgroundColor: colorScheme.background, |
|
|
|
cardColor: colorScheme.background, // For LicensePage |
|
|
|
cardColor: colorScheme.background, |
|
|
|
|
|
|
|
// For LicensePage |
|
|
|
snackBarTheme: _snackBarTheme, |
|
|
|
snackBarTheme: _snackBarTheme, |
|
|
|
dividerTheme: _dividerTheme, |
|
|
|
dividerTheme: _dividerTheme, |
|
|
|
scrollbarTheme: _scrollbarTheme, |
|
|
|
scrollbarTheme: _scrollbarTheme, |
|
|
|