2025-01-21 14:24:31 +03:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:friflex_starter/features/debug/debug_routes.dart';
|
|
|
|
|
import 'package:friflex_starter/features/debug/i_debug_service.dart';
|
|
|
|
|
import 'package:friflex_starter/features/main/presentation/main_routes.dart';
|
2025-04-27 17:08:34 +03:00
|
|
|
import 'package:friflex_starter/features/profile/presentation/profile_routes.dart';
|
2025-01-21 14:24:31 +03:00
|
|
|
import 'package:friflex_starter/features/root/root_screen.dart';
|
2025-02-12 10:53:38 +03:00
|
|
|
import 'package:friflex_starter/features/splash/splash_screen.dart';
|
2025-09-26 08:21:42 +03:00
|
|
|
import 'package:friflex_starter/features/update/update_routes.dart';
|
2025-01-21 14:24:31 +03:00
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
|
|
2025-04-27 17:08:34 +03:00
|
|
|
/// {@template app_router}
|
|
|
|
|
/// AppRouter - класс для управления навигацией в приложении
|
|
|
|
|
/// [createRouter] - метод для создания экземпляра GoRouter
|
|
|
|
|
/// {@endtemplate}
|
2025-01-21 14:24:31 +03:00
|
|
|
class AppRouter {
|
2025-04-27 17:08:34 +03:00
|
|
|
/// {@macro app_router}
|
2025-01-21 14:24:31 +03:00
|
|
|
const AppRouter();
|
2025-02-04 10:18:41 +03:00
|
|
|
|
2025-01-21 14:24:31 +03:00
|
|
|
/// Ключ для доступа к корневому навигатору приложения
|
|
|
|
|
static final rootNavigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
|
|
|
|
|
|
/// Начальный роут приложения
|
2025-04-27 17:08:34 +03:00
|
|
|
static String get initialLocation => '/main';
|
2025-01-21 14:24:31 +03:00
|
|
|
|
|
|
|
|
/// Метод для создания экземпляра GoRouter
|
|
|
|
|
static GoRouter createRouter(IDebugService debugService) {
|
|
|
|
|
return GoRouter(
|
|
|
|
|
navigatorKey: rootNavigatorKey,
|
|
|
|
|
initialLocation: initialLocation,
|
2025-05-28 16:38:56 +03:00
|
|
|
observers: [debugService.routeObserver],
|
2025-01-21 14:24:31 +03:00
|
|
|
routes: [
|
|
|
|
|
StatefulShellRoute.indexedStack(
|
|
|
|
|
parentNavigatorKey: rootNavigatorKey,
|
|
|
|
|
builder: (context, state, navigationShell) =>
|
|
|
|
|
RootScreen(navigationShell: navigationShell),
|
|
|
|
|
branches: [
|
|
|
|
|
MainRoutes.buildShellBranch(),
|
2025-04-27 17:08:34 +03:00
|
|
|
ProfileRoutes.buildShellBranch(),
|
2025-01-21 14:24:31 +03:00
|
|
|
],
|
|
|
|
|
),
|
2025-04-27 17:08:34 +03:00
|
|
|
DebugRoutes.buildRoutes(),
|
2025-02-12 10:53:38 +03:00
|
|
|
GoRoute(
|
|
|
|
|
path: '/splash',
|
|
|
|
|
builder: (context, state) => const SplashScreen(),
|
|
|
|
|
),
|
2025-09-26 08:21:42 +03:00
|
|
|
UpdateRoutes.buildRoutes(),
|
2025-01-21 14:24:31 +03:00
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|