107 lines
3.5 KiB
Dart
107 lines
3.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'app_colors.dart';
|
|
|
|
/// Theme extension for gradients and colors not covered by [ColorScheme].
|
|
@immutable
|
|
class AppThemeExtras extends ThemeExtension<AppThemeExtras> {
|
|
const AppThemeExtras({
|
|
required this.dashboardBackgroundGradient,
|
|
required this.dashboardGradientStops,
|
|
required this.heroProgressStart,
|
|
required this.heroProgressEnd,
|
|
required this.actionCardGradientStart,
|
|
required this.actionCardGradientEnd,
|
|
required this.authBackgroundGradient,
|
|
required this.dashboardHeaderTextColor,
|
|
});
|
|
|
|
final List<Color> dashboardBackgroundGradient;
|
|
final List<double> dashboardGradientStops;
|
|
final Color heroProgressStart;
|
|
final Color heroProgressEnd;
|
|
final Color actionCardGradientStart;
|
|
final Color actionCardGradientEnd;
|
|
final List<Color> authBackgroundGradient;
|
|
final Color dashboardHeaderTextColor;
|
|
|
|
static final AppThemeExtras light = AppThemeExtras(
|
|
dashboardBackgroundGradient: [
|
|
AppColors.primaryTeal,
|
|
AppColors.primaryTeal.withValues(alpha: 0.8),
|
|
AppColors.primaryOrange,
|
|
LightColors.background,
|
|
],
|
|
dashboardGradientStops: [0.0, 0.2, 0.6, 1.0],
|
|
heroProgressStart: Colors.white,
|
|
heroProgressEnd: Color(0xFFF8F9FA),
|
|
actionCardGradientStart: AppColors.primaryTeal,
|
|
actionCardGradientEnd: AppColors.gradientEnd,
|
|
authBackgroundGradient: [
|
|
const Color(0xFFD4E8E8),
|
|
const Color(0xFFE8D4C0),
|
|
const Color(0xFFD8E0E8),
|
|
],
|
|
dashboardHeaderTextColor: Colors.white,
|
|
);
|
|
|
|
static final AppThemeExtras dark = AppThemeExtras(
|
|
dashboardBackgroundGradient: [
|
|
DarkColors.surfaceVariant,
|
|
DarkColors.surface,
|
|
DarkColors.background,
|
|
DarkColors.background,
|
|
],
|
|
dashboardGradientStops: [0.0, 0.25, 0.55, 1.0],
|
|
heroProgressStart: Colors.white.withValues(alpha: 0.9),
|
|
heroProgressEnd: Colors.white.withValues(alpha: 0.55),
|
|
actionCardGradientStart: DarkBrandColors.gradientStart,
|
|
actionCardGradientEnd: DarkBrandColors.gradientEnd,
|
|
authBackgroundGradient: [
|
|
DarkColors.surfaceVariant,
|
|
DarkColors.surface,
|
|
DarkColors.background,
|
|
],
|
|
dashboardHeaderTextColor: DarkColors.textPrimary,
|
|
);
|
|
|
|
static AppThemeExtras of(BuildContext context) {
|
|
return Theme.of(context).extension<AppThemeExtras>() ?? light;
|
|
}
|
|
|
|
@override
|
|
AppThemeExtras copyWith({
|
|
List<Color>? dashboardBackgroundGradient,
|
|
List<double>? dashboardGradientStops,
|
|
Color? heroProgressStart,
|
|
Color? heroProgressEnd,
|
|
Color? actionCardGradientStart,
|
|
Color? actionCardGradientEnd,
|
|
List<Color>? authBackgroundGradient,
|
|
Color? dashboardHeaderTextColor,
|
|
}) {
|
|
return AppThemeExtras(
|
|
dashboardBackgroundGradient:
|
|
dashboardBackgroundGradient ?? this.dashboardBackgroundGradient,
|
|
dashboardGradientStops:
|
|
dashboardGradientStops ?? this.dashboardGradientStops,
|
|
heroProgressStart: heroProgressStart ?? this.heroProgressStart,
|
|
heroProgressEnd: heroProgressEnd ?? this.heroProgressEnd,
|
|
actionCardGradientStart:
|
|
actionCardGradientStart ?? this.actionCardGradientStart,
|
|
actionCardGradientEnd:
|
|
actionCardGradientEnd ?? this.actionCardGradientEnd,
|
|
authBackgroundGradient:
|
|
authBackgroundGradient ?? this.authBackgroundGradient,
|
|
dashboardHeaderTextColor:
|
|
dashboardHeaderTextColor ?? this.dashboardHeaderTextColor,
|
|
);
|
|
}
|
|
|
|
@override
|
|
AppThemeExtras lerp(ThemeExtension<AppThemeExtras>? other, double t) {
|
|
if (other is! AppThemeExtras) return this;
|
|
return t < 0.5 ? this : other;
|
|
}
|
|
}
|