Merge remote-tracking branch 'origin/main'

This commit is contained in:
sion
2026-04-10 00:27:43 +08:00
140 changed files with 76177 additions and 87936 deletions

View File

@@ -29,7 +29,7 @@ class ActionButtonsRow extends StatelessWidget {
return Row(
children: [
ActionButton(
icon: LucideIcons.arrowUpRight,
icon: LucideIcons.arrowDownToLine,
label: '充值',
accentColor: accentColor,
bgColor: bgColor,
@@ -37,7 +37,7 @@ class ActionButtonsRow extends StatelessWidget {
),
const SizedBox(width: 12),
ActionButton(
icon: LucideIcons.arrowDownLeft,
icon: LucideIcons.arrowUpFromLine,
label: '提現',
accentColor: accentColor,
bgColor: bgColor,

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../components/material_input.dart';
import 'package:provider/provider.dart';
import '../../../../core/theme/app_theme.dart';
import '../../../../core/theme/app_theme_extension.dart';
@@ -129,10 +129,10 @@ class WalletAddressCard extends StatelessWidget {
/// 充值對話框
void showDepositDialog(BuildContext context) {
final amountController = TextEditingController();
final formKey = GlobalKey<ShadFormState>();
final formKey = GlobalKey<FormState>();
final colorScheme = Theme.of(context).colorScheme;
showShadDialog(
showDialog(
context: context,
builder: (ctx) => Dialog(
backgroundColor: Colors.transparent,
@@ -178,22 +178,21 @@ void showDepositDialog(BuildContext context) {
],
),
const SizedBox(height: AppSpacing.lg),
ShadForm(
Form(
key: formKey,
child: ShadInputFormField(
id: 'amount',
controller: amountController,
label: const Text('充值金額'),
placeholder: const Text('最低 1000 USDT'),
keyboardType: const TextInputType.numberWithOptions(decimal: true),
validator: (v) {
if (v == null || v.isEmpty) return '請輸入金額';
final n = double.tryParse(v);
if (n == null || n <= 0) return '請輸入有效金額';
if (n < 1000) return '單筆最低充值1000 USDT';
return null;
},
),
child: MaterialInput(
controller: amountController,
labelText: '充值金額',
hintText: '最低 1000 USDT',
keyboardType: const TextInputType.numberWithOptions(decimal: true),
validator: (v) {
if (v == null || v.isEmpty) return '請輸入金額';
final n = double.tryParse(v);
if (n == null || n <= 0) return '請輸入有效金額';
if (n < 1000) return '單筆最低充值1000 USDT';
return null;
},
),
),
const SizedBox(height: AppSpacing.lg),
Row(
@@ -213,7 +212,7 @@ void showDepositDialog(BuildContext context) {
text: '下一步',
type: NeonButtonType.primary,
onPressed: () async {
if (formKey.currentState!.saveAndValidate()) {
if (formKey.currentState!.validate()) {
Navigator.of(ctx).pop();
final response = await context.read<AssetProvider>().deposit(
amount: amountController.text,
@@ -248,7 +247,7 @@ void showDepositResultDialog(BuildContext context, Map<String, dynamic> data) {
final walletNetwork = data['walletNetwork'] as String? ?? 'TRC20';
final colorScheme = Theme.of(context).colorScheme;
showShadDialog(
showDialog(
context: context,
builder: (ctx) => Dialog(
backgroundColor: Colors.transparent,
@@ -359,7 +358,7 @@ void showWithdrawDialog(BuildContext context, String? balance) {
final amountController = TextEditingController();
final addressController = TextEditingController();
final contactController = TextEditingController();
final formKey = GlobalKey<ShadFormState>();
final formKey = GlobalKey<FormState>();
final feeNotifier = ValueNotifier<String>('提現將扣除10%手續費');
final networksNotifier = ValueNotifier<List<String>>([]);
final selectedNetworkNotifier = ValueNotifier<String?>(null);
@@ -384,7 +383,7 @@ void showWithdrawDialog(BuildContext context, String? balance) {
}
});
showShadDialog(
showDialog(
context: context,
builder: (ctx) => Dialog(
backgroundColor: Colors.transparent,
@@ -460,17 +459,21 @@ void showWithdrawDialog(BuildContext context, String? balance) {
),
],
const SizedBox(height: AppSpacing.lg),
ShadForm(
Form(
key: formKey,
child: Column(
children: [
ShadInputFormField(
id: 'amount',
MaterialInput(
controller: amountController,
label: const Text('提現金額'),
placeholder: const Text('請輸入提現金額(USDT)'),
labelText: '提現金額',
hintText: '請輸入提現金額(USDT)',
keyboardType: const TextInputType.numberWithOptions(decimal: true),
validator: Validators.amount,
validator: (v) {
if (v == null || v.isEmpty) return '請輸入金額';
final n = double.tryParse(v);
if (n == null || n <= 0) return '請輸入有效金額';
return null;
},
),
const SizedBox(height: AppSpacing.md),
// 手續費/應收款提示
@@ -518,14 +521,16 @@ void showWithdrawDialog(BuildContext context, String? balance) {
builder: (_, selected, __) {
return SizedBox(
width: double.infinity,
child: ShadSelect<String>(
placeholder: const Text('選擇提現網絡'),
initialValue: selected,
selectedOptionBuilder: (context, val) => Text(val),
child: DropdownButtonFormField<String>(
value: selected,
hint: const Text('選擇提現網絡'),
decoration: InputDecoration(
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),
),
onChanged: (value) {
if (value != null) selectedNetworkNotifier.value = value;
},
options: networks.map((n) => ShadOption(value: n, child: Text(n))).toList(),
items: networks.map((n) => DropdownMenuItem(value: n, child: Text(n))).toList(),
),
);
},
@@ -535,19 +540,20 @@ void showWithdrawDialog(BuildContext context, String? balance) {
},
),
const SizedBox(height: AppSpacing.md),
ShadInputFormField(
id: 'address',
MaterialInput(
controller: addressController,
label: const Text('目標地址'),
placeholder: const Text('請輸入提現地址'),
validator: (v) => Validators.required(v, '提現地址'),
labelText: '目標地址',
hintText: '請輸入提現地址',
validator: (v) {
if (v == null || v.isEmpty) return '請輸入提現地址';
return null;
},
),
const SizedBox(height: AppSpacing.md),
ShadInputFormField(
id: 'contact',
MaterialInput(
controller: contactController,
label: const Text('聯繫方式(可選)'),
placeholder: const Text('聯繫方式'),
labelText: '聯繫方式(可選)',
hintText: '方便客服與您聯繫',
),
],
),
@@ -570,7 +576,7 @@ void showWithdrawDialog(BuildContext context, String? balance) {
text: '提交',
type: NeonButtonType.primary,
onPressed: () async {
if (formKey.currentState!.saveAndValidate()) {
if (formKey.currentState!.validate()) {
Navigator.of(ctx).pop();
final response = await context.read<AssetProvider>().withdraw(
amount: amountController.text,
@@ -619,7 +625,7 @@ void showWithdrawDialog(BuildContext context, String? balance) {
void showResultDialog(BuildContext context, String title, String? message) {
final colorScheme = Theme.of(context).colorScheme;
showShadDialog(
showDialog(
context: context,
builder: (ctx) => Dialog(
backgroundColor: Colors.transparent,

View File

@@ -2,15 +2,13 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_theme_extension.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/utils/toast_utils.dart';
import '../../../providers/asset_provider.dart';
import '../../components/material_input.dart';
/// 充值頁面 — 獨立頁面,替代彈窗
/// 充值页面
class DepositPage extends StatefulWidget {
const DepositPage({super.key});
@@ -20,24 +18,44 @@ class DepositPage extends StatefulWidget {
class _DepositPageState extends State<DepositPage> {
final _amountController = TextEditingController();
final _formKey = GlobalKey<ShadFormState>();
final _amountFocus = FocusNode();
bool _isSubmitting = false;
// 充值結果狀態
// 充值结果
bool _showResult = false;
String? _orderNo;
String? _amount;
String? _walletAddress;
String _walletNetwork = 'TRC20';
@override
void initState() {
super.initState();
_amountController.addListener(() => setState(() {}));
}
@override
void dispose() {
_amountController.dispose();
_amountFocus.dispose();
super.dispose();
}
// ============================================
// 业务逻辑
// ============================================
Future<void> _submitDeposit() async {
if (!_formKey.currentState!.saveAndValidate()) return;
final text = _amountController.text;
final n = double.tryParse(text);
if (text.isEmpty || n == null || n <= 0) {
ToastUtils.showError('請輸入有效金額');
return;
}
if (n < 1000) {
ToastUtils.showError('單筆最低充值 1000 USDT');
return;
}
if (_isSubmitting) return;
setState(() => _isSubmitting = true);
@@ -52,8 +70,10 @@ class _DepositPageState extends State<DepositPage> {
_showResult = true;
_orderNo = response.data!['orderNo'] as String? ?? '';
_amount = response.data!['amount']?.toString() ?? '0.00';
_walletAddress = response.data!['walletAddress'] as String? ?? '';
_walletNetwork = response.data!['walletNetwork'] as String? ?? 'TRC20';
_walletAddress =
response.data!['walletAddress'] as String? ?? '';
_walletNetwork =
response.data!['walletNetwork'] as String? ?? 'TRC20';
});
} else {
ToastUtils.showError(response.message ?? '申請失敗');
@@ -89,7 +109,8 @@ class _DepositPageState extends State<DepositPage> {
if (confirmed != true || !mounted) return;
try {
final response = await context.read<AssetProvider>().confirmPay(_orderNo!);
final response =
await context.read<AssetProvider>().confirmPay(_orderNo!);
if (!mounted) return;
if (response.success) {
@@ -104,27 +125,28 @@ class _DepositPageState extends State<DepositPage> {
}
// ============================================
// 建 UI
// 建 UI
// ============================================
@override
Widget build(BuildContext context) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: colorScheme.background,
backgroundColor: colorScheme.surface,
appBar: AppBar(
leading: IconButton(
icon: const Icon(LucideIcons.arrowLeft, size: 20),
icon: Icon(LucideIcons.arrowLeft,
color: colorScheme.onSurface, size: 20),
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
'充值',
style: AppTextStyles.headlineLarge(context).copyWith(
color: colorScheme.onSurface,
fontWeight: FontWeight.w600,
),
),
backgroundColor: colorScheme.background,
backgroundColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
@@ -133,183 +155,185 @@ class _DepositPageState extends State<DepositPage> {
);
}
/// 表單視圖 — 輸入充值金額
// ============================================
// 表单视图
// ============================================
Widget _buildFormView() {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return SingleChildScrollView(
padding: const EdgeInsets.all(AppSpacing.lg),
padding: const EdgeInsets.fromLTRB(
AppSpacing.md, AppSpacing.xs, AppSpacing.md, AppSpacing.xl),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 幣種選擇卡片
Container(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.3),
),
),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: colorScheme.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.md),
),
child: Icon(
LucideIcons.coins,
color: colorScheme.primary,
size: 20,
),
),
const SizedBox(width: AppSpacing.md),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'USDT',
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.bold,
),
),
Text(
'Tether USD',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
),
],
),
),
const SizedBox(height: AppSpacing.xl),
// 金額輸入
Text(
'充值金額',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.sm),
ShadForm(
key: _formKey,
child: ShadInputFormField(
id: 'amount',
controller: _amountController,
placeholder: const Text('請輸入充值金額'),
keyboardType: const TextInputType.numberWithOptions(decimal: true),
validator: (v) {
if (v == null || v.isEmpty) return '請輸入金額';
final n = double.tryParse(v);
if (n == null || n <= 0) return '請輸入有效金額';
if (n < 1000) return '單筆最低充值 1000 USDT';
return null;
},
),
),
const SizedBox(height: AppSpacing.sm),
// 最低金額提示
Container(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.md,
vertical: AppSpacing.sm,
),
decoration: BoxDecoration(
color: AppColorScheme.info.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(AppRadius.md),
border: Border.all(
color: AppColorScheme.info.withValues(alpha: 0.15),
),
),
child: Row(
children: [
Icon(Icons.info_outline, size: 16, color: AppColorScheme.info),
const SizedBox(width: AppSpacing.sm),
Text(
'單筆最低充值 1000 USDT',
style: AppTextStyles.bodySmall(context).copyWith(
color: AppColorScheme.info,
),
),
],
),
),
const SizedBox(height: AppSpacing.xl),
// 操作說明
Text(
'操作流程',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.md),
_buildStepItem(1, '輸入充值金額並提交申請'),
_buildStepItem(2, '向指定錢包地址轉賬'),
_buildStepItem(3, '點擊「已打款」確認'),
_buildStepItem(4, '等待管理員審核通過'),
const SizedBox(height: AppSpacing.xxl),
// 提交按鈕
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: _isSubmitting ? null : _submitDeposit,
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.primary,
foregroundColor: colorScheme.onPrimary,
disabledBackgroundColor: colorScheme.primary.withValues(alpha: 0.5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
),
elevation: 0,
),
child: _isSubmitting
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
: Text(
'下一步',
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onPrimary,
),
),
),
),
// 币种行
_buildCoinRow(colorScheme),
const SizedBox(height: AppSpacing.lg),
// 安全提示
_buildSecurityTip(),
// 金额输入
_buildAmountInput(colorScheme),
const SizedBox(height: AppSpacing.sm),
// 最低金额提示
_buildMinTip(colorScheme),
const SizedBox(height: AppSpacing.xl),
// 操作流程
_buildSteps(colorScheme),
const SizedBox(height: AppSpacing.xxl),
// 提交按钮
_buildSubmitButton(colorScheme, '下一步', _submitDeposit),
const SizedBox(height: AppSpacing.md),
// 底部提示
_buildBottomTip(colorScheme),
],
),
);
}
/// 結果視圖 — 展示錢包地址和確認打款
Widget _buildCoinRow(ColorScheme colorScheme) {
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
),
child: Row(
children: [
Text(
'USDT',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 8),
Text(
'Tether USD',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
);
}
Widget _buildAmountLabel(ColorScheme colorScheme) {
return Text(
'充值金額',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
);
}
Widget _buildAmountInput(ColorScheme colorScheme) {
return MaterialInput(
controller: _amountController,
focusNode: _amountFocus,
labelText: '充值金額',
hintText: '0.00',
keyboardType: const TextInputType.numberWithOptions(decimal: true),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d{0,8}')),
],
suffixIcon: Padding(
padding: const EdgeInsets.only(right: AppSpacing.md),
child: Text(
'USDT',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
),
);
}
Widget _buildMinTip(ColorScheme colorScheme) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
Icon(LucideIcons.info,
size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 6),
Text(
'單筆最低充值 1000 USDT',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
);
}
Widget _buildSteps(ColorScheme colorScheme) {
final steps = [
'輸入充值金額並提交申請',
'向指定錢包地址轉賬',
'點擊「已打款」確認',
'等待管理員審核通過',
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'操作流程',
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 12),
...steps.asMap().entries.map((e) => Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Row(
children: [
Text(
'${e.key + 1}.',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
e.value,
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
),
],
),
)),
],
);
}
// ============================================
// 结果视图
// ============================================
Widget _buildResultView() {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return SingleChildScrollView(
padding: const EdgeInsets.all(AppSpacing.lg),
padding: const EdgeInsets.fromLTRB(
AppSpacing.md, AppSpacing.xs, AppSpacing.md, AppSpacing.xl),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -317,27 +341,19 @@ class _DepositPageState extends State<DepositPage> {
Center(
child: Column(
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: context.appColors.up.withValues(alpha: 0.12),
shape: BoxShape.circle,
),
child: Icon(
Icons.check_circle_outline_rounded,
color: context.appColors.up,
size: 32,
),
Icon(
LucideIcons.circleCheck,
size: 48,
color: colorScheme.secondary,
),
const SizedBox(height: AppSpacing.md),
const SizedBox(height: 12),
Text(
'充值申請成功',
style: AppTextStyles.headlineLarge(context).copyWith(
fontWeight: FontWeight.w700,
style: AppTextStyles.headlineSmall(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.xs),
const SizedBox(height: 4),
Text(
'請向以下地址轉賬完成充值',
style: AppTextStyles.bodyMedium(context).copyWith(
@@ -349,113 +365,28 @@ class _DepositPageState extends State<DepositPage> {
),
const SizedBox(height: AppSpacing.xl),
// 訂單信息
Container(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.3),
),
),
child: Column(
children: [
_buildInfoRow('訂單號', _orderNo ?? ''),
const SizedBox(height: AppSpacing.sm),
Divider(color: colorScheme.outlineVariant.withValues(alpha: 0.2), height: 1),
const SizedBox(height: AppSpacing.sm),
_buildInfoRow('充值金額', '${_amount ?? "0.00"} USDT', isBold: true),
],
),
),
// 订单信息
_buildInfoCard(colorScheme),
const SizedBox(height: AppSpacing.lg),
// 錢包地址
Text(
'收款地址',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.sm),
Container(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.3),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
_walletAddress ?? '',
style: AppTextStyles.bodyMedium(context).copyWith(
fontFamily: 'monospace',
),
),
),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: _walletAddress ?? ''));
ToastUtils.showSuccess('地址已複製到剪貼板');
},
child: Container(
padding: const EdgeInsets.all(AppSpacing.sm),
decoration: BoxDecoration(
color: colorScheme.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Icon(
LucideIcons.copy,
size: 16,
color: colorScheme.primary,
),
),
),
],
),
const SizedBox(height: AppSpacing.sm),
Text(
'網絡: $_walletNetwork',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
),
// 收款地址
_buildAddressCard(colorScheme),
const SizedBox(height: AppSpacing.md),
// 重要提示
Container(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: AppColorScheme.warning.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(AppRadius.md),
border: Border.all(
color: AppColorScheme.warning.withValues(alpha: 0.15),
),
),
// 提示
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.info_outline, size: 18, color: AppColorScheme.warning),
const SizedBox(width: AppSpacing.sm),
Icon(LucideIcons.info,
size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 6),
Expanded(
child: Text(
'轉賬完成後請點擊下方「已打款」按鈕確認,管理員審核通過後資金將到賬。',
style: AppTextStyles.bodyMedium(context).copyWith(
color: AppColorScheme.warning,
'轉賬完成後請點擊「已打款」確認,管理員審核通過後資金將到賬。',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
),
@@ -464,24 +395,24 @@ class _DepositPageState extends State<DepositPage> {
),
const SizedBox(height: AppSpacing.xl),
// 操作按
// 操作按
Row(
children: [
Expanded(
child: SizedBox(
height: 50,
height: 48,
child: OutlinedButton(
onPressed: () => Navigator.of(context).pop(),
style: OutlinedButton.styleFrom(
side: BorderSide(color: colorScheme.outline),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
borderRadius: BorderRadius.circular(14),
),
),
child: Text(
'稍後確認',
style: AppTextStyles.headlineSmall(context).copyWith(
fontWeight: FontWeight.w600,
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.w500,
),
),
),
@@ -490,22 +421,22 @@ class _DepositPageState extends State<DepositPage> {
const SizedBox(width: AppSpacing.md),
Expanded(
child: SizedBox(
height: 50,
height: 48,
child: ElevatedButton(
onPressed: _confirmPay,
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.primary,
foregroundColor: colorScheme.onPrimary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
),
backgroundColor: colorScheme.onSurface,
foregroundColor: colorScheme.surface,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
),
child: Text(
'已打款',
style: AppTextStyles.headlineSmall(context).copyWith(
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onPrimary,
color: colorScheme.surface,
),
),
),
@@ -513,100 +444,191 @@ class _DepositPageState extends State<DepositPage> {
),
],
),
const SizedBox(height: AppSpacing.lg),
_buildSecurityTip(),
],
),
);
}
// ============================================
// 輔助組件
// ============================================
Widget _buildStepItem(int step, String text) {
final colorScheme = context.colors;
return Padding(
padding: const EdgeInsets.only(bottom: AppSpacing.sm + AppSpacing.xs),
child: Row(
Widget _buildInfoCard(ColorScheme colorScheme) {
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
),
child: Column(
children: [
Container(
width: 24,
height: 24,
decoration: BoxDecoration(
color: colorScheme.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Center(
child: Text(
'$step',
style: AppTextStyles.labelSmall(context).copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.bold,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'訂單號',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
),
),
const SizedBox(width: AppSpacing.sm),
Expanded(
child: Text(
text,
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
Text(
_orderNo ?? '',
style: AppTextStyles.bodySmall(context).copyWith(
fontWeight: FontWeight.w500,
),
),
),
],
),
const SizedBox(height: 10),
Divider(
height: 1,
color: colorScheme.outlineVariant.withValues(alpha: 0.3)),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'充值金額',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
Text(
'${_amount ?? "0.00"} USDT',
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.w600,
),
),
],
),
],
),
);
}
Widget _buildInfoRow(String label, String value, {bool isBold = false}) {
final colorScheme = context.colors;
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Widget _buildAddressCard(ColorScheme colorScheme) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
'收款地址',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
Flexible(
child: Text(
value,
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: isBold ? FontWeight.bold : FontWeight.w400,
const SizedBox(height: AppSpacing.sm),
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
textAlign: TextAlign.right,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
_walletAddress ?? '',
style: AppTextStyles.bodyMedium(context).copyWith(
fontFamily: 'monospace',
),
),
),
GestureDetector(
onTap: () {
Clipboard.setData(
ClipboardData(text: _walletAddress ?? ''));
ToastUtils.showSuccess('地址已複製');
},
child: Padding(
padding: const EdgeInsets.all(4),
child: Icon(
LucideIcons.copy,
size: 16,
color: colorScheme.onSurfaceVariant,
),
),
),
],
),
const SizedBox(height: 8),
Text(
'網絡: $_walletNetwork',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
),
],
);
}
Widget _buildSecurityTip() {
final colorScheme = context.colors;
return Container(
// ============================================
// 共享组件
// ============================================
Widget _buildSubmitButton(
ColorScheme colorScheme, String text, VoidCallback onPressed) {
return SizedBox(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppRadius.md),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.verified_user_outlined,
size: 14,
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
height: 48,
child: ElevatedButton(
onPressed: _isSubmitting ? null : onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.onSurface,
foregroundColor: colorScheme.surface,
disabledBackgroundColor:
colorScheme.surfaceContainerHighest,
disabledForegroundColor: colorScheme.onSurfaceVariant,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
const SizedBox(width: AppSpacing.xs),
),
child: _isSubmitting
? SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
colorScheme.onSurfaceVariant,
),
),
)
: Text(
text,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
),
);
}
Widget _buildBottomTip(ColorScheme colorScheme) {
return Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(LucideIcons.shieldCheck,
size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 4),
Text(
'資金安全由平台全程保障',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
color: colorScheme.onSurfaceVariant,
),
),
],

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_theme_extension.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/utils/toast_utils.dart';
import '../../../providers/asset_provider.dart';
import '../../shared/ui_constants.dart';
import '../../components/material_input.dart';
/// 提現頁面 — 獨立頁面,替代彈窗
/// 提现页面
class WithdrawPage extends StatefulWidget {
final String? balance;
@@ -24,17 +22,16 @@ class _WithdrawPageState extends State<WithdrawPage> {
final _amountController = TextEditingController();
final _addressController = TextEditingController();
final _contactController = TextEditingController();
final _formKey = GlobalKey<ShadFormState>();
final _amountFocus = FocusNode();
bool _isSubmitting = false;
final _feeNotifier = ValueNotifier<String>('提現將扣除 10% 手續費');
final _networksNotifier = ValueNotifier<List<String>>([]);
final _selectedNetworkNotifier = ValueNotifier<String?>(null);
List<String> _networks = [];
String? _selectedNetwork;
@override
void initState() {
super.initState();
_amountController.addListener(_onAmountChanged);
_amountController.addListener(() => setState(() {}));
_loadNetworks();
}
@@ -43,47 +40,57 @@ class _WithdrawPageState extends State<WithdrawPage> {
_amountController.dispose();
_addressController.dispose();
_contactController.dispose();
_feeNotifier.dispose();
_networksNotifier.dispose();
_selectedNetworkNotifier.dispose();
_amountFocus.dispose();
super.dispose();
}
void _onAmountChanged() {
final amount = double.tryParse(_amountController.text) ?? 0;
if (amount > 0) {
final fee = amount * 0.1;
final receivable = amount - fee;
_feeNotifier.value =
'手續費(10%): -${fee.toStringAsFixed(2)} USDT\n應收款: ${receivable.toStringAsFixed(2)} USDT';
} else {
_feeNotifier.value = '提現將扣除 10% 手續費';
}
}
// ============================================
// 业务逻辑
// ============================================
void _loadNetworks() {
context.read<AssetProvider>().getWalletNetworks().then((list) {
if (mounted) {
_networksNotifier.value = list;
if (list.isNotEmpty) {
_selectedNetworkNotifier.value = list.first;
}
setState(() {
_networks = list;
if (list.isNotEmpty) _selectedNetwork = list.first;
});
}
});
}
String get _feeText {
final amount = double.tryParse(_amountController.text) ?? 0;
if (amount > 0) {
final fee = amount * 0.1;
final receivable = amount - fee;
return '手續費(10%): -${fee.toStringAsFixed(2)} USDT | 應收款: ${receivable.toStringAsFixed(2)} USDT';
}
return '提現將扣除 10% 手續費';
}
Future<void> _submitWithdraw() async {
if (!_formKey.currentState!.saveAndValidate()) return;
final amount = double.tryParse(_amountController.text);
if (amount == null || amount <= 0) {
ToastUtils.showError('請輸入有效金額');
return;
}
final address = _addressController.text.trim();
if (address.isEmpty) {
ToastUtils.showError('請輸入提現地址');
return;
}
if (_isSubmitting) return;
setState(() => _isSubmitting = true);
try {
final response = await context.read<AssetProvider>().withdraw(
amount: _amountController.text,
withdrawAddress: _addressController.text,
withdrawContact:
_contactController.text.isNotEmpty ? _contactController.text : null,
network: _selectedNetworkNotifier.value,
withdrawAddress: address,
withdrawContact: _contactController.text.trim().isNotEmpty
? _contactController.text.trim()
: null,
network: _selectedNetwork,
);
if (!mounted) return;
@@ -101,309 +108,316 @@ class _WithdrawPageState extends State<WithdrawPage> {
}
// ============================================
// 建 UI
// 建 UI
// ============================================
@override
Widget build(BuildContext context) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: colorScheme.background,
backgroundColor: colorScheme.surface,
appBar: AppBar(
leading: IconButton(
icon: const Icon(LucideIcons.arrowLeft, size: 20),
icon: Icon(LucideIcons.arrowLeft,
color: colorScheme.onSurface, size: 20),
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
'提現',
style: AppTextStyles.headlineLarge(context).copyWith(
color: colorScheme.onSurface,
fontWeight: FontWeight.w600,
),
),
backgroundColor: colorScheme.background,
backgroundColor: Colors.transparent,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: true,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(AppSpacing.lg),
padding: const EdgeInsets.fromLTRB(
AppSpacing.md, AppSpacing.xs, AppSpacing.md, AppSpacing.xl),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 餘額顯示
// 可用余额
if (widget.balance != null) ...[
Container(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.3),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'可用餘額',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
Text(
'${widget.balance} USDT',
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.bold,
color: context.appColors.up,
),
),
],
),
),
_buildBalanceRow(colorScheme),
const SizedBox(height: AppSpacing.lg),
],
// 表單
ShadForm(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 提現金額
Text(
'提現金額',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.sm),
ShadInputFormField(
id: 'amount',
controller: _amountController,
placeholder: const Text('請輸入提現金額 (USDT)'),
keyboardType:
const TextInputType.numberWithOptions(decimal: true),
validator: Validators.amount,
),
const SizedBox(height: AppSpacing.sm),
// 提现金额
_buildAmountInput(colorScheme),
const SizedBox(height: AppSpacing.sm),
// 手續費提示
ValueListenableBuilder<String>(
valueListenable: _feeNotifier,
builder: (_, feeText, __) {
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.md,
vertical: AppSpacing.sm,
),
decoration: BoxDecoration(
color: colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppRadius.md),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.info_outline,
size: 14, color: colorScheme.onSurfaceVariant),
const SizedBox(width: AppSpacing.xs),
Expanded(
child: Text(
feeText,
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
),
],
),
);
},
),
const SizedBox(height: AppSpacing.lg),
// 手续费提示
_buildFeeTip(colorScheme),
const SizedBox(height: AppSpacing.lg),
// 提現網絡
ValueListenableBuilder<List<String>>(
valueListenable: _networksNotifier,
builder: (_, networks, __) {
if (networks.isEmpty) return const SizedBox.shrink();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'提現網絡',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.sm),
ValueListenableBuilder<String?>(
valueListenable: _selectedNetworkNotifier,
builder: (_, selected, __) {
return SizedBox(
width: double.infinity,
child: ShadSelect<String>(
placeholder: const Text('選擇提現網絡'),
initialValue: selected,
selectedOptionBuilder: (context, val) =>
Text(val),
onChanged: (value) {
if (value != null) {
_selectedNetworkNotifier.value = value;
}
},
options: networks
.map((n) =>
ShadOption(value: n, child: Text(n)))
.toList(),
),
);
},
),
const SizedBox(height: AppSpacing.lg),
],
);
},
),
// 提现网络
if (_networks.isNotEmpty) ...[
_buildSectionLabel(colorScheme, '提現網絡'),
const SizedBox(height: AppSpacing.sm),
_buildNetworkSelector(colorScheme),
const SizedBox(height: AppSpacing.lg),
],
// 目地址
Text(
'目標地址',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.sm),
ShadInputFormField(
id: 'address',
controller: _addressController,
placeholder: const Text('請輸入提現地址'),
validator: (v) => Validators.required(v, '提現地址'),
),
const SizedBox(height: AppSpacing.lg),
// 目地址
_buildAddressInput(colorScheme),
const SizedBox(height: AppSpacing.lg),
// 聯繫方式
Text(
'聯繫方式(可選)',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: AppSpacing.sm),
ShadInputFormField(
id: 'contact',
controller: _contactController,
placeholder: const Text('方便客服與您聯繫'),
),
],
),
),
// 联系方式
_buildContactInput(colorScheme),
const SizedBox(height: AppSpacing.xl),
// 安全提示
Container(
width: double.infinity,
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: AppColorScheme.warning.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(AppRadius.md),
border: Border.all(
color: AppColorScheme.warning.withValues(alpha: 0.15),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(Icons.shield_outlined,
size: 16, color: AppColorScheme.warning),
const SizedBox(width: AppSpacing.xs),
Text(
'安全提示',
style: AppTextStyles.labelLarge(context).copyWith(
fontWeight: FontWeight.w600,
color: AppColorScheme.warning,
),
),
],
),
const SizedBox(height: AppSpacing.sm),
Text(
'• 請仔細核對提現地址,地址錯誤將導致資產無法找回\n'
'• 提現申請提交後需等待管理員審批\n'
'• 提現將扣除 10% 手續費',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
height: 1.6,
),
),
],
),
),
_buildSecurityTips(colorScheme),
const SizedBox(height: AppSpacing.xl),
// 提交按
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: _isSubmitting ? null : _submitWithdraw,
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.primary,
foregroundColor: colorScheme.onPrimary,
disabledBackgroundColor:
colorScheme.primary.withValues(alpha: 0.5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
),
elevation: 0,
),
child: _isSubmitting
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
: Text(
'提交申請',
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onPrimary,
),
),
),
),
const SizedBox(height: AppSpacing.lg),
// 提交按
_buildSubmitButton(colorScheme),
const SizedBox(height: AppSpacing.md),
// 底部安全保障
Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.verified_user_outlined,
size: 14,
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
),
const SizedBox(width: AppSpacing.xs),
Text(
'資金安全由平台全程保障',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
),
),
],
),
),
_buildBottomTip(colorScheme),
],
),
),
);
}
// ============================================
// 组件
// ============================================
Widget _buildBalanceRow(ColorScheme colorScheme) {
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'可用餘額',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
Text(
'${widget.balance} USDT',
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.w600,
),
),
],
),
);
}
Widget _buildSectionLabel(ColorScheme colorScheme, String text) {
return Text(
text,
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
);
}
Widget _buildAmountInput(ColorScheme colorScheme) {
return MaterialInput(
controller: _amountController,
focusNode: _amountFocus,
labelText: '提現金額',
hintText: '0.00',
keyboardType: const TextInputType.numberWithOptions(decimal: true),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d{0,8}')),
],
suffixIcon: Padding(
padding: const EdgeInsets.only(right: AppSpacing.md),
child: Text(
'USDT',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
),
);
}
Widget _buildFeeTip(ColorScheme colorScheme) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
Icon(LucideIcons.info,
size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 6),
Expanded(
child: Text(
_feeText,
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
),
],
),
);
}
Widget _buildNetworkSelector(ColorScheme colorScheme) {
return Container(
width: double.infinity,
height: 48,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: _selectedNetwork,
isExpanded: true,
hint: Text(
'選擇提現網絡',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
items: _networks
.map((n) => DropdownMenuItem(
value: n,
child: Text(n),
))
.toList(),
onChanged: (value) {
if (value != null) setState(() => _selectedNetwork = value);
},
),
),
);
}
Widget _buildAddressInput(ColorScheme colorScheme) {
return MaterialInput(
controller: _addressController,
labelText: '目標地址',
hintText: '請輸入提現地址',
);
}
Widget _buildContactInput(ColorScheme colorScheme) {
return MaterialInput(
controller: _contactController,
labelText: '聯繫方式(可選)',
hintText: '方便客服與您聯繫',
);
}
Widget _buildSecurityTips(ColorScheme colorScheme) {
final tips = [
'請仔細核對提現地址,地址錯誤將導致資產無法找回',
'提現申請提交後需等待管理員審批',
'提現將扣除 10% 手續費',
];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: tips
.map((t) => Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
Expanded(
child: Text(
t,
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
),
],
),
))
.toList(),
);
}
Widget _buildSubmitButton(ColorScheme colorScheme) {
return SizedBox(
width: double.infinity,
height: 48,
child: ElevatedButton(
onPressed: _isSubmitting ? null : _submitWithdraw,
style: ElevatedButton.styleFrom(
backgroundColor: colorScheme.onSurface,
foregroundColor: colorScheme.surface,
disabledBackgroundColor: colorScheme.surfaceContainerHighest,
disabledForegroundColor: colorScheme.onSurfaceVariant,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
),
child: _isSubmitting
? SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
colorScheme.onSurfaceVariant,
),
),
)
: Text(
'提交申請',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
),
);
}
Widget _buildBottomTip(ColorScheme colorScheme) {
return Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(LucideIcons.shieldCheck,
size: 13, color: colorScheme.onSurfaceVariant),
const SizedBox(width: 4),
Text(
'資金安全由平台全程保障',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
);
}
}

View File

@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_color_scheme.dart';
@@ -7,6 +6,7 @@ import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_theme_extension.dart';
import '../../../providers/auth_provider.dart';
import '../../components/material_input.dart';
import '../main/main_page.dart';
import 'register_page.dart';
@@ -18,14 +18,13 @@ class LoginPage extends StatefulWidget {
}
class _LoginPageState extends State<LoginPage> {
final formKey = GlobalKey<ShadFormState>();
final _formKey = GlobalKey<FormState>();
final _usernameController = TextEditingController();
final _passwordController = TextEditingController();
bool _obscurePassword = true;
static const _loadingIndicatorSize = 16.0;
static const _logoCircleSize = 80.0;
static const _inputHeight = 52.0;
static const _buttonHeight = 52.0;
@override
@@ -45,8 +44,8 @@ class _LoginPageState extends State<LoginPage> {
horizontal: AppSpacing.xl,
vertical: AppSpacing.xxl,
),
child: ShadForm(
key: formKey,
child: Form(
key: _formKey,
child: Column(
children: [
// 頂部品牌區域
@@ -135,63 +134,22 @@ class _LoginPageState extends State<LoginPage> {
}
Widget _buildUsernameField() {
return SizedBox(
height: _inputHeight,
child: ShadInputFormField(
id: 'username',
placeholder: const Text('請輸入用戶名'),
leading: Padding(
padding: const EdgeInsets.only(right: AppSpacing.sm),
child: Icon(LucideIcons.user, size: 18, color: context.appColors.onSurfaceMuted),
),
validator: _validateUsername,
controller: _usernameController,
decoration: ShadDecoration(
border: ShadBorder.all(
color: context.colors.outlineVariant,
radius: AppRadius.radiusLg,
),
),
style: AppTextStyles.headlineMedium(context).copyWith(
color: context.colors.onSurface,
),
),
return MaterialInput(
controller: _usernameController,
labelText: '用戶名',
hintText: '請輸入用戶名',
prefixIcon: Icons.person_outline,
validator: _validateUsername,
);
}
Widget _buildPasswordField() {
final iconColor = context.appColors.onSurfaceMuted;
return SizedBox(
height: _inputHeight,
child: ShadInputFormField(
id: 'password',
placeholder: const Text('請輸入密碼'),
obscureText: _obscurePassword,
leading: Padding(
padding: const EdgeInsets.only(right: AppSpacing.sm),
child: Icon(LucideIcons.lock, size: 18, color: iconColor),
),
trailing: GestureDetector(
onTap: () => setState(() => _obscurePassword = !_obscurePassword),
child: Icon(
_obscurePassword ? LucideIcons.eyeOff : LucideIcons.eye,
size: 18,
color: iconColor,
),
),
validator: _validatePassword,
controller: _passwordController,
decoration: ShadDecoration(
border: ShadBorder.all(
color: context.colors.outlineVariant,
radius: AppRadius.radiusLg,
),
),
style: AppTextStyles.headlineMedium(context).copyWith(
color: context.colors.onSurface,
),
),
return MaterialPasswordInput(
controller: _passwordController,
labelText: '密碼',
hintText: '請輸入密碼',
prefixIcon: Icons.lock_outline,
validator: _validatePassword,
);
}
@@ -204,13 +162,21 @@ class _LoginPageState extends State<LoginPage> {
builder: (context, auth, _) {
return SizedBox(
height: _buttonHeight,
child: ShadButton(
child: ElevatedButton(
onPressed: auth.isLoading ? null : () => _handleLogin(auth),
backgroundColor: buttonColor,
foregroundColor: textColor,
decoration: ShadDecoration(
border: ShadBorder.all(
radius: AppRadius.radiusLg,
style: ElevatedButton.styleFrom(
backgroundColor: buttonColor,
foregroundColor: textColor,
disabledBackgroundColor: buttonColor.withValues(alpha: 0.5),
disabledForegroundColor: textColor.withValues(alpha: 0.5),
elevation: 0,
shadowColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
),
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.xl,
vertical: AppSpacing.md,
),
),
child: auth.isLoading
@@ -299,12 +265,11 @@ class _LoginPageState extends State<LoginPage> {
// ============================================
Future<void> _handleLogin(AuthProvider auth) async {
if (!formKey.currentState!.saveAndValidate()) return;
if (!_formKey.currentState!.validate()) return;
final values = formKey.currentState!.value;
final response = await auth.login(
values['username'],
values['password'],
_usernameController.text.trim(),
_passwordController.text,
);
if (!mounted) return;
@@ -331,15 +296,15 @@ class _LoginPageState extends State<LoginPage> {
}
void _showErrorDialog(String message) {
showShadDialog(
showDialog(
context: context,
builder: (context) => ShadDialog.alert(
builder: (context) => AlertDialog(
title: const Text('登錄失敗'),
description: Text(message),
content: Text(message),
actions: [
ShadButton(
child: const Text('確定'),
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('確定'),
),
],
),

View File

@@ -1,17 +1,19 @@
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:provider/provider.dart';
import 'package:image_picker/image_picker.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
import '../../../providers/auth_provider.dart';
import '../../components/glass_panel.dart';
import '../../components/neon_glow.dart';
import '../../components/material_input.dart';
import '../main/main_page.dart';
/// 註冊頁面(兩步註冊賬號信息 + 身份證上傳
/// 註冊頁面(兩步註冊:賬號信息 + 身份證上傳)
class RegisterPage extends StatefulWidget {
const RegisterPage({super.key});
@@ -84,7 +86,7 @@ class _RegisterPageState extends State<RegisterPage> {
backgroundColor: AppColorScheme.darkBackground.withValues(alpha: 0),
elevation: 0,
leading: IconButton(
icon: Icon(LucideIcons.chevronLeft, color: colorScheme.onSurface),
icon: Icon(LucideIcons.arrowLeft, color: colorScheme.onSurface),
onPressed: _currentStep == 1
? () => setState(() => _currentStep = 0)
: () => Navigator.pop(context),
@@ -98,7 +100,7 @@ class _RegisterPageState extends State<RegisterPage> {
children: [
// 步驟指示器
_buildStepIndicator(colorScheme),
SizedBox(height: AppSpacing.xl),
const SizedBox(height: AppSpacing.xl),
// 內容區
_currentStep == 0 ? _buildStep1(colorScheme) : _buildStep2(colorScheme),
@@ -180,7 +182,7 @@ class _RegisterPageState extends State<RegisterPage> {
),
),
),
SizedBox(height: AppSpacing.xs),
const SizedBox(height: AppSpacing.xs),
Text(
label,
style: AppTextStyles.bodySmall(context).copyWith(
@@ -191,7 +193,7 @@ class _RegisterPageState extends State<RegisterPage> {
);
}
/// 第一步賬號信息
/// 第一步:賬號信息
Widget _buildStep1(ColorScheme colorScheme) {
return Form(
key: _formKey,
@@ -208,83 +210,59 @@ class _RegisterPageState extends State<RegisterPage> {
),
),
),
SizedBox(height: AppSpacing.xxl),
const SizedBox(height: AppSpacing.xxl),
// 用戶名
TextFormField(
MaterialInput(
controller: _usernameController,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '請輸入賬號(4-20位字母數字)',
prefixIcon: Icon(Icons.person_outline, color: colorScheme.onSurfaceVariant),
),
labelText: '賬號',
hintText: '請輸入賬號(4-20位字母數字)',
prefixIcon: Icons.person_outline,
validator: (value) {
if (value == null || value.isEmpty) return '請輸入賬號';
if (value.length < 4) return '賬號至少4位';
if (value.length > 20) return '賬號最多20位';
if (value.length < 4) return '賬號過短';
if (value.length > 20) return '賬號過長';
return null;
},
),
SizedBox(height: AppSpacing.md),
const SizedBox(height: AppSpacing.md),
// 密碼
TextFormField(
MaterialPasswordInput(
controller: _passwordController,
obscureText: _obscurePassword,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '請輸入密碼(至少6位)',
prefixIcon: Icon(Icons.lock_outline, color: colorScheme.onSurfaceVariant),
suffixIcon: IconButton(
icon: Icon(
_obscurePassword ? Icons.visibility_off : Icons.visibility,
color: colorScheme.onSurfaceVariant,
),
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
),
),
labelText: '密碼',
hintText: '請輸入密碼(至少6位)',
prefixIcon: Icons.lock_outline,
validator: (value) {
if (value == null || value.isEmpty) return '請輸入密碼';
if (value.length < 6) return '密碼至少6位';
if (value.length < 6) return '密碼過短';
return null;
},
),
SizedBox(height: AppSpacing.md),
const SizedBox(height: AppSpacing.md),
// 確認密碼
TextFormField(
MaterialPasswordInput(
controller: _confirmPasswordController,
obscureText: _obscureConfirmPassword,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '請再次輸入密碼',
prefixIcon: Icon(Icons.lock_outline, color: colorScheme.onSurfaceVariant),
suffixIcon: IconButton(
icon: Icon(
_obscureConfirmPassword ? Icons.visibility_off : Icons.visibility,
color: colorScheme.onSurfaceVariant,
),
onPressed: () => setState(() => _obscureConfirmPassword = !_obscureConfirmPassword),
),
),
labelText: '確認密碼',
hintText: '請再次輸入密碼',
prefixIcon: Icons.lock_outline,
validator: (value) {
if (value == null || value.isEmpty) return '請再次輸入密碼';
if (value != _passwordController.text) return '兩次密碼不一致';
return null;
},
),
SizedBox(height: AppSpacing.md),
const SizedBox(height: AppSpacing.md),
// 推廣碼(可選
TextFormField(
// 推廣碼(可選)
MaterialInput(
controller: _referralCodeController,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '推廣碼(選填)',
prefixIcon: Icon(Icons.card_giftcard, color: colorScheme.onSurfaceVariant),
),
labelText: '推廣碼',
hintText: '請輸入推廣碼(選填)',
prefixIcon: Icons.card_giftcard,
),
SizedBox(height: AppSpacing.xl),
const SizedBox(height: AppSpacing.xl),
// 下一步按鈕
SizedBox(
@@ -301,13 +279,16 @@ class _RegisterPageState extends State<RegisterPage> {
showGlow: true,
),
),
SizedBox(height: AppSpacing.md),
const SizedBox(height: AppSpacing.md),
// 登錄鏈接
Center(
child: TextButton(
onPressed: () => Navigator.pop(context),
child: Text('已有賬號?立即登錄', style: AppTextStyles.headlineMedium(context)),
child: Text(
'已有賬號?立即登錄',
style: AppTextStyles.headlineMedium(context),
),
),
),
],
@@ -315,21 +296,21 @@ class _RegisterPageState extends State<RegisterPage> {
);
}
/// 第二步身份證上傳
/// 第二步:身份證上傳
Widget _buildStep2(ColorScheme colorScheme) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 標題區
GlassPanel(
padding: EdgeInsets.all(AppSpacing.lg),
padding: const EdgeInsets.all(AppSpacing.lg),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: EdgeInsets.all(AppSpacing.sm),
padding: const EdgeInsets.all(AppSpacing.sm),
decoration: BoxDecoration(
color: colorScheme.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.md),
@@ -340,7 +321,7 @@ class _RegisterPageState extends State<RegisterPage> {
size: 22,
),
),
SizedBox(width: AppSpacing.md),
const SizedBox(width: AppSpacing.md),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -351,7 +332,7 @@ class _RegisterPageState extends State<RegisterPage> {
color: colorScheme.onSurface,
),
),
SizedBox(height: AppSpacing.xs),
const SizedBox(height: AppSpacing.xs),
Text(
'上傳身份證正反面完成註冊',
style: AppTextStyles.bodyMedium(context).copyWith(
@@ -362,17 +343,17 @@ class _RegisterPageState extends State<RegisterPage> {
),
],
),
SizedBox(height: AppSpacing.xl),
const SizedBox(height: AppSpacing.xl),
// 身份證正面
Text(
'身份證正面人像面',
'身份證正面(人像面)',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onSurface,
),
),
SizedBox(height: AppSpacing.sm),
const SizedBox(height: AppSpacing.sm),
_buildUploadZone(
imageFile: _frontFile,
imageBytes: _frontBytes,
@@ -380,17 +361,17 @@ class _RegisterPageState extends State<RegisterPage> {
onTap: () => _pickImage(true),
colorScheme: colorScheme,
),
SizedBox(height: AppSpacing.lg),
const SizedBox(height: AppSpacing.lg),
// 身份證反面
Text(
'身份證反面國徽面',
'身份證反面(國徽面)',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onSurface,
),
),
SizedBox(height: AppSpacing.sm),
const SizedBox(height: AppSpacing.sm),
_buildUploadZone(
imageFile: _backFile,
imageBytes: _backBytes,
@@ -398,7 +379,7 @@ class _RegisterPageState extends State<RegisterPage> {
onTap: () => _pickImage(false),
colorScheme: colorScheme,
),
SizedBox(height: AppSpacing.xl),
const SizedBox(height: AppSpacing.xl),
// 註冊按鈕
Consumer<AuthProvider>(
@@ -408,7 +389,9 @@ class _RegisterPageState extends State<RegisterPage> {
child: NeonButton(
text: _isLoading ? '註冊中...' : '完成註冊',
type: NeonButtonType.primary,
onPressed: _canSubmit && !auth.isLoading ? _handleRegister : null,
onPressed: _canSubmit && !auth.isLoading
? _handleRegister
: null,
height: 48,
showGlow: _canSubmit,
),
@@ -418,20 +401,22 @@ class _RegisterPageState extends State<RegisterPage> {
],
),
),
SizedBox(height: AppSpacing.lg),
const SizedBox(height: AppSpacing.lg),
// 安全提示
Container(
padding: EdgeInsets.all(AppSpacing.md),
padding: const EdgeInsets.all(AppSpacing.md),
decoration: BoxDecoration(
color: AppColorScheme.up.withValues(alpha: 0.06),
borderRadius: AppRadius.radiusLg,
border: Border.all(color: AppColorScheme.up.withValues(alpha: 0.12)),
border: Border.all(
color: AppColorScheme.up.withValues(alpha: 0.12),
),
),
child: Row(
children: [
Icon(LucideIcons.lock, size: 16, color: AppColorScheme.up),
SizedBox(width: AppSpacing.sm),
const SizedBox(width: AppSpacing.sm),
Expanded(
child: Text(
'您的身份信息將被加密存儲,僅用於身份驗證',
@@ -468,7 +453,9 @@ class _RegisterPageState extends State<RegisterPage> {
: colorScheme.surfaceContainerHigh.withValues(alpha: 0.3),
borderRadius: AppRadius.radiusXl,
border: Border.all(
color: hasImage ? AppColorScheme.up.withValues(alpha: 0.3) : AppColorScheme.darkBackground.withValues(alpha: 0),
color: hasImage
? AppColorScheme.up.withValues(alpha: 0.3)
: Colors.transparent,
),
),
child: hasImage
@@ -483,7 +470,7 @@ class _RegisterPageState extends State<RegisterPage> {
right: 0,
bottom: 0,
child: Container(
padding: EdgeInsets.symmetric(
padding: const EdgeInsets.symmetric(
vertical: AppSpacing.sm,
horizontal: AppSpacing.md,
),
@@ -491,9 +478,13 @@ class _RegisterPageState extends State<RegisterPage> {
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [AppColorScheme.darkBackground.withValues(alpha: 0), AppColorScheme.darkSurfaceLowest.withValues(alpha: 0.6)],
colors: [
AppColorScheme.darkBackground.withValues(alpha: 0),
AppColorScheme.darkSurfaceLowest
.withValues(alpha: 0.6),
],
),
borderRadius: BorderRadius.only(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(AppRadius.xl),
bottomRight: Radius.circular(AppRadius.xl),
),
@@ -521,12 +512,17 @@ class _RegisterPageState extends State<RegisterPage> {
});
},
child: Container(
padding: EdgeInsets.all(AppSpacing.xs),
padding: const EdgeInsets.all(AppSpacing.xs),
decoration: BoxDecoration(
color: AppColorScheme.darkOnPrimary.withValues(alpha: 0.15),
color: AppColorScheme.darkOnPrimary
.withValues(alpha: 0.15),
shape: BoxShape.circle,
),
child: Icon(LucideIcons.x, size: 14, color: AppColorScheme.darkOnPrimary),
child: Icon(
LucideIcons.x,
size: 14,
color: AppColorScheme.darkOnPrimary,
),
),
),
],
@@ -549,14 +545,14 @@ class _RegisterPageState extends State<RegisterPage> {
size: 28,
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
),
SizedBox(height: AppSpacing.sm),
const SizedBox(height: AppSpacing.sm),
Text(
'點擊上傳$label',
style: AppTextStyles.bodyLarge(context).copyWith(
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.6),
),
),
SizedBox(height: AppSpacing.xs),
const SizedBox(height: AppSpacing.xs),
Text(
'支持 JPG、PNG 格式',
style: AppTextStyles.bodySmall(context).copyWith(
@@ -594,15 +590,15 @@ class _RegisterPageState extends State<RegisterPage> {
MaterialPageRoute(builder: (_) => const MainPage()),
);
} else {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: const Text('註冊失敗'),
description: Text(response.message ?? '請稍後重試'),
content: Text(response.message ?? '請稍後重試'),
actions: [
ShadButton(
child: const Text('確定'),
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('確定'),
),
],
),
@@ -610,15 +606,15 @@ class _RegisterPageState extends State<RegisterPage> {
}
} catch (e) {
if (mounted) {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: const Text('註冊失敗'),
description: Text(e.toString()),
content: Text(e.toString()),
actions: [
ShadButton(
child: const Text('確定'),
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('確定'),
),
],
),
@@ -630,7 +626,7 @@ class _RegisterPageState extends State<RegisterPage> {
}
}
/// 虛線邊框畫
/// 虚线边框画
class _DashedBorderPainter extends CustomPainter {
final Color color;
final double borderRadius;
@@ -647,8 +643,8 @@ class _DashedBorderPainter extends CustomPainter {
..strokeWidth = 1.5
..style = PaintingStyle.stroke;
final dashWidth = 6.0;
final dashSpace = 4.0;
const dashWidth = 6.0;
const dashSpace = 4.0;
final path = Path()
..addRRect(RRect.fromRectAndRadius(

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_chen_kchart/k_chart.dart';
import 'package:provider/provider.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:decimal/decimal.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
@@ -16,7 +16,7 @@ class ChartPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return ChangeNotifierProvider(
create: (_) => ChartProvider()
@@ -46,7 +46,7 @@ class ChartPage extends StatelessWidget {
final data = provider.klineData;
if (data.isEmpty) {
return const Center(child: Text('暂无数据'));
return const Center(child: Text('暫無數據'));
}
return Column(
@@ -137,7 +137,7 @@ class ChartPage extends StatelessWidget {
}
Widget _buildPriceHeader(BuildContext context, ChartProvider provider) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
final candles = provider.candles;
if (candles.isEmpty) return const SizedBox.shrink();
@@ -213,7 +213,7 @@ class ChartPage extends StatelessWidget {
}
Widget _buildDataItem(BuildContext context, String label, String value) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -224,7 +224,7 @@ class ChartPage extends StatelessWidget {
}
Widget _buildIntervalTabs(BuildContext context, ChartProvider provider) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return Container(
height: 40,
@@ -260,7 +260,7 @@ class ChartPage extends StatelessWidget {
/// 底部指标切换(官方 demo 风格)
Widget _buildIndicatorTabs(BuildContext context, ChartProvider provider) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
final selectedColor = colorScheme.primary;
final unselectedColor = colorScheme.onSurfaceVariant;
@@ -361,7 +361,7 @@ class ChartPage extends StatelessWidget {
}
Widget _buildBottomActions(BuildContext context, ChartProvider provider) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.all(AppSpacing.md),
@@ -382,7 +382,7 @@ class ChartPage extends StatelessWidget {
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppRadius.md)),
),
child: Text('', style: AppTextStyles.headlineSmall(context).copyWith(fontWeight: FontWeight.w600, color: Colors.white)),
child: Text('', style: AppTextStyles.headlineSmall(context).copyWith(fontWeight: FontWeight.w600, color: Colors.white)),
),
),
),
@@ -398,7 +398,7 @@ class ChartPage extends StatelessWidget {
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(AppRadius.md)),
),
child: Text('', style: AppTextStyles.headlineSmall(context).copyWith(fontWeight: FontWeight.w600, color: Colors.white)),
child: Text('', style: AppTextStyles.headlineSmall(context).copyWith(fontWeight: FontWeight.w600, color: Colors.white)),
),
),
),
@@ -408,13 +408,13 @@ class ChartPage extends StatelessWidget {
}
void _navigateToTrade(BuildContext context, String symbol, String side) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('$symbol $side - 跳交易面(待实现')));
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('$symbol $side - 跳交易面(待實現')));
}
Widget _buildTitle(BuildContext context) {
return Consumer<ChartProvider>(
builder: (context, provider, _) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -428,16 +428,16 @@ class ChartPage extends StatelessWidget {
}
Widget _buildErrorView(BuildContext context, ChartProvider provider) {
final colorScheme = context.colors;
final colorScheme = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.error_outline, size: 48, color: colorScheme.error),
const SizedBox(height: AppSpacing.md),
Text('载失败', style: AppTextStyles.bodyLarge(context)),
Text('載失敗', style: AppTextStyles.bodyLarge(context)),
const SizedBox(height: AppSpacing.sm),
TextButton(onPressed: provider.loadCandles, child: const Text('')),
TextButton(onPressed: provider.loadCandles, child: const Text('')),
],
),
);

View File

@@ -8,6 +8,7 @@ import '../../../core/theme/app_spacing.dart';
import '../../../data/models/account_models.dart';
import '../../../data/services/bonus_service.dart';
import '../../../providers/asset_provider.dart';
import '../../components/coin_icon.dart';
/// 賬單頁面 — 代幣盈虧賬單 + 新人福利賬單 + 推廣福利賬單
class BillsPage extends StatefulWidget {
@@ -302,17 +303,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
children: [
Row(
children: [
CircleAvatar(
radius: 16,
backgroundColor: colorScheme.primary.withValues(alpha: 0.1),
child: Text(
h.coinCode.substring(0, 1),
style: AppTextStyles.labelLarge(context).copyWith(
color: colorScheme.primary,
fontWeight: FontWeight.bold,
),
),
),
CoinIcon(symbol: h.coinCode, size: 32),
const SizedBox(width: AppSpacing.sm),
Text(h.coinCode, style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.bold,

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';

View File

@@ -1,7 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme_extension.dart';
@@ -87,12 +87,12 @@ class _HomePageState extends State<HomePage>
super.build(context);
return Scaffold(
backgroundColor: context.colors.background,
backgroundColor: Theme.of(context).colorScheme.background,
body: Consumer<AssetProvider>(
builder: (context, provider, _) {
return RefreshIndicator(
onRefresh: () => provider.refreshAll(force: true),
color: context.colors.primary,
color: Theme.of(context).colorScheme.primary,
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: EdgeInsets.only(
@@ -270,7 +270,7 @@ class _AssetCardState extends State<_AssetCard> {
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: BoxDecoration(
color: context.colors.primary,
color: Theme.of(context).colorScheme.primary,
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Row(
@@ -280,7 +280,7 @@ class _AssetCardState extends State<_AssetCard> {
Text(
'充值',
style: AppTextStyles.labelLarge(context).copyWith(
color: context.colors.onPrimary,
color: Theme.of(context).colorScheme.onPrimary,
fontSize: 12,
),
),
@@ -359,9 +359,9 @@ class _WelfareCard extends StatelessWidget {
width: double.infinity,
padding: EdgeInsets.all(AppSpacing.lg),
decoration: BoxDecoration(
color: context.colors.surface,
color: Theme.of(context).colorScheme.surface,
borderRadius: BorderRadius.circular(AppRadius.xl),
border: Border.all(color: context.colors.outlineVariant.withValues(alpha: 0.2)),
border: Border.all(color: Theme.of(context).colorScheme.outlineVariant.withValues(alpha: 0.2)),
),
child: Row(
children: [
@@ -370,12 +370,12 @@ class _WelfareCard extends StatelessWidget {
width: 48,
height: 48,
decoration: BoxDecoration(
color: context.colors.primary.withValues(alpha: 0.15),
color: Theme.of(context).colorScheme.primary.withValues(alpha: 0.15),
borderRadius: BorderRadius.circular(AppRadius.lg),
),
child: Icon(
LucideIcons.gift,
color: context.colors.primary,
color: Theme.of(context).colorScheme.primary,
size: 24,
),
),
@@ -426,7 +426,7 @@ class _WelfareCard extends StatelessWidget {
style: AppTextStyles.bodySmall(context).copyWith(
fontSize: 10,
fontWeight: FontWeight.bold,
color: context.colors.onPrimary,
color: Theme.of(context).colorScheme.onPrimary,
),
),
),
@@ -504,13 +504,13 @@ class _EmptyHoldings extends StatelessWidget {
width: double.infinity,
padding: EdgeInsets.symmetric(vertical: AppSpacing.xxl, horizontal: AppSpacing.lg),
decoration: BoxDecoration(
color: context.colors.surfaceContainerLow.withValues(alpha: 0.5),
color: Theme.of(context).colorScheme.surfaceContainerLow.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(AppRadius.xxl),
border: Border.all(color: context.colors.outlineVariant.withValues(alpha: 0.1)),
border: Border.all(color: Theme.of(context).colorScheme.outlineVariant.withValues(alpha: 0.1)),
),
child: Column(
children: [
Icon(LucideIcons.wallet, size: 48, color: context.colors.onSurfaceVariant),
Icon(LucideIcons.wallet, size: 48, color: Theme.of(context).colorScheme.onSurfaceVariant),
SizedBox(height: AppSpacing.md),
Text(
'暫無持倉',
@@ -542,9 +542,9 @@ class _HoldingsList extends StatelessWidget {
return Container(
decoration: BoxDecoration(
color: context.colors.surface.withValues(alpha: 0.5),
color: Theme.of(context).colorScheme.surface.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(AppRadius.xxl),
border: Border.all(color: context.colors.outlineVariant.withValues(alpha: 0.1)),
border: Border.all(color: Theme.of(context).colorScheme.outlineVariant.withValues(alpha: 0.1)),
),
child: ListView.separated(
shrinkWrap: true,

View File

@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme_extension.dart';
@@ -36,9 +35,9 @@ class HotCoinsSection extends StatelessWidget {
// Card
Container(
decoration: BoxDecoration(
color: context.colors.surfaceContainer,
color: Theme.of(context).colorScheme.surfaceContainer,
border: Border.all(
color: context.colors.outlineVariant,
color: Theme.of(context).colorScheme.outlineVariant,
width: 1,
),
borderRadius: BorderRadius.circular(AppRadius.xl),

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_spacing.dart';
@@ -49,13 +49,13 @@ class QuickActionsRow extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_ActionItem(
icon: LucideIcons.arrowUpRight,
icon: LucideIcons.arrowDownToLine,
label: '充值',
colorScheme: colorScheme,
onTap: onDeposit,
),
_ActionItem(
icon: LucideIcons.arrowDownLeft,
icon: LucideIcons.arrowUpFromLine,
label: '提現',
colorScheme: colorScheme,
onTap: onWithdraw,

View File

@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../core/theme/app_color_scheme.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
import '../../../providers/asset_provider.dart';

View File

@@ -1,13 +1,10 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_theme_extension.dart';
import '../../../data/models/coin.dart';
import '../../../providers/market_provider.dart';
import '../../components/glass_panel.dart';
import '../../components/coin_icon.dart';
import '../main/main_page.dart';
@@ -35,9 +32,10 @@ class _MarketPageState extends State<MarketPage>
@override
Widget build(BuildContext context) {
super.build(context);
final colorScheme = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: context.colors.surface,
backgroundColor: colorScheme.surface,
body: Consumer<MarketProvider>(
builder: (context, provider, _) {
if (provider.isLoading) {
@@ -50,8 +48,8 @@ class _MarketPageState extends State<MarketPage>
return RefreshIndicator(
onRefresh: () => provider.refresh(),
color: context.colors.primary,
backgroundColor: context.colors.surfaceContainerHighest,
color: colorScheme.primary,
backgroundColor: colorScheme.surfaceContainerHighest,
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.only(
@@ -63,22 +61,18 @@ class _MarketPageState extends State<MarketPage>
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 頁面標題 "行情"
Padding(
padding: const EdgeInsets.only(bottom: AppSpacing.sm),
child: Text(
'行情',
style: AppTextStyles.displaySmall(context),
Text(
'行情',
style: AppTextStyles.displaySmall(context).copyWith(
fontSize: 24,
fontWeight: FontWeight.w800,
),
),
const SizedBox(height: AppSpacing.md),
// 精選區域BTC + ETH 卡片
_buildSearchBar(colorScheme),
const SizedBox(height: AppSpacing.md),
_buildFeaturedSection(provider),
const SizedBox(height: AppSpacing.md),
// 分區標題:全部幣種 + 更多
_buildSectionHeader(),
const SizedBox(height: AppSpacing.md),
// 幣種列表卡片
_buildCoinList(provider),
],
),
@@ -89,7 +83,43 @@ class _MarketPageState extends State<MarketPage>
);
}
/// 精選區域BTC + ETH 大卡片
// ============================================
// 搜索框
// ============================================
Widget _buildSearchBar(ColorScheme colorScheme) {
return GestureDetector(
onTap: () {
// TODO: 彈出搜索界面
},
child: Container(
height: 40,
decoration: BoxDecoration(
color: colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(AppRadius.md),
),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
child: Row(
children: [
Icon(LucideIcons.search,
size: 16, color: colorScheme.onSurfaceVariant),
const SizedBox(width: AppSpacing.sm),
Text(
'搜索幣種名稱或代碼',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
),
);
}
// ============================================
// 精選區域
// ============================================
Widget _buildFeaturedSection(MarketProvider provider) {
final featured = provider.featuredCoins;
if (featured.isEmpty) return const SizedBox.shrink();
@@ -103,7 +133,7 @@ class _MarketPageState extends State<MarketPage>
Expanded(child: _FeaturedCard(coin: btc))
else
const Expanded(child: SizedBox.shrink()),
const SizedBox(width: AppSpacing.sm + AppSpacing.xs),
const SizedBox(width: 10),
if (eth != null)
Expanded(child: _FeaturedCard(coin: eth))
else
@@ -112,27 +142,12 @@ 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) {
final colorScheme = Theme.of(context).colorScheme;
final coins = provider.otherCoins;
if (coins.isEmpty) {
@@ -145,46 +160,108 @@ class _MarketPageState extends State<MarketPage>
return Container(
decoration: BoxDecoration(
color: context.appColors.surfaceCard,
color: colorScheme.surface,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: context.appColors.ghostBorder,
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
),
child: ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: coins.length,
separatorBuilder: (_, __) => Divider(
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]),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
_buildListHeader(colorScheme),
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: coins.length,
separatorBuilder: (_, __) => Divider(
height: 1,
thickness: 1,
color: colorScheme.outlineVariant.withValues(alpha: 0.15),
indent: AppSpacing.md,
endIndent: AppSpacing.md,
),
itemBuilder: (context, index) => _CoinRow(coin: coins[index]),
),
],
),
);
}
/// 錯誤狀態
Widget _buildListHeader(ColorScheme colorScheme) {
return Padding(
padding: const 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: colorScheme.onSurfaceVariant,
),
),
),
SizedBox(
width: 90,
child: Text(
'最新價',
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: colorScheme.onSurfaceVariant,
),
),
),
const SizedBox(width: AppSpacing.sm),
SizedBox(
width: 72,
child: Text(
'漲跌幅',
textAlign: TextAlign.right,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: colorScheme.onSurfaceVariant,
),
),
),
],
),
);
}
// ============================================
// 錯誤狀態
// ============================================
Widget _buildErrorState(MarketProvider provider) {
final colorScheme = Theme.of(context).colorScheme;
return Center(
child: Padding(
padding: AppSpacing.pagePadding,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(LucideIcons.circleAlert, size: 48, color: context.colors.error),
Icon(LucideIcons.circleAlert,
size: 48, color: colorScheme.error),
const SizedBox(height: AppSpacing.md),
Text(
provider.error ?? '加載失敗',
style: TextStyle(color: context.colors.error),
style: TextStyle(color: colorScheme.error),
textAlign: TextAlign.center,
),
const SizedBox(height: AppSpacing.md),
ShadButton(
ElevatedButton(
onPressed: () => provider.refresh(),
child: const Text('重試'),
),
@@ -195,7 +272,10 @@ class _MarketPageState extends State<MarketPage>
}
}
/// 精選卡片BTC / ETH (130px 高度,含迷你柱狀圖)
// ============================================
// 精選卡片 — 簡約風格,用貨幣圖標代替柱狀圖
// ============================================
class _FeaturedCard extends StatelessWidget {
final Coin coin;
@@ -203,68 +283,80 @@ class _FeaturedCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final isUp = coin.isUp;
final changeColor =
isUp ? context.appColors.up : context.appColors.down;
final changeBgColor = isUp
? context.appColors.upBackground
: context.appColors.downBackground;
return GlassPanel(
final changeColor =
isUp ? colorScheme.tertiary : colorScheme.error;
final changeBgColor =
changeColor.withValues(alpha: 0.12);
return Container(
height: 120,
padding: const EdgeInsets.all(AppSpacing.md),
height: 130,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
),
child: Row(
children: [
// 第一行:幣種名稱 + 漲跌徽章
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// 左側:圖標 + 交易對
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
CoinIcon(symbol: coin.code, size: 32),
const SizedBox(height: 8),
Text(
'${coin.code}/USDT',
style: AppTextStyles.labelLarge(context), // 縮小文字
),
Container(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xs + 2, vertical: 2),
decoration: BoxDecoration(
color: changeBgColor,
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Text(
coin.formattedChange,
style: AppTextStyles.labelSmall(context).copyWith(
color: changeColor,
fontSize: 10, // 縮小文字
),
'${coin.code}/U',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
],
),
// 第二行:價格
Text(
'\$${_formatFeaturedPrice(coin)}',
style: AppTextStyles.headlineLarge(context).copyWith( // 縮小文字
fontWeight: FontWeight.bold,
),
),
// 第三行:幣種全名
Text(
coin.name,
style: AppTextStyles.bodySmall(context).copyWith( // 縮小文字
color: context.colors.onSurfaceVariant,
),
),
// 第四行:迷你柱狀圖
Expanded(
child: _MiniBarChart(isUp: isUp, seed: coin.code.hashCode),
const Spacer(),
// 右側:價格 + 漲跌
Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
_formatFeaturedPrice(coin),
style: AppTextStyles.numberLarge(context).copyWith(
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 4),
Container(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.xs + 2,
vertical: 2,
),
decoration: BoxDecoration(
color: changeBgColor,
borderRadius: BorderRadius.circular(4),
),
child: Text(
coin.formattedChange,
style: TextStyle(
color: changeColor,
fontSize: 10,
fontWeight: FontWeight.w600,
),
),
),
],
),
],
),
);
}
/// 精選卡片使用簡短價格格式(帶逗號)
String _formatFeaturedPrice(Coin coin) {
if (coin.price >= 1000) {
return _addCommas(coin.price.toStringAsFixed(2));
@@ -289,51 +381,10 @@ class _FeaturedCard extends StatelessWidget {
}
}
/// 迷你柱狀圖(模擬價格走勢)
class _MiniBarChart extends StatelessWidget {
final bool isUp;
final int seed;
// ============================================
// 幣種列表行
// ============================================
const _MiniBarChart({required this.isUp, required this.seed});
@override
Widget build(BuildContext context) {
final barColor = isUp
? context.appColors.up
: context.appColors.down;
// 生成隨機但確定的高度序列
final heights = _generateHeights();
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: heights.map((h) {
return Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 2), // 增加間距
child: Container(
height: h,
decoration: BoxDecoration(
color: barColor,
borderRadius: BorderRadius.circular(AppRadius.sm),
),
),
),
);
}).toList(),
);
}
List<double> _generateHeights() {
final random = Random(seed);
final base = 6.0; // 降低基礎高度
final range = 12.0; // 降低範圍
return List.generate(6, (_) => base + random.nextDouble() * range);
}
}
/// 幣種列表行
class _CoinRow extends StatelessWidget {
final Coin coin;
@@ -341,32 +392,37 @@ class _CoinRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final isUp = coin.isUp;
final changeColor =
isUp ? context.appColors.up : context.appColors.down;
final changeBgColor = isUp
? context.appColors.upBackground
: context.appColors.downBackground;
final changeColor = isUp ? colorScheme.tertiary : colorScheme.error;
final changeBgColor = changeColor.withValues(alpha: 0.12);
return GestureDetector(
onTap: () => _navigateToTrade(context),
behavior: HitTestBehavior.opaque,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: 14),
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.md,
vertical: 14,
),
child: Row(
children: [
// 頭像:圓形字母頭像
_CoinAvatar(letter: coin.displayIcon, code: coin.code),
CoinIcon(
symbol: coin.code,
size: 36,
isCircle: true,
),
const SizedBox(width: AppSpacing.sm + AppSpacing.xs),
// 幣種信息:交易對 + 全名
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'${coin.code}/USDT',
style: AppTextStyles.numberMedium(context),
'${coin.code}/U',
style: AppTextStyles.numberMedium(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 2),
Text(
@@ -376,30 +432,34 @@ class _CoinRow extends StatelessWidget {
],
),
),
// 右側:價格 + 漲跌標籤
Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'\$${coin.formattedPrice}',
style: AppTextStyles.numberMedium(context),
SizedBox(
width: 90,
child: Text(
coin.formattedPrice,
textAlign: TextAlign.right,
style: AppTextStyles.numberMedium(context),
),
),
const SizedBox(width: AppSpacing.sm),
SizedBox(
width: 72,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: AppSpacing.xs + 2,
vertical: 4,
),
const SizedBox(height: 2),
Container(
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xs + 2, vertical: 2),
decoration: BoxDecoration(
color: changeBgColor,
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Text(
coin.formattedChange,
style: AppTextStyles.labelMedium(context).copyWith(
color: changeColor,
),
decoration: BoxDecoration(
color: changeBgColor,
borderRadius: BorderRadius.circular(4),
),
child: Text(
coin.formattedChange,
textAlign: TextAlign.center,
style: AppTextStyles.labelSmall(context).copyWith(
color: changeColor,
),
),
],
),
),
],
),
@@ -413,48 +473,39 @@ 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 {
final IconData icon;
final String message;
final VoidCallback? onRetry;
const _EmptyState({required this.icon, required this.message, this.onRetry});
const _EmptyState({
required this.icon,
required this.message,
this.onRetry,
});
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return Center(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.xl),
child: Column(
children: [
Icon(icon, size: 48, color: context.colors.onSurfaceVariant),
Icon(icon, size: 48, color: colorScheme.onSurfaceVariant),
const SizedBox(height: AppSpacing.sm + AppSpacing.xs),
Text(
message,
style: TextStyle(color: context.colors.onSurfaceVariant),
style: TextStyle(color: colorScheme.onSurfaceVariant),
),
if (onRetry != null) ...[
const SizedBox(height: AppSpacing.md),
ShadButton(
ElevatedButton(
onPressed: onRetry,
child: const Text('重試'),
),

View File

@@ -1,34 +1,29 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/app_color_scheme.dart';
import '../../../../core/theme/app_spacing.dart';
import '../../../../core/theme/app_theme.dart';
/// 退出登錄按鈕
/// 退出登录按钮
class LogoutButton extends StatelessWidget {
final VoidCallback onLogout;
const LogoutButton({super.key, required this.onLogout});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onLogout,
child: Container(
width: double.infinity,
height: 48,
decoration: BoxDecoration(
color: AppColorScheme.down.withOpacity(0.05),
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: AppColorScheme.down.withOpacity(0.15),
final colorScheme = Theme.of(context).colorScheme;
return SizedBox(
width: double.infinity,
height: 48,
child: OutlinedButton(
onPressed: onLogout,
style: OutlinedButton.styleFrom(
foregroundColor: colorScheme.error,
side: BorderSide(color: colorScheme.error),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
),
child: Center(
child: Text(
'退出登錄',
style: AppTextStyles.headlineMedium(context).copyWith(
color: AppColorScheme.down,
),
),
child: const Text(
'退出登錄',
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
),
),
);

View File

@@ -1,16 +1,12 @@
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../../core/theme/app_color_scheme.dart';
import '../../../../core/theme/app_spacing.dart';
import '../../../../core/theme/app_theme_extension.dart';
import '../kyc_page.dart';
import '../welfare_center_page.dart';
import 'menu_group_container.dart';
import 'menu_row.dart';
import 'menu_trailing_widgets.dart';
/// 菜單分組1 - 福利中心 / 實名認證 / 安全置 / 消息通知
/// 菜单分组1 - 福利中心 / 实名认证 / 安全置 / 消息通知
class MenuGroup1 extends StatelessWidget {
final int kycStatus;
final void Function(String) onShowComingSoon;
@@ -23,13 +19,14 @@ class MenuGroup1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return MenuGroupContainer(
child: Column(
children: [
// 福利中心
MenuRow(
icon: LucideIcons.gift,
iconColor: AppColorScheme.darkSecondary, // gold
iconColor: colorScheme.secondary,
title: '福利中心',
onTap: () {
Navigator.push(
@@ -39,15 +36,14 @@ class MenuGroup1 extends StatelessWidget {
},
),
const Divider(height: 1),
// 實名認證
MenuRow(
icon: LucideIcons.shieldCheck,
iconColor: context.appColors.up,
iconColor: colorScheme.secondary,
title: '實名認證',
trailing: KycBadge(kycStatus: kycStatus),
onTap: () {
if (kycStatus == 2) {
showKycStatusDialog(context);
_showKycStatusDialog(context);
} else {
Navigator.push(
context,
@@ -57,18 +53,16 @@ class MenuGroup1 extends StatelessWidget {
},
),
const Divider(height: 1),
// 安全設置
MenuRow(
icon: LucideIcons.lock,
iconColor: context.colors.onSurfaceVariant,
iconColor: colorScheme.onSurfaceVariant,
title: '安全設置',
onTap: () => onShowComingSoon('安全設置'),
),
const Divider(height: 1),
// 消息通知
MenuRow(
icon: LucideIcons.bell,
iconColor: context.colors.onSurfaceVariant,
iconColor: colorScheme.onSurfaceVariant,
title: '消息通知',
trailing: const RedDotIndicator(),
onTap: () => onShowComingSoon('消息通知'),
@@ -79,23 +73,16 @@ class MenuGroup1 extends StatelessWidget {
}
}
/// 顯示 KYC 認證狀態對話框
void showKycStatusDialog(BuildContext context) {
showShadDialog(
void _showKycStatusDialog(BuildContext context) {
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
title: Row(
children: [
Icon(Icons.check_circle, color: AppColorScheme.up, size: 20),
SizedBox(width: AppSpacing.sm),
const Text('實名認證'),
],
),
description: const Text('您的實名認證已通過'),
builder: (ctx) => AlertDialog(
title: const Text('實名認證'),
content: const Text('您的實名認證已通過'),
actions: [
ShadButton(
child: const Text('確定'),
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('確定'),
),
],
),

View File

@@ -1,11 +1,6 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/app_spacing.dart';
import '../../../../core/theme/app_theme_extension.dart';
/// 菜單分組容器 - 統一的圓角卡片樣式
///
/// 所有菜單分組共享相同的容器樣式:背景色、圓角、邊框。
/// 通過 [child] 傳入菜單項 Column。
/// 菜单分组容器
class MenuGroupContainer extends StatelessWidget {
final Widget child;
@@ -13,14 +8,16 @@ class MenuGroupContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return Container(
width: double.infinity,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: context.appColors.surfaceCard,
borderRadius: BorderRadius.circular(AppRadius.lg),
color: colorScheme.surface,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: context.appColors.ghostBorder,
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
),
),
child: child,

View File

@@ -1,12 +1,8 @@
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../../core/theme/app_spacing.dart';
import '../../../../core/theme/app_theme.dart';
import '../../../../core/theme/app_theme_extension.dart';
/// 行菜單項:圖標 + 標題 + 尾部組件 (chevron)
///
/// 圖標顏色 (通常是使用主題色)
/// 行菜单项:图标 + 标题 + 尾部
class MenuRow extends StatelessWidget {
final IconData icon;
final Color iconColor;
@@ -25,38 +21,30 @@ class MenuRow extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
children: [
// Icon in 36x36 rounded container
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: context.appColors.surfaceCardHigh,
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Icon(icon, size: 18, color: iconColor),
),
),
Icon(icon, size: 18, color: iconColor),
const SizedBox(width: 10),
// Title
Expanded(
child: Text(
title,
style: AppTextStyles.headlineMedium(context),
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w500,
),
),
),
// Trailing
if (trailing != null)
if (trailing != null) trailing!,
if (trailing == null)
Icon(
LucideIcons.chevronRight,
size: 16,
color: context.colors.onSurfaceVariant,
color: colorScheme.onSurfaceVariant,
),
],
),

View File

@@ -1,178 +1,96 @@
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import '../../../../core/theme/app_color_scheme.dart';
import '../../../../core/theme/app_spacing.dart';
import '../../../../core/theme/app_theme.dart';
import '../../../../core/theme/app_theme_extension.dart';
import '../../../../providers/theme_provider.dart';
/// KYC 狀態徽章 (e.g. "已認證" green badge + chevron)
///
/// 根據 [kycStatus] 顯示不同狀態:
/// - 2: 已認證(綠色)
/// - 1: 審核中(橙色)
/// - 其他: 僅顯示 chevron
/// KYC 状态文字
class KycBadge extends StatelessWidget {
final int kycStatus;
const KycBadge({super.key, required this.kycStatus});
@override
Widget build(BuildContext context) {
final green = context.appColors.up;
final colorScheme = Theme.of(context).colorScheme;
if (kycStatus == 2) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
color: green.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Text(
'已認證',
style: AppTextStyles.labelMedium(context).copyWith(
color: green,
),
),
),
const SizedBox(width: 8),
Icon(
LucideIcons.chevronRight,
size: 16,
color: context.colors.onSurfaceVariant,
),
],
return Text(
'已認證',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.secondary,
fontWeight: FontWeight.w500,
),
);
}
if (kycStatus == 1) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
color: AppColorScheme.warning.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Text(
'審核中',
style: AppTextStyles.labelMedium(context).copyWith(
color: AppColorScheme.warning,
),
),
),
const SizedBox(width: 8),
Icon(
LucideIcons.chevronRight,
size: 16,
color: context.colors.onSurfaceVariant,
),
],
return Text(
'審核中',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.tertiary,
fontWeight: FontWeight.w500,
),
);
}
return Icon(
LucideIcons.chevronRight,
size: 16,
color: context.colors.onSurfaceVariant,
return Text(
'未認證',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
);
}
}
/// 紅點指示器 - 消息通知 + chevron
/// 红点指示器
class RedDotIndicator extends StatelessWidget {
const RedDotIndicator({super.key});
@override
Widget build(BuildContext context) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: AppColorScheme.down,
shape: BoxShape.circle,
),
),
const SizedBox(width: 8),
Icon(
LucideIcons.chevronRight,
size: 16,
color: context.colors.onSurfaceVariant,
),
],
final colorScheme = Theme.of(context).colorScheme;
return Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: colorScheme.error,
shape: BoxShape.circle,
),
);
}
}
/// 深色模式切
/// 深色模式切
class DarkModeRow extends StatelessWidget {
const DarkModeRow({super.key});
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final themeProvider = context.watch<ThemeProvider>();
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
children: [
// Icon in 36x36 rounded container
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: context.appColors.surfaceCardHigh,
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Icon(
LucideIcons.moon,
size: 18,
color: context.colors.onSurfaceVariant,
),
),
Icon(
LucideIcons.moon,
size: 18,
color: colorScheme.onSurfaceVariant,
),
const SizedBox(width: 10),
Expanded(
child: Text(
'深色模式',
style: AppTextStyles.headlineMedium(context),
),
),
// Toggle switch - matching .pen design (44x24 rounded pill)
GestureDetector(
onTap: () => themeProvider.toggleTheme(),
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
width: 44,
height: 24,
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: context.appColors.surfaceCardHigh,
borderRadius: BorderRadius.circular(12),
),
child: AnimatedAlign(
duration: const Duration(milliseconds: 200),
alignment:
themeProvider.isDarkMode
? Alignment.centerRight : Alignment.centerLeft,
child: Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: context.colors.onSurface,
shape: BoxShape.circle,
),
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w500,
),
),
),
),
Switch(
value: themeProvider.isDarkMode,
onChanged: (_) => themeProvider.toggleTheme(),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
],
),

View File

@@ -1,60 +1,59 @@
import 'package:flutter/material.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../../core/theme/app_spacing.dart';
import '../../../../core/theme/app_theme.dart';
import '../../../../core/theme/app_theme_extension.dart';
import 'avatar_circle.dart';
/// 用戶資料卡片 - 頭像 + 用戶名 + 徽章 + chevron
/// 用户资料卡片
class ProfileCard extends StatelessWidget {
final dynamic user;
const ProfileCard({super.key, required this.user});
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: context.appColors.surfaceCard,
borderRadius: BorderRadius.circular(AppRadius.lg),
color: colorScheme.surface,
borderRadius: BorderRadius.circular(14),
border: Border.all(
color: context.appColors.ghostBorder,
color: colorScheme.outlineVariant.withValues(alpha: 0.5),
),
),
child: Row(
children: [
// Avatar
AvatarCircle(
radius: 24,
fontSize: 18,
radius: 22,
fontSize: 16,
text: user?.avatarText,
),
const SizedBox(width: 12),
// Name + badge column
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
user?.username ?? '未登錄',
style: AppTextStyles.headlineLarge(context),
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
const SizedBox(height: 2),
Text(
'普通用戶',
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.normal,
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
),
],
),
),
// Chevron
Icon(
LucideIcons.chevronRight,
size: 16,
color: context.colors.onSurfaceVariant,
color: colorScheme.onSurfaceVariant,
),
],
),

View File

@@ -1,7 +1,7 @@
import 'dart:typed_data';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import 'package:image_picker/image_picker.dart';
import '../../../core/theme/app_color_scheme.dart';
@@ -431,9 +431,9 @@ class _KycPageState extends State<KycPage> {
if (!mounted) return;
if (response.success) {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: Row(
children: [
NeonIcon(
@@ -445,9 +445,9 @@ class _KycPageState extends State<KycPage> {
const Text('認證成功'),
],
),
description: const Text('您的實名認證已通過,現在可以進行提現操作'),
content: const Text('您的實名認證已通過,現在可以進行提現操作'),
actions: [
ShadButton(
TextButton(
child: const Text('確定'),
onPressed: () {
Navigator.of(ctx).pop();
@@ -458,13 +458,13 @@ class _KycPageState extends State<KycPage> {
),
);
} else {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: const Text('認證失敗'),
description: Text(response.message ?? '請稍後重試'),
content: Text(response.message ?? '請稍後重試'),
actions: [
ShadButton(
TextButton(
child: const Text('確定'),
onPressed: () => Navigator.of(ctx).pop(),
),
@@ -474,13 +474,13 @@ class _KycPageState extends State<KycPage> {
}
} catch (e) {
if (mounted) {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: const Text('認證失敗'),
description: Text(e.toString()),
content: Text(e.toString()),
actions: [
ShadButton(
TextButton(
child: const Text('確定'),
onPressed: () => Navigator.of(ctx).pop(),
),

View File

@@ -1,19 +1,16 @@
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 '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../providers/auth_provider.dart';
import '../auth/login_page.dart';
import 'components/about_dialog_helpers.dart';
import 'components/avatar_circle.dart';
import 'components/logout_button.dart';
import 'components/menu_group1.dart';
import 'components/menu_group2.dart';
import 'components/profile_card.dart';
/// 我的頁面 - 匹配 .pen 設計稿
/// 我的页面
class MinePage extends StatefulWidget {
const MinePage({super.key});
@@ -32,7 +29,7 @@ class _MinePageState extends State<MinePage>
final colorScheme = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: colorScheme.background,
backgroundColor: colorScheme.surface,
body: Consumer<AuthProvider>(
builder: (context, auth, _) {
return SingleChildScrollView(
@@ -55,12 +52,6 @@ class _MinePageState extends State<MinePage>
SizedBox(height: AppSpacing.lg),
LogoutButton(onLogout: () => _handleLogout(auth)),
SizedBox(height: AppSpacing.md),
Text(
'System Build v1.0.0',
style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant.withOpacity(0.5),
),
),
],
),
);
@@ -70,21 +61,15 @@ class _MinePageState extends State<MinePage>
}
void _showComingSoon(String feature) {
showShadDialog(
showDialog(
context: context,
builder: (context) => ShadDialog.alert(
title: Row(
children: [
Icon(Icons.construction, color: AppColorScheme.warning, size: 20),
SizedBox(width: AppSpacing.sm),
const Text('功能開發中'),
],
),
description: Text('$feature功能正在開發中,敬請期待~'),
builder: (ctx) => AlertDialog(
title: const Text('功能開發中'),
content: Text('$feature功能正在開發中,敬請期待'),
actions: [
ShadButton(
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('知道了'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
@@ -92,37 +77,29 @@ class _MinePageState extends State<MinePage>
}
void _showAboutDialog() {
final colorScheme = Theme.of(context).colorScheme;
showShadDialog(
showDialog(
context: context,
builder: (context) => ShadDialog(
builder: (ctx) => AlertDialog(
title: Row(
children: [
AvatarCircle(radius: 20, fontSize: 16),
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
AvatarCircle(radius: 16, fontSize: 12),
const SizedBox(width: 8),
const Text('模擬所'),
],
),
child: Column(
content: const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'虛擬貨幣模擬交易平臺',
style: TextStyle(color: colorScheme.onSurfaceVariant),
),
SizedBox(height: AppSpacing.md),
InfoRow(icon: Icons.code, text: '版本: 1.0.0'),
SizedBox(height: AppSpacing.sm),
InfoRow(
icon: Icons.favorite,
text: 'Built with Flutter & Material Design 3'),
Text('虛擬貨幣模擬交易平臺'),
SizedBox(height: 8),
Text('版本: 1.0.0'),
],
),
actions: [
ShadButton(
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('確定'),
onPressed: () => Navigator.of(context).pop(),
),
],
),
@@ -130,18 +107,19 @@ class _MinePageState extends State<MinePage>
}
void _handleLogout(AuthProvider auth) {
showShadDialog(
final colorScheme = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
title: const Text('確認退出'),
description: const Text('確定要退出登錄嗎?'),
builder: (ctx) => AlertDialog(
title: const Text('退出登錄'),
content: const Text('確定要退出登錄嗎?'),
actions: [
ShadButton.outline(
child: const Text('取消'),
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: Text('取消',
style: TextStyle(color: colorScheme.onSurfaceVariant)),
),
ShadButton.destructive(
child: const Text('退出'),
TextButton(
onPressed: () async {
Navigator.of(ctx).pop();
await auth.logout();
@@ -152,6 +130,8 @@ class _MinePageState extends State<MinePage>
);
}
},
child: Text('退出', style: TextStyle(color: colorScheme.error)),
),
],
),

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
@@ -145,9 +145,9 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
final goldAccent = context.appColors.accentPrimary;
return Scaffold(
backgroundColor: context.colors.surface,
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: AppBar(
backgroundColor: context.colors.surface,
backgroundColor: Theme.of(context).colorScheme.surface,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: false,
@@ -157,7 +157,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
style: AppTextStyles.headlineLarge(context),
),
leading: IconButton(
icon: Icon(LucideIcons.arrowLeft, color: context.colors.onSurface, size: 24),
icon: Icon(LucideIcons.arrowLeft, color: Theme.of(context).colorScheme.onSurface, size: 24),
onPressed: () => Navigator.of(context).pop(),
),
),
@@ -209,7 +209,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
// Header Row: gift icon + 標題
Row(
children: [
Icon(LucideIcons.gift, color: goldAccent, size: 24),
Icon(LucideIcons.userPlus, color: goldAccent, size: 24),
const SizedBox(width: 10),
Text(
'我的邀請碼',
@@ -242,7 +242,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
},
style: ElevatedButton.styleFrom(
backgroundColor: goldAccent,
foregroundColor: context.colors.onPrimary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
@@ -251,7 +251,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
),
child: Text(
'複製邀請碼',
style: AppTextStyles.headlineMedium(context).copyWith(color: context.colors.onPrimary),
style: AppTextStyles.headlineMedium(context).copyWith(color: Theme.of(context).colorScheme.onPrimary),
),
),
),
@@ -325,21 +325,21 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
'+100 USDT',
style: AppTextStyles.displayLarge(context).copyWith(
fontWeight: FontWeight.w800,
color: claimed ? context.colors.onSurfaceVariant : profitGreen,
color: claimed ? Theme.of(context).colorScheme.onSurfaceVariant : profitGreen,
),
),
const SizedBox(height: 8),
Text(
description,
style: AppTextStyles.bodyLarge(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 16),
_fullWidthButton(
text: buttonText,
backgroundColor: profitGreen,
foregroundColor: context.colors.onPrimary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
onPressed: canClaim ? () => _claimNewUserBonus() : null,
),
],
@@ -425,12 +425,12 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
child: Column(
children: [
Text(label, style: AppTextStyles.bodySmall(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
)),
const SizedBox(height: 2),
Text(value, style: AppTextStyles.headlineSmall(context).copyWith(
fontWeight: FontWeight.w700,
color: highlight ? context.appColors.up : context.colors.onSurface,
color: highlight ? context.appColors.up : Theme.of(context).colorScheme.onSurface,
)),
],
),
@@ -452,7 +452,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
Text(
'暫無推廣用戶',
style: AppTextStyles.bodyLarge(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
@@ -592,7 +592,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
label = '${threshold}';
} else {
bgColor = context.appColors.surfaceCardHigh;
textColor = context.colors.onSurfaceVariant;
textColor = Theme.of(context).colorScheme.onSurfaceVariant;
label = '${threshold}';
}
@@ -631,7 +631,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
child: Text(
username.isNotEmpty ? username[0].toUpperCase() : '?',
style: AppTextStyles.headlineSmall(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
@@ -719,7 +719,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
Text(
'已推廣 $indirectRefCount',
style: AppTextStyles.bodyMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
if (indirectClaimableCount > 0) ...[
@@ -773,7 +773,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
label = '50\u{1F381}';
} else {
bgColor = context.appColors.surfaceCardHigh;
textColor = context.colors.onSurfaceVariant;
textColor = Theme.of(context).colorScheme.onSurfaceVariant;
label = '50';
}
@@ -841,7 +841,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
child: Text(
'\u2022 $text',
style: AppTextStyles.bodyMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);

View File

@@ -1,9 +1,8 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_theme_extension.dart';
import '../../../core/storage/local_storage.dart';
/// 引導頁數據模型
@@ -93,7 +92,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: context.colors.surface,
backgroundColor: Theme.of(context).colorScheme.surface,
body: SafeArea(
child: Column(
children: [
@@ -111,7 +110,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
child: Text(
'跳過',
style: AppTextStyles.headlineMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
@@ -159,8 +158,8 @@ class _OnboardingPageState extends State<OnboardingPage> {
child: ElevatedButton(
onPressed: _nextPage,
style: ElevatedButton.styleFrom(
backgroundColor: context.colors.primary,
foregroundColor: context.colors.onPrimary,
backgroundColor: Theme.of(context).colorScheme.primary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
),
@@ -221,7 +220,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
return Icon(
item.icon ?? LucideIcons.image,
size: 72,
color: context.colors.onPrimary,
color: Theme.of(context).colorScheme.onPrimary,
);
},
),
@@ -229,7 +228,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
: Icon(
item.icon ?? LucideIcons.star,
size: 72,
color: context.colors.onPrimary,
color: Theme.of(context).colorScheme.onPrimary,
),
),
),
@@ -239,7 +238,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
item.title,
style: AppTextStyles.displaySmall(context).copyWith(
fontWeight: FontWeight.bold,
color: context.colors.onSurface,
color: Theme.of(context).colorScheme.onSurface,
letterSpacing: -0.5,
),
),
@@ -249,7 +248,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
item.description,
textAlign: TextAlign.center,
style: AppTextStyles.headlineMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
height: 1.6,
),
),
@@ -267,7 +266,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
width: isActive ? 24 : 8,
height: 8,
decoration: BoxDecoration(
color: isActive ? context.colors.primary : context.colors.outlineVariant,
color: isActive ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.outlineVariant,
borderRadius: BorderRadius.circular(AppRadius.sm),
),
);

View File

@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_color_scheme.dart';
@@ -84,7 +83,7 @@ class _FundOrderCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
final isDeposit = order.type == 1;
final statusColor = _getStatusColor(order.status, isDeposit);
@@ -93,9 +92,10 @@ class _FundOrderCard extends StatelessWidget {
? order.receivableAmount
: order.amount;
return ShadCard(
padding: AppSpacing.cardPadding,
child: Column(
return Card(
child: Padding(
padding: AppSpacing.cardPadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
@@ -126,7 +126,7 @@ class _FundOrderCard extends StatelessWidget {
if (order.fee != null) ...[
Row(
children: [
Text('手續費(10%): ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('手續費(10%): ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text('-${order.fee} USDT', style: AppTextStyles.bodyMedium(context)),
],
),
@@ -135,7 +135,7 @@ class _FundOrderCard extends StatelessWidget {
if (order.receivableAmount != null) ...[
Row(
children: [
Text('到賬金額: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('到賬金額: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text('${order.receivableAmount} USDT', style: AppTextStyles.bodyMedium(context).copyWith(fontWeight: FontWeight.w700)),
],
),
@@ -144,7 +144,7 @@ class _FundOrderCard extends StatelessWidget {
if (order.network != null) ...[
Row(
children: [
Text('提現網絡: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('提現網絡: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text(order.network!, style: AppTextStyles.bodyMedium(context)),
],
),
@@ -153,7 +153,7 @@ class _FundOrderCard extends StatelessWidget {
if (order.walletAddress != null) ...[
Row(
children: [
Text('提現地址: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('提現地址: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Expanded(
child: Text(
order.walletAddress!,
@@ -169,14 +169,14 @@ class _FundOrderCard extends StatelessWidget {
],
Row(
children: [
Text('訂單號: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('訂單號: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text(order.orderNo, style: AppTextStyles.bodyMedium(context)),
],
),
SizedBox(height: AppSpacing.xs),
Row(
children: [
Text('創建時間: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('創建時間: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text(
order.createTime?.toString() ?? '',
style: AppTextStyles.bodyMedium(context),
@@ -187,7 +187,7 @@ class _FundOrderCard extends StatelessWidget {
SizedBox(height: AppSpacing.xs),
Row(
children: [
Text('駁回原因: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('駁回原因: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Expanded(
child: Text(
order.rejectReason!,
@@ -202,14 +202,14 @@ class _FundOrderCard extends StatelessWidget {
Row(
children: [
Expanded(
child: ShadButton.outline(
child: OutlinedButton(
onPressed: () => _handleConfirmPay(context),
child: const Text('已打款'),
),
),
SizedBox(width: AppSpacing.sm),
Expanded(
child: ShadButton.outline(
child: OutlinedButton(
onPressed: () => _handleCancel(context),
child: const Text('取消訂單'),
),
@@ -219,6 +219,7 @@ class _FundOrderCard extends StatelessWidget {
],
],
),
),
);
}

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
@@ -16,7 +16,7 @@ class FundOrdersList extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
final orders = provider.fundOrders;
if (orders.isEmpty) {
@@ -33,7 +33,7 @@ class FundOrdersList extends StatelessWidget {
physics: const AlwaysScrollableScrollPhysics(),
padding: AppSpacing.pagePadding,
itemCount: orders.length,
separatorBuilder: (_, __) => Divider(color: theme.colorScheme.border, height: 1),
separatorBuilder: (_, __) => Divider(color: theme.colorScheme.outline, height: 1),
itemBuilder: (context, index) {
final order = orders[index];
return FundOrderCard(order: order);
@@ -52,7 +52,7 @@ class _EmptyState extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
return Center(
child: Padding(
@@ -60,9 +60,9 @@ class _EmptyState extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 48, color: theme.colorScheme.mutedForeground),
Icon(icon, size: 48, color: theme.colorScheme.onSurfaceVariant),
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
Text(message, style: theme.textTheme.muted),
Text(message, style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
],
),
),
@@ -155,13 +155,14 @@ class _FundOrderCardContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
final isDeposit = order.type == 1;
final statusColor = _getStatusColor(order.status, isDeposit);
return ShadCard(
padding: AppSpacing.cardPadding,
child: Column(
return Card(
child: Padding(
padding: AppSpacing.cardPadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
@@ -192,7 +193,7 @@ class _FundOrderCardContent extends StatelessWidget {
if (order.fee != null) ...[
Row(
children: [
Text('手續費(10%): ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('手續費(10%): ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text('-${order.fee} USDT', style: AppTextStyles.bodyMedium(context)),
],
),
@@ -201,7 +202,7 @@ class _FundOrderCardContent extends StatelessWidget {
if (order.receivableAmount != null) ...[
Row(
children: [
Text('到賬金額: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('到賬金額: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text('${order.receivableAmount} USDT', style: AppTextStyles.bodyMedium(context).copyWith(fontWeight: FontWeight.w700)),
],
),
@@ -210,7 +211,7 @@ class _FundOrderCardContent extends StatelessWidget {
if (order.network != null) ...[
Row(
children: [
Text('提現網絡: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('提現網絡: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text(order.network!, style: AppTextStyles.bodyMedium(context)),
],
),
@@ -219,7 +220,7 @@ class _FundOrderCardContent extends StatelessWidget {
if (order.walletAddress != null) ...[
Row(
children: [
Text('提現地址: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('提現地址: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Expanded(
child: Text(
order.walletAddress!,
@@ -234,14 +235,14 @@ class _FundOrderCardContent extends StatelessWidget {
],
Row(
children: [
Text('訂單號: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('訂單號: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text(order.orderNo, style: AppTextStyles.bodyMedium(context)),
],
),
SizedBox(height: AppSpacing.xs),
Row(
children: [
Text('創建時間: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.mutedForeground)),
Text('創建時間: ', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
Text(
order.createTime?.toString() ?? '',
style: AppTextStyles.bodyMedium(context),
@@ -250,6 +251,7 @@ class _FundOrderCardContent extends StatelessWidget {
),
],
),
),
);
}
}

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
@@ -35,10 +35,10 @@ class _OrdersPageState extends State<OrdersPage> with AutomaticKeepAliveClientMi
@override
Widget build(BuildContext context) {
super.build(context);
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
return Scaffold(
backgroundColor: theme.colorScheme.background,
backgroundColor: theme.colorScheme.surface,
body: Consumer<AssetProvider>(
builder: (context, provider, _) {
return RefreshIndicator(
@@ -83,12 +83,12 @@ class TabSelector extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
return Container(
padding: const EdgeInsets.all(AppSpacing.xs),
decoration: BoxDecoration(
color: theme.colorScheme.card,
color: theme.colorScheme.surfaceContainer,
borderRadius: AppRadius.radiusLg,
),
child: Row(
@@ -115,7 +115,7 @@ class TabSelector extends StatelessWidget {
color: context.colors.surface,
)
: AppTextStyles.labelLarge(context).copyWith(
color: theme.colorScheme.mutedForeground,
color: theme.colorScheme.onSurfaceVariant,
fontWeight: FontWeight.w400,
),
),
@@ -137,7 +137,7 @@ class TradeOrdersList extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
return Center(
child: Padding(
@@ -145,9 +145,9 @@ class TradeOrdersList extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(LucideIcons.receipt, size: 48, color: theme.colorScheme.mutedForeground),
Icon(LucideIcons.receipt, size: 48, color: theme.colorScheme.onSurfaceVariant),
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
Text('暫無交易記錄', style: theme.textTheme.muted),
Text('暫無交易記錄', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
],
),
),

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme_extension.dart';
@@ -126,7 +126,7 @@ class _TradePageState extends State<TradePage>
super.build(context);
return Scaffold(
backgroundColor: context.colors.background,
backgroundColor: Theme.of(context).colorScheme.surface,
body: Consumer2<MarketProvider, AssetProvider>(
builder: (context, market, asset, _) {
return SafeArea(
@@ -283,25 +283,25 @@ class _TradePageState extends State<TradePage>
}
void _showResultDialog(bool success, String title, String message) {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: Row(
children: [
NeonIcon(
icon: success ? Icons.check_circle : Icons.error,
color: success
? ctx.appColors.up
: ctx.colors.error,
: Theme.of(ctx).colorScheme.error,
size: 24,
),
SizedBox(width: AppSpacing.sm),
Text(title),
],
),
description: Text(message),
content: Text(message),
actions: [
ShadButton(
TextButton(
child: const Text('確定'),
onPressed: () => Navigator.of(ctx).pop(),
),