feat: 静态页面开发完成
This commit is contained in:
149
lib/theme.dart
149
lib/theme.dart
@@ -4,45 +4,106 @@ import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
|
||||
class AppColors {
|
||||
// Brand colors (stable across light/dark)
|
||||
static const primary = Color(0xFF1A56DB);
|
||||
static const primaryLight = Color(0xFF3B82F6);
|
||||
static const primaryDark = Color(0xFF1E40AF);
|
||||
static const accent = Color(0xFF00C9A7);
|
||||
static const accentLight = Color(0xFF6EE7B7);
|
||||
static const background = Color(0xFFF8FAFC);
|
||||
static const surface = Colors.white;
|
||||
static const error = Color(0xFFEF4444);
|
||||
static const warning = Color(0xFFF59E0B);
|
||||
static const success = Color(0xFF10B981);
|
||||
static const textPrimary = Color(0xFF1E293B);
|
||||
static const textSecondary = Color(0xFF64748B);
|
||||
static const textTertiary = Color(0xFF94A3B8);
|
||||
static const divider = Color(0xFFE2E8F0);
|
||||
static const cardShadow = Color(0x1A000000);
|
||||
static const gradientStart = Color(0xFF1A56DB);
|
||||
static const gradientEnd = Color(0xFF00C9A7);
|
||||
static const chatUserBubble = Color(0xFF1A56DB);
|
||||
static const chatAiBubble = Color(0xFFF1F5F9);
|
||||
static const scanOverlay = Color(0x801A56DB);
|
||||
|
||||
// Light palette (raw values)
|
||||
static const _lightBackground = Color(0xFFF8FAFC);
|
||||
static const _lightSurface = Color(0xFFFFFFFF);
|
||||
static const _lightTextPrimary = Color(0xFF1E293B);
|
||||
static const _lightTextSecondary = Color(0xFF64748B);
|
||||
static const _lightTextTertiary = Color(0xFF94A3B8);
|
||||
static const _lightDivider = Color(0xFFE2E8F0);
|
||||
static const _lightCardShadow = Color(0x1A000000);
|
||||
static const _lightChatAiBubble = Color(0xFFF1F5F9);
|
||||
|
||||
// Dark palette (raw values)
|
||||
static const _darkBackground = Color(0xFF0F172A);
|
||||
static const _darkSurface = Color(0xFF1E293B);
|
||||
static const _darkTextPrimary = Color(0xFFE2E8F0);
|
||||
static const _darkTextSecondary = Color(0xFF94A3B8);
|
||||
static const _darkTextTertiary = Color(0xFF64748B);
|
||||
static const _darkDivider = Color(0xFF334155);
|
||||
static const _darkCardShadow = Color(0x40000000);
|
||||
static const _darkChatAiBubble = Color(0xFF1E293B);
|
||||
|
||||
// Mutable references — flipped at runtime via applyMode.
|
||||
static Color background = _lightBackground;
|
||||
static Color surface = _lightSurface;
|
||||
static Color textPrimary = _lightTextPrimary;
|
||||
static Color textSecondary = _lightTextSecondary;
|
||||
static Color textTertiary = _lightTextTertiary;
|
||||
static Color divider = _lightDivider;
|
||||
static Color cardShadow = _lightCardShadow;
|
||||
static Color chatAiBubble = _lightChatAiBubble;
|
||||
static bool isDark = false;
|
||||
|
||||
static void applyMode(bool dark) {
|
||||
isDark = dark;
|
||||
if (dark) {
|
||||
background = _darkBackground;
|
||||
surface = _darkSurface;
|
||||
textPrimary = _darkTextPrimary;
|
||||
textSecondary = _darkTextSecondary;
|
||||
textTertiary = _darkTextTertiary;
|
||||
divider = _darkDivider;
|
||||
cardShadow = _darkCardShadow;
|
||||
chatAiBubble = _darkChatAiBubble;
|
||||
} else {
|
||||
background = _lightBackground;
|
||||
surface = _lightSurface;
|
||||
textPrimary = _lightTextPrimary;
|
||||
textSecondary = _lightTextSecondary;
|
||||
textTertiary = _lightTextTertiary;
|
||||
divider = _lightDivider;
|
||||
cardShadow = _lightCardShadow;
|
||||
chatAiBubble = _lightChatAiBubble;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AppTheme {
|
||||
static ThemeData get lightTheme {
|
||||
static ThemeData get theme {
|
||||
final dark = AppColors.isDark;
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.light,
|
||||
colorScheme: const ColorScheme.light(
|
||||
primary: AppColors.primary,
|
||||
onPrimary: Colors.white,
|
||||
secondary: AppColors.accent,
|
||||
onSecondary: Colors.white,
|
||||
surface: AppColors.surface,
|
||||
onSurface: AppColors.textPrimary,
|
||||
error: AppColors.error,
|
||||
onError: Colors.white,
|
||||
background: AppColors.background,
|
||||
onBackground: AppColors.textPrimary,
|
||||
),
|
||||
brightness: dark ? Brightness.dark : Brightness.light,
|
||||
colorScheme: dark
|
||||
? ColorScheme.dark(
|
||||
primary: AppColors.primaryLight,
|
||||
onPrimary: Colors.white,
|
||||
secondary: AppColors.accent,
|
||||
onSecondary: Colors.white,
|
||||
surface: AppColors.surface,
|
||||
onSurface: AppColors.textPrimary,
|
||||
error: AppColors.error,
|
||||
onError: Colors.white,
|
||||
background: AppColors.background,
|
||||
onBackground: AppColors.textPrimary,
|
||||
)
|
||||
: ColorScheme.light(
|
||||
primary: AppColors.primary,
|
||||
onPrimary: Colors.white,
|
||||
secondary: AppColors.accent,
|
||||
onSecondary: Colors.white,
|
||||
surface: AppColors.surface,
|
||||
onSurface: AppColors.textPrimary,
|
||||
error: AppColors.error,
|
||||
onError: Colors.white,
|
||||
background: AppColors.background,
|
||||
onBackground: AppColors.textPrimary,
|
||||
),
|
||||
scaffoldBackgroundColor: AppColors.background,
|
||||
textTheme: GoogleFonts.notoSansScTextTheme().copyWith(
|
||||
displayLarge: GoogleFonts.notoSansSc(
|
||||
@@ -72,7 +133,8 @@ class AppTheme {
|
||||
centerTitle: true,
|
||||
backgroundColor: AppColors.surface,
|
||||
foregroundColor: AppColors.textPrimary,
|
||||
systemOverlayStyle: SystemUiOverlayStyle.dark,
|
||||
systemOverlayStyle:
|
||||
dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark,
|
||||
titleTextStyle: GoogleFonts.notoSansSc(
|
||||
fontSize: 18, fontWeight: FontWeight.w600, color: AppColors.textPrimary,
|
||||
),
|
||||
@@ -148,7 +210,7 @@ class AppTheme {
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 4,
|
||||
),
|
||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
||||
bottomNavigationBarTheme: BottomNavigationBarThemeData(
|
||||
backgroundColor: AppColors.surface,
|
||||
selectedItemColor: AppColors.primary,
|
||||
unselectedItemColor: AppColors.textTertiary,
|
||||
@@ -163,7 +225,7 @@ class AppTheme {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
dividerTheme: const DividerThemeData(
|
||||
dividerTheme: DividerThemeData(
|
||||
color: AppColors.divider,
|
||||
thickness: 1,
|
||||
space: 1,
|
||||
@@ -181,33 +243,22 @@ class AppTheme {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static ThemeData get darkTheme {
|
||||
return lightTheme.copyWith(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: const ColorScheme.dark(
|
||||
primary: AppColors.primaryLight,
|
||||
onPrimary: Colors.white,
|
||||
secondary: AppColors.accent,
|
||||
onSecondary: Colors.white,
|
||||
surface: Color(0xFF1E293B),
|
||||
onSurface: Colors.white,
|
||||
error: AppColors.error,
|
||||
onError: Colors.white,
|
||||
background: Color(0xFF0F172A),
|
||||
onBackground: Colors.white,
|
||||
),
|
||||
scaffoldBackgroundColor: const Color(0xFF0F172A),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AppGradients {
|
||||
static const primary = LinearGradient(
|
||||
colors: [AppColors.gradientStart, AppColors.gradientEnd],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
);
|
||||
// Light: bright brand blue → teal. Dark: deeper, more subdued.
|
||||
static const _lightStart = Color(0xFF1A56DB);
|
||||
static const _lightEnd = Color(0xFF00C9A7);
|
||||
static const _darkStart = Color(0xFF1E3A8A);
|
||||
static const _darkEnd = Color(0xFF0F766E);
|
||||
|
||||
static LinearGradient get primary => LinearGradient(
|
||||
colors: AppColors.isDark
|
||||
? const [_darkStart, _darkEnd]
|
||||
: const [_lightStart, _lightEnd],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
);
|
||||
|
||||
static const card = LinearGradient(
|
||||
colors: [Color(0xFF1A56DB), Color(0xFF2563EB)],
|
||||
|
||||
Reference in New Issue
Block a user