feat(ui): 新增精選卡片漸變色並優化市場頁面設計

This commit is contained in:
2026-04-08 01:58:53 +08:00
parent dc6a8afc9a
commit 9760f7a8a1
5 changed files with 289 additions and 177 deletions

View File

@@ -133,6 +133,30 @@ class AppColorScheme {
static const Color lightOnSurfaceVariant = Color(0xFF475569); static const Color lightOnSurfaceVariant = Color(0xFF475569);
static const Color lightOnSurfaceMuted = Color(0xFF94A3B8); static const Color lightOnSurfaceMuted = Color(0xFF94A3B8);
// ============================================
// 精選卡片漸變色 (Featured Card Gradients)
// ============================================
/// BTC 卡片漸變 - 深藍色 (#1A1A2E → #0F3460)
static const LinearGradient btcCardGradient = LinearGradient(
colors: [Color(0xFF1A1A2E), Color(0xFF0F3460)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
/// BTC 柱狀圖顏色 - 金色
static const Color btcBarColor = Color(0xFFD4AF37);
/// ETH 卡片漸變 - 深紫色 (#1A1040 → #312E81)
static const LinearGradient ethCardGradient = LinearGradient(
colors: [Color(0xFF1A1040), Color(0xFF312E81)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
/// ETH 柱狀圖顏色 - 紫色
static const Color ethBarColor = Color(0xFF818CF8);
// ============================================ // ============================================
// Glass Panel 毛玻璃效果顏色 // Glass Panel 毛玻璃效果顏色
// ============================================ // ============================================

View File

@@ -48,11 +48,11 @@ class _DepositPageState extends State<DepositPage> {
final text = _amountController.text; final text = _amountController.text;
final n = double.tryParse(text); final n = double.tryParse(text);
if (text.isEmpty || n == null || n <= 0) { if (text.isEmpty || n == null || n <= 0) {
ToastUtils.showError('请输入有效金'); ToastUtils.showError('請輸入有效金');
return; return;
} }
if (n < 1000) { if (n < 1000) {
ToastUtils.showError('单笔最低充值 1000 USDT'); ToastUtils.showError('單筆最低充值 1000 USDT');
return; return;
} }
if (_isSubmitting) return; if (_isSubmitting) return;
@@ -75,10 +75,10 @@ class _DepositPageState extends State<DepositPage> {
response.data!['walletNetwork'] as String? ?? 'TRC20'; response.data!['walletNetwork'] as String? ?? 'TRC20';
}); });
} else { } else {
ToastUtils.showError(response.message ?? '请失败'); ToastUtils.showError(response.message ?? '請失敗');
} }
} catch (e) { } catch (e) {
if (mounted) ToastUtils.showError('请失败: $e'); if (mounted) ToastUtils.showError('請失敗: $e');
} finally { } finally {
if (mounted) setState(() => _isSubmitting = false); if (mounted) setState(() => _isSubmitting = false);
} }
@@ -90,8 +90,8 @@ class _DepositPageState extends State<DepositPage> {
final confirmed = await showDialog<bool>( final confirmed = await showDialog<bool>(
context: context, context: context,
builder: (ctx) => AlertDialog( builder: (ctx) => AlertDialog(
title: const Text('确认已打款'), title: const Text('確認已打款'),
content: const Text('确认您已完成向指定地址的转账'), content: const Text('確認您已完成向指定地址的轉賬'),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => Navigator.pop(ctx, false), onPressed: () => Navigator.pop(ctx, false),
@@ -99,7 +99,7 @@ class _DepositPageState extends State<DepositPage> {
), ),
TextButton( TextButton(
onPressed: () => Navigator.pop(ctx, true), onPressed: () => Navigator.pop(ctx, true),
child: const Text('确认'), child: const Text('確認'),
), ),
], ],
), ),
@@ -113,13 +113,13 @@ class _DepositPageState extends State<DepositPage> {
if (!mounted) return; if (!mounted) return;
if (response.success) { if (response.success) {
ToastUtils.showSuccess('确认成功,等待管理员审'); ToastUtils.showSuccess('確認成功,等待管理員審');
Navigator.of(context).pop(true); Navigator.of(context).pop(true);
} else { } else {
ToastUtils.showError(response.message ?? '确认失败'); ToastUtils.showError(response.message ?? '確認失敗');
} }
} catch (e) { } catch (e) {
if (mounted) ToastUtils.showError('确认失败: $e'); if (mounted) ToastUtils.showError('確認失敗: $e');
} }
} }
@@ -230,7 +230,7 @@ class _DepositPageState extends State<DepositPage> {
Widget _buildAmountLabel(ColorScheme colorScheme) { Widget _buildAmountLabel(ColorScheme colorScheme) {
return Text( return Text(
'充值金', '充值金',
style: AppTextStyles.bodyMedium(context).copyWith( style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@@ -316,10 +316,10 @@ class _DepositPageState extends State<DepositPage> {
Widget _buildSteps(ColorScheme colorScheme) { Widget _buildSteps(ColorScheme colorScheme) {
final steps = [ final steps = [
'入充值金额并提交申', '入充值金額並提交申',
'向指定包地址转账', '向指定包地址轉賬',
'点击「已打款」确认', '點擊「已打款」確認',
'等待管理员审核通', '等待管理員審核通',
]; ];
return Column( return Column(
@@ -383,14 +383,14 @@ class _DepositPageState extends State<DepositPage> {
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
Text( Text(
'充值申成功', '充值申成功',
style: AppTextStyles.headlineSmall(context).copyWith( style: AppTextStyles.headlineSmall(context).copyWith(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
'向以下地址转账完成充值', '向以下地址轉賬完成充值',
style: AppTextStyles.bodyMedium(context).copyWith( style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -419,7 +419,7 @@ class _DepositPageState extends State<DepositPage> {
const SizedBox(width: 6), const SizedBox(width: 6),
Expanded( Expanded(
child: Text( child: Text(
'转账完成后请点击「已打款」确认,管理员审核通过后资金将到账', '轉賬完成後請點擊「已打款」確認,管理員審核通過後資金將到賬',
style: AppTextStyles.bodySmall(context).copyWith( style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -445,7 +445,7 @@ class _DepositPageState extends State<DepositPage> {
), ),
), ),
child: Text( child: Text(
'后确认', '後確認',
style: AppTextStyles.bodyMedium(context).copyWith( style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
), ),
@@ -502,7 +502,7 @@ class _DepositPageState extends State<DepositPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'订单号', '訂單號',
style: AppTextStyles.bodySmall(context).copyWith( style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -524,7 +524,7 @@ class _DepositPageState extends State<DepositPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'充值金', '充值金',
style: AppTextStyles.bodySmall(context).copyWith( style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -581,7 +581,7 @@ class _DepositPageState extends State<DepositPage> {
onTap: () { onTap: () {
Clipboard.setData( Clipboard.setData(
ClipboardData(text: _walletAddress ?? '')); ClipboardData(text: _walletAddress ?? ''));
ToastUtils.showSuccess('地址已复制'); ToastUtils.showSuccess('地址已複製');
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(4),
@@ -661,7 +661,7 @@ class _DepositPageState extends State<DepositPage> {
size: 13, color: colorScheme.onSurfaceVariant), size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 4), const SizedBox(width: 4),
Text( Text(
'金安全由平台全程保障', '金安全由平台全程保障',
style: AppTextStyles.bodySmall(context).copyWith( style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),

View File

@@ -80,8 +80,8 @@ class _TransferPageState extends State<TransferPage> {
String get _availableBalance => String get _availableBalance =>
_direction == 1 ? _fundBalance : _tradeUsdtBalance; _direction == 1 ? _fundBalance : _tradeUsdtBalance;
String get _fromLabel => _direction == 1 ? '资金账户' : '交易账户'; String get _fromLabel => _direction == 1 ? '資金賬戶' : '交易賬戶';
String get _toLabel => _direction == 1 ? '交易账户' : '资金账户'; String get _toLabel => _direction == 1 ? '交易賬戶' : '資金賬戶';
String get _fromBalance => _direction == 1 ? _fundBalance : _tradeUsdtBalance; String get _fromBalance => _direction == 1 ? _fundBalance : _tradeUsdtBalance;
String get _toBalance => _direction == 1 ? _tradeUsdtBalance : _fundBalance; String get _toBalance => _direction == 1 ? _tradeUsdtBalance : _fundBalance;
@@ -95,12 +95,12 @@ class _TransferPageState extends State<TransferPage> {
final transferAmount = double.tryParse(amount) ?? 0; final transferAmount = double.tryParse(amount) ?? 0;
if (transferAmount <= 0) { if (transferAmount <= 0) {
_showSnackBar('请输入有效的划转金额'); _showSnackBar('請輸入有效的劃轉金額');
return; return;
} }
if (transferAmount > available) { if (transferAmount > available) {
_showSnackBar('余额不足'); _showSnackBar('餘額不足');
return; return;
} }
@@ -115,11 +115,11 @@ class _TransferPageState extends State<TransferPage> {
if (mounted) { if (mounted) {
if (response.success) { if (response.success) {
_amountController.clear(); _amountController.clear();
_showSnackBar('划转成功'); _showSnackBar('劃轉成功');
await Future.delayed(const Duration(milliseconds: 500)); await Future.delayed(const Duration(milliseconds: 500));
if (mounted) Navigator.of(context).pop(true); if (mounted) Navigator.of(context).pop(true);
} else { } else {
_showSnackBar(response.message ?? '划转失败'); _showSnackBar(response.message ?? '劃轉失敗');
} }
} }
} finally { } finally {
@@ -171,7 +171,7 @@ class _TransferPageState extends State<TransferPage> {
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
title: Text( title: Text(
'账户划转', '賬戶劃轉',
style: AppTextStyles.headlineLarge(context).copyWith( style: AppTextStyles.headlineLarge(context).copyWith(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
@@ -339,7 +339,7 @@ class _TransferPageState extends State<TransferPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'划转金额', '劃轉金額',
style: AppTextStyles.bodyMedium(context).copyWith( style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@@ -422,7 +422,7 @@ class _TransferPageState extends State<TransferPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'可用余额', '可用餘額',
style: AppTextStyles.bodySmall(context).copyWith( style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -492,7 +492,7 @@ class _TransferPageState extends State<TransferPage> {
size: 13, color: colorScheme.onSurfaceVariant), size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 6), const SizedBox(width: 6),
Text( Text(
'划转即时到账,无需手续费', '劃轉即時到賬,無需手續費',
style: AppTextStyles.bodySmall(context).copyWith( style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -542,7 +542,7 @@ class _TransferPageState extends State<TransferPage> {
), ),
) )
: Text( : Text(
'确认划转', '確認劃轉',
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 15,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,

View File

@@ -63,20 +63,20 @@ class _WithdrawPageState extends State<WithdrawPage> {
if (amount > 0) { if (amount > 0) {
final fee = amount * 0.1; final fee = amount * 0.1;
final receivable = amount - fee; final receivable = amount - fee;
return '续费(10%): -${fee.toStringAsFixed(2)} USDT | 收款: ${receivable.toStringAsFixed(2)} USDT'; return '續費(10%): -${fee.toStringAsFixed(2)} USDT | 收款: ${receivable.toStringAsFixed(2)} USDT';
} }
return '现将扣除 10% 手续费'; return '現將扣除 10% 手續費';
} }
Future<void> _submitWithdraw() async { Future<void> _submitWithdraw() async {
final amount = double.tryParse(_amountController.text); final amount = double.tryParse(_amountController.text);
if (amount == null || amount <= 0) { if (amount == null || amount <= 0) {
ToastUtils.showError('请输入有效金'); ToastUtils.showError('請輸入有效金');
return; return;
} }
final address = _addressController.text.trim(); final address = _addressController.text.trim();
if (address.isEmpty) { if (address.isEmpty) {
ToastUtils.showError('请输入提地址'); ToastUtils.showError('請輸入提地址');
return; return;
} }
if (_isSubmitting) return; if (_isSubmitting) return;
@@ -94,13 +94,13 @@ class _WithdrawPageState extends State<WithdrawPage> {
if (!mounted) return; if (!mounted) return;
if (response.success) { if (response.success) {
ToastUtils.showSuccess('成功,等待管理员审'); ToastUtils.showSuccess('成功,等待管理員審');
Navigator.of(context).pop(true); Navigator.of(context).pop(true);
} else { } else {
ToastUtils.showError(response.message ?? '请失败'); ToastUtils.showError(response.message ?? '請失敗');
} }
} catch (e) { } catch (e) {
if (mounted) ToastUtils.showError('请失败: $e'); if (mounted) ToastUtils.showError('請失敗: $e');
} finally { } finally {
if (mounted) setState(() => _isSubmitting = false); if (mounted) setState(() => _isSubmitting = false);
} }
@@ -123,7 +123,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
title: Text( title: Text(
'', '',
style: AppTextStyles.headlineLarge(context).copyWith( style: AppTextStyles.headlineLarge(context).copyWith(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
), ),
@@ -146,7 +146,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
], ],
// 提现金额 // 提现金额
_buildSectionLabel(colorScheme, '现金额'), _buildSectionLabel(colorScheme, '現金額'),
const SizedBox(height: AppSpacing.sm), const SizedBox(height: AppSpacing.sm),
_buildAmountInput(colorScheme), _buildAmountInput(colorScheme),
const SizedBox(height: AppSpacing.sm), const SizedBox(height: AppSpacing.sm),
@@ -157,20 +157,20 @@ class _WithdrawPageState extends State<WithdrawPage> {
// 提现网络 // 提现网络
if (_networks.isNotEmpty) ...[ if (_networks.isNotEmpty) ...[
_buildSectionLabel(colorScheme, '现网络'), _buildSectionLabel(colorScheme, '現網絡'),
const SizedBox(height: AppSpacing.sm), const SizedBox(height: AppSpacing.sm),
_buildNetworkSelector(colorScheme), _buildNetworkSelector(colorScheme),
const SizedBox(height: AppSpacing.lg), const SizedBox(height: AppSpacing.lg),
], ],
// 目标地址 // 目标地址
_buildSectionLabel(colorScheme, '地址'), _buildSectionLabel(colorScheme, '地址'),
const SizedBox(height: AppSpacing.sm), const SizedBox(height: AppSpacing.sm),
_buildAddressInput(colorScheme), _buildAddressInput(colorScheme),
const SizedBox(height: AppSpacing.lg), const SizedBox(height: AppSpacing.lg),
// 联系方式 // 联系方式
_buildSectionLabel(colorScheme, '联系方式(可'), _buildSectionLabel(colorScheme, '聯繫方式(可'),
const SizedBox(height: AppSpacing.sm), const SizedBox(height: AppSpacing.sm),
_buildContactInput(colorScheme), _buildContactInput(colorScheme),
const SizedBox(height: AppSpacing.xl), const SizedBox(height: AppSpacing.xl),
@@ -210,7 +210,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'可用余额', '可用餘額',
style: AppTextStyles.bodyMedium(context).copyWith( style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -332,7 +332,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
value: _selectedNetwork, value: _selectedNetwork,
isExpanded: true, isExpanded: true,
hint: Text( hint: Text(
'选择提现网络', '選擇提現網絡',
style: AppTextStyles.bodyMedium(context).copyWith( style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
@@ -369,7 +369,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
controller: _addressController, controller: _addressController,
style: AppTextStyles.bodyMedium(context), style: AppTextStyles.bodyMedium(context),
decoration: InputDecoration( decoration: InputDecoration(
hintText: '请输入提地址', hintText: '請輸入提地址',
hintStyle: AppTextStyles.bodyMedium(context).copyWith( hintStyle: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5), color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
), ),
@@ -399,7 +399,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
controller: _contactController, controller: _contactController,
style: AppTextStyles.bodyMedium(context), style: AppTextStyles.bodyMedium(context),
decoration: InputDecoration( decoration: InputDecoration(
hintText: '方便客服与您联系', hintText: '方便客服與您聯繫',
hintStyle: AppTextStyles.bodyMedium(context).copyWith( hintStyle: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5), color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
), ),
@@ -413,9 +413,9 @@ class _WithdrawPageState extends State<WithdrawPage> {
Widget _buildSecurityTips(ColorScheme colorScheme) { Widget _buildSecurityTips(ColorScheme colorScheme) {
final tips = [ final tips = [
'请仔细核对提现地址,地址错误将导致资产无法找回', '請仔細核對提現地址,地址錯誤將導致資產無法找回',
'现申请提交需等待管理员审', '現申請提交需等待管理員審',
'现将扣除 10% 手续费', '現將扣除 10% 手續費',
]; ];
return Column( return Column(
@@ -475,7 +475,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
), ),
) )
: Text( : Text(
'提交申', '提交申',
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 15,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@@ -494,7 +494,7 @@ class _WithdrawPageState extends State<WithdrawPage> {
size: 13, color: colorScheme.onSurfaceVariant), size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 4), const SizedBox(width: 4),
Text( Text(
'金安全由平台全程保障', '金安全由平台全程保障',
style: AppTextStyles.bodySmall(context).copyWith( style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),

View File

@@ -2,12 +2,12 @@ import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart'; import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart'; import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart'; import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_theme_extension.dart'; import '../../../core/theme/app_theme_extension.dart';
import '../../../data/models/coin.dart'; import '../../../data/models/coin.dart';
import '../../../providers/market_provider.dart'; import '../../../providers/market_provider.dart';
import '../../components/glass_panel.dart';
import '../../components/coin_icon.dart'; import '../../components/coin_icon.dart';
import '../main/main_page.dart'; import '../main/main_page.dart';
@@ -64,21 +64,21 @@ class _MarketPageState extends State<MarketPage>
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// 頁面標題 "行情" // 頁面標題 "行情"
Padding( Text(
padding: const EdgeInsets.only(bottom: AppSpacing.sm), '行情',
child: Text( style: AppTextStyles.displaySmall(context).copyWith(
'行情', fontSize: 24,
style: AppTextStyles.displaySmall(context), fontWeight: FontWeight.w800,
), ),
), ),
const SizedBox(height: AppSpacing.md), const SizedBox(height: AppSpacing.md),
// 搜索框
_buildSearchBar(context),
const SizedBox(height: AppSpacing.md),
// 精選區域BTC + ETH 卡片 // 精選區域BTC + ETH 卡片
_buildFeaturedSection(provider), _buildFeaturedSection(provider),
const SizedBox(height: AppSpacing.md), const SizedBox(height: AppSpacing.md),
// 分區標題:全部幣種 + 更多 // 全部幣種列表(含表頭)
_buildSectionHeader(),
const SizedBox(height: AppSpacing.md),
// 幣種列表卡片
_buildCoinList(provider), _buildCoinList(provider),
], ],
), ),
@@ -89,6 +89,39 @@ class _MarketPageState extends State<MarketPage>
); );
} }
/// 搜索框
Widget _buildSearchBar(BuildContext context) {
return GestureDetector(
onTap: () {
// TODO: 彈出搜索界面
},
child: Container(
height: 40,
decoration: BoxDecoration(
color: context.colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(AppRadius.md),
),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
child: Row(
children: [
Icon(
LucideIcons.search,
size: 16,
color: context.colors.onSurfaceVariant,
),
const SizedBox(width: AppSpacing.sm),
Text(
'搜索幣種名稱或代碼',
style: AppTextStyles.bodyMedium(context).copyWith(
color: context.appColors.onSurfaceMuted,
),
),
],
),
),
);
}
/// 精選區域BTC + ETH 大卡片 /// 精選區域BTC + ETH 大卡片
Widget _buildFeaturedSection(MarketProvider provider) { Widget _buildFeaturedSection(MarketProvider provider) {
final featured = provider.featuredCoins; final featured = provider.featuredCoins;
@@ -103,7 +136,7 @@ class _MarketPageState extends State<MarketPage>
Expanded(child: _FeaturedCard(coin: btc)) Expanded(child: _FeaturedCard(coin: btc))
else else
const Expanded(child: SizedBox.shrink()), const Expanded(child: SizedBox.shrink()),
const SizedBox(width: AppSpacing.sm + AppSpacing.xs), const SizedBox(width: 10),
if (eth != null) if (eth != null)
Expanded(child: _FeaturedCard(coin: eth)) Expanded(child: _FeaturedCard(coin: eth))
else else
@@ -112,26 +145,7 @@ class _MarketPageState extends State<MarketPage>
); );
} }
/// 分區標題:全部幣種 + 更多 /// 幣種列表(含表頭)
Widget _buildSectionHeader() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'全部幣種',
style: AppTextStyles.headlineLarge(context),
),
Text(
'更多 >',
style: AppTextStyles.bodyMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
),
),
],
);
}
/// 幣種列表
Widget _buildCoinList(MarketProvider provider) { Widget _buildCoinList(MarketProvider provider) {
final coins = provider.otherCoins; final coins = provider.otherCoins;
@@ -152,18 +166,77 @@ class _MarketPageState extends State<MarketPage>
width: 1, width: 1,
), ),
), ),
child: ListView.separated( child: Column(
shrinkWrap: true, mainAxisSize: MainAxisSize.min,
physics: const NeverScrollableScrollPhysics(), children: [
itemCount: coins.length, // 表頭行
separatorBuilder: (_, __) => Divider( _buildListHeader(context),
height: 1, // 列表項
thickness: 1, ListView.separated(
color: context.colors.outlineVariant.withValues(alpha: 0.5 * 0.15), shrinkWrap: true,
indent: AppSpacing.md, physics: const NeverScrollableScrollPhysics(),
endIndent: AppSpacing.md, itemCount: coins.length,
), separatorBuilder: (_, __) => Divider(
itemBuilder: (context, index) => _CoinRow(coin: coins[index]), height: 1,
thickness: 1,
color: context.colors.outlineVariant.withValues(alpha: 0.5 * 0.15),
indent: AppSpacing.md,
endIndent: AppSpacing.md,
),
itemBuilder: (context, index) => _CoinRow(coin: coins[index]),
),
],
),
);
}
/// 列表表頭行:幣種 | 最新價 | 漲跌幅
Widget _buildListHeader(BuildContext context) {
return const Padding(
padding: EdgeInsets.fromLTRB(
AppSpacing.md,
AppSpacing.sm + AppSpacing.xs,
AppSpacing.md,
AppSpacing.sm,
),
child: Row(
children: [
Expanded(
child: Text(
'幣種',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: AppColorScheme.darkOnSurfaceVariant,
),
),
),
SizedBox(
width: 90,
child: Text(
'最新價',
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: AppColorScheme.darkOnSurfaceVariant,
),
),
),
SizedBox(width: AppSpacing.sm),
SizedBox(
width: 72,
child: Text(
'漲跌幅',
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: AppColorScheme.darkOnSurfaceVariant,
),
),
),
],
), ),
); );
} }
@@ -195,7 +268,7 @@ class _MarketPageState extends State<MarketPage>
} }
} }
/// 精選卡片BTC / ETH (130px 高度,含迷你柱狀圖) /// 精選卡片BTC / ETH (148px 高度,漸變背景,含迷你柱狀圖)
class _FeaturedCard extends StatelessWidget { class _FeaturedCard extends StatelessWidget {
final Coin coin; final Coin coin;
@@ -204,60 +277,78 @@ class _FeaturedCard extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isUp = coin.isUp; final isUp = coin.isUp;
final changeColor = final isBtc = coin.code == 'BTC';
isUp ? context.appColors.up : context.appColors.down;
final changeBgColor = isUp
? context.appColors.upBackground
: context.appColors.downBackground;
return GlassPanel( final gradient =
isBtc ? AppColorScheme.btcCardGradient : AppColorScheme.ethCardGradient;
final barColor =
isBtc ? AppColorScheme.btcBarColor : AppColorScheme.ethBarColor;
final changeBgColor = isUp
? AppColorScheme.darkTertiary.withValues(alpha: 0.2)
: AppColorScheme.darkError.withValues(alpha: 0.2);
final changeColor = isUp
? AppColorScheme.darkTertiary
: AppColorScheme.darkError;
return Container(
height: 148,
padding: const EdgeInsets.all(AppSpacing.md), padding: const EdgeInsets.all(AppSpacing.md),
height: 130, decoration: BoxDecoration(
gradient: gradient,
borderRadius: BorderRadius.circular(AppRadius.lg),
),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
// 第一行:幣種名稱 + 漲跌徽章 // 第一行:交易對名 + 漲跌幅標籤
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'${coin.code}/USDT', '${coin.code}/USDT',
style: AppTextStyles.labelLarge(context), // 縮小文字 style: const TextStyle(
color: Colors.white,
fontSize: 13,
fontWeight: FontWeight.w600,
),
), ),
Container( Container(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xs + 2, vertical: 2), padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.xs + 2,
vertical: 2,
),
decoration: BoxDecoration( decoration: BoxDecoration(
color: changeBgColor, color: changeBgColor,
borderRadius: BorderRadius.circular(AppRadius.sm), borderRadius: BorderRadius.circular(4),
), ),
child: Text( child: Text(
coin.formattedChange, coin.formattedChange,
style: AppTextStyles.labelSmall(context).copyWith( style: TextStyle(
color: changeColor, color: changeColor,
fontSize: 10, // 縮小文字 fontSize: 10,
fontWeight: FontWeight.w600,
), ),
), ),
), ),
], ],
), ),
// 第二行:價格 // 第二行:大號價格
Text( Text(
'\$${_formatFeaturedPrice(coin)}', '\$${_formatFeaturedPrice(coin)}',
style: AppTextStyles.headlineLarge(context).copyWith( // 縮小文字 style: const TextStyle(
fontWeight: FontWeight.bold, color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w800,
height: 1.2,
), ),
), ),
// 第三行:幣種全名 // 第三行:迷你柱狀圖
Text(
coin.name,
style: AppTextStyles.bodySmall(context).copyWith( // 縮小文字
color: context.colors.onSurfaceVariant,
),
),
// 第四行:迷你柱狀圖
Expanded( Expanded(
child: _MiniBarChart(isUp: isUp, seed: coin.code.hashCode), child: _MiniBarChart(
barColor: barColor,
seed: coin.code.hashCode,
),
), ),
], ],
), ),
@@ -291,17 +382,13 @@ class _FeaturedCard extends StatelessWidget {
/// 迷你柱狀圖(模擬價格走勢) /// 迷你柱狀圖(模擬價格走勢)
class _MiniBarChart extends StatelessWidget { class _MiniBarChart extends StatelessWidget {
final bool isUp; final Color barColor;
final int seed; final int seed;
const _MiniBarChart({required this.isUp, required this.seed}); const _MiniBarChart({required this.barColor, required this.seed});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final barColor = isUp
? context.appColors.up
: context.appColors.down;
// 生成隨機但確定的高度序列 // 生成隨機但確定的高度序列
final heights = _generateHeights(); final heights = _generateHeights();
@@ -311,7 +398,7 @@ class _MiniBarChart extends StatelessWidget {
children: heights.map((h) { children: heights.map((h) {
return Expanded( return Expanded(
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 2), // 增加間距 padding: const EdgeInsets.only(left: 2),
child: Container( child: Container(
height: h, height: h,
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -327,8 +414,8 @@ class _MiniBarChart extends StatelessWidget {
List<double> _generateHeights() { List<double> _generateHeights() {
final random = Random(seed); final random = Random(seed);
final base = 6.0; // 降低基礎高度 const base = 6.0;
final range = 12.0; // 降低範圍 const range = 12.0;
return List.generate(6, (_) => base + random.nextDouble() * range); return List.generate(6, (_) => base + random.nextDouble() * range);
} }
} }
@@ -352,11 +439,18 @@ class _CoinRow extends StatelessWidget {
onTap: () => _navigateToTrade(context), onTap: () => _navigateToTrade(context),
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: 14), padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.md,
vertical: 14,
),
child: Row( child: Row(
children: [ children: [
// 頭像:圓形字母頭像 // 頭像:36px 圓形
_CoinAvatar(letter: coin.displayIcon, code: coin.code), CoinIcon(
symbol: coin.code,
size: 36,
isCircle: true,
),
const SizedBox(width: AppSpacing.sm + AppSpacing.xs), const SizedBox(width: AppSpacing.sm + AppSpacing.xs),
// 幣種信息:交易對 + 全名 // 幣種信息:交易對 + 全名
Expanded( Expanded(
@@ -366,7 +460,9 @@ class _CoinRow extends StatelessWidget {
children: [ children: [
Text( Text(
'${coin.code}/USDT', '${coin.code}/USDT',
style: AppTextStyles.numberMedium(context), style: AppTextStyles.numberMedium(context).copyWith(
fontWeight: FontWeight.w600,
),
), ),
const SizedBox(height: 2), const SizedBox(height: 2),
Text( Text(
@@ -376,30 +472,36 @@ class _CoinRow extends StatelessWidget {
], ],
), ),
), ),
// 右側:價格 + 漲跌標籤 // 價格固定寬度90右對齊
Column( SizedBox(
crossAxisAlignment: CrossAxisAlignment.end, width: 90,
mainAxisSize: MainAxisSize.min, child: Text(
children: [ '\$${coin.formattedPrice}',
Text( textAlign: TextAlign.right,
'\$${coin.formattedPrice}', style: AppTextStyles.numberMedium(context),
style: AppTextStyles.numberMedium(context), ),
),
const SizedBox(width: AppSpacing.sm),
// 漲跌幅標籤固定寬度72
SizedBox(
width: 72,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.xs + 2,
vertical: 4,
), ),
const SizedBox(height: 2), decoration: BoxDecoration(
Container( color: changeBgColor,
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xs + 2, vertical: 2), borderRadius: BorderRadius.circular(4),
decoration: BoxDecoration( ),
color: changeBgColor, child: Text(
borderRadius: BorderRadius.circular(AppRadius.sm), coin.formattedChange,
), textAlign: TextAlign.center,
child: Text( style: AppTextStyles.labelSmall(context).copyWith(
coin.formattedChange, color: changeColor,
style: AppTextStyles.labelMedium(context).copyWith(
color: changeColor,
),
), ),
), ),
], ),
), ),
], ],
), ),
@@ -413,31 +515,17 @@ class _CoinRow extends StatelessWidget {
} }
} }
/// 幣種頭像組件
class _CoinAvatar extends StatelessWidget {
final String letter;
final String code;
const _CoinAvatar({required this.letter, required this.code});
@override
Widget build(BuildContext context) {
// 使用新的 CoinIcon 组件
return CoinIcon(
symbol: code,
size: 36,
isCircle: true,
);
}
}
/// 空狀態 /// 空狀態
class _EmptyState extends StatelessWidget { class _EmptyState extends StatelessWidget {
final IconData icon; final IconData icon;
final String message; final String message;
final VoidCallback? onRetry; final VoidCallback? onRetry;
const _EmptyState({required this.icon, required this.message, this.onRetry}); const _EmptyState({
required this.icon,
required this.message,
this.onRetry,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {