- 所有 AlertDialog 替换为 ModernDialog - ConfirmDialog/AssetDialogs 去掉 GlassPanel,统一 surfaceContainer 背景 - 按钮统一 FilledButton + TextButton - 修复 import 路径
122 lines
3.4 KiB
Dart
122 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../../../core/theme/app_theme.dart';
|
|
import '../../../core/theme/app_spacing.dart';
|
|
import '../../../providers/auth_provider.dart';
|
|
import '../../shared/modern_dialog.dart';
|
|
import '../auth/login_page.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';
|
|
|
|
/// 我的页面
|
|
class MinePage extends StatefulWidget {
|
|
const MinePage({super.key});
|
|
|
|
@override
|
|
State<MinePage> createState() => _MinePageState();
|
|
}
|
|
|
|
class _MinePageState extends State<MinePage>
|
|
with AutomaticKeepAliveClientMixin {
|
|
@override
|
|
bool get wantKeepAlive => true;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
super.build(context);
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return Scaffold(
|
|
backgroundColor: colorScheme.surface,
|
|
body: Consumer<AuthProvider>(
|
|
builder: (context, auth, _) {
|
|
return SingleChildScrollView(
|
|
padding: EdgeInsets.fromLTRB(
|
|
AppSpacing.md,
|
|
AppSpacing.md,
|
|
AppSpacing.md,
|
|
AppSpacing.xl + AppSpacing.md,
|
|
),
|
|
child: Column(
|
|
children: [
|
|
ProfileCard(user: auth.user),
|
|
SizedBox(height: AppSpacing.sm),
|
|
MenuGroup1(
|
|
kycStatus: auth.user?.kycStatus ?? 0,
|
|
onShowComingSoon: _showComingSoon,
|
|
),
|
|
SizedBox(height: AppSpacing.sm),
|
|
MenuGroup2(onShowAbout: _showAboutDialog),
|
|
SizedBox(height: AppSpacing.lg),
|
|
LogoutButton(onLogout: () => _handleLogout(auth)),
|
|
SizedBox(height: AppSpacing.md),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
void _showComingSoon(String feature) {
|
|
ModernDialog.info(
|
|
context: context,
|
|
title: '功能開發中',
|
|
description: '$feature功能正在開發中,敬請期待',
|
|
);
|
|
}
|
|
|
|
void _showAboutDialog() {
|
|
ModernDialog.show(
|
|
context: context,
|
|
titleWidget: Row(
|
|
children: [
|
|
AvatarCircle(radius: 16, fontSize: 12),
|
|
const SizedBox(width: 8),
|
|
const Text('模擬所'),
|
|
],
|
|
),
|
|
content: const Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('虛擬貨幣模擬交易平臺'),
|
|
SizedBox(height: 8),
|
|
Text('版本: 1.0.0'),
|
|
],
|
|
),
|
|
actions: [
|
|
ModernDialogAction(label: '確定', isPrimary: true),
|
|
],
|
|
);
|
|
}
|
|
|
|
void _handleLogout(AuthProvider auth) {
|
|
ModernDialog.show(
|
|
context: context,
|
|
title: '退出登錄',
|
|
description: '確定要退出登錄嗎?',
|
|
actions: [
|
|
ModernDialogAction(label: '取消'),
|
|
ModernDialogAction(
|
|
label: '退出',
|
|
isPrimary: true,
|
|
isDestructive: true,
|
|
onPressed: () async {
|
|
await auth.logout();
|
|
if (context.mounted) {
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
MaterialPageRoute(builder: (_) => const LoginPage()),
|
|
(route) => false,
|
|
);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|