134 lines
4.4 KiB
Dart
Executable File
134 lines
4.4 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
||
|
||
import 'generated/theme_colors.dart';
|
||
|
||
class AppThemeColors {
|
||
const AppThemeColors({
|
||
required this.headingColor,
|
||
required this.accentColor,
|
||
required this.scaffoldGradientStart,
|
||
required this.scaffoldGradientEnd,
|
||
required this.shellSurface,
|
||
required this.shellBorder,
|
||
required this.mutedText,
|
||
required this.textOnDark,
|
||
required this.textOnDarkSecondary,
|
||
required this.controlsGradientStart,
|
||
required this.controlsGradientEnd,
|
||
required this.controlsShadow,
|
||
required this.bodyText,
|
||
required this.cardSurface,
|
||
required this.cardBorder,
|
||
required this.successColor,
|
||
required this.dangerColor,
|
||
});
|
||
|
||
/// Website: `primary` → headings (h1–h6)
|
||
final Color headingColor;
|
||
/// Website: `accent` → links & accent highlights
|
||
final Color accentColor;
|
||
/// Page background gradient start — website: `background` (cream)
|
||
final Color scaffoldGradientStart;
|
||
/// Page background gradient end — website: `light`
|
||
final Color scaffoldGradientEnd;
|
||
/// Top header card surface
|
||
final Color shellSurface;
|
||
/// Top header card border
|
||
final Color shellBorder;
|
||
/// Website: `medium` → muted / secondary text
|
||
final Color mutedText;
|
||
/// Website: `white` → text on dark surfaces
|
||
final Color textOnDark;
|
||
/// Website: `light` → secondary text on dark surfaces
|
||
final Color textOnDarkSecondary;
|
||
/// Controls bar / card surface gradient start — website: `primary_dark`
|
||
final Color controlsGradientStart;
|
||
/// Controls bar / card surface gradient end — website: `primary_dark`
|
||
final Color controlsGradientEnd;
|
||
/// Shadow color for elevated surfaces
|
||
final Color controlsShadow;
|
||
/// Website: `text` → body text
|
||
final Color bodyText;
|
||
/// Inner card background overlay — derived from `primary_dark` / `primary_light`
|
||
final Color cardSurface;
|
||
/// Inner card border — derived from `primary_dark` / `primary_light`
|
||
final Color cardBorder;
|
||
/// Website: `success` → live indicator, success states
|
||
final Color successColor;
|
||
/// Website: `danger` → error states
|
||
final Color dangerColor;
|
||
}
|
||
|
||
class AppThemeBusinessObject {
|
||
static const AppThemeColors lightColors = GeneratedThemeColors.lightColors;
|
||
static const AppThemeColors darkColors = GeneratedThemeColors.darkColors;
|
||
|
||
static bool isDarkMode(BuildContext context) {
|
||
return MediaQuery.platformBrightnessOf(context) == Brightness.dark;
|
||
}
|
||
|
||
static AppThemeColors colorsFor(BuildContext context) {
|
||
return isDarkMode(context) ? darkColors : lightColors;
|
||
}
|
||
|
||
static ThemeData lightTheme() {
|
||
final ColorScheme scheme = ColorScheme.light(
|
||
brightness: Brightness.light,
|
||
primary: lightColors.headingColor,
|
||
onPrimary: lightColors.textOnDark,
|
||
secondary: lightColors.accentColor,
|
||
onSecondary: lightColors.textOnDark,
|
||
surface: lightColors.shellSurface,
|
||
onSurface: lightColors.bodyText,
|
||
error: lightColors.dangerColor,
|
||
onError: lightColors.textOnDark,
|
||
);
|
||
|
||
return ThemeData(
|
||
useMaterial3: true,
|
||
colorScheme: scheme,
|
||
scaffoldBackgroundColor: scheme.surface,
|
||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||
style: ElevatedButton.styleFrom(
|
||
backgroundColor: scheme.primary,
|
||
foregroundColor: scheme.onPrimary,
|
||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 14),
|
||
shape: RoundedRectangleBorder(
|
||
borderRadius: BorderRadius.circular(16),
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
static ThemeData darkTheme() {
|
||
final ColorScheme scheme = ColorScheme.dark(
|
||
brightness: Brightness.dark,
|
||
primary: darkColors.headingColor,
|
||
onPrimary: darkColors.textOnDark,
|
||
secondary: darkColors.accentColor,
|
||
onSecondary: darkColors.textOnDark,
|
||
surface: darkColors.shellSurface,
|
||
onSurface: darkColors.bodyText,
|
||
error: darkColors.dangerColor,
|
||
onError: darkColors.textOnDark,
|
||
);
|
||
|
||
return ThemeData(
|
||
useMaterial3: true,
|
||
colorScheme: scheme,
|
||
scaffoldBackgroundColor: scheme.surface,
|
||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||
style: ElevatedButton.styleFrom(
|
||
backgroundColor: scheme.primary,
|
||
foregroundColor: scheme.onPrimary,
|
||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 14),
|
||
shape: RoundedRectangleBorder(
|
||
borderRadius: BorderRadius.circular(16),
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
}
|