diff --git a/lib/core/theme/app_theme.dart b/lib/core/theme/app_theme.dart index 8738441..e032eb7 100644 --- a/lib/core/theme/app_theme.dart +++ b/lib/core/theme/app_theme.dart @@ -2,120 +2,263 @@ import 'package:flutter/material.dart'; enum AppThemeMode { light, dark, system } +/// Material 3 主题(参考 ZalithLauncher 的 M3 实现风格): +/// - 用种子色生成完整 tonal palette,强调 colorScheme 的 surface container 层级 +/// - 形状体系改用 M3 标准圆角(8 / 12 / 16 / 28),容器类用 16-28 的大圆角 +/// - 卡片/列表靠 surfaceContainer 区分层次,弱化描边、不用阴影 class AppTheme { static const _primaryColor = Color(0xFF4CAF50); - /// 全局圆角体系 - static const radiusS = 10.0; // chips / 小元素 - static const radiusM = 14.0; // 输入框 / 按钮 - static const radiusL = 18.0; // 卡片 / 弹窗 + /// 形状体系(对齐 M3 shape scale) + static const radiusXS = 8.0; // 小控件 / chip + static const radiusS = 12.0; // 输入框 / 按钮 + static const radiusM = 16.0; // 卡片 / 列表容器 + static const radiusL = 28.0; // 弹窗 / 底部面板 / FAB static ThemeData _base(Brightness brightness) { + final isDark = brightness == Brightness.dark; final scheme = ColorScheme.fromSeed( seedColor: _primaryColor, brightness: brightness, + // 让主色更饱和、更接近 ZL2 那种"绿色主色调穿透整个界面"的效果 + dynamicSchemeVariant: DynamicSchemeVariant.fidelity, + ).copyWith( + surface: isDark ? const Color(0xFF101410) : const Color(0xFFF7FAF5), + surfaceContainerLowest: isDark ? const Color(0xFF0B0E0B) : Colors.white, + surfaceContainerLow: isDark ? const Color(0xFF161A16) : const Color(0xFFF1F5EE), + surfaceContainer: isDark ? const Color(0xFF1B201B) : const Color(0xFFEBF0E8), + surfaceContainerHigh: isDark ? const Color(0xFF232823) : const Color(0xFFE3E9E0), + surfaceContainerHighest: isDark ? const Color(0xFF2C322C) : const Color(0xFFDCE3D9), ); - final isDark = brightness == Brightness.dark; + + final cardColor = isDark ? scheme.surfaceContainer : scheme.surfaceContainerLowest; + final outline = isDark ? const Color(0xFF2E352E) : const Color(0xFFDDE4DA); + + final shapeXS = RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusXS)); + final shapeS = RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusS)); + final shapeM = RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)); + final shapeL = RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusL)); return ThemeData( useMaterial3: true, colorScheme: scheme, - scaffoldBackgroundColor: isDark ? const Color(0xFF111318) : const Color(0xFFF7F8FA), + scaffoldBackgroundColor: scheme.surface, + // M3 强调排版层级:标题加粗收紧字距,正文行高放宽 + textTheme: Typography.material2021(platform: TargetPlatform.android) + .black + .apply( + bodyColor: scheme.onSurface, + displayColor: scheme.onSurface, + ) + .copyWith( + titleLarge: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w700, + letterSpacing: -0.2, + color: scheme.onSurface, + ), + titleMedium: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + letterSpacing: 0, + color: scheme.onSurface, + ), + bodyMedium: TextStyle( + fontSize: 14, + height: 1.5, + color: scheme.onSurface, + ), + labelLarge: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + letterSpacing: 0.1, + color: scheme.onSurface, + ), + ), appBarTheme: AppBarTheme( - centerTitle: true, + centerTitle: false, elevation: 0, - scrolledUnderElevation: 1, - backgroundColor: isDark ? const Color(0xFF111318) : const Color(0xFFF7F8FA), + scrolledUnderElevation: 0, + backgroundColor: scheme.surface, + surfaceTintColor: Colors.transparent, + titleTextStyle: TextStyle( + fontSize: 22, + fontWeight: FontWeight.w700, + letterSpacing: -0.2, + color: scheme.onSurface, + ), ), cardTheme: CardTheme( elevation: 0, margin: EdgeInsets.zero, clipBehavior: Clip.antiAlias, - color: isDark ? const Color(0xFF1B1E24) : Colors.white, + color: cardColor, + surfaceTintColor: Colors.transparent, shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(radiusL), - side: BorderSide( - color: isDark ? Colors.white10 : Colors.black.withOpacity(0.06), - ), + borderRadius: BorderRadius.circular(radiusM), + side: BorderSide(color: outline, width: 1), ), ), inputDecorationTheme: InputDecorationTheme( filled: true, - fillColor: isDark ? Colors.white.withOpacity(0.05) : Colors.black.withOpacity(0.04), - contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12), + fillColor: isDark ? scheme.surfaceContainerHigh : scheme.surfaceContainerLow, + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), border: OutlineInputBorder( - borderRadius: BorderRadius.circular(radiusM), + borderRadius: BorderRadius.circular(radiusS), borderSide: BorderSide.none, ), enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(radiusM), + borderRadius: BorderRadius.circular(radiusS), borderSide: BorderSide.none, ), focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(radiusM), + borderRadius: BorderRadius.circular(radiusS), borderSide: BorderSide(color: scheme.primary, width: 2), ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(radiusS), + borderSide: BorderSide(color: scheme.error), + ), ), filledButtonTheme: FilledButtonThemeData( style: FilledButton.styleFrom( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), - minimumSize: const Size(0, 46), - textStyle: const TextStyle(fontWeight: FontWeight.w600), + shape: shapeS, + minimumSize: const Size(0, 48), + padding: const EdgeInsets.symmetric(horizontal: 22), + textStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 14), ), ), outlinedButtonTheme: OutlinedButtonThemeData( style: OutlinedButton.styleFrom( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), - minimumSize: const Size(0, 46), + shape: shapeS, + minimumSize: const Size(0, 48), + side: BorderSide(color: scheme.outlineVariant), + textStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 14), ), ), textButtonTheme: TextButtonThemeData( - style: TextButton.styleFrom( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + style: TextButton.styleFrom(shape: shapeXS), + ), + // M3 的 FAB 是大圆角容器(16),extended 用 16 胶囊 + floatingActionButtonTheme: FloatingActionButtonThemeData( + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(16)), ), + elevation: 1, + highlightElevation: 1, ), dialogTheme: DialogTheme( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusL)), - backgroundColor: isDark ? const Color(0xFF1B1E24) : Colors.white, + shape: shapeL, + backgroundColor: isDark ? scheme.surfaceContainerHigh : scheme.surfaceContainerLowest, + surfaceTintColor: Colors.transparent, + ), + bottomSheetTheme: BottomSheetThemeData( + backgroundColor: isDark ? scheme.surfaceContainer : scheme.surfaceContainerLowest, + surfaceTintColor: Colors.transparent, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(28)), + ), ), snackBarTheme: SnackBarThemeData( behavior: SnackBarBehavior.floating, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + shape: shapeXS, + insetPadding: const EdgeInsets.all(16), ), navigationBarTheme: NavigationBarThemeData( - height: 66, + height: 72, elevation: 0, - backgroundColor: isDark ? const Color(0xFF16191F) : Colors.white, - indicatorColor: scheme.primary.withOpacity(0.15), - indicatorShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + backgroundColor: isDark ? scheme.surfaceContainer : scheme.surfaceContainerLowest, + surfaceTintColor: Colors.transparent, + indicatorColor: scheme.secondaryContainer, + indicatorShape: const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(16)), + ), labelBehavior: NavigationDestinationLabelBehavior.alwaysShow, + labelTextStyle: WidgetStateProperty.resolveWith((states) { + final selected = states.contains(WidgetState.selected); + return TextStyle( + fontSize: 12, + fontWeight: selected ? FontWeight.w600 : FontWeight.w500, + color: selected ? scheme.onSurface : scheme.onSurfaceVariant, + ); + }), + iconTheme: WidgetStateProperty.resolveWith((states) { + final selected = states.contains(WidgetState.selected); + return IconThemeData( + size: 24, + color: selected ? scheme.onSecondaryContainer : scheme.onSurfaceVariant, + ); + }), ), progressIndicatorTheme: ProgressIndicatorThemeData( - linearTrackColor: scheme.primary.withOpacity(0.15), - linearMinHeight: 8, + linearTrackColor: scheme.surfaceContainerHighest, + linearMinHeight: 6, + circularTrackColor: scheme.surfaceContainerHighest, ), chipTheme: ChipThemeData( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusS)), + shape: shapeXS, side: BorderSide.none, - backgroundColor: scheme.primary.withOpacity(0.08), + backgroundColor: scheme.surfaceContainerHigh, + selectedColor: scheme.secondaryContainer, + labelStyle: TextStyle(fontSize: 13, color: scheme.onSurfaceVariant), + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), ), dividerTheme: DividerThemeData( thickness: 1, space: 1, - color: isDark ? Colors.white10 : Colors.black.withOpacity(0.06), + color: scheme.outlineVariant, ), listTileTheme: ListTileThemeData( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + shape: shapeM, + iconColor: scheme.onSurfaceVariant, ), popupMenuTheme: PopupMenuThemeData( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), - elevation: 4, + shape: shapeM, + elevation: 2, + color: isDark ? scheme.surfaceContainerHigh : scheme.surfaceContainerLowest, + surfaceTintColor: Colors.transparent, ), expansionTileTheme: ExpansionTileThemeData( - shape: const Border(), - collapsedShape: const Border(), + shape: shapeM, + collapsedShape: shapeM, + iconColor: scheme.onSurfaceVariant, + ), + tabBarTheme: TabBarTheme( + dividerColor: Colors.transparent, + indicatorSize: TabBarIndicatorSize.label, + labelColor: scheme.onSurface, + unselectedLabelColor: scheme.onSurfaceVariant, + indicator: UnderlineTabIndicator( + borderSide: BorderSide(width: 3, color: scheme.primary), + borderRadius: const BorderRadius.vertical(top: Radius.circular(3)), + ), + ), + segmentedButtonTheme: SegmentedButtonThemeData( + style: ButtonStyle( + shape: WidgetStateProperty.all( + const RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(radiusS)), + ), + ), + side: WidgetStateProperty.all(BorderSide(color: outline)), + textStyle: WidgetStateProperty.all( + const TextStyle(fontSize: 13, fontWeight: FontWeight.w600), + ), + ), + ), + switchTheme: SwitchThemeData( + thumbColor: WidgetStateProperty.resolveWith((states) => + states.contains(WidgetState.selected) ? scheme.onPrimary : scheme.outline), + trackColor: WidgetStateProperty.resolveWith((states) => + states.contains(WidgetState.selected) ? scheme.primary : scheme.surfaceContainerHighest), + ), + bottomNavigationBarTheme: BottomNavigationBarThemeData( + elevation: 0, + backgroundColor: isDark ? scheme.surfaceContainer : scheme.surfaceContainerLowest, + selectedItemColor: scheme.primary, + unselectedItemColor: scheme.onSurfaceVariant, + type: BottomNavigationBarType.fixed, ), - tabBarTheme: const TabBarTheme(dividerColor: Colors.transparent), ); } diff --git a/lib/features/dashboard/dashboard_page.dart b/lib/features/dashboard/dashboard_page.dart index 34a3672..f0b7152 100644 --- a/lib/features/dashboard/dashboard_page.dart +++ b/lib/features/dashboard/dashboard_page.dart @@ -261,13 +261,11 @@ class _DashboardPageState extends State { return Card( margin: const EdgeInsets.only(bottom: 8), shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(AppTheme.radiusL), + borderRadius: BorderRadius.circular(AppTheme.radiusM), side: isSel ? BorderSide(color: Theme.of(context).colorScheme.primary, width: 1.6) : BorderSide( - color: Theme.of(context).brightness == Brightness.dark - ? Colors.white10 - : Colors.black.withOpacity(0.06)), + color: Theme.of(context).colorScheme.outlineVariant), ), color: isSel ? Theme.of(context).colorScheme.primary.withOpacity(0.06) @@ -400,22 +398,16 @@ class _DashboardPageState extends State { }) { return Expanded( child: Material( - color: Theme.of(context).brightness == Brightness.dark - ? const Color(0xFF1B1E24) - : Colors.white, - borderRadius: BorderRadius.circular(AppTheme.radiusL), + color: Theme.of(context).colorScheme.surfaceContainerLow, + borderRadius: BorderRadius.circular(AppTheme.radiusM), child: InkWell( onTap: onTap, - borderRadius: BorderRadius.circular(AppTheme.radiusL), + borderRadius: BorderRadius.circular(AppTheme.radiusM), child: Container( padding: const EdgeInsets.symmetric(vertical: 14), decoration: BoxDecoration( - borderRadius: BorderRadius.circular(AppTheme.radiusL), - border: Border.all( - color: Theme.of(context).brightness == Brightness.dark - ? Colors.white10 - : Colors.black.withOpacity(0.06), - ), + borderRadius: BorderRadius.circular(AppTheme.radiusM), + border: Border.all(color: Theme.of(context).colorScheme.outlineVariant), ), child: Column( children: [ @@ -423,7 +415,7 @@ class _DashboardPageState extends State { padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: color.withOpacity(0.14), - borderRadius: BorderRadius.circular(12), + borderRadius: BorderRadius.circular(AppTheme.radiusS), ), child: Icon(icon, color: color, size: 22), ),