|
|
@ -7,40 +7,79 @@ import 'package:nextcloud/nextcloud.dart'; |
|
|
|
const themePrimaryColor = Color(0xFFF37736); |
|
|
|
const themePrimaryColor = Color(0xFFF37736); |
|
|
|
|
|
|
|
|
|
|
|
@internal |
|
|
|
@internal |
|
|
|
ThemeData getThemeFromNextcloudTheme( |
|
|
|
@immutable |
|
|
|
final CoreServerCapabilities_Ocs_Data_Capabilities_Theming? nextcloudTheme, |
|
|
|
class AppTheme { |
|
|
|
final Brightness brightness, { |
|
|
|
AppTheme( |
|
|
|
required final bool keepOriginalAccentColor, |
|
|
|
this.nextcloudTheme, { |
|
|
|
final bool oledAsDark = false, |
|
|
|
final bool keepOriginalAccentColor = false, |
|
|
|
}) { |
|
|
|
this.oledAsDark = false, |
|
|
|
if (oledAsDark) { |
|
|
|
this.appThemes, |
|
|
|
assert(brightness == Brightness.dark, 'Brightness.dark is required for oledAsDark.'); |
|
|
|
}) : keepOriginalAccentColor = nextcloudTheme == null || keepOriginalAccentColor; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final CoreServerCapabilities_Ocs_Data_Capabilities_Theming? nextcloudTheme; |
|
|
|
|
|
|
|
final bool keepOriginalAccentColor; |
|
|
|
|
|
|
|
final bool oledAsDark; |
|
|
|
|
|
|
|
final Iterable<ThemeExtension>? appThemes; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
late final _primaryColor = nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color!) : themePrimaryColor; |
|
|
|
|
|
|
|
late final _keepOriginalAccentColorOverride = keepOriginalAccentColor ? _primaryColor : null; |
|
|
|
|
|
|
|
|
|
|
|
final primaryColor = nextcloudTheme?.color != null ? HexColor(nextcloudTheme!.color!) : themePrimaryColor; |
|
|
|
ColorScheme _buildColorScheme(final Brightness brightness) { |
|
|
|
|
|
|
|
final oledBackgroundOverride = oledAsDark && brightness == Brightness.dark ? Colors.black : null; |
|
|
|
|
|
|
|
|
|
|
|
final oledBackgroundOverride = oledAsDark ? Colors.black : null; |
|
|
|
return ColorScheme.fromSeed( |
|
|
|
final keepOriginalAccentColorOverride = keepOriginalAccentColor ? primaryColor : null; |
|
|
|
seedColor: _primaryColor, |
|
|
|
final colorScheme = ColorScheme.fromSeed( |
|
|
|
|
|
|
|
seedColor: primaryColor, |
|
|
|
|
|
|
|
brightness: brightness, |
|
|
|
brightness: brightness, |
|
|
|
).copyWith( |
|
|
|
).copyWith( |
|
|
|
background: oledBackgroundOverride, |
|
|
|
background: oledBackgroundOverride, |
|
|
|
primary: keepOriginalAccentColorOverride, |
|
|
|
primary: _keepOriginalAccentColorOverride, |
|
|
|
secondary: keepOriginalAccentColorOverride, |
|
|
|
secondary: _keepOriginalAccentColorOverride, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ThemeData _getTheme(final Brightness brightness) { |
|
|
|
|
|
|
|
final colorScheme = _buildColorScheme(brightness); |
|
|
|
|
|
|
|
|
|
|
|
return ThemeData( |
|
|
|
return ThemeData( |
|
|
|
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: const SnackBarThemeData( |
|
|
|
snackBarTheme: _snackBarTheme, |
|
|
|
|
|
|
|
dividerTheme: _dividerTheme, |
|
|
|
|
|
|
|
extensions: [ |
|
|
|
|
|
|
|
const NeonTheme(), |
|
|
|
|
|
|
|
...?appThemes, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ThemeData get lightTheme => _getTheme(Brightness.light); |
|
|
|
|
|
|
|
ThemeData get darkTheme => _getTheme(Brightness.dark); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static const _snackBarTheme = SnackBarThemeData( |
|
|
|
behavior: SnackBarBehavior.floating, |
|
|
|
behavior: SnackBarBehavior.floating, |
|
|
|
), |
|
|
|
); |
|
|
|
dividerTheme: const DividerThemeData( |
|
|
|
|
|
|
|
|
|
|
|
static const _dividerTheme = DividerThemeData( |
|
|
|
thickness: 1.5, |
|
|
|
thickness: 1.5, |
|
|
|
space: 30, |
|
|
|
space: 30, |
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@internal |
|
|
|
|
|
|
|
@immutable |
|
|
|
|
|
|
|
class NeonTheme extends ThemeExtension<NeonTheme> { |
|
|
|
|
|
|
|
const NeonTheme(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
NeonTheme copyWith() => const NeonTheme(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
|
|
|
NeonTheme lerp(final NeonTheme? other, final double t) { |
|
|
|
|
|
|
|
if (other is! NeonTheme) { |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return const NeonTheme(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|