109 lines
3.2 KiB
Dart
109 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'generated/theme_colors.dart';
|
|
|
|
class AppThemeColors {
|
|
const AppThemeColors({
|
|
required this.primarySeed,
|
|
required this.secondarySeed,
|
|
required this.scaffoldGradientStart,
|
|
required this.scaffoldGradientEnd,
|
|
required this.shellSurface,
|
|
required this.shellBorder,
|
|
required this.accent,
|
|
required this.webViewBorder,
|
|
required this.webViewBackground,
|
|
required this.controlsGradientStart,
|
|
required this.controlsGradientEnd,
|
|
required this.controlsShadow,
|
|
required this.statusText,
|
|
});
|
|
|
|
final Color primarySeed;
|
|
final Color secondarySeed;
|
|
final Color scaffoldGradientStart;
|
|
final Color scaffoldGradientEnd;
|
|
final Color shellSurface;
|
|
final Color shellBorder;
|
|
final Color accent;
|
|
final Color webViewBorder;
|
|
final Color webViewBackground;
|
|
final Color controlsGradientStart;
|
|
final Color controlsGradientEnd;
|
|
final Color controlsShadow;
|
|
final Color statusText;
|
|
}
|
|
|
|
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.fromSeed(
|
|
seedColor: lightColors.primarySeed,
|
|
brightness: Brightness.light,
|
|
).copyWith(
|
|
primary: lightColors.primarySeed,
|
|
secondary: lightColors.secondarySeed,
|
|
tertiary: const Color(0xFF2C85E1),
|
|
surface: const Color(0xFFFFFBF7),
|
|
onSurface: lightColors.statusText,
|
|
);
|
|
|
|
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.fromSeed(
|
|
seedColor: darkColors.primarySeed,
|
|
brightness: Brightness.dark,
|
|
).copyWith(
|
|
primary: darkColors.primarySeed,
|
|
secondary: darkColors.secondarySeed,
|
|
tertiary: const Color(0xFF4E97E8),
|
|
surface: const Color(0xFF111A27),
|
|
onSurface: darkColors.statusText,
|
|
);
|
|
|
|
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),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|