@@ -15,103 +15,111 @@ import 'package:revitool/features/tweaks/personalization/personalization_page.da
1515import 'package:revitool/features/tweaks/security/security_page.dart' ;
1616import 'package:revitool/features/tweaks/tweaks_page.dart' ;
1717import 'package:revitool/main.dart' ;
18+ import 'package:riverpod_annotation/riverpod_annotation.dart' ;
19+
20+ part 'app_router.g.dart' ;
1821
1922final _rootNavigatorKey = GlobalKey <NavigatorState >(debugLabel: 'root' );
2023final _shellNavigatorKey = GlobalKey <NavigatorState >(debugLabel: 'shell' );
2124
22- final appRouter = GoRouter (
23- navigatorKey: _rootNavigatorKey,
24- initialLocation: initialRoute ?? RouteMeta .home.path,
25- redirect: (context, state) {
26- if (! WinRegistryService .isSupported) {
27- return AppRoutes .unsupported;
28- }
29- return null ; // Allow navigation
30- },
31- routes: [
32- ShellRoute (
33- navigatorKey: _shellNavigatorKey,
34- builder: (context, state, child) {
35- return AppShell (shellContext: context, child: child);
36- },
37- routes: [
38- GoRoute (
39- path: RouteMeta .home.path,
40- name: 'home' ,
41- builder: (context, state) => const HomePage (),
42- ),
43- GoRoute (
44- path: RouteMeta .tweaks.path,
45- name: 'tweaks' ,
46- builder: (context, state) => const TweaksPage (),
47- routes: [
48- GoRoute (
49- path: 'security' ,
50- name: 'security' ,
51- pageBuilder: (context, state) =>
52- AppRoutes .buildPageWithHorizontalTransition (
53- barrierColor: context.theme.scaffoldBackgroundColor,
54- state: state,
55- child: const SecurityPage (),
56- ),
57- ),
58- GoRoute (
59- path: 'performance' ,
60- name: 'performance' ,
61- pageBuilder: (context, state) =>
62- AppRoutes .buildPageWithHorizontalTransition (
63- barrierColor: context.theme.scaffoldBackgroundColor,
64- state: state,
65- child: const PerformancePage (),
66- ),
67- ),
68- GoRoute (
69- path: 'personalization' ,
70- name: 'personalization' ,
71- pageBuilder: (context, state) =>
72- AppRoutes .buildPageWithHorizontalTransition (
73- barrierColor: context.theme.scaffoldBackgroundColor,
74- state: state,
75- child: const PersonalizationPage (),
76- ),
77- ),
78- GoRoute (
79- path: 'utilities' ,
80- name: 'utilities' ,
81- pageBuilder: (context, state) =>
82- AppRoutes .buildPageWithHorizontalTransition (
83- barrierColor: context.theme.scaffoldBackgroundColor,
84- state: state,
85- child: const UtilitiesPage (),
86- ),
87- ),
88- GoRoute (
89- path: 'updates' ,
90- name: 'updates' ,
91- pageBuilder: (context, state) =>
92- AppRoutes .buildPageWithHorizontalTransition (
93- barrierColor: context.theme.scaffoldBackgroundColor,
94- state: state,
95- child: const UpdatesPage (),
96- ),
97- ),
98- ],
99- ),
100- GoRoute (
101- path: RouteMeta .msStore.path,
102- name: 'msstore' ,
103- builder: (context, state) => const MSStorePage (),
104- ),
105- GoRoute (
106- path: RouteMeta .settings.path,
107- name: 'settings' ,
108- builder: (context, state) => const SettingsPage (),
109- ),
110- ],
111- ),
112- GoRoute (
113- path: AppRoutes .unsupported,
114- builder: (context, state) => const UnsupportedWidget (),
115- ),
116- ],
117- );
25+ @riverpod
26+ GoRouter appRouter (Ref ref) {
27+ final router = GoRouter (
28+ navigatorKey: _rootNavigatorKey,
29+ initialLocation: initialRoute ?? RouteMeta .home.path,
30+ redirect: (context, state) {
31+ if (! WinRegistryService .isSupported) {
32+ return AppRoutes .unsupported;
33+ }
34+ return null ; // Allow navigation
35+ },
36+ routes: [
37+ ShellRoute (
38+ navigatorKey: _shellNavigatorKey,
39+ builder: (context, state, child) {
40+ return AppShell (shellContext: context, child: child);
41+ },
42+ routes: [
43+ GoRoute (
44+ path: RouteMeta .home.path,
45+ name: 'home' ,
46+ builder: (context, state) => const HomePage (),
47+ ),
48+ GoRoute (
49+ path: RouteMeta .tweaks.path,
50+ name: 'tweaks' ,
51+ builder: (context, state) => const TweaksPage (),
52+ routes: [
53+ GoRoute (
54+ path: 'security' ,
55+ name: 'security' ,
56+ pageBuilder: (context, state) =>
57+ AppRoutes .buildPageWithHorizontalTransition (
58+ barrierColor: context.theme.scaffoldBackgroundColor,
59+ state: state,
60+ child: const SecurityPage (),
61+ ),
62+ ),
63+ GoRoute (
64+ path: 'performance' ,
65+ name: 'performance' ,
66+ pageBuilder: (context, state) =>
67+ AppRoutes .buildPageWithHorizontalTransition (
68+ barrierColor: context.theme.scaffoldBackgroundColor,
69+ state: state,
70+ child: const PerformancePage (),
71+ ),
72+ ),
73+ GoRoute (
74+ path: 'personalization' ,
75+ name: 'personalization' ,
76+ pageBuilder: (context, state) =>
77+ AppRoutes .buildPageWithHorizontalTransition (
78+ barrierColor: context.theme.scaffoldBackgroundColor,
79+ state: state,
80+ child: const PersonalizationPage (),
81+ ),
82+ ),
83+ GoRoute (
84+ path: 'utilities' ,
85+ name: 'utilities' ,
86+ pageBuilder: (context, state) =>
87+ AppRoutes .buildPageWithHorizontalTransition (
88+ barrierColor: context.theme.scaffoldBackgroundColor,
89+ state: state,
90+ child: const UtilitiesPage (),
91+ ),
92+ ),
93+ GoRoute (
94+ path: 'updates' ,
95+ name: 'updates' ,
96+ pageBuilder: (context, state) =>
97+ AppRoutes .buildPageWithHorizontalTransition (
98+ barrierColor: context.theme.scaffoldBackgroundColor,
99+ state: state,
100+ child: const UpdatesPage (),
101+ ),
102+ ),
103+ ],
104+ ),
105+ GoRoute (
106+ path: RouteMeta .msStore.path,
107+ name: 'msstore' ,
108+ builder: (context, state) => const MSStorePage (),
109+ ),
110+ GoRoute (
111+ path: RouteMeta .settings.path,
112+ name: 'settings' ,
113+ builder: (context, state) => const SettingsPage (),
114+ ),
115+ ],
116+ ),
117+ GoRoute (
118+ path: AppRoutes .unsupported,
119+ builder: (context, state) => const UnsupportedWidget (),
120+ ),
121+ ],
122+ );
123+
124+ return router;
125+ }
0 commit comments