app_theme.dart 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import 'package:flutter/material.dart';
  2. import 'app_colors.dart';
  3. /// 应用主题配置
  4. class AppTheme {
  5. static ThemeData lightTheme = ThemeData(
  6. useMaterial3: true,
  7. fontFamily: 'Noto Sans SC',
  8. colorScheme: ColorScheme.fromSeed(
  9. seedColor: AppColors.primary,
  10. brightness: Brightness.light,
  11. ),
  12. // 卡片主题
  13. cardTheme: CardThemeData(
  14. elevation: 2,
  15. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
  16. margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
  17. ),
  18. // 按钮主题
  19. elevatedButtonTheme: ElevatedButtonThemeData(
  20. style: ElevatedButton.styleFrom(
  21. elevation: 0,
  22. padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
  23. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
  24. ),
  25. ),
  26. // 输入框主题
  27. inputDecorationTheme: InputDecorationTheme(
  28. border: OutlineInputBorder(
  29. borderRadius: BorderRadius.circular(6),
  30. borderSide: const BorderSide(color: AppColors.border),
  31. ),
  32. enabledBorder: OutlineInputBorder(
  33. borderRadius: BorderRadius.circular(6),
  34. borderSide: const BorderSide(color: AppColors.border),
  35. ),
  36. focusedBorder: OutlineInputBorder(
  37. borderRadius: BorderRadius.circular(6),
  38. borderSide: const BorderSide(color: AppColors.primary, width: 2),
  39. ),
  40. contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
  41. ),
  42. // 文本主题
  43. textTheme: const TextTheme(
  44. displayLarge: TextStyle(
  45. fontSize: 32,
  46. fontWeight: FontWeight.bold,
  47. color: AppColors.textPrimary,
  48. ),
  49. displayMedium: TextStyle(
  50. fontSize: 28,
  51. fontWeight: FontWeight.bold,
  52. color: AppColors.textPrimary,
  53. ),
  54. displaySmall: TextStyle(
  55. fontSize: 24,
  56. fontWeight: FontWeight.bold,
  57. color: AppColors.textPrimary,
  58. ),
  59. headlineLarge: TextStyle(
  60. fontSize: 20,
  61. fontWeight: FontWeight.w600,
  62. color: AppColors.textPrimary,
  63. ),
  64. headlineMedium: TextStyle(
  65. fontSize: 18,
  66. fontWeight: FontWeight.w600,
  67. color: AppColors.textPrimary,
  68. ),
  69. headlineSmall: TextStyle(
  70. fontSize: 16,
  71. fontWeight: FontWeight.w600,
  72. color: AppColors.textPrimary,
  73. ),
  74. bodyLarge: TextStyle(fontSize: 16, color: AppColors.textPrimary),
  75. bodyMedium: TextStyle(fontSize: 14, color: AppColors.textPrimary),
  76. bodySmall: TextStyle(fontSize: 12, color: AppColors.textSecondary),
  77. ),
  78. // 应用栏主题
  79. appBarTheme: const AppBarTheme(
  80. elevation: 0,
  81. centerTitle: false,
  82. backgroundColor: AppColors.backgroundLight,
  83. foregroundColor: AppColors.textPrimary,
  84. ),
  85. // 分割线主题
  86. dividerTheme: const DividerThemeData(
  87. color: AppColors.borderLight,
  88. thickness: 1,
  89. space: 1,
  90. ),
  91. );
  92. static ThemeData darkTheme = ThemeData(
  93. useMaterial3: true,
  94. fontFamily: 'Noto Sans SC',
  95. colorScheme: ColorScheme.fromSeed(
  96. seedColor: AppColors.primary,
  97. brightness: Brightness.dark,
  98. ),
  99. );
  100. }