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:
@@ -3,6 +3,8 @@ import 'package:flutter/services.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 '../../shared/ui_constants.dart';
|
||||
import '../orders/fund_orders_page.dart';
|
||||
@@ -45,17 +47,17 @@ class _AssetPageState extends State<AssetPage> with AutomaticKeepAliveClientMixi
|
||||
color: theme.colorScheme.primary,
|
||||
child: SingleChildScrollView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: AppSpacing.pagePadding,
|
||||
child: Column(
|
||||
children: [
|
||||
_AssetCard(overview: provider.overview),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
_TabSelector(
|
||||
tabs: const ['资金账户', '交易账户'],
|
||||
selectedIndex: _activeTab,
|
||||
onChanged: (index) => setState(() => _activeTab = index),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
_activeTab == 0
|
||||
? _FundAccountCard(provider: provider)
|
||||
: _TradeAccountCard(holdings: provider.holdings),
|
||||
@@ -81,14 +83,14 @@ class _AssetCard extends StatelessWidget {
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(24),
|
||||
padding: EdgeInsets.all(AppSpacing.lg),
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
colors: AppColors.gradientColors,
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
borderRadius: BorderRadius.circular(AppRadius.xl),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -96,7 +98,7 @@ class _AssetCard extends StatelessWidget {
|
||||
'总资产估值(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.h1.copyWith(
|
||||
@@ -104,12 +106,12 @@ class _AssetCard extends StatelessWidget {
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(LucideIcons.trendingUp, color: Colors.white70, size: 16),
|
||||
const SizedBox(width: 4),
|
||||
SizedBox(width: AppSpacing.xs),
|
||||
Text(
|
||||
'总盈亏: ${overview?.totalProfit ?? '0.00'} USDT',
|
||||
style: theme.textTheme.small.copyWith(color: Colors.white70),
|
||||
@@ -139,10 +141,10 @@ class _TabSelector extends StatelessWidget {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
padding: EdgeInsets.all(AppSpacing.xs),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.card,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: BorderRadius.circular(AppRadius.lg),
|
||||
),
|
||||
child: Row(
|
||||
children: tabs.asMap().entries.map((entry) {
|
||||
@@ -154,10 +156,10 @@ class _TabSelector extends StatelessWidget {
|
||||
child: GestureDetector(
|
||||
onTap: () => onChanged(index),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
padding: EdgeInsets.symmetric(vertical: AppSpacing.sm + AppSpacing.xs),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? theme.colorScheme.primary : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
@@ -189,7 +191,7 @@ class _FundAccountCard extends StatelessWidget {
|
||||
final fund = provider.fundAccount;
|
||||
|
||||
return ShadCard(
|
||||
padding: const EdgeInsets.all(20),
|
||||
padding: EdgeInsets.all(AppSpacing.lg + AppSpacing.xs),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -211,15 +213,15 @@ class _FundAccountCard extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
Text(fund?.balance ?? '0.00', style: theme.textTheme.h2.copyWith(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(height: AppSpacing.lg),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: _ActionButton(label: '充值', icon: LucideIcons.plus, color: AppColors.deposit, onTap: () => _showDepositDialog(context))),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _ActionButton(label: '提现', icon: LucideIcons.minus, color: AppColors.withdraw, onTap: () => _showWithdrawDialog(context, fund?.balance))),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _ActionButton(label: '充值', icon: LucideIcons.plus, color: AppColorScheme.success, onTap: () => _showDepositDialog(context))),
|
||||
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
||||
Expanded(child: _ActionButton(label: '提现', icon: LucideIcons.minus, color: AppColorScheme.warning, onTap: () => _showWithdrawDialog(context, fund?.balance))),
|
||||
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
||||
Expanded(child: _ActionButton.outline(label: '划转', icon: LucideIcons.arrowRightLeft, onTap: () => _showTransferDialog(context))),
|
||||
],
|
||||
),
|
||||
@@ -256,7 +258,7 @@ class _ActionButton extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon, size: 18, color: isOutline ? null : Colors.white),
|
||||
const SizedBox(width: 4),
|
||||
SizedBox(width: AppSpacing.xs),
|
||||
Text(label),
|
||||
],
|
||||
);
|
||||
@@ -278,12 +280,12 @@ class _TradeAccountCard extends StatelessWidget {
|
||||
final theme = ShadTheme.of(context);
|
||||
|
||||
return ShadCard(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: AppSpacing.cardPadding,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('持仓列表', style: theme.textTheme.large.copyWith(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
if (holdings.isEmpty)
|
||||
const _EmptyState(icon: LucideIcons.wallet, message: '暂无持仓')
|
||||
else
|
||||
@@ -313,11 +315,11 @@ class _EmptyState extends StatelessWidget {
|
||||
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
padding: EdgeInsets.all(AppSpacing.xl),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, size: 48, color: theme.colorScheme.mutedForeground),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
||||
Text(message, style: theme.textTheme.muted),
|
||||
],
|
||||
),
|
||||
@@ -337,7 +339,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(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
@@ -348,7 +350,7 @@ class _HoldingItem extends StatelessWidget {
|
||||
style: TextStyle(color: theme.colorScheme.primary, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -365,7 +367,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,
|
||||
),
|
||||
),
|
||||
@@ -434,13 +436,13 @@ void _showDepositResultDialog(BuildContext context, Map<String, dynamic> data) {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('订单号: $orderNo', style: const TextStyle(fontSize: 12)),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
Text('充值金额: $amount USDT', style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
const Text('请向以下地址转账:', style: TextStyle(fontSize: 12)),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
_WalletAddressCard(address: walletAddress, network: walletNetwork),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
||||
const Text('转账完成后请点击"已打款"按钮确认', style: TextStyle(fontSize: 12, color: Colors.orange)),
|
||||
],
|
||||
),
|
||||
@@ -474,10 +476,10 @@ class _WalletAddressCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: EdgeInsets.all(AppSpacing.sm + AppSpacing.xs),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[100],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -499,7 +501,7 @@ class _WalletAddressCard extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
SizedBox(height: AppSpacing.xs),
|
||||
Text('网络: $network', style: const TextStyle(fontSize: 12, color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
@@ -526,7 +528,7 @@ void _showWithdrawDialog(BuildContext context, String? balance) {
|
||||
children: [
|
||||
if (balance != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
padding: EdgeInsets.only(bottom: AppSpacing.sm + AppSpacing.xs),
|
||||
child: Text('可用余额: $balance USDT', style: const TextStyle(color: Colors.grey)),
|
||||
),
|
||||
ShadInputFormField(
|
||||
@@ -536,14 +538,14 @@ void _showWithdrawDialog(BuildContext context, String? balance) {
|
||||
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||
validator: Validators.amount,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
||||
ShadInputFormField(
|
||||
id: 'address',
|
||||
controller: addressController,
|
||||
placeholder: const Text('请输入提现地址'),
|
||||
validator: (v) => Validators.required(v, '提现地址'),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
||||
ShadInputFormField(
|
||||
id: 'contact',
|
||||
controller: contactController,
|
||||
@@ -593,7 +595,7 @@ void _showTransferDialog(BuildContext context) {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -602,7 +604,7 @@ void _showTransferDialog(BuildContext context) {
|
||||
isSelected: direction == 1,
|
||||
onTap: () => setState(() => direction = 1),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: AppSpacing.sm),
|
||||
_DirectionButton(
|
||||
label: '交易→资金',
|
||||
isSelected: direction == 2,
|
||||
@@ -610,7 +612,7 @@ void _showTransferDialog(BuildContext context) {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
ShadForm(
|
||||
key: formKey,
|
||||
child: ShadInputFormField(
|
||||
@@ -661,7 +663,7 @@ class _DirectionButton extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
if (isSelected) const Icon(LucideIcons.check, size: 14) else const SizedBox(width: 14),
|
||||
const SizedBox(width: 4),
|
||||
SizedBox(width: AppSpacing.xs),
|
||||
Text(label),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user