feat(ui): 优化所有页面使用现代设计系统

- 使用 AppSpacing 替换硬编码间距
- 使用 AppRadius 替换硬编码圆角
- 使用 withValues(alpha:) 替换 withOpacity
- 优化 login_page, home_page, market_page, trade_page, asset_page, mine_page

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-23 15:37:59 +08:00
parent 51b2f30a1b
commit b40c9f8360
7 changed files with 172 additions and 162 deletions

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../providers/auth_provider.dart';
import '../../../providers/theme_provider.dart';
import '../auth/login_page.dart';
@@ -40,13 +42,13 @@ class _MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin
body: Consumer<AuthProvider>(
builder: (context, auth, _) {
return SingleChildScrollView(
padding: const EdgeInsets.all(16),
padding: AppSpacing.pagePadding,
child: Column(
children: [
_UserCard(user: auth.user),
const SizedBox(height: 16),
SizedBox(height: AppSpacing.md),
_MenuList(onShowComingSoon: _showComingSoon, onShowAbout: _showAboutDialog),
const SizedBox(height: 24),
SizedBox(height: AppSpacing.lg),
_LogoutButton(onLogout: () => _handleLogout(auth)),
],
),
@@ -60,11 +62,11 @@ class _MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin
showShadDialog(
context: context,
builder: (context) => ShadDialog.alert(
title: const Row(
title: Row(
children: [
Icon(LucideIcons.construction, color: Color(0xFFFF9800), size: 20),
SizedBox(width: 8),
Text('功能开发中'),
const Icon(LucideIcons.construction, color: Color(0xFFFF9800), size: 20),
SizedBox(width: AppSpacing.sm),
const Text('功能开发中'),
],
),
description: Text('$feature功能正在开发中,敬请期待~'),
@@ -87,7 +89,7 @@ class _MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin
title: Row(
children: [
_AppLogo(radius: 20, fontSize: 20),
const SizedBox(width: 12),
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
const Text('模拟所'),
],
),
@@ -96,9 +98,9 @@ class _MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('虚拟货币模拟交易平台', style: theme.textTheme.muted),
const SizedBox(height: 16),
SizedBox(height: AppSpacing.md),
_InfoRow(icon: LucideIcons.code, text: '版本: 1.0.0'),
const SizedBox(height: 8),
SizedBox(height: AppSpacing.sm),
const _InfoRow(icon: LucideIcons.heart, text: 'Built with Flutter & shadcn_ui'),
],
),
@@ -153,11 +155,11 @@ class _UserCard extends StatelessWidget {
final theme = ShadTheme.of(context);
return ShadCard(
padding: const EdgeInsets.all(20),
padding: EdgeInsets.all(AppSpacing.lg + AppSpacing.sm),
child: Row(
children: [
_AppLogo(radius: 32, fontSize: 24, text: user?.avatarText),
const SizedBox(width: 16),
SizedBox(width: AppSpacing.md),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -166,7 +168,7 @@ class _UserCard extends StatelessWidget {
user?.username ?? '未登录',
style: theme.textTheme.h3.copyWith(fontWeight: FontWeight.bold),
),
const SizedBox(height: 6),
SizedBox(height: AppSpacing.sm - AppSpacing.xs),
ShadBadge(
backgroundColor: theme.colorScheme.primary.withValues(alpha: 0.2),
child: Text(
@@ -225,7 +227,7 @@ class _InfoRow extends StatelessWidget {
return Row(
children: [
Icon(icon, size: 14, color: theme.colorScheme.mutedForeground),
const SizedBox(width: 6),
SizedBox(width: AppSpacing.sm - AppSpacing.xs),
Text(text, style: theme.textTheme.muted.copyWith(fontSize: 12)),
],
);
@@ -287,17 +289,17 @@ class _ThemeToggleTile extends StatelessWidget {
return InkWell(
onTap: () => themeProvider.toggleTheme(),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: AppSpacing.sm + AppSpacing.xs),
child: Row(
children: [
_MenuIcon(icon: isDarkMode ? LucideIcons.moon : LucideIcons.sun),
const SizedBox(width: 12),
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('深色模式', style: theme.textTheme.small.copyWith(fontWeight: FontWeight.w500)),
const SizedBox(height: 2),
SizedBox(height: AppSpacing.xs / 2),
Text(
isDarkMode ? '当前:深色主题' : '当前:浅色主题',
style: theme.textTheme.muted.copyWith(fontSize: 11),
@@ -331,18 +333,18 @@ class _MenuItemTile extends StatelessWidget {
return InkWell(
onTap: item.onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: AppSpacing.sm + AppSpacing.xs),
child: Row(
children: [
_MenuIcon(icon: item.icon),
const SizedBox(width: 12),
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(item.title, style: theme.textTheme.small.copyWith(fontWeight: FontWeight.w500)),
if (item.subtitle != null) ...[
const SizedBox(height: 2),
SizedBox(height: AppSpacing.xs / 2),
Text(item.subtitle!, style: theme.textTheme.muted.copyWith(fontSize: 11)),
],
],
@@ -371,7 +373,7 @@ class _MenuIcon extends StatelessWidget {
height: 40,
decoration: BoxDecoration(
color: theme.colorScheme.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(10),
borderRadius: BorderRadius.circular(AppRadius.md + AppSpacing.xs),
),
child: Icon(icon, size: 20, color: theme.colorScheme.primary),
);
@@ -391,12 +393,12 @@ class _LogoutButton extends StatelessWidget {
height: 48,
child: ShadButton.destructive(
onPressed: onLogout,
child: const Row(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(LucideIcons.logOut, size: 18),
SizedBox(width: 8),
Text('退出登录', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
const Icon(LucideIcons.logOut, size: 18),
SizedBox(width: AppSpacing.sm),
const Text('退出登录', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
],
),
),