theme.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import 'package:flutter/material.dart';
  2. class AppTheme {
  3. AppTheme._(); // 私有构造,禁止实例化
  4. /// ======================
  5. /// 颜色体系(医疗风)
  6. /// ======================
  7. static const Color primaryColor = Color(0xFF00BFA5); // 绿为主
  8. static const Color secondaryColor = Color(0xFF2F7CF6); // 蓝为辅
  9. static const Color backgroundColor = Color(0xFFF6F8FA);
  10. static const Color surfaceColor = Colors.white;
  11. static const Color textPrimary = Color(0xFF1F2937);
  12. static const Color textSecondary = Color(0xFF6B7280);
  13. static const Color dividerColor = Color(0xFFE5E7EB);
  14. static const Color errorColor = Color(0xFFEF4444);
  15. /// ======================
  16. /// 亮色主题(默认)
  17. /// ======================
  18. static final ThemeData light = ThemeData(
  19. useMaterial3: true,
  20. /// 主色
  21. colorScheme: ColorScheme.light(
  22. primary: primaryColor,
  23. secondary: secondaryColor,
  24. background: backgroundColor,
  25. surface: surfaceColor,
  26. error: errorColor,
  27. onPrimary: Colors.white,
  28. onBackground: textPrimary,
  29. ),
  30. scaffoldBackgroundColor: backgroundColor,
  31. /// AppBar
  32. appBarTheme: const AppBarTheme(
  33. elevation: 0,
  34. backgroundColor: Colors.white,
  35. foregroundColor: textPrimary,
  36. centerTitle: false,
  37. titleTextStyle: TextStyle(
  38. fontSize: 18,
  39. fontWeight: FontWeight.w600,
  40. color: textPrimary,
  41. ),
  42. ),
  43. /// 字体
  44. textTheme: const TextTheme(
  45. headlineLarge: TextStyle(
  46. fontSize: 22,
  47. fontWeight: FontWeight.w600,
  48. color: textPrimary,
  49. ),
  50. bodyLarge: TextStyle(
  51. fontSize: 16,
  52. color: textPrimary,
  53. ),
  54. bodyMedium: TextStyle(
  55. fontSize: 14,
  56. color: textSecondary,
  57. ),
  58. labelLarge: TextStyle(
  59. fontSize: 14,
  60. fontWeight: FontWeight.w500,
  61. color: Colors.white,
  62. ),
  63. ),
  64. /// Divider
  65. dividerTheme: const DividerThemeData(
  66. color: dividerColor,
  67. thickness: 1,
  68. space: 1,
  69. ),
  70. /// Card(Pad 页面大量使用)
  71. cardTheme: CardThemeData(
  72. color: surfaceColor,
  73. elevation: 0,
  74. shape: RoundedRectangleBorder(
  75. borderRadius: BorderRadius.circular(12),
  76. ),
  77. ),
  78. /// 按钮
  79. elevatedButtonTheme: ElevatedButtonThemeData(
  80. style: ElevatedButton.styleFrom(
  81. minimumSize: const Size(88, 44),
  82. backgroundColor: primaryColor,
  83. foregroundColor: Colors.white,
  84. textStyle: const TextStyle(
  85. fontSize: 14,
  86. fontWeight: FontWeight.w500,
  87. ),
  88. shape: RoundedRectangleBorder(
  89. borderRadius: BorderRadius.circular(8),
  90. ),
  91. ),
  92. ),
  93. /// 输入框(病历 / 诊断高频)
  94. inputDecorationTheme: InputDecorationTheme(
  95. filled: true,
  96. fillColor: Colors.white,
  97. contentPadding:
  98. const EdgeInsets.fromLTRB(12, 18, 12, 10),
  99. border: OutlineInputBorder(
  100. borderRadius: BorderRadius.circular(8),
  101. borderSide: const BorderSide(color: dividerColor),
  102. ),
  103. enabledBorder: OutlineInputBorder(
  104. borderRadius: BorderRadius.circular(8),
  105. borderSide: const BorderSide(color: dividerColor),
  106. ),
  107. focusedBorder: OutlineInputBorder(
  108. borderRadius: BorderRadius.circular(8),
  109. borderSide: const BorderSide(color: primaryColor, width: 1.5),
  110. ),
  111. errorBorder: OutlineInputBorder(
  112. borderRadius: BorderRadius.circular(8),
  113. borderSide: const BorderSide(color: errorColor),
  114. ),
  115. ),
  116. );
  117. /// ======================
  118. /// 暗色主题(预留)
  119. /// ======================
  120. static final ThemeData dark = ThemeData.dark(useMaterial3: true);
  121. }