2026-04-04 21:19:29 +08:00
|
|
|
|
import 'dart:async';
|
2026-03-22 00:21:21 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2026-04-05 22:38:56 +08:00
|
|
|
|
import 'package:provider/provider.dart';
|
2026-03-23 15:37:59 +08:00
|
|
|
|
import '../../../core/theme/app_spacing.dart';
|
2026-04-05 23:37:27 +08:00
|
|
|
|
import '../../../core/theme/app_theme.dart';
|
2026-04-04 21:19:29 +08:00
|
|
|
|
import '../../../core/event/app_event_bus.dart';
|
2026-03-22 00:21:21 +08:00
|
|
|
|
import '../../../providers/asset_provider.dart';
|
2026-04-05 22:38:56 +08:00
|
|
|
|
import 'components/account_tab_switcher.dart';
|
|
|
|
|
|
import 'components/action_buttons_row.dart';
|
|
|
|
|
|
import 'components/asset_dialogs.dart';
|
|
|
|
|
|
import 'components/balance_card.dart';
|
|
|
|
|
|
import 'components/holdings_section.dart';
|
|
|
|
|
|
import 'components/records_link_row.dart';
|
2026-03-22 23:15:23 +08:00
|
|
|
|
import '../orders/fund_orders_page.dart';
|
2026-03-27 20:40:51 +08:00
|
|
|
|
import 'transfer_page.dart';
|
2026-03-22 00:21:21 +08:00
|
|
|
|
|
2026-04-05 22:24:04 +08:00
|
|
|
|
/// 资产页面 - Matching .pen design spec (CMcqs)
|
2026-03-22 00:21:21 +08:00
|
|
|
|
class AssetPage extends StatefulWidget {
|
|
|
|
|
|
const AssetPage({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
State<AssetPage> createState() => _AssetPageState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _AssetPageState extends State<AssetPage> with AutomaticKeepAliveClientMixin {
|
2026-03-25 09:23:24 +08:00
|
|
|
|
int _activeTab = 0;
|
2026-04-04 21:19:29 +08:00
|
|
|
|
StreamSubscription<AppEvent>? _eventSub;
|
2026-03-25 09:23:24 +08:00
|
|
|
|
|
2026-03-22 00:21:21 +08:00
|
|
|
|
@override
|
|
|
|
|
|
bool get wantKeepAlive => true;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
super.initState();
|
2026-04-04 21:19:29 +08:00
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
|
_loadData();
|
|
|
|
|
|
_listenEvents();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
_eventSub?.cancel();
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _listenEvents() {
|
|
|
|
|
|
final eventBus = context.read<AppEventBus>();
|
|
|
|
|
|
_eventSub = eventBus.on(AppEventType.assetChanged, (_) {
|
|
|
|
|
|
if (mounted) {
|
|
|
|
|
|
context.read<AssetProvider>().refreshAll(force: true);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-03-22 00:21:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _loadData() {
|
2026-03-24 16:58:31 +08:00
|
|
|
|
context.read<AssetProvider>().refreshAll(force: true);
|
2026-03-22 00:21:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
super.build(context);
|
2026-03-24 02:50:25 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
2026-03-22 04:50:19 +08:00
|
|
|
|
|
2026-03-22 00:21:21 +08:00
|
|
|
|
return Scaffold(
|
2026-03-24 02:50:25 +08:00
|
|
|
|
backgroundColor: colorScheme.background,
|
2026-03-22 00:21:21 +08:00
|
|
|
|
body: Consumer<AssetProvider>(
|
|
|
|
|
|
builder: (context, provider, _) {
|
|
|
|
|
|
return RefreshIndicator(
|
2026-03-23 00:43:19 +08:00
|
|
|
|
onRefresh: () => provider.refreshAll(force: true),
|
2026-03-24 02:50:25 +08:00
|
|
|
|
color: colorScheme.primary,
|
|
|
|
|
|
backgroundColor: colorScheme.surfaceContainerHighest,
|
2026-03-22 00:21:21 +08:00
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
2026-04-05 22:24:04 +08:00
|
|
|
|
padding: const EdgeInsets.fromLTRB(AppSpacing.md, AppSpacing.md + 8, AppSpacing.md, 32),
|
2026-03-22 00:21:21 +08:00
|
|
|
|
child: Column(
|
2026-04-05 22:24:04 +08:00
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2026-03-22 00:21:21 +08:00
|
|
|
|
children: [
|
2026-04-05 22:24:04 +08:00
|
|
|
|
// Page title: "资产" 22px bold — matching .pen titleFrame padding [16,0,8,0]
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(top: 16, bottom: 8),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
'资产',
|
2026-04-05 23:37:27 +08:00
|
|
|
|
style: AppTextStyles.displaySmall(context),
|
2026-04-05 22:24:04 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.sm),
|
|
|
|
|
|
// Account tab switcher — pill-style matching .pen UE6xC
|
2026-04-05 22:38:56 +08:00
|
|
|
|
AccountTabSwitcher(
|
2026-03-25 09:23:24 +08:00
|
|
|
|
selectedIndex: _activeTab,
|
|
|
|
|
|
onChanged: (index) => setState(() => _activeTab = index),
|
|
|
|
|
|
),
|
2026-04-05 22:24:04 +08:00
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
// Balance card — matching .pen 59637 (cornerRadius lg, stroke, padding 20, gap 12)
|
2026-04-05 22:38:56 +08:00
|
|
|
|
BalanceCard(
|
2026-04-05 22:24:04 +08:00
|
|
|
|
provider: provider,
|
|
|
|
|
|
activeTab: _activeTab,
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
// Action buttons row — matching .pen pIpHe (gap 12)
|
2026-04-05 22:38:56 +08:00
|
|
|
|
ActionButtonsRow(
|
|
|
|
|
|
onDeposit: () => showDepositDialog(context),
|
|
|
|
|
|
onWithdraw: () => showWithdrawDialog(context, provider.fundAccount?.balance),
|
2026-04-05 22:24:04 +08:00
|
|
|
|
onTransfer: () => _navigateToTransfer(context),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
// Records link row — matching .pen fLHtq (cornerRadius lg, padding [14,16], stroke)
|
2026-04-05 22:38:56 +08:00
|
|
|
|
RecordsLinkRow(
|
2026-04-05 22:24:04 +08:00
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(builder: (_) => const FundOrdersPage()),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
// Holdings section — matching .pen th9BG + 6X6tC
|
2026-04-05 22:38:56 +08:00
|
|
|
|
HoldingsSection(holdings: _activeTab == 1 ? provider.holdings : []),
|
2026-03-22 00:21:21 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-04-06 00:24:54 +08:00
|
|
|
|
);
|
|
|
|
|
|
},
|
2026-03-22 04:50:19 +08:00
|
|
|
|
),
|
2026-03-22 00:21:21 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-04-06 00:24:54 +08:00
|
|
|
|
|
|
|
|
|
|
void _navigateToTransfer(BuildContext context) async {
|
|
|
|
|
|
final result = await Navigator.push<bool>(
|
|
|
|
|
|
context,
|
|
|
|
|
|
MaterialPageRoute(builder: (_) => const TransferPage()),
|
|
|
|
|
|
);
|
|
|
|
|
|
if (result == true && context.mounted) {
|
|
|
|
|
|
context.read<AssetProvider>().refreshAll(force: true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-23 00:43:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-25 09:23:24 +08:00
|
|
|
|
/// 交易账户卡片 - Glass Panel 风格
|
|
|
|
|
|
class _TradeAccountCard extends StatelessWidget {
|
2026-03-23 00:43:19 +08:00
|
|
|
|
final List holdings;
|
2026-03-25 23:59:50 +08:00
|
|
|
|
final String? tradeBalance;
|
2026-03-23 00:43:19 +08:00
|
|
|
|
|
2026-03-25 23:59:50 +08:00
|
|
|
|
const _TradeAccountCard({required this.holdings, this.tradeBalance});
|
2026-03-23 00:43:19 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-24 02:50:25 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
2026-03-25 23:59:50 +08:00
|
|
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
|
|
|
|
|
|
|
|
// 计算总市值(所有持仓折算成USDT)
|
|
|
|
|
|
double totalValue = 0;
|
|
|
|
|
|
for (var h in holdings) {
|
|
|
|
|
|
final value = double.tryParse(h.currentValue?.toString() ?? '0') ?? 0;
|
|
|
|
|
|
totalValue += value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 对持仓进行排序:USDT 放在最上面
|
|
|
|
|
|
final sortedHoldings = List.from(holdings);
|
|
|
|
|
|
sortedHoldings.sort((a, b) {
|
|
|
|
|
|
final codeA = (a.coinCode ?? a['coinCode'] ?? '').toString().toUpperCase();
|
|
|
|
|
|
final codeB = (b.coinCode ?? b['coinCode'] ?? '').toString().toUpperCase();
|
|
|
|
|
|
if (codeA == 'USDT') return -1;
|
|
|
|
|
|
if (codeB == 'USDT') return 1;
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
2026-03-24 02:50:25 +08:00
|
|
|
|
|
2026-03-25 09:23:24 +08:00
|
|
|
|
return GlassPanel(
|
|
|
|
|
|
padding: AppSpacing.cardPadding,
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
2026-03-25 23:59:50 +08:00
|
|
|
|
// 标题行
|
|
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Container(
|
|
|
|
|
|
width: 36,
|
|
|
|
|
|
height: 36,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: colorScheme.primary.withOpacity(0.1),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
LucideIcons.trendingUp,
|
|
|
|
|
|
size: 18,
|
|
|
|
|
|
color: colorScheme.primary,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'交易账户',
|
|
|
|
|
|
style: GoogleFonts.spaceGrotesk(
|
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
color: colorScheme.onSurface,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
LucideIcons.chevronRight,
|
|
|
|
|
|
size: 14,
|
|
|
|
|
|
color: colorScheme.primary,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.md),
|
2026-03-26 01:35:51 +08:00
|
|
|
|
// 余额
|
2026-03-25 09:23:24 +08:00
|
|
|
|
Text(
|
2026-03-26 01:35:51 +08:00
|
|
|
|
'余额 (USDT)',
|
2026-03-25 23:59:50 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.xs),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
totalValue.toStringAsFixed(2),
|
2026-03-25 09:23:24 +08:00
|
|
|
|
style: GoogleFonts.spaceGrotesk(
|
2026-04-01 12:49:17 +08:00
|
|
|
|
fontSize: 20,
|
2026-03-25 09:23:24 +08:00
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
color: colorScheme.onSurface,
|
2026-03-22 00:21:21 +08:00
|
|
|
|
),
|
2026-03-24 18:00:07 +08:00
|
|
|
|
),
|
2026-03-25 23:59:50 +08:00
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
// 持仓列表标题
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'持仓列表',
|
|
|
|
|
|
style: GoogleFonts.spaceGrotesk(
|
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-25 09:23:24 +08:00
|
|
|
|
SizedBox(height: AppSpacing.md),
|
2026-03-25 23:59:50 +08:00
|
|
|
|
if (sortedHoldings.isEmpty)
|
2026-03-25 09:23:24 +08:00
|
|
|
|
const _EmptyState(icon: LucideIcons.wallet, message: '暂无持仓')
|
|
|
|
|
|
else
|
|
|
|
|
|
ListView.separated(
|
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
2026-03-25 23:59:50 +08:00
|
|
|
|
itemCount: sortedHoldings.length,
|
2026-03-25 09:23:24 +08:00
|
|
|
|
separatorBuilder: (_, __) => Container(
|
|
|
|
|
|
margin: EdgeInsets.only(left: 56),
|
|
|
|
|
|
height: 1,
|
|
|
|
|
|
color: AppColorScheme.glassPanelBorder,
|
|
|
|
|
|
),
|
2026-03-25 23:59:50 +08:00
|
|
|
|
itemBuilder: (context, index) => _HoldingItem(holding: sortedHoldings[index]),
|
2026-03-25 09:23:24 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
2026-03-22 00:21:21 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-03-23 00:43:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 空状态
|
|
|
|
|
|
class _EmptyState extends StatelessWidget {
|
|
|
|
|
|
final IconData icon;
|
|
|
|
|
|
final String message;
|
|
|
|
|
|
|
|
|
|
|
|
const _EmptyState({required this.icon, required this.message});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-24 02:50:25 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
|
|
2026-03-23 00:43:19 +08:00
|
|
|
|
return Center(
|
|
|
|
|
|
child: Padding(
|
2026-03-23 15:37:59 +08:00
|
|
|
|
padding: EdgeInsets.all(AppSpacing.xl),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
2026-03-24 02:16:19 +08:00
|
|
|
|
Icon(
|
|
|
|
|
|
icon,
|
|
|
|
|
|
size: 48,
|
2026-03-24 02:50:25 +08:00
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-03-23 15:37:59 +08:00
|
|
|
|
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
message,
|
2026-03-24 02:50:25 +08:00
|
|
|
|
style: TextStyle(color: colorScheme.onSurfaceVariant),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-25 09:23:24 +08:00
|
|
|
|
/// 持仓项
|
|
|
|
|
|
class _HoldingItem extends StatelessWidget {
|
2026-03-23 00:43:19 +08:00
|
|
|
|
final dynamic holding;
|
2026-03-22 00:21:21 +08:00
|
|
|
|
|
2026-03-25 09:23:24 +08:00
|
|
|
|
const _HoldingItem({required this.holding});
|
2026-03-23 00:43:19 +08:00
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-24 02:50:25 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
2026-03-24 08:58:18 +08:00
|
|
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
2026-03-24 02:50:25 +08:00
|
|
|
|
|
2026-03-22 04:50:19 +08:00
|
|
|
|
return Padding(
|
2026-03-25 09:23:24 +08:00
|
|
|
|
padding: EdgeInsets.symmetric(vertical: AppSpacing.sm),
|
2026-03-22 04:50:19 +08:00
|
|
|
|
child: Row(
|
|
|
|
|
|
children: [
|
2026-03-24 02:16:19 +08:00
|
|
|
|
Container(
|
2026-03-25 09:23:24 +08:00
|
|
|
|
width: 40,
|
|
|
|
|
|
height: 40,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2026-03-24 02:50:25 +08:00
|
|
|
|
color: colorScheme.primary.withOpacity(0.1),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Center(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
holding.coinCode.substring(0, 1),
|
|
|
|
|
|
style: TextStyle(
|
2026-03-24 02:50:25 +08:00
|
|
|
|
color: colorScheme.primary,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-22 04:50:19 +08:00
|
|
|
|
),
|
2026-03-22 00:21:21 +08:00
|
|
|
|
),
|
2026-03-25 09:23:24 +08:00
|
|
|
|
SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
2026-03-22 04:50:19 +08:00
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
2026-03-25 09:23:24 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
holding.coinCode,
|
|
|
|
|
|
style: GoogleFonts.spaceGrotesk(
|
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
color: colorScheme.onSurface,
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
Text(
|
2026-03-25 09:23:24 +08:00
|
|
|
|
'数量: ${holding.quantity}',
|
2026-03-24 02:16:19 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
2026-03-24 02:50:25 +08:00
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-22 04:50:19 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-03-22 00:21:21 +08:00
|
|
|
|
),
|
2026-03-22 04:50:19 +08:00
|
|
|
|
Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
|
children: [
|
2026-03-24 02:16:19 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
'${holding.currentValue} USDT',
|
2026-03-25 09:23:24 +08:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
2026-03-24 02:50:25 +08:00
|
|
|
|
color: colorScheme.onSurface,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-22 04:50:19 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
holding.formattedProfitRate,
|
|
|
|
|
|
style: TextStyle(
|
2026-03-24 08:58:18 +08:00
|
|
|
|
color: holding.isProfit ? AppColorScheme.getUpColor(isDark) : AppColorScheme.down,
|
2026-03-22 04:50:19 +08:00
|
|
|
|
fontSize: 12,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
fontWeight: FontWeight.w600,
|
2026-03-22 04:50:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
2026-03-22 00:21:21 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-03-23 00:43:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-24 02:16:19 +08:00
|
|
|
|
// ============================================
|
|
|
|
|
|
// Dialogs - Glass Panel 风格
|
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
2026-03-23 00:43:19 +08:00
|
|
|
|
void _showDepositDialog(BuildContext context) {
|
|
|
|
|
|
final amountController = TextEditingController();
|
|
|
|
|
|
final formKey = GlobalKey<ShadFormState>();
|
2026-03-24 02:55:55 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
2026-03-23 00:43:19 +08:00
|
|
|
|
|
|
|
|
|
|
showShadDialog(
|
|
|
|
|
|
context: context,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
builder: (ctx) => Dialog(
|
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
|
child: GlassPanel(
|
2026-03-30 03:31:42 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
padding: EdgeInsets.all(AppSpacing.lg),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
2026-03-25 09:23:24 +08:00
|
|
|
|
'Deposit (充值)',
|
2026-03-24 02:16:19 +08:00
|
|
|
|
style: GoogleFonts.spaceGrotesk(
|
2026-04-01 12:49:17 +08:00
|
|
|
|
fontSize: 16,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
fontWeight: FontWeight.bold,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurface,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.xs),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'Asset: USDT',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
letterSpacing: 0.1,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.all(AppSpacing.sm),
|
|
|
|
|
|
decoration: BoxDecoration(
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.surfaceContainerHigh,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
LucideIcons.wallet,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.secondary,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
ShadForm(
|
|
|
|
|
|
key: formKey,
|
|
|
|
|
|
child: ShadInputFormField(
|
|
|
|
|
|
id: 'amount',
|
|
|
|
|
|
controller: amountController,
|
2026-03-24 02:21:25 +08:00
|
|
|
|
label: const Text('充值金额'),
|
2026-04-04 21:19:29 +08:00
|
|
|
|
placeholder: const Text('最低 1000 USDT'),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
2026-04-04 21:19:29 +08:00
|
|
|
|
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;
|
|
|
|
|
|
},
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: NeonButton(
|
|
|
|
|
|
text: '取消',
|
|
|
|
|
|
type: NeonButtonType.outline,
|
|
|
|
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
|
|
|
|
height: 48,
|
|
|
|
|
|
showGlow: false,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: NeonButton(
|
|
|
|
|
|
text: '下一步',
|
|
|
|
|
|
type: NeonButtonType.primary,
|
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
|
if (formKey.currentState!.saveAndValidate()) {
|
|
|
|
|
|
Navigator.of(ctx).pop();
|
|
|
|
|
|
final response = await context.read<AssetProvider>().deposit(
|
|
|
|
|
|
amount: amountController.text,
|
|
|
|
|
|
);
|
|
|
|
|
|
if (context.mounted) {
|
|
|
|
|
|
if (response.success && response.data != null) {
|
|
|
|
|
|
_showDepositResultDialog(context, response.data!);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
_showResultDialog(context, '申请失败', response.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
height: 48,
|
|
|
|
|
|
showGlow: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-03-22 00:21:21 +08:00
|
|
|
|
|
2026-03-23 00:43:19 +08:00
|
|
|
|
void _showDepositResultDialog(BuildContext context, Map<String, dynamic> data) {
|
|
|
|
|
|
final orderNo = data['orderNo'] as String? ?? '';
|
|
|
|
|
|
final amount = data['amount']?.toString() ?? '0.00';
|
|
|
|
|
|
final walletAddress = data['walletAddress'] as String? ?? '';
|
|
|
|
|
|
final walletNetwork = data['walletNetwork'] as String? ?? 'TRC20';
|
2026-03-24 02:55:55 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
2026-03-24 08:58:18 +08:00
|
|
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
2026-03-22 23:15:23 +08:00
|
|
|
|
|
2026-03-23 00:43:19 +08:00
|
|
|
|
showShadDialog(
|
|
|
|
|
|
context: context,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
builder: (ctx) => Dialog(
|
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
|
child: GlassPanel(
|
2026-03-30 03:31:42 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
padding: EdgeInsets.all(AppSpacing.lg),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
NeonIcon(
|
|
|
|
|
|
icon: Icons.check_circle,
|
2026-03-24 08:58:18 +08:00
|
|
|
|
color: AppColorScheme.getUpColor(isDark),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
size: 24,
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'充值申请成功',
|
|
|
|
|
|
style: GoogleFonts.spaceGrotesk(
|
2026-04-01 12:49:17 +08:00
|
|
|
|
fontSize: 16,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
fontWeight: FontWeight.bold,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurface,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
_InfoRow(label: '订单号', value: orderNo),
|
|
|
|
|
|
SizedBox(height: AppSpacing.sm),
|
|
|
|
|
|
_InfoRow(label: '充值金额', value: '$amount USDT', isBold: true),
|
|
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'请向以下地址转账:',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.sm),
|
|
|
|
|
|
_WalletAddressCard(address: walletAddress, network: walletNetwork),
|
|
|
|
|
|
SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.all(AppSpacing.sm),
|
|
|
|
|
|
decoration: BoxDecoration(
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: AppColorScheme.warning.withOpacity(0.1),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
border: Border.all(
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: AppColorScheme.warning.withOpacity(0.2),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Icon(Icons.info_outline, size: 16, color: AppColorScheme.warning),
|
|
|
|
|
|
SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
'转账完成后请点击"已打款"按钮确认',
|
|
|
|
|
|
style: TextStyle(fontSize: 12, color: AppColorScheme.warning),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: NeonButton(
|
|
|
|
|
|
text: '稍后确认',
|
|
|
|
|
|
type: NeonButtonType.outline,
|
|
|
|
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
|
|
|
|
height: 44,
|
|
|
|
|
|
showGlow: false,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: NeonButton(
|
|
|
|
|
|
text: '已打款',
|
|
|
|
|
|
type: NeonButtonType.primary,
|
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
|
Navigator.of(ctx).pop();
|
|
|
|
|
|
final response = await context.read<AssetProvider>().confirmPay(orderNo);
|
|
|
|
|
|
if (context.mounted) {
|
|
|
|
|
|
_showResultDialog(
|
|
|
|
|
|
context,
|
|
|
|
|
|
response.success ? '确认成功' : '确认失败',
|
|
|
|
|
|
response.success ? '请等待管理员审核' : response.message,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
height: 44,
|
|
|
|
|
|
showGlow: true,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-24 02:16:19 +08:00
|
|
|
|
class _InfoRow extends StatelessWidget {
|
|
|
|
|
|
final String label;
|
|
|
|
|
|
final String value;
|
|
|
|
|
|
final bool isBold;
|
|
|
|
|
|
|
|
|
|
|
|
const _InfoRow({required this.label, required this.value, this.isBold = false});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-24 02:55:55 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
|
|
2026-03-24 02:16:19 +08:00
|
|
|
|
return Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
label,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
value,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: isBold ? FontWeight.bold : FontWeight.normal,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurface,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-23 00:43:19 +08:00
|
|
|
|
class _WalletAddressCard extends StatelessWidget {
|
|
|
|
|
|
final String address;
|
|
|
|
|
|
final String network;
|
|
|
|
|
|
|
|
|
|
|
|
const _WalletAddressCard({required this.address, required this.network});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-03-24 02:55:55 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
|
|
2026-03-23 00:43:19 +08:00
|
|
|
|
return Container(
|
2026-03-24 02:16:19 +08:00
|
|
|
|
padding: EdgeInsets.all(AppSpacing.md),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.surfaceContainerHigh,
|
2026-03-23 15:37:59 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
border: Border.all(
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.outlineVariant.withOpacity(0.3),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(
|
2026-03-24 02:16:19 +08:00
|
|
|
|
child: Text(
|
|
|
|
|
|
address,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
style: TextStyle(
|
2026-03-24 02:16:19 +08:00
|
|
|
|
fontFamily: 'monospace',
|
|
|
|
|
|
fontSize: 12,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurface,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
GestureDetector(
|
|
|
|
|
|
onTap: () {
|
2026-03-23 00:43:19 +08:00
|
|
|
|
Clipboard.setData(ClipboardData(text: address));
|
2026-03-30 11:26:47 +08:00
|
|
|
|
ToastUtils.show('地址已复制到剪贴板');
|
2026-03-23 00:43:19 +08:00
|
|
|
|
},
|
2026-03-24 02:16:19 +08:00
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: EdgeInsets.all(AppSpacing.xs),
|
|
|
|
|
|
decoration: BoxDecoration(
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.primary.withOpacity(0.1),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
LucideIcons.copy,
|
|
|
|
|
|
size: 16,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.primary,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
SizedBox(height: AppSpacing.sm),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'网络: $network',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 11,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _showWithdrawDialog(BuildContext context, String? balance) {
|
|
|
|
|
|
final amountController = TextEditingController();
|
|
|
|
|
|
final addressController = TextEditingController();
|
|
|
|
|
|
final contactController = TextEditingController();
|
|
|
|
|
|
final formKey = GlobalKey<ShadFormState>();
|
2026-04-05 21:01:42 +08:00
|
|
|
|
final feeNotifier = ValueNotifier<String>('提现将扣除10%手续费');
|
2026-03-24 02:55:55 +08:00
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
2026-04-05 23:28:38 +08:00
|
|
|
|
final networksNotifier = ValueNotifier<List<String>>([]);
|
|
|
|
|
|
final selectedNetworkNotifier = ValueNotifier<String?>(null);
|
2026-03-23 00:43:19 +08:00
|
|
|
|
|
2026-04-05 21:01:42 +08:00
|
|
|
|
amountController.addListener(() {
|
|
|
|
|
|
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 | 应付款: ${receivable.toStringAsFixed(2)} USDT';
|
|
|
|
|
|
} else {
|
|
|
|
|
|
feeNotifier.value = '提现将扣除10%手续费';
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-04-05 23:28:38 +08:00
|
|
|
|
// 获取网络列表
|
|
|
|
|
|
context.read<AssetProvider>().getWalletNetworks().then((list) {
|
|
|
|
|
|
networksNotifier.value = list;
|
|
|
|
|
|
if (list.isNotEmpty) {
|
|
|
|
|
|
selectedNetworkNotifier.value = list.first;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-03-23 00:43:19 +08:00
|
|
|
|
showShadDialog(
|
|
|
|
|
|
context: context,
|
2026-04-05 23:28:38 +08:00
|
|
|
|
builder: (ctx) => StatefulBuilder(
|
|
|
|
|
|
builder: (ctx, setState) => Dialog(
|
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
|
child: GlassPanel(
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
|
|
|
|
|
padding: EdgeInsets.all(AppSpacing.lg),
|
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.all(AppSpacing.sm),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: colorScheme.primary.withOpacity(0.1),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Icon(
|
|
|
|
|
|
LucideIcons.wallet,
|
|
|
|
|
|
color: colorScheme.primary,
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'提现 (Withdraw)',
|
|
|
|
|
|
style: GoogleFonts.spaceGrotesk(
|
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
color: colorScheme.onSurface,
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
],
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(height: AppSpacing.xs),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'Securely transfer your assets to an external wallet address.',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
),
|
|
|
|
|
|
if (balance != null) ...[
|
|
|
|
|
|
SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
|
horizontal: AppSpacing.md,
|
|
|
|
|
|
vertical: AppSpacing.sm,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: AppColorScheme.up.withOpacity(0.1),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.full),
|
|
|
|
|
|
border: Border.all(
|
|
|
|
|
|
color: AppColorScheme.up.withOpacity(0.2),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'可用余额: ',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
|
letterSpacing: 0.1,
|
|
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
Text(
|
|
|
|
|
|
'$balance USDT',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
|
color: AppColorScheme.up,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
ShadForm(
|
|
|
|
|
|
key: formKey,
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
ShadInputFormField(
|
|
|
|
|
|
id: 'amount',
|
|
|
|
|
|
controller: amountController,
|
|
|
|
|
|
label: const Text('提现金额'),
|
|
|
|
|
|
placeholder: const Text('请输入提现金额(USDT)'),
|
|
|
|
|
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
|
|
|
|
|
validator: Validators.amount,
|
2026-04-05 21:01:42 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(height: AppSpacing.xs),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
|
horizontal: AppSpacing.md,
|
|
|
|
|
|
vertical: AppSpacing.sm,
|
|
|
|
|
|
),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Colors.orange.withOpacity(0.1),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
|
|
|
|
|
border: Border.all(color: Colors.orange.withOpacity(0.3)),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Icon(Icons.info_outline, size: 14, color: Colors.orange),
|
|
|
|
|
|
SizedBox(width: AppSpacing.xs),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: ValueListenableBuilder<String>(
|
|
|
|
|
|
valueListenable: feeNotifier,
|
|
|
|
|
|
builder: (_, text, __) => Text(
|
|
|
|
|
|
text,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
color: Colors.orange.shade800,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-04-05 21:01:42 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
// 提现网络选择
|
|
|
|
|
|
ValueListenableBuilder<List<String>>(
|
|
|
|
|
|
valueListenable: networksNotifier,
|
|
|
|
|
|
builder: (_, networks, __) {
|
|
|
|
|
|
if (networks.isEmpty) return const SizedBox.shrink();
|
|
|
|
|
|
return Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'提现网络',
|
2026-04-05 21:01:42 +08:00
|
|
|
|
style: TextStyle(
|
2026-04-05 23:28:38 +08:00
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
color: colorScheme.onSurfaceVariant,
|
2026-04-05 21:01:42 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
child: ValueListenableBuilder<String?>(
|
|
|
|
|
|
valueListenable: selectedNetworkNotifier,
|
|
|
|
|
|
builder: (_, selected, __) => ShadSelect<String>(
|
|
|
|
|
|
initialValue: selected ?? networks.first,
|
|
|
|
|
|
placeholder: const Text('选择提现网络'),
|
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
|
selectedNetworkNotifier.value = value;
|
|
|
|
|
|
},
|
|
|
|
|
|
selectedOptionBuilder: (context, value) => Text(value),
|
|
|
|
|
|
options: networks.map((network) => ShadOption<String>(
|
|
|
|
|
|
value: network,
|
|
|
|
|
|
child: Text(network),
|
|
|
|
|
|
)),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
2026-04-05 21:01:42 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
ShadInputFormField(
|
|
|
|
|
|
id: 'address',
|
|
|
|
|
|
controller: addressController,
|
|
|
|
|
|
label: const Text('目标地址'),
|
|
|
|
|
|
placeholder: const Text('请输入提现地址'),
|
|
|
|
|
|
validator: (v) => Validators.required(v, '提现地址'),
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
ShadInputFormField(
|
|
|
|
|
|
id: 'contact',
|
|
|
|
|
|
controller: contactController,
|
|
|
|
|
|
label: const Text('联系方式(可选)'),
|
|
|
|
|
|
placeholder: const Text('联系方式'),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(height: AppSpacing.lg),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: NeonButton(
|
|
|
|
|
|
text: '取消',
|
|
|
|
|
|
type: NeonButtonType.outline,
|
|
|
|
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
|
|
|
|
height: 44,
|
|
|
|
|
|
showGlow: false,
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: NeonButton(
|
|
|
|
|
|
text: '提交',
|
|
|
|
|
|
type: NeonButtonType.primary,
|
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
|
if (formKey.currentState!.saveAndValidate()) {
|
|
|
|
|
|
Navigator.of(ctx).pop();
|
|
|
|
|
|
final response = await context.read<AssetProvider>().withdraw(
|
|
|
|
|
|
amount: amountController.text,
|
|
|
|
|
|
withdrawAddress: addressController.text,
|
|
|
|
|
|
network: selectedNetworkNotifier.value,
|
|
|
|
|
|
withdrawContact: contactController.text.isNotEmpty
|
|
|
|
|
|
? contactController.text
|
|
|
|
|
|
: null,
|
2026-03-24 02:16:19 +08:00
|
|
|
|
);
|
2026-04-05 23:28:38 +08:00
|
|
|
|
if (context.mounted) {
|
|
|
|
|
|
_showResultDialog(
|
|
|
|
|
|
context,
|
|
|
|
|
|
response.success ? '申请成功' : '申请失败',
|
|
|
|
|
|
response.success ? '请等待管理员审批' : response.message,
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
2026-03-24 02:16:19 +08:00
|
|
|
|
}
|
2026-04-05 23:28:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
height: 44,
|
|
|
|
|
|
showGlow: true,
|
|
|
|
|
|
),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
SizedBox(height: AppSpacing.md),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Icon(
|
|
|
|
|
|
Icons.verified_user,
|
|
|
|
|
|
size: 12,
|
2026-03-24 02:55:55 +08:00
|
|
|
|
color: colorScheme.onSurfaceVariant.withOpacity(0.5),
|
2026-03-24 02:16:19 +08:00
|
|
|
|
),
|
2026-04-05 23:28:38 +08:00
|
|
|
|
SizedBox(width: AppSpacing.xs),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'End-to-End Encrypted Transaction',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
fontSize: 10,
|
|
|
|
|
|
letterSpacing: 0.1,
|
|
|
|
|
|
color: colorScheme.onSurfaceVariant.withOpacity(0.5),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-03-22 23:15:23 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-03-23 00:43:19 +08:00
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|