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

@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:provider/provider.dart';
import '../../../core/constants/app_colors.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../providers/asset_provider.dart';
import '../../../providers/auth_provider.dart';
import '../../shared/ui_constants.dart';
@@ -44,22 +46,22 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
color: theme.colorScheme.primary,
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.all(16),
padding: AppSpacing.pagePadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8),
SizedBox(height: AppSpacing.sm),
_Header(),
const SizedBox(height: 20),
SizedBox(height: AppSpacing.lg + AppSpacing.sm),
_AssetOverviewCard(overview: provider.overview),
const SizedBox(height: 16),
SizedBox(height: AppSpacing.md),
_QuickActions(
onDeposit: _showDeposit,
onWithdraw: _showWithdraw,
onTransfer: _showTransfer,
onTrade: _navigateToTrade,
),
const SizedBox(height: 24),
SizedBox(height: AppSpacing.lg),
_HoldingsList(holdings: provider.holdings),
],
),
@@ -96,14 +98,14 @@ class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin
keyboardType: const TextInputType.numberWithOptions(decimal: true),
validator: Validators.amount,
),
const SizedBox(height: 12),
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
ShadInputFormField(
id: 'address',
placeholder: const Text('请输入提现地址'),
controller: addressController,
validator: (v) => Validators.required(v, '提现地址'),
),
const SizedBox(height: 12),
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
ShadInputFormField(
id: 'contact',
placeholder: const Text('联系方式(可选)'),
@@ -187,7 +189,7 @@ class _Header extends StatelessWidget {
return Row(
children: [
_Avatar(text: user?.avatarText),
const SizedBox(width: 12),
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -196,7 +198,7 @@ class _Header extends StatelessWidget {
'你好,${user?.username ?? '用户'}',
style: theme.textTheme.large.copyWith(fontWeight: FontWeight.bold),
),
const SizedBox(height: 2),
SizedBox(height: AppSpacing.xs),
Text('欢迎来到模拟所', style: theme.textTheme.muted),
],
),
@@ -241,25 +243,25 @@ class _AssetOverviewCard extends StatelessWidget {
return Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
padding: EdgeInsets.all(AppSpacing.lg + AppSpacing.sm),
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: AppColors.gradientColors,
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(16),
borderRadius: BorderRadius.circular(AppRadius.xl),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('总资产(USDT)', style: theme.textTheme.small.copyWith(color: Colors.white70)),
const SizedBox(height: 8),
SizedBox(height: AppSpacing.sm),
Text(
overview?.totalAsset ?? '0.00',
style: theme.textTheme.h2.copyWith(color: Colors.white, fontWeight: FontWeight.bold),
),
const SizedBox(height: 20),
SizedBox(height: AppSpacing.lg + AppSpacing.sm),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -286,7 +288,7 @@ class _AssetItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: const TextStyle(fontSize: 12, color: Colors.white70)),
const SizedBox(height: 4),
SizedBox(height: AppSpacing.xs),
Text(value, style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Colors.white)),
],
);
@@ -310,14 +312,14 @@ class _QuickActions extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ShadCard(
padding: const EdgeInsets.all(16),
padding: AppSpacing.cardPadding,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_ActionButton(icon: LucideIcons.arrowDownToLine, text: '充值', color: AppColors.deposit, onTap: onDeposit),
_ActionButton(icon: LucideIcons.arrowUpFromLine, text: '提现', color: AppColors.withdraw, onTap: onWithdraw),
_ActionButton(icon: LucideIcons.arrowRightLeft, text: '划转', color: AppColors.trade, onTap: onTransfer),
_ActionButton(icon: LucideIcons.trendingUp, text: '交易', color: AppColors.trade, onTap: onTrade),
_ActionButton(icon: LucideIcons.arrowDownToLine, text: '充值', color: AppColorScheme.success, onTap: onDeposit),
_ActionButton(icon: LucideIcons.arrowUpFromLine, text: '提现', color: AppColorScheme.warning, onTap: onWithdraw),
_ActionButton(icon: LucideIcons.arrowRightLeft, text: '划转', color: AppColorScheme.info, onTap: onTransfer),
_ActionButton(icon: LucideIcons.trendingUp, text: '交易', color: AppColorScheme.info, onTap: onTrade),
],
),
).animate().fadeIn(duration: 500.ms, delay: 100.ms);
@@ -349,10 +351,10 @@ class _ActionButton extends StatelessWidget {
Container(
width: 48,
height: 48,
decoration: BoxDecoration(color: color.withOpacity(0.15), shape: BoxShape.circle),
decoration: BoxDecoration(color: color.withValues(alpha: 0.15), shape: BoxShape.circle),
child: Icon(icon, color: color, size: 22),
),
const SizedBox(height: 8),
SizedBox(height: AppSpacing.sm),
Text(text, style: TextStyle(fontSize: 12, color: theme.colorScheme.foreground)),
],
),
@@ -371,7 +373,7 @@ class _HoldingsList extends StatelessWidget {
final theme = ShadTheme.of(context);
return ShadCard(
padding: const EdgeInsets.all(16),
padding: AppSpacing.cardPadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -382,7 +384,7 @@ class _HoldingsList extends StatelessWidget {
Icon(LucideIcons.chevronRight, color: theme.colorScheme.mutedForeground, size: 20),
],
),
const SizedBox(height: 16),
SizedBox(height: AppSpacing.md),
if (holdings.isEmpty)
_EmptyHoldings()
else
@@ -401,13 +403,13 @@ class _EmptyHoldings extends StatelessWidget {
return Center(
child: Padding(
padding: const EdgeInsets.all(32),
padding: EdgeInsets.all(AppSpacing.xl),
child: Column(
children: [
Icon(LucideIcons.wallet, size: 48, color: theme.colorScheme.mutedForeground),
const SizedBox(height: 12),
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
Text('暂无持仓', style: theme.textTheme.muted),
const SizedBox(height: 4),
SizedBox(height: AppSpacing.xs),
Text('快去交易吧~', style: theme.textTheme.muted.copyWith(fontSize: 12)),
],
),
@@ -452,7 +454,7 @@ class _HoldingItem extends StatelessWidget {
final theme = ShadTheme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
padding: EdgeInsets.symmetric(vertical: AppSpacing.sm),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -466,7 +468,7 @@ class _HoldingItem extends StatelessWidget {
style: TextStyle(color: theme.colorScheme.primary, fontWeight: FontWeight.bold),
),
),
const SizedBox(width: 12),
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -483,7 +485,7 @@ class _HoldingItem extends StatelessWidget {
Text(
holding.formattedProfitRate,
style: TextStyle(
color: holding.isProfit ? AppColors.up : AppColors.down,
color: holding.isProfit ? AppColorScheme.up : AppColorScheme.down,
fontSize: 12,
),
),