184 lines
5.5 KiB
Dart
184 lines
5.5 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/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/profile/presentation/pages/profile_page.dart';
|
||
import '../features/profile/presentation/pages/edit_profile_page.dart';
|
||
import 'route_paths.dart';
|
||
import 'route_names.dart';
|
||
|
||
final _rootNavigatorKey = GlobalKey<NavigatorState>();
|
||
final _shellNavigatorKey = GlobalKey<NavigatorState>();
|
||
|
||
/// 备份助记词页面参数
|
||
class BackupMnemonicParams {
|
||
final List<String> mnemonicWords;
|
||
final String kavaAddress;
|
||
final String dstAddress;
|
||
final String bscAddress;
|
||
final String serialNumber;
|
||
|
||
BackupMnemonicParams({
|
||
required this.mnemonicWords,
|
||
required this.kavaAddress,
|
||
required this.dstAddress,
|
||
required this.bscAddress,
|
||
required this.serialNumber,
|
||
});
|
||
}
|
||
|
||
/// 确认备份页面参数(复用 BackupMnemonicParams)
|
||
typedef VerifyMnemonicParams = BackupMnemonicParams;
|
||
|
||
/// 创建成功页面参数
|
||
class WalletCreatedParams {
|
||
final String kavaAddress;
|
||
final String dstAddress;
|
||
final String bscAddress;
|
||
final String serialNumber;
|
||
|
||
WalletCreatedParams({
|
||
required this.kavaAddress,
|
||
required this.dstAddress,
|
||
required this.bscAddress,
|
||
required this.serialNumber,
|
||
});
|
||
}
|
||
|
||
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) => const GuidePage(),
|
||
),
|
||
|
||
// Onboarding / Create Account
|
||
GoRoute(
|
||
path: RoutePaths.onboarding,
|
||
name: RouteNames.onboarding,
|
||
builder: (context, state) => const OnboardingPage(),
|
||
),
|
||
|
||
// Backup Mnemonic
|
||
GoRoute(
|
||
path: RoutePaths.backupMnemonic,
|
||
name: RouteNames.backupMnemonic,
|
||
builder: (context, state) {
|
||
final params = state.extra as BackupMnemonicParams;
|
||
return BackupMnemonicPage(
|
||
mnemonicWords: params.mnemonicWords,
|
||
kavaAddress: params.kavaAddress,
|
||
dstAddress: params.dstAddress,
|
||
bscAddress: params.bscAddress,
|
||
serialNumber: params.serialNumber,
|
||
);
|
||
},
|
||
),
|
||
|
||
// 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,
|
||
serialNumber: params.serialNumber,
|
||
);
|
||
},
|
||
),
|
||
|
||
// 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,
|
||
serialNumber: params.serialNumber,
|
||
);
|
||
},
|
||
),
|
||
|
||
// Edit Profile (编辑资料)
|
||
GoRoute(
|
||
path: RoutePaths.editProfile,
|
||
name: RouteNames.editProfile,
|
||
builder: (context, state) => const EditProfilePage(),
|
||
),
|
||
|
||
// 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(),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
],
|
||
);
|
||
});
|