mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2026-02-05 11:42:17 +00:00
refactor(full refactor): Рефакторинг стартера (#8)
This commit is contained in:
@@ -2,29 +2,33 @@ 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';
|
||||
import 'package:friflex_starter/features/profile/presentation/screens/profile_screen.dart';
|
||||
import 'package:friflex_starter/features/profile_scope/presentation/screens/profile_scope_screen.dart';
|
||||
import 'package:friflex_starter/features/profile/presentation/profile_routes.dart';
|
||||
import 'package:friflex_starter/features/root/root_screen.dart';
|
||||
import 'package:friflex_starter/features/splash/splash_screen.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
/// Класс, реализующий роутер приложения и все поля классов
|
||||
/// {@template app_router}
|
||||
/// AppRouter - класс для управления навигацией в приложении
|
||||
/// [createRouter] - метод для создания экземпляра GoRouter
|
||||
/// {@endtemplate}
|
||||
class AppRouter {
|
||||
/// Конструктор для инициализации роутера
|
||||
/// {@macro app_router}
|
||||
const AppRouter();
|
||||
|
||||
/// Ключ для доступа к корневому навигатору приложения
|
||||
static final rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
/// Начальный роут приложения
|
||||
static String get initialLocation => '/debug';
|
||||
static String get initialLocation => '/main';
|
||||
|
||||
/// Метод для создания экземпляра GoRouter
|
||||
static GoRouter createRouter(IDebugService debugService) {
|
||||
return GoRouter(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
debugLogDiagnostics: true,
|
||||
initialLocation: initialLocation,
|
||||
observers: [
|
||||
debugService.routeObserver,
|
||||
],
|
||||
routes: [
|
||||
StatefulShellRoute.indexedStack(
|
||||
parentNavigatorKey: rootNavigatorKey,
|
||||
@@ -32,21 +36,14 @@ class AppRouter {
|
||||
RootScreen(navigationShell: navigationShell),
|
||||
branches: [
|
||||
MainRoutes.buildShellBranch(),
|
||||
DebugRoutes.buildShellBranch(),
|
||||
ProfileRoutes.buildShellBranch(),
|
||||
],
|
||||
),
|
||||
DebugRoutes.buildRoutes(),
|
||||
GoRoute(
|
||||
path: '/splash',
|
||||
builder: (context, state) => const SplashScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/profile',
|
||||
builder: (context, state) => const ProfileScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/profile_scope',
|
||||
builder: (context, state) => const ProfileScopeScreen(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user