Files
sf-app-platform/apps/mobile_app/lib/navigation/app_router.dart

104 lines
2.9 KiB
Dart
Raw Normal View History

2025-11-17 00:15:31 +01:00
import 'package:auth/auth.dart';
import 'package:dashboard_shell/dashboard_builder.dart';
import 'package:flutter/material.dart';
2025-12-03 13:42:14 +01:00
import 'package:get_it/get_it.dart';
2025-11-17 00:15:31 +01:00
import 'package:go_router/go_router.dart';
import 'package:home/home.dart';
import 'package:navigation/navigation.dart';
import 'package:notifications/notifications.dart';
import 'package:profile/profile.dart';
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
late final GoRouter appRouter;
void configureAppRouter() {
appRouter = GoRouter(
navigatorKey: rootNavigatorKey,
initialLocation: AppRoutes.login,
2025-12-03 13:42:14 +01:00
debugLogDiagnostics: true,
2025-11-17 00:15:31 +01:00
routes: [
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.login,
2025-11-17 00:15:31 +01:00
name: 'login',
pageBuilder: LoginBuilder().buildPage,
),
GoRoute(
path: AppRoutes.signup,
name: 'signup',
pageBuilder: SignupBuilder().buildPage,
),
2025-11-17 00:15:31 +01:00
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.onboarding,
2025-11-17 00:15:31 +01:00
name: 'onboarding',
pageBuilder: OnboardingBuilder().buildPage,
),
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.linkPhone,
name: 'request_link_phone',
pageBuilder: RequestLinkPhoneBuilder().buildPage,
2025-11-17 00:15:31 +01:00
),
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.phoneCode,
name: 'Verify_link_phone_code',
pageBuilder: VerifyLinkPhoneCodeBuilder().buildPage,
2025-11-17 00:15:31 +01:00
),
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.recoverPassword,
2025-11-17 00:15:31 +01:00
name: 'recover_password',
pageBuilder: RecoverPasswordBuilder().buildPage,
),
GoRoute(
path: AppRoutes.deviceSignup,
name: 'device_signup',
pageBuilder: DeviceSignupBuilder().buildPage,
),
2025-11-17 00:15:31 +01:00
StatefulShellRoute.indexedStack(
builder: (context, state, navShell) {
return DashboardBuilder().build(context, navShell);
},
branches: [
StatefulShellBranch(
routes: [
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.dashboardHome,
2025-11-17 00:15:31 +01:00
name: 'home',
pageBuilder: const HomeBuilder().buildPage,
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.dashboardActivity,
2025-11-17 00:15:31 +01:00
name: 'activity',
pageBuilder: const ActivityBuilder().buildPage,
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.dashboardNotifications,
2025-11-17 00:15:31 +01:00
name: 'notifications',
pageBuilder: const NotificationsBuilder().buildPage,
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
2025-12-03 13:42:14 +01:00
path: AppRoutes.dashboardProfile,
2025-11-17 00:15:31 +01:00
name: 'profile',
pageBuilder: const ProfileBuilder().buildPage,
),
],
),
],
),
],
);
GetIt.I<NavigationContract>().setRouter(appRouter);
}