This commit is contained in:
sion
2026-04-07 01:05:05 +08:00
parent edad10ff06
commit 5ca1274607
83 changed files with 1561 additions and 1241 deletions

View File

@@ -8,7 +8,7 @@ import '../../../core/theme/app_spacing.dart';
import '../../../providers/asset_provider.dart';
import '../../../data/models/account_models.dart';
/// 划转页
/// 劃轉頁
class TransferPage extends StatefulWidget {
const TransferPage({super.key});
@@ -19,7 +19,7 @@ class TransferPage extends StatefulWidget {
class _TransferPageState extends State<TransferPage> {
final _amountController = TextEditingController();
final _focusNode = FocusNode();
int _direction = 1; // 1: 金→交易, 2: 交易→
int _direction = 1; // 1: 金→交易, 2: 交易→
bool _isLoading = false;
@override
@@ -38,26 +38,26 @@ class _TransferPageState extends State<TransferPage> {
}
// ============================================
// 数据访问
// 數據訪問
// ============================================
/// 获取资金账户余额(安全查)
/// 獲取資金賬戶餘額(安全查)
String get _fundBalance {
try {
final provider = context.read<AssetProvider>();
final balance = provider.fundAccount?.balance ?? provider.overview?.fundBalance ?? '0.00';
// 保返回的是有效的字格式
// 保返回的是有效的字格式
return _formatBalance(balance);
} catch (e) {
return '0.00';
}
}
/// 取交易账户 USDT 余额(安全查)
/// 取交易賬戶 USDT 餘額(安全查)
String get _tradeUsdtBalance {
try {
final provider = context.read<AssetProvider>();
// 先查列表是否
// 先查列表是否
if (provider.tradeAccounts.isEmpty) {
return '0.00';
}
@@ -81,32 +81,32 @@ class _TransferPageState extends State<TransferPage> {
}
}
/// 获取当前可用余额(根方向)
/// 獲取當前可用餘額(根方向)
String get _availableBalance => _direction == 1 ? _fundBalance : _tradeUsdtBalance;
/// 从账户
String get _fromLabel => _direction == 1 ? '资金账户' : '交易账户';
String get _toLabel => _direction == 1 ? '交易账户' : '资金账户';
/// 從賬戶
String get _fromLabel => _direction == 1 ? '資金賬戶' : '交易賬戶';
String get _toLabel => _direction == 1 ? '交易賬戶' : '資金賬戶';
String get _fromBalance => _direction == 1 ? _fundBalance : _tradeUsdtBalance;
String get _toBalance => _direction == 1 ? _tradeUsdtBalance : _fundBalance;
// ============================================
// 业务逻辑
// 業務邏輯
// ============================================
/// 执行划转
/// 執行劃轉
Future<void> _doTransfer() async {
final amount = _amountController.text;
final available = double.tryParse(_availableBalance) ?? 0;
final transferAmount = double.tryParse(amount) ?? 0;
if (transferAmount <= 0) {
_showSnackBar('请输入有效的划转金额');
_showSnackBar('請輸入有效的劃轉金額');
return;
}
if (transferAmount > available) {
_showSnackBar('余额不足');
_showSnackBar('餘額不足');
return;
}
@@ -121,10 +121,10 @@ class _TransferPageState extends State<TransferPage> {
if (mounted) {
if (response.success) {
_amountController.clear();
_showSnackBar('划转成功');
_showSnackBar('劃轉成功');
Navigator.of(context).pop(true);
} else {
_showSnackBar(response.message ?? '划转失败');
_showSnackBar(response.message ?? '劃轉失敗');
}
}
} finally {
@@ -140,14 +140,14 @@ class _TransferPageState extends State<TransferPage> {
);
}
/// 置快捷百分比金
/// 置快捷百分比金
void _setQuickAmount(double percent) {
final available = double.tryParse(_availableBalance) ?? 0;
final amount = available * percent;
_amountController.text = amount.toStringAsFixed(8).replaceAll(RegExp(r'\.?0+$'), '');
}
/// 切方向
/// 切方向
void _toggleDirection() {
setState(() {
_direction = _direction == 1 ? 2 : 1;
@@ -155,7 +155,7 @@ class _TransferPageState extends State<TransferPage> {
}
// ============================================
// 建 UI
// 建 UI
// ============================================
@override
@@ -173,7 +173,7 @@ class _TransferPageState extends State<TransferPage> {
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
'账户划转',
'賬戶劃轉',
style: AppTextStyles.headlineLarge(context),
),
centerTitle: true,
@@ -205,7 +205,7 @@ class _TransferPageState extends State<TransferPage> {
Widget _buildTransferDirectionCard() {
final colorScheme = Theme.of(context).colorScheme;
// 金色主感知: Dark #D4AF37 (primary), Light #F59E0B (secondary)
// 金色主感知: Dark #D4AF37 (primary), Light #F59E0B (secondary)
final goldAccent = colorScheme.brightness == Brightness.dark
? colorScheme.primary
: colorScheme.secondary;
@@ -225,7 +225,7 @@ class _TransferPageState extends State<TransferPage> {
key: 'src-$_direction',
beginOffset: const Offset(0, -1),
child: _buildAccountRow(
label: '',
label: '',
accountName: _fromLabel,
balance: _fromBalance,
),
@@ -239,7 +239,7 @@ class _TransferPageState extends State<TransferPage> {
height: 40,
margin: const EdgeInsets.symmetric(vertical: AppSpacing.md),
decoration: BoxDecoration(
// 椭圆形半透明金色背景
// 橢圓形半透明金色背景
color: goldAccent.withValues(alpha: 0.15),
shape: BoxShape.circle,
border: Border.all(
@@ -272,7 +272,7 @@ class _TransferPageState extends State<TransferPage> {
);
}
/// 一的 AnimatedSwitcher
/// 一的 AnimatedSwitcher
Widget _animatedSwitcher({
required String key,
required Offset beginOffset,
@@ -313,7 +313,7 @@ class _TransferPageState extends State<TransferPage> {
Row(
children: [
Icon(
label == '' ? LucideIcons.wallet : LucideIcons.trendingUp,
label == '' ? LucideIcons.wallet : LucideIcons.trendingUp,
size: 18,
color: colorScheme.onSurfaceVariant,
),
@@ -342,14 +342,14 @@ class _TransferPageState extends State<TransferPage> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Label row: "划转金额" + "全部划转"
// Label row: "劃轉金額" + "全部劃轉"
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('划转金额', style: AppTextStyles.headlineSmall(context).copyWith(color: colorScheme.onSurfaceVariant)),
Text('劃轉金額', style: AppTextStyles.headlineSmall(context).copyWith(color: colorScheme.onSurfaceVariant)),
GestureDetector(
onTap: () => _setQuickAmount(1.0),
child: Text('全部划转', style: AppTextStyles.labelLarge(context).copyWith(
child: Text('全部劃轉', style: AppTextStyles.labelLarge(context).copyWith(
color: colorScheme.secondary,
fontWeight: FontWeight.w600,
)),
@@ -461,7 +461,7 @@ class _TransferPageState extends State<TransferPage> {
const SizedBox(width: AppSpacing.sm),
Expanded(
child: Text(
'划转即时到账,无需手续费',
'劃轉即時到賬,無需手續費',
style: AppTextStyles.bodyMedium(context).copyWith(color: upColor),
),
),
@@ -472,7 +472,7 @@ class _TransferPageState extends State<TransferPage> {
Widget _buildConfirmButton() {
final colorScheme = Theme.of(context).colorScheme;
// 金色主感知: Dark #D4AF37 (primary), Light #F59E0B (secondary)
// 金色主感知: Dark #D4AF37 (primary), Light #F59E0B (secondary)
final goldAccent = colorScheme.brightness == Brightness.dark
? colorScheme.primary
: colorScheme.secondary;
@@ -498,7 +498,7 @@ class _TransferPageState extends State<TransferPage> {
),
)
: const Text(
'确认划转',
'確認劃轉',
style: TextStyle(
color: Colors.white,
fontSize: 16,