330 lines
10 KiB
Dart
330 lines
10 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../features/auth/presentation/pages/splash_page.dart';
|
|
import '../features/auth/presentation/pages/guide_page.dart';
|
|
import '../features/auth/presentation/pages/onboarding_page.dart';
|
|
import '../features/auth/presentation/pages/backup_mnemonic_page.dart';
|
|
import '../features/auth/presentation/pages/verify_mnemonic_page.dart';
|
|
import '../features/auth/presentation/pages/wallet_created_page.dart';
|
|
import '../features/auth/presentation/pages/import_mnemonic_page.dart';
|
|
import '../features/home/presentation/pages/home_shell_page.dart';
|
|
import '../features/ranking/presentation/pages/ranking_page.dart';
|
|
import '../features/mining/presentation/pages/mining_page.dart';
|
|
import '../features/trading/presentation/pages/trading_page.dart';
|
|
import '../features/trading/presentation/pages/ledger_detail_page.dart';
|
|
import '../features/profile/presentation/pages/profile_page.dart';
|
|
import '../features/profile/presentation/pages/edit_profile_page.dart';
|
|
import '../features/share/presentation/pages/share_page.dart';
|
|
import '../features/deposit/presentation/pages/deposit_usdt_page.dart';
|
|
import '../features/planting/presentation/pages/planting_quantity_page.dart';
|
|
import '../features/planting/presentation/pages/planting_location_page.dart';
|
|
import '../features/security/presentation/pages/google_auth_page.dart';
|
|
import '../features/security/presentation/pages/change_password_page.dart';
|
|
import '../features/security/presentation/pages/bind_email_page.dart';
|
|
import '../features/withdraw/presentation/pages/withdraw_usdt_page.dart';
|
|
import '../features/withdraw/presentation/pages/withdraw_confirm_page.dart';
|
|
import '../features/notification/presentation/pages/notification_inbox_page.dart';
|
|
import '../features/account/presentation/pages/account_switch_page.dart';
|
|
import 'route_paths.dart';
|
|
import 'route_names.dart';
|
|
|
|
final _rootNavigatorKey = GlobalKey<NavigatorState>();
|
|
final _shellNavigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
/// 备份助记词页面参数 (新版 - 只需要用户序列号)
|
|
class BackupMnemonicParams {
|
|
final String userSerialNum;
|
|
final String? referralCode;
|
|
|
|
BackupMnemonicParams({
|
|
required this.userSerialNum,
|
|
this.referralCode,
|
|
});
|
|
}
|
|
|
|
/// 确认备份页面参数
|
|
class VerifyMnemonicParams {
|
|
final List<String> mnemonicWords;
|
|
final String kavaAddress;
|
|
final String dstAddress;
|
|
final String bscAddress;
|
|
final String userSerialNum;
|
|
final String? referralCode;
|
|
|
|
VerifyMnemonicParams({
|
|
required this.mnemonicWords,
|
|
required this.kavaAddress,
|
|
required this.dstAddress,
|
|
required this.bscAddress,
|
|
required this.userSerialNum,
|
|
this.referralCode,
|
|
});
|
|
}
|
|
|
|
/// 创建成功页面参数
|
|
class WalletCreatedParams {
|
|
final String kavaAddress;
|
|
final String dstAddress;
|
|
final String bscAddress;
|
|
final String userSerialNum;
|
|
final String? referralCode;
|
|
|
|
WalletCreatedParams({
|
|
required this.kavaAddress,
|
|
required this.dstAddress,
|
|
required this.bscAddress,
|
|
required this.userSerialNum,
|
|
this.referralCode,
|
|
});
|
|
}
|
|
|
|
/// 分享页面参数
|
|
class SharePageParams {
|
|
final String shareLink;
|
|
final String? referralCode;
|
|
|
|
SharePageParams({
|
|
required this.shareLink,
|
|
this.referralCode,
|
|
});
|
|
}
|
|
|
|
final appRouterProvider = Provider<GoRouter>((ref) {
|
|
return GoRouter(
|
|
navigatorKey: _rootNavigatorKey,
|
|
initialLocation: RoutePaths.splash,
|
|
debugLogDiagnostics: true,
|
|
routes: [
|
|
// Splash Screen
|
|
GoRoute(
|
|
path: RoutePaths.splash,
|
|
name: RouteNames.splash,
|
|
builder: (context, state) => const SplashPage(),
|
|
),
|
|
|
|
// Guide Pages (向导页)
|
|
GoRoute(
|
|
path: RoutePaths.guide,
|
|
name: RouteNames.guide,
|
|
builder: (context, state) {
|
|
// 支持传入初始页索引
|
|
final initialPage = state.extra as int? ?? 0;
|
|
return GuidePage(initialPage: initialPage);
|
|
},
|
|
),
|
|
|
|
// Onboarding / Create Account
|
|
GoRoute(
|
|
path: RoutePaths.onboarding,
|
|
name: RouteNames.onboarding,
|
|
builder: (context, state) => const OnboardingPage(),
|
|
),
|
|
|
|
// Import Mnemonic (导入助记词)
|
|
GoRoute(
|
|
path: RoutePaths.importMnemonic,
|
|
name: RouteNames.importMnemonic,
|
|
builder: (context, state) => const ImportMnemonicPage(),
|
|
),
|
|
|
|
// Backup Mnemonic (备份助记词 - 会调用 API 获取钱包信息)
|
|
GoRoute(
|
|
path: RoutePaths.backupMnemonic,
|
|
name: RouteNames.backupMnemonic,
|
|
builder: (context, state) {
|
|
final params = state.extra as BackupMnemonicParams;
|
|
return BackupMnemonicPage(
|
|
userSerialNum: params.userSerialNum,
|
|
referralCode: params.referralCode,
|
|
);
|
|
},
|
|
),
|
|
|
|
// Verify Mnemonic (确认备份)
|
|
GoRoute(
|
|
path: RoutePaths.verifyMnemonic,
|
|
name: RouteNames.verifyMnemonic,
|
|
builder: (context, state) {
|
|
final params = state.extra as VerifyMnemonicParams;
|
|
return VerifyMnemonicPage(
|
|
mnemonicWords: params.mnemonicWords,
|
|
kavaAddress: params.kavaAddress,
|
|
dstAddress: params.dstAddress,
|
|
bscAddress: params.bscAddress,
|
|
userSerialNum: params.userSerialNum,
|
|
referralCode: params.referralCode,
|
|
);
|
|
},
|
|
),
|
|
|
|
// Wallet Created (创建成功)
|
|
GoRoute(
|
|
path: RoutePaths.walletCreated,
|
|
name: RouteNames.walletCreated,
|
|
builder: (context, state) {
|
|
final params = state.extra as WalletCreatedParams;
|
|
return WalletCreatedPage(
|
|
kavaAddress: params.kavaAddress,
|
|
dstAddress: params.dstAddress,
|
|
bscAddress: params.bscAddress,
|
|
userSerialNum: params.userSerialNum,
|
|
referralCode: params.referralCode,
|
|
);
|
|
},
|
|
),
|
|
|
|
// Edit Profile (编辑资料)
|
|
GoRoute(
|
|
path: RoutePaths.editProfile,
|
|
name: RouteNames.editProfile,
|
|
builder: (context, state) => const EditProfilePage(),
|
|
),
|
|
|
|
// Notification Inbox (通知中心)
|
|
GoRoute(
|
|
path: RoutePaths.notifications,
|
|
name: RouteNames.notifications,
|
|
builder: (context, state) => const NotificationInboxPage(),
|
|
),
|
|
|
|
// Account Switch Page (账号切换)
|
|
GoRoute(
|
|
path: RoutePaths.accountSwitch,
|
|
name: RouteNames.accountSwitch,
|
|
builder: (context, state) => const AccountSwitchPage(),
|
|
),
|
|
|
|
// Share Page (分享页面)
|
|
GoRoute(
|
|
path: RoutePaths.share,
|
|
name: RouteNames.share,
|
|
builder: (context, state) {
|
|
final params = state.extra as SharePageParams;
|
|
return SharePage(
|
|
shareLink: params.shareLink,
|
|
referralCode: params.referralCode,
|
|
);
|
|
},
|
|
),
|
|
|
|
// Deposit USDT Page (充值 USDT)
|
|
GoRoute(
|
|
path: RoutePaths.depositUsdt,
|
|
name: RouteNames.depositUsdt,
|
|
builder: (context, state) => const DepositUsdtPage(),
|
|
),
|
|
|
|
// Planting Quantity Page (认种 - 选择数量)
|
|
GoRoute(
|
|
path: RoutePaths.plantingQuantity,
|
|
name: RouteNames.plantingQuantity,
|
|
builder: (context, state) => const PlantingQuantityPage(),
|
|
),
|
|
|
|
// Planting Location Page (认种 - 选择省市)
|
|
GoRoute(
|
|
path: RoutePaths.plantingLocation,
|
|
name: RouteNames.plantingLocation,
|
|
builder: (context, state) {
|
|
final params = state.extra as PlantingLocationParams;
|
|
return PlantingLocationPage(
|
|
quantity: params.quantity,
|
|
totalPrice: params.totalPrice,
|
|
orderNo: params.orderNo,
|
|
);
|
|
},
|
|
),
|
|
|
|
// Google Auth Page (谷歌验证器)
|
|
GoRoute(
|
|
path: RoutePaths.googleAuth,
|
|
name: RouteNames.googleAuth,
|
|
builder: (context, state) => const GoogleAuthPage(),
|
|
),
|
|
|
|
// Change Password Page (修改密码)
|
|
GoRoute(
|
|
path: RoutePaths.changePassword,
|
|
name: RouteNames.changePassword,
|
|
builder: (context, state) => const ChangePasswordPage(),
|
|
),
|
|
|
|
// Bind Email Page (绑定邮箱)
|
|
GoRoute(
|
|
path: RoutePaths.bindEmail,
|
|
name: RouteNames.bindEmail,
|
|
builder: (context, state) => const BindEmailPage(),
|
|
),
|
|
|
|
// Ledger Detail Page (账本明细)
|
|
GoRoute(
|
|
path: RoutePaths.ledgerDetail,
|
|
name: RouteNames.ledgerDetail,
|
|
builder: (context, state) => const LedgerDetailPage(),
|
|
),
|
|
|
|
// Withdraw USDT Page (USDT 提款)
|
|
GoRoute(
|
|
path: RoutePaths.withdrawUsdt,
|
|
name: RouteNames.withdrawUsdt,
|
|
builder: (context, state) => const WithdrawUsdtPage(),
|
|
),
|
|
|
|
// Withdraw Confirm Page (提款确认)
|
|
GoRoute(
|
|
path: RoutePaths.withdrawConfirm,
|
|
name: RouteNames.withdrawConfirm,
|
|
builder: (context, state) {
|
|
final params = state.extra as WithdrawUsdtParams;
|
|
return WithdrawConfirmPage(params: params);
|
|
},
|
|
),
|
|
|
|
// Main Shell with Bottom Navigation
|
|
ShellRoute(
|
|
navigatorKey: _shellNavigatorKey,
|
|
builder: (context, state, child) => HomeShellPage(child: child),
|
|
routes: [
|
|
// Ranking Tab
|
|
GoRoute(
|
|
path: RoutePaths.ranking,
|
|
name: RouteNames.ranking,
|
|
pageBuilder: (context, state) => const NoTransitionPage(
|
|
child: RankingPage(),
|
|
),
|
|
),
|
|
|
|
// Mining Tab
|
|
GoRoute(
|
|
path: RoutePaths.mining,
|
|
name: RouteNames.mining,
|
|
pageBuilder: (context, state) => const NoTransitionPage(
|
|
child: MiningPage(),
|
|
),
|
|
),
|
|
|
|
// Trading Tab
|
|
GoRoute(
|
|
path: RoutePaths.trading,
|
|
name: RouteNames.trading,
|
|
pageBuilder: (context, state) => const NoTransitionPage(
|
|
child: TradingPage(),
|
|
),
|
|
),
|
|
|
|
// Profile Tab
|
|
GoRoute(
|
|
path: RoutePaths.profile,
|
|
name: RouteNames.profile,
|
|
pageBuilder: (context, state) => const NoTransitionPage(
|
|
child: ProfilePage(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
});
|