103 lines
2.9 KiB
Dart
103 lines
2.9 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 '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),
|
|
const MenuGroup2(),
|
|
SizedBox(height: AppSpacing.lg),
|
|
LogoutButton(onLogout: () => _handleLogout(auth)),
|
|
SizedBox(height: AppSpacing.md),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
void _showComingSoon(String feature) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
title: const Text('功能開發中'),
|
|
content: Text('$feature功能正在開發中,敬請期待'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
child: const Text('知道了'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
void _handleLogout(AuthProvider auth) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
showDialog(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
title: const Text('退出登錄'),
|
|
content: const Text('確定要退出登錄嗎?'),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
child: Text('取消',
|
|
style: TextStyle(color: colorScheme.onSurfaceVariant)),
|
|
),
|
|
TextButton(
|
|
onPressed: () async {
|
|
Navigator.of(ctx).pop();
|
|
await auth.logout();
|
|
},
|
|
child: Text('退出', style: TextStyle(color: colorScheme.error)),
|
|
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|