import 'package:flutter/material.dart'; /// Readful应用主题配置 /// /// 提供完整的Material Design 3主题系统,包括: /// - 亮色和暗色主题支持 /// - 自动跟随系统主题切换 /// - 统一的颜色方案和字体系统 /// - 专业的电子书阅读器配色 class AppTheme { /// 主题种子颜色 /// /// 选择蓝绿色调(#0D7A7F),原因: /// - 眼睛友好,适合长时间阅读 /// - 专业且现代的视觉效果 /// - 在亮色和暗色模式下都有良好对比度 static const Color primarySeed = Color(0xFF0D7A7F); // 亮色主题 static ThemeData lightTheme = ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed( seedColor: primarySeed, brightness: Brightness.light, ), // 文本主题配置 textTheme: const TextTheme( headlineLarge: TextStyle( fontSize: 32, fontWeight: FontWeight.bold, letterSpacing: -0.5, ), headlineMedium: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, letterSpacing: -0.25, ), bodyLarge: TextStyle( fontSize: 16, fontWeight: FontWeight.normal, letterSpacing: 0.1, ), bodyMedium: TextStyle( fontSize: 14, fontWeight: FontWeight.normal, letterSpacing: 0.25, ), ), // AppBar主题 appBarTheme: const AppBarTheme( centerTitle: true, elevation: 0, scrolledUnderElevation: 1, ), // Card主题 cardTheme: const CardTheme( elevation: 2, margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), ), // 底部导航栏主题 bottomNavigationBarTheme: const BottomNavigationBarThemeData( selectedItemColor: Color(0xFF0D7A7F), // 主题色 unselectedItemColor: Colors.grey, type: BottomNavigationBarType.fixed, ), ); // 暗色主题 static ThemeData darkTheme = ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed( seedColor: primarySeed, brightness: Brightness.dark, ), // 文本主题配置(暗色模式下的字体配置) textTheme: const TextTheme( headlineLarge: TextStyle( fontSize: 32, fontWeight: FontWeight.bold, letterSpacing: -0.5, color: Colors.white, ), headlineMedium: TextStyle( fontSize: 24, fontWeight: FontWeight.w600, letterSpacing: -0.25, color: Colors.white, ), bodyLarge: TextStyle( fontSize: 16, fontWeight: FontWeight.normal, letterSpacing: 0.1, color: Colors.white70, ), bodyMedium: TextStyle( fontSize: 14, fontWeight: FontWeight.normal, letterSpacing: 0.25, color: Colors.white70, ), ), // AppBar主题(暗色模式) appBarTheme: const AppBarTheme( centerTitle: true, elevation: 0, scrolledUnderElevation: 1, ), // Card主题(暗色模式) cardTheme: const CardTheme( elevation: 2, margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), ), // 底部导航栏主题(暗色模式) bottomNavigationBarTheme: const BottomNavigationBarThemeData( selectedItemColor: Color(0xFF4DD0E1), // 暗色模式下的亮色版本 unselectedItemColor: Colors.grey, type: BottomNavigationBarType.fixed, ), ); /// 获取系统当前的主题模式 static Brightness getCurrentBrightness(BuildContext context) { return MediaQuery.of(context).platformBrightness; } /// 根据系统返回对应的主题 static ThemeData getSystemTheme(BuildContext context) { return getCurrentBrightness(context) == Brightness.dark ? darkTheme : lightTheme; } }