| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- import 'package:flutter/material.dart';
- import 'package:tdesign_flutter/tdesign_flutter.dart';
- import 'app_colors.dart';
- import 'app_colors_extension.dart';
- class AppTheme {
- AppTheme._();
- static Map<String, Font> _fontMap() => <String, Font>{
- 'fontBodyMedium': Font(size: AppFontSizes.body.toInt(), lineHeight: 22),
- 'fontBodySmall': Font(
- size: AppFontSizes.caption.toInt(),
- lineHeight: 20,
- ),
- 'fontTitleMedium': Font(
- size: AppFontSizes.subtitle.toInt(),
- lineHeight: 24,
- ),
- 'fontTitleLarge': Font(
- size: AppFontSizes.title.toInt(),
- lineHeight: 26,
- ),
- };
- /// TDesign 亮色主题
- static TDThemeData get tdThemeData {
- final base = TDThemeData.defaultData();
- return base.copyWithTDThemeData(
- 'tbossLight',
- colorMap: <String, Color>{
- 'brandNormalColor': AppColors.primary,
- 'brandClickColor': AppColors.primaryActive,
- 'successNormalColor': AppColors.success,
- 'warningNormalColor': AppColors.warning,
- 'errorNormalColor': AppColors.danger,
- 'textColorPrimary': AppColors.textPrimary,
- 'textColorSecondary': AppColors.textSecondary,
- 'textColorPlaceholder': AppColors.textPlaceholder,
- 'bgColorPage': AppColors.bgPage,
- 'bgColorContainer': AppColors.bgCard,
- 'borderColor': AppColors.border,
- },
- fontMap: _fontMap(),
- );
- }
- /// TDesign 深色主题
- static TDThemeData get darkTdThemeData {
- final base = TDThemeData.defaultData();
- return base.copyWithTDThemeData(
- 'tbossDark',
- colorMap: <String, Color>{
- 'brandNormalColor': AppColors.primary,
- 'brandClickColor': AppColors.primaryActive,
- 'successNormalColor': AppDarkColors.success,
- 'warningNormalColor': AppDarkColors.warning,
- 'errorNormalColor': AppDarkColors.danger,
- 'textColorPrimary': AppDarkColors.textPrimary,
- 'textColorSecondary': AppDarkColors.textSecondary,
- 'textColorPlaceholder': AppDarkColors.textPlaceholder,
- 'bgColorPage': AppDarkColors.bgPage,
- 'bgColorContainer': AppDarkColors.bgCard,
- 'borderColor': AppDarkColors.border,
- },
- fontMap: _fontMap(),
- );
- }
- static ThemeData get light {
- final colorScheme = ColorScheme.fromSeed(
- seedColor: AppColors.primary,
- brightness: Brightness.light,
- ).copyWith(surface: AppColors.bgPage);
- return ThemeData(
- useMaterial3: true,
- extensions: [AppColorsExtension.light, AppTheme.tdThemeData],
- colorScheme: colorScheme,
- canvasColor: AppColors.bgPage,
- scaffoldBackgroundColor: AppColors.bgPage,
- appBarTheme: const AppBarTheme(
- backgroundColor: AppColors.primary,
- foregroundColor: Colors.white,
- elevation: 0,
- centerTitle: false,
- titleTextStyle: TextStyle(
- fontSize: AppFontSizes.title,
- fontWeight: FontWeight.w600,
- color: Colors.white,
- ),
- ),
- cardTheme: CardThemeData(
- color: AppColors.bgCard,
- elevation: 1,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
- ),
- elevatedButtonTheme: ElevatedButtonThemeData(
- style: ElevatedButton.styleFrom(
- backgroundColor: AppColors.primary,
- foregroundColor: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(22),
- ),
- minimumSize: const Size(double.infinity, 44),
- textStyle: const TextStyle(
- fontSize: AppFontSizes.body,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- outlinedButtonTheme: OutlinedButtonThemeData(
- style: OutlinedButton.styleFrom(
- foregroundColor: AppColors.textPrimary,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(22),
- ),
- minimumSize: const Size(double.infinity, 44),
- side: const BorderSide(color: AppColors.border),
- textStyle: const TextStyle(fontSize: AppFontSizes.body),
- ),
- ),
- dividerColor: AppColors.border,
- dividerTheme: const DividerThemeData(
- color: AppColors.border,
- thickness: 1,
- ),
- );
- }
- static ThemeData get dark {
- final colorScheme = ColorScheme.fromSeed(
- seedColor: AppColors.primary,
- brightness: Brightness.dark,
- ).copyWith(surface: AppDarkColors.bgPage);
- return ThemeData(
- useMaterial3: true,
- extensions: [AppColorsExtension.dark, AppTheme.darkTdThemeData],
- colorScheme: colorScheme,
- canvasColor: AppDarkColors.bgPage,
- scaffoldBackgroundColor: AppDarkColors.bgPage,
- appBarTheme: const AppBarTheme(
- backgroundColor: AppDarkColors.bgCard,
- foregroundColor: AppDarkColors.textPrimary,
- elevation: 0,
- centerTitle: false,
- titleTextStyle: TextStyle(
- fontSize: AppFontSizes.title,
- fontWeight: FontWeight.w600,
- color: AppDarkColors.textPrimary,
- ),
- ),
- cardTheme: CardThemeData(
- color: AppDarkColors.bgCard,
- elevation: 1,
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
- ),
- elevatedButtonTheme: ElevatedButtonThemeData(
- style: ElevatedButton.styleFrom(
- backgroundColor: AppColors.primary,
- foregroundColor: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(22),
- ),
- minimumSize: const Size(double.infinity, 44),
- textStyle: const TextStyle(
- fontSize: AppFontSizes.body,
- fontWeight: FontWeight.w600,
- ),
- ),
- ),
- outlinedButtonTheme: OutlinedButtonThemeData(
- style: OutlinedButton.styleFrom(
- foregroundColor: AppDarkColors.textPrimary,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(22),
- ),
- minimumSize: const Size(double.infinity, 44),
- side: const BorderSide(color: AppDarkColors.border),
- textStyle: const TextStyle(fontSize: AppFontSizes.body),
- ),
- ),
- dividerColor: AppDarkColors.border,
- dividerTheme: const DividerThemeData(
- color: AppDarkColors.border,
- thickness: 1,
- ),
- );
- }
- }
|