111
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
@@ -7,6 +8,7 @@ import 'package:google_fonts/google_fonts.dart';
|
||||
import '../../../core/theme/app_color_scheme.dart';
|
||||
import '../../../core/theme/app_spacing.dart';
|
||||
import '../../../core/utils/toast_utils.dart';
|
||||
import '../../../core/event/app_event_bus.dart';
|
||||
import '../../../providers/asset_provider.dart';
|
||||
import '../../../providers/auth_provider.dart';
|
||||
import '../../shared/ui_constants.dart';
|
||||
@@ -14,7 +16,6 @@ import '../../components/glass_panel.dart';
|
||||
import '../../components/neon_glow.dart';
|
||||
import '../orders/fund_orders_page.dart';
|
||||
import 'transfer_page.dart';
|
||||
import '../mine/kyc_page.dart';
|
||||
|
||||
/// 资产页面 - Material Design 3 风格
|
||||
class AssetPage extends StatefulWidget {
|
||||
@@ -26,6 +27,7 @@ class AssetPage extends StatefulWidget {
|
||||
|
||||
class _AssetPageState extends State<AssetPage> with AutomaticKeepAliveClientMixin {
|
||||
int _activeTab = 0;
|
||||
StreamSubscription<AppEvent>? _eventSub;
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
@@ -33,12 +35,28 @@ class _AssetPageState extends State<AssetPage> with AutomaticKeepAliveClientMixi
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 强制刷新数据,确保加载最新数据
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _loadData());
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
// 强制刷新,不使用缓存
|
||||
context.read<AssetProvider>().refreshAll(force: true);
|
||||
}
|
||||
|
||||
@@ -628,9 +646,15 @@ void _showDepositDialog(BuildContext context) {
|
||||
id: 'amount',
|
||||
controller: amountController,
|
||||
label: const Text('充值金额'),
|
||||
placeholder: const Text('0.00'),
|
||||
placeholder: const Text('最低 1000 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 '请输入有效金额';
|
||||
if (n < 1000) return '单笔最低充值1000 USDT';
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppSpacing.lg),
|
||||
@@ -896,13 +920,6 @@ class _WalletAddressCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
void _showWithdrawDialog(BuildContext context, String? balance) {
|
||||
// KYC校验:未完成实名认证则引导去认证
|
||||
final auth = context.read<AuthProvider>();
|
||||
if (auth.user?.kycStatus != 2) {
|
||||
_showKycRequiredDialog(context);
|
||||
return;
|
||||
}
|
||||
|
||||
final amountController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final contactController = TextEditingController();
|
||||
@@ -1145,84 +1162,3 @@ void _showResultDialog(BuildContext context, String title, String? message) {
|
||||
);
|
||||
}
|
||||
|
||||
void _showKycRequiredDialog(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (ctx) => Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
child: GlassPanel(
|
||||
borderRadius: BorderRadius.circular(AppRadius.lg),
|
||||
padding: EdgeInsets.all(AppSpacing.lg),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(AppSpacing.md),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColorScheme.warning.withOpacity(0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
LucideIcons.shieldAlert,
|
||||
color: AppColorScheme.warning,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppSpacing.md),
|
||||
Text(
|
||||
'需要实名认证',
|
||||
style: GoogleFonts.spaceGrotesk(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
Text(
|
||||
'提现前请先完成实名认证,保障账户安全',
|
||||
style: TextStyle(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
fontSize: 14,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
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: () {
|
||||
Navigator.of(ctx).pop();
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const KycPage(returnToWithdraw: true),
|
||||
),
|
||||
);
|
||||
},
|
||||
height: 44,
|
||||
showGlow: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user