Files
sf-app-platform/apps/mobile_app/lib/navigation/app_router.dart
2025-12-03 18:37:07 +01:00

95 lines
2.6 KiB
Dart

import 'package:auth/auth.dart';
import 'package:dashboard_shell/dashboard_builder.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
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.onboarding,
debugLogDiagnostics: true,
routes: [
GoRoute(
path: AppRoutes.login,
name: 'login',
pageBuilder: LoginBuilder().buildPage,
),
GoRoute(
path: AppRoutes.onboarding,
name: 'onboarding',
pageBuilder: OnboardingBuilder().buildPage,
),
GoRoute(
path: AppRoutes.linkPhone,
name: 'link_phone',
pageBuilder: LinkPhoneBuilder().buildPage,
),
GoRoute(
path: AppRoutes.phoneCode,
name: 'phone_code',
pageBuilder: PhoneCodeBuilder().buildPage,
),
GoRoute(
path: AppRoutes.recoverPassword,
name: 'recover_password',
pageBuilder: RecoverPasswordBuilder().buildPage,
),
StatefulShellRoute.indexedStack(
builder: (context, state, navShell) {
return DashboardBuilder().build(context, navShell);
},
branches: [
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.dashboardHome,
name: 'home',
pageBuilder: const HomeBuilder().buildPage,
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.dashboardActivity,
name: 'activity',
pageBuilder: const ActivityBuilder().buildPage,
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.dashboardNotifications,
name: 'notifications',
pageBuilder: const NotificationsBuilder().buildPage,
),
],
),
StatefulShellBranch(
routes: [
GoRoute(
path: AppRoutes.dashboardProfile,
name: 'profile',
pageBuilder: const ProfileBuilder().buildPage,
),
],
),
],
),
],
);
GetIt.I<NavigationContract>().setRouter(appRouter);
}