style: 全面 UI 美化——统一圆角/配色/间距主题体系,Dashboard 状态卡与快捷入口重设计,服务器卡片选中态强化
This commit is contained in:
1 parent
88e4f43ab1
commit
132769e156
2 files changed
+241
-66
No files matched your search
+115
-20
@@ -5,28 +5,123 @@ enum AppThemeMode { light, dark, system }
|
|||||||
class AppTheme {
|
class AppTheme {
|
||||||
static const _primaryColor = Color(0xFF4CAF50);
|
static const _primaryColor = Color(0xFF4CAF50);
|
||||||
|
|
||||||
static ThemeData get lightTheme => ThemeData(
|
/// 全局圆角体系
|
||||||
useMaterial3: true,
|
static const radiusS = 10.0; // chips / 小元素
|
||||||
brightness: Brightness.light,
|
static const radiusM = 14.0; // 输入框 / 按钮
|
||||||
colorSchemeSeed: _primaryColor,
|
static const radiusL = 18.0; // 卡片 / 弹窗
|
||||||
appBarTheme: const AppBarTheme(centerTitle: true),
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
|
||||||
filled: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
static ThemeData get darkTheme => ThemeData(
|
static ThemeData _base(Brightness brightness) {
|
||||||
useMaterial3: true,
|
final scheme = ColorScheme.fromSeed(
|
||||||
brightness: Brightness.dark,
|
seedColor: _primaryColor,
|
||||||
colorSchemeSeed: _primaryColor,
|
brightness: brightness,
|
||||||
appBarTheme: const AppBarTheme(centerTitle: true),
|
);
|
||||||
scaffoldBackgroundColor: const Color(0xFF121212),
|
final isDark = brightness == Brightness.dark;
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
return ThemeData(
|
||||||
filled: true,
|
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) {
|
static ThemeMode toFlutterThemeMode(AppThemeMode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import '../../providers/wallpaper_provider.dart';
|
import '../../providers/wallpaper_provider.dart';
|
||||||
import '../../app.dart' show navigatorKey;
|
import '../../app.dart' show navigatorKey;
|
||||||
|
import '../../core/theme/app_theme.dart';
|
||||||
import '../../providers/rcon_provider.dart';
|
import '../../providers/rcon_provider.dart';
|
||||||
import '../../providers/server_provider.dart';
|
import '../../providers/server_provider.dart';
|
||||||
import '../server_list/server_form_dialog.dart';
|
import '../server_list/server_form_dialog.dart';
|
||||||
@@ -191,7 +192,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ListView(
|
: ListView(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||||
children: [
|
children: [
|
||||||
// 服务器选择器
|
// 服务器选择器
|
||||||
Card(
|
Card(
|
||||||
@@ -218,9 +219,9 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
childAspectRatio: 1.8,
|
childAspectRatio: 1.9,
|
||||||
mainAxisSpacing: 8,
|
mainAxisSpacing: 10,
|
||||||
crossAxisSpacing: 8,
|
crossAxisSpacing: 10,
|
||||||
children: [
|
children: [
|
||||||
_statusCard(
|
_statusCard(
|
||||||
icon: status?.online == true ? Icons.circle : Icons.circle_outlined,
|
icon: status?.online == true ? Icons.circle : Icons.circle_outlined,
|
||||||
@@ -250,14 +251,30 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
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) {
|
...servers.map((s) {
|
||||||
final st = _status[s.id];
|
final st = _status[s.id];
|
||||||
final isSel = selected?.id == s.id;
|
final isSel = selected?.id == s.id;
|
||||||
return Card(
|
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(
|
child: ListTile(
|
||||||
selected: isSel,
|
selected: isSel,
|
||||||
|
selectedTileColor: Colors.transparent,
|
||||||
leading: Icon(
|
leading: Icon(
|
||||||
st?.online == true ? Icons.circle : Icons.circle_outlined,
|
st?.online == true ? Icons.circle : Icons.circle_outlined,
|
||||||
color: st?.online == true ? Colors.green : Colors.red,
|
color: st?.online == true ? Colors.green : Colors.red,
|
||||||
@@ -290,41 +307,42 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
}),
|
}),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
// 快捷入口
|
// 快捷入口
|
||||||
Card(
|
Padding(
|
||||||
child: Column(
|
padding: const EdgeInsets.fromLTRB(4, 16, 4, 8),
|
||||||
children: [
|
child: T('快捷入口', style: Theme.of(context).textTheme.titleMedium),
|
||||||
ListTile(
|
),
|
||||||
leading: const Icon(Icons.download_outlined),
|
Row(
|
||||||
title: T('下载中心'),
|
children: [
|
||||||
subtitle: T('Modrinth 搜索 · 镜像加速'),
|
_quickEntry(
|
||||||
trailing: const Icon(Icons.chevron_right),
|
icon: Icons.download_outlined,
|
||||||
onTap: () => Navigator.push(
|
color: Colors.blue,
|
||||||
context,
|
label: S.t('下载中心'),
|
||||||
MaterialPageRoute(builder: (_) => const DownloadPage()),
|
onTap: () => Navigator.push(
|
||||||
),
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const DownloadPage()),
|
||||||
),
|
),
|
||||||
ListTile(
|
),
|
||||||
leading: const Icon(Icons.terminal),
|
const SizedBox(width: 10),
|
||||||
title: T('远程终端'),
|
_quickEntry(
|
||||||
subtitle: const Text('SSH Shell'),
|
icon: Icons.terminal,
|
||||||
trailing: const Icon(Icons.chevron_right),
|
color: Colors.deepOrange,
|
||||||
onTap: () => Navigator.push(
|
label: S.t('远程终端'),
|
||||||
context,
|
onTap: () => Navigator.push(
|
||||||
MaterialPageRoute(builder: (_) => const TerminalPage()),
|
context,
|
||||||
),
|
MaterialPageRoute(builder: (_) => const TerminalPage()),
|
||||||
),
|
),
|
||||||
ListTile(
|
),
|
||||||
leading: const Icon(Icons.extension_outlined),
|
const SizedBox(width: 10),
|
||||||
title: T('模组管理'),
|
_quickEntry(
|
||||||
subtitle: T('上传 / 删除 / 查看依赖'),
|
icon: Icons.extension_outlined,
|
||||||
trailing: const Icon(Icons.chevron_right),
|
color: Colors.purple,
|
||||||
onTap: () => Navigator.push(
|
label: S.t('模组管理'),
|
||||||
context,
|
onTap: () => Navigator.push(
|
||||||
MaterialPageRoute(builder: (_) => const ModListPage()),
|
context,
|
||||||
),
|
MaterialPageRoute(builder: (_) => const ModListPage()),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -337,23 +355,85 @@ class _DashboardPageState extends State<DashboardPage> {
|
|||||||
required String label,
|
required String label,
|
||||||
required String sub,
|
required String sub,
|
||||||
}) {
|
}) {
|
||||||
|
final dark = Theme.of(context).brightness == Brightness.dark;
|
||||||
return Card(
|
return Card(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.all(14),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(children: [
|
Container(
|
||||||
Icon(icon, color: color, size: 18),
|
padding: const EdgeInsets.all(7),
|
||||||
const SizedBox(width: 6),
|
decoration: BoxDecoration(
|
||||||
Text(label, style: Theme.of(context).textTheme.bodyMedium),
|
color: color.withOpacity(0.14),
|
||||||
]),
|
borderRadius: BorderRadius.circular(10),
|
||||||
const SizedBox(height: 6),
|
),
|
||||||
Text(sub, style: Theme.of(context).textTheme.headlineSmall),
|
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),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user