From 132769e156af568f2ab23565606fc9fef4dca1ae Mon Sep 17 00:00:00 2001 From: ZV Team Date: Sun, 25 Oct 2026 19:00:47 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E5=85=A8=E9=9D=A2=20UI=20=E7=BE=8E?= =?UTF-8?q?=E5=8C=96=E2=80=94=E2=80=94=E7=BB=9F=E4=B8=80=E5=9C=86=E8=A7=92?= =?UTF-8?q?/=E9=85=8D=E8=89=B2/=E9=97=B4=E8=B7=9D=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E4=BD=93=E7=B3=BB=EF=BC=8CDashboard=20=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8D=A1=E4=B8=8E=E5=BF=AB=E6=8D=B7=E5=85=A5=E5=8F=A3=E9=87=8D?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=EF=BC=8C=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=8D=A1?= =?UTF-8?q?=E7=89=87=E9=80=89=E4=B8=AD=E6=80=81=E5=BC=BA=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/theme/app_theme.dart | 135 +++++++++++++--- lib/features/dashboard/dashboard_page.dart | 172 +++++++++++++++------ 2 files changed, 241 insertions(+), 66 deletions(-) diff --git a/lib/core/theme/app_theme.dart b/lib/core/theme/app_theme.dart index a878019..8738441 100644 --- a/lib/core/theme/app_theme.dart +++ b/lib/core/theme/app_theme.dart @@ -5,28 +5,123 @@ enum AppThemeMode { light, dark, system } class AppTheme { static const _primaryColor = Color(0xFF4CAF50); - static ThemeData get lightTheme => ThemeData( - useMaterial3: true, - brightness: Brightness.light, - colorSchemeSeed: _primaryColor, - appBarTheme: const AppBarTheme(centerTitle: true), - inputDecorationTheme: InputDecorationTheme( - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - filled: true, - ), - ); + /// 全局圆角体系 + static const radiusS = 10.0; // chips / 小元素 + static const radiusM = 14.0; // 输入框 / 按钮 + static const radiusL = 18.0; // 卡片 / 弹窗 - static ThemeData get darkTheme => ThemeData( - useMaterial3: true, - brightness: Brightness.dark, - colorSchemeSeed: _primaryColor, - appBarTheme: const AppBarTheme(centerTitle: true), - scaffoldBackgroundColor: const Color(0xFF121212), - inputDecorationTheme: InputDecorationTheme( - border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)), - filled: true, + static ThemeData _base(Brightness brightness) { + final scheme = ColorScheme.fromSeed( + seedColor: _primaryColor, + brightness: brightness, + ); + final isDark = brightness == Brightness.dark; + + return ThemeData( + useMaterial3: true, + colorScheme: scheme, + scaffoldBackgroundColor: isDark ? const Color(0xFF111318) : const Color(0xFFF7F8FA), + appBarTheme: AppBarTheme( + centerTitle: true, + elevation: 0, + scrolledUnderElevation: 1, + backgroundColor: isDark ? const Color(0xFF111318) : const Color(0xFFF7F8FA), + ), + cardTheme: CardTheme( + elevation: 0, + margin: EdgeInsets.zero, + clipBehavior: Clip.antiAlias, + color: isDark ? const Color(0xFF1B1E24) : Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(radiusL), + side: BorderSide( + color: isDark ? Colors.white10 : Colors.black.withOpacity(0.06), + ), ), - ); + ), + inputDecorationTheme: InputDecorationTheme( + filled: true, + fillColor: isDark ? Colors.white.withOpacity(0.05) : Colors.black.withOpacity(0.04), + contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(radiusM), + borderSide: BorderSide.none, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(radiusM), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(radiusM), + borderSide: BorderSide(color: scheme.primary, width: 2), + ), + ), + filledButtonTheme: FilledButtonThemeData( + style: FilledButton.styleFrom( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + minimumSize: const Size(0, 46), + textStyle: const TextStyle(fontWeight: FontWeight.w600), + ), + ), + outlinedButtonTheme: OutlinedButtonThemeData( + style: OutlinedButton.styleFrom( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + minimumSize: const Size(0, 46), + ), + ), + textButtonTheme: TextButtonThemeData( + style: TextButton.styleFrom( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + ), + ), + dialogTheme: DialogTheme( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusL)), + backgroundColor: isDark ? const Color(0xFF1B1E24) : Colors.white, + ), + snackBarTheme: SnackBarThemeData( + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + ), + navigationBarTheme: NavigationBarThemeData( + height: 66, + elevation: 0, + backgroundColor: isDark ? const Color(0xFF16191F) : Colors.white, + indicatorColor: scheme.primary.withOpacity(0.15), + indicatorShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + labelBehavior: NavigationDestinationLabelBehavior.alwaysShow, + ), + progressIndicatorTheme: ProgressIndicatorThemeData( + linearTrackColor: scheme.primary.withOpacity(0.15), + linearMinHeight: 8, + ), + chipTheme: ChipThemeData( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusS)), + side: BorderSide.none, + backgroundColor: scheme.primary.withOpacity(0.08), + ), + dividerTheme: DividerThemeData( + thickness: 1, + space: 1, + color: isDark ? Colors.white10 : Colors.black.withOpacity(0.06), + ), + listTileTheme: ListTileThemeData( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + ), + popupMenuTheme: PopupMenuThemeData( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(radiusM)), + elevation: 4, + ), + expansionTileTheme: ExpansionTileThemeData( + shape: const Border(), + collapsedShape: const Border(), + ), + tabBarTheme: const TabBarTheme(dividerColor: Colors.transparent), + ); + } + + static ThemeData get lightTheme => _base(Brightness.light); + + static ThemeData get darkTheme => _base(Brightness.dark); static ThemeMode toFlutterThemeMode(AppThemeMode mode) { switch (mode) { diff --git a/lib/features/dashboard/dashboard_page.dart b/lib/features/dashboard/dashboard_page.dart index 5b051ac..34a3672 100644 --- a/lib/features/dashboard/dashboard_page.dart +++ b/lib/features/dashboard/dashboard_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../providers/wallpaper_provider.dart'; import '../../app.dart' show navigatorKey; +import '../../core/theme/app_theme.dart'; import '../../providers/rcon_provider.dart'; import '../../providers/server_provider.dart'; import '../server_list/server_form_dialog.dart'; @@ -191,7 +192,7 @@ class _DashboardPageState extends State { ), ) : ListView( - padding: const EdgeInsets.all(12), + padding: const EdgeInsets.fromLTRB(16, 12, 16, 24), children: [ // 服务器选择器 Card( @@ -218,9 +219,9 @@ class _DashboardPageState extends State { crossAxisCount: 2, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - childAspectRatio: 1.8, - mainAxisSpacing: 8, - crossAxisSpacing: 8, + childAspectRatio: 1.9, + mainAxisSpacing: 10, + crossAxisSpacing: 10, children: [ _statusCard( icon: status?.online == true ? Icons.circle : Icons.circle_outlined, @@ -250,14 +251,30 @@ class _DashboardPageState extends State { ), const SizedBox(height: 8), // 服务器卡片列表(点击选中) - T('服务器', style: Theme.of(context).textTheme.titleMedium), + Padding( + padding: const EdgeInsets.fromLTRB(4, 16, 4, 8), + child: T('服务器', style: Theme.of(context).textTheme.titleMedium), + ), ...servers.map((s) { final st = _status[s.id]; final isSel = selected?.id == s.id; return Card( - margin: const EdgeInsets.symmetric(vertical: 4), + margin: const EdgeInsets.only(bottom: 8), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(AppTheme.radiusL), + 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: isSel + ? Theme.of(context).colorScheme.primary.withOpacity(0.06) + : null, child: ListTile( selected: isSel, + selectedTileColor: Colors.transparent, leading: Icon( st?.online == true ? Icons.circle : Icons.circle_outlined, color: st?.online == true ? Colors.green : Colors.red, @@ -290,41 +307,42 @@ class _DashboardPageState extends State { }), const SizedBox(height: 8), // 快捷入口 - Card( - child: Column( - children: [ - ListTile( - leading: const Icon(Icons.download_outlined), - title: T('下载中心'), - subtitle: T('Modrinth 搜索 · 镜像加速'), - trailing: const Icon(Icons.chevron_right), - onTap: () => Navigator.push( - context, - MaterialPageRoute(builder: (_) => const DownloadPage()), - ), + Padding( + padding: const EdgeInsets.fromLTRB(4, 16, 4, 8), + child: T('快捷入口', style: Theme.of(context).textTheme.titleMedium), + ), + Row( + children: [ + _quickEntry( + icon: Icons.download_outlined, + color: Colors.blue, + label: S.t('下载中心'), + onTap: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const DownloadPage()), ), - ListTile( - leading: const Icon(Icons.terminal), - title: T('远程终端'), - subtitle: const Text('SSH Shell'), - trailing: const Icon(Icons.chevron_right), - onTap: () => Navigator.push( - context, - MaterialPageRoute(builder: (_) => const TerminalPage()), - ), + ), + const SizedBox(width: 10), + _quickEntry( + icon: Icons.terminal, + color: Colors.deepOrange, + label: S.t('远程终端'), + onTap: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const TerminalPage()), ), - ListTile( - leading: const Icon(Icons.extension_outlined), - title: T('模组管理'), - subtitle: T('上传 / 删除 / 查看依赖'), - trailing: const Icon(Icons.chevron_right), - onTap: () => Navigator.push( - context, - MaterialPageRoute(builder: (_) => const ModListPage()), - ), + ), + const SizedBox(width: 10), + _quickEntry( + icon: Icons.extension_outlined, + color: Colors.purple, + label: S.t('模组管理'), + onTap: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const ModListPage()), ), - ], - ), + ), + ], ), ], ), @@ -337,23 +355,85 @@ class _DashboardPageState extends State { required String label, required String sub, }) { + final dark = Theme.of(context).brightness == Brightness.dark; return Card( child: Padding( - padding: const EdgeInsets.all(12), + padding: const EdgeInsets.all(14), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row(children: [ - Icon(icon, color: color, size: 18), - const SizedBox(width: 6), - Text(label, style: Theme.of(context).textTheme.bodyMedium), - ]), - const SizedBox(height: 6), - Text(sub, style: Theme.of(context).textTheme.headlineSmall), + Container( + padding: const EdgeInsets.all(7), + decoration: BoxDecoration( + color: color.withOpacity(0.14), + borderRadius: BorderRadius.circular(10), + ), + child: Icon(icon, color: color, size: 16), + ), + const SizedBox(height: 10), + Text(label, style: Theme.of(context).textTheme.bodySmall), + const SizedBox(height: 2), + FittedBox( + fit: BoxFit.scaleDown, + child: Text( + sub, + maxLines: 1, + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.w700, + color: dark ? Colors.white : const Color(0xFF222222), + ), + ), + ), ], ), ), ); } + + /// 快捷入口:彩色图标 + 标题的方块按钮。 + Widget _quickEntry({ + required IconData icon, + required Color color, + required String label, + required VoidCallback onTap, + }) { + return Expanded( + child: Material( + color: Theme.of(context).brightness == Brightness.dark + ? const Color(0xFF1B1E24) + : Colors.white, + borderRadius: BorderRadius.circular(AppTheme.radiusL), + child: InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(AppTheme.radiusL), + 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), + ), + ), + child: Column( + children: [ + Container( + padding: const EdgeInsets.all(10), + decoration: BoxDecoration( + color: color.withOpacity(0.14), + borderRadius: BorderRadius.circular(12), + ), + child: Icon(icon, color: color, size: 22), + ), + const SizedBox(height: 8), + Text(label, style: Theme.of(context).textTheme.bodySmall), + ], + ), + ), + ), + ), + ); + } }