diff --git a/lib/core/router/app_router.dart b/lib/core/router/app_router.dart index eb1dd515..e65faa03 100644 --- a/lib/core/router/app_router.dart +++ b/lib/core/router/app_router.dart @@ -18,7 +18,7 @@ GoRouter router(RouterRef ref) { }, ); final initialLink = deepLink.read(); - String initialLocation = HomeRoute.path; + String initialLocation = const HomeRoute().location; if (initialLink case AsyncData(value: final link?)) { initialLocation = AddProfileRoute(url: link.url).location; } diff --git a/lib/core/router/routes/desktop_routes.dart b/lib/core/router/routes/desktop_routes.dart index 880804ab..1fa42f74 100644 --- a/lib/core/router/routes/desktop_routes.dart +++ b/lib/core/router/routes/desktop_routes.dart @@ -13,6 +13,7 @@ part 'desktop_routes.g.dart'; TypedGoRoute( path: HomeRoute.path, routes: [ + TypedGoRoute(path: AddProfileRoute.path), TypedGoRoute(path: ProfilesRoute.path), TypedGoRoute(path: NewProfileRoute.path), TypedGoRoute(path: ProfileDetailsRoute.path), @@ -58,6 +59,19 @@ class SettingsRoute extends GoRouteData { } } +class ClashOverridesRoute extends GoRouteData { + const ClashOverridesRoute(); + static const path = 'clash'; + + @override + Page buildPage(BuildContext context, GoRouterState state) { + return const MaterialPage( + fullscreenDialog: true, + child: ClashOverridesPage(), + ); + } +} + class AboutRoute extends GoRouteData { const AboutRoute(); static const path = '/about'; diff --git a/lib/core/router/routes/mobile_routes.dart b/lib/core/router/routes/mobile_routes.dart index 41bf4760..94f12063 100644 --- a/lib/core/router/routes/mobile_routes.dart +++ b/lib/core/router/routes/mobile_routes.dart @@ -13,9 +13,18 @@ part 'mobile_routes.g.dart'; TypedGoRoute( path: HomeRoute.path, routes: [ + TypedGoRoute(path: AddProfileRoute.path), TypedGoRoute(path: ProfilesRoute.path), TypedGoRoute(path: NewProfileRoute.path), TypedGoRoute(path: ProfileDetailsRoute.path), + TypedGoRoute(path: LogsRoute.path), + TypedGoRoute( + path: SettingsRoute.path, + routes: [ + TypedGoRoute(path: ClashOverridesRoute.path), + ], + ), + TypedGoRoute(path: AboutRoute.path), ], ), TypedGoRoute(path: ProxiesRoute.path), @@ -30,10 +39,9 @@ class MobileWrapperRoute extends ShellRouteData { } } -@TypedGoRoute(path: LogsRoute.path) class LogsRoute extends GoRouteData { const LogsRoute(); - static const path = '/logs'; + static const path = 'logs'; static final GlobalKey $parentNavigatorKey = rootNavigatorKey; @@ -46,15 +54,9 @@ class LogsRoute extends GoRouteData { } } -@TypedGoRoute( - path: SettingsRoute.path, - routes: [ - TypedGoRoute(path: ClashOverridesRoute.path), - ], -) class SettingsRoute extends GoRouteData { const SettingsRoute(); - static const path = '/settings'; + static const path = 'settings'; static final GlobalKey $parentNavigatorKey = rootNavigatorKey; @@ -67,10 +69,24 @@ class SettingsRoute extends GoRouteData { } } -@TypedGoRoute(path: AboutRoute.path) +class ClashOverridesRoute extends GoRouteData { + const ClashOverridesRoute(); + static const path = 'clash'; + + static final GlobalKey $parentNavigatorKey = rootNavigatorKey; + + @override + Page buildPage(BuildContext context, GoRouterState state) { + return const MaterialPage( + fullscreenDialog: true, + child: ClashOverridesPage(), + ); + } +} + class AboutRoute extends GoRouteData { const AboutRoute(); - static const path = '/about'; + static const path = 'about'; static final GlobalKey $parentNavigatorKey = rootNavigatorKey; diff --git a/lib/core/router/routes/routes.dart b/lib/core/router/routes/routes.dart index 1cc0940d..9c3bf2d7 100644 --- a/lib/core/router/routes/routes.dart +++ b/lib/core/router/routes/routes.dart @@ -1,16 +1,14 @@ import 'package:go_router/go_router.dart'; import 'package:hiddify/core/router/routes/desktop_routes.dart' as desktop; import 'package:hiddify/core/router/routes/mobile_routes.dart' as mobile; -import 'package:hiddify/core/router/routes/shared_routes.dart' as shared; import 'package:hiddify/utils/utils.dart'; export 'mobile_routes.dart'; -export 'shared_routes.dart' hide $appRoutes; +export 'shared_routes.dart'; List get $routes => [ if (PlatformUtils.isDesktop) ...desktop.$appRoutes else ...mobile.$appRoutes, - ...shared.$appRoutes, ]; diff --git a/lib/core/router/routes/shared_routes.dart b/lib/core/router/routes/shared_routes.dart index 300046b9..a45ef978 100644 --- a/lib/core/router/routes/shared_routes.dart +++ b/lib/core/router/routes/shared_routes.dart @@ -4,13 +4,8 @@ import 'package:hiddify/features/home/view/view.dart'; import 'package:hiddify/features/profile_detail/view/view.dart'; import 'package:hiddify/features/profiles/view/view.dart'; import 'package:hiddify/features/proxies/view/view.dart'; -import 'package:hiddify/features/settings/view/view.dart'; import 'package:hiddify/utils/utils.dart'; -part 'shared_routes.g.dart'; - -List get $sharedRoutes => $appRoutes; - final GlobalKey rootNavigatorKey = GlobalKey(); class HomeRoute extends GoRouteData { @@ -33,10 +28,9 @@ class ProxiesRoute extends GoRouteData { } } -@TypedGoRoute(path: AddProfileRoute.path) class AddProfileRoute extends GoRouteData { const AddProfileRoute({this.url}); - static const path = '/add'; + static const path = 'add'; final String? url; static final GlobalKey $parentNavigatorKey = rootNavigatorKey; @@ -103,16 +97,3 @@ class ProfileDetailsRoute extends GoRouteData { ); } } - -class ClashOverridesRoute extends GoRouteData { - const ClashOverridesRoute(); - static const path = 'clash-overrides'; - - @override - Page buildPage(BuildContext context, GoRouterState state) { - return const MaterialPage( - fullscreenDialog: true, - child: ClashOverridesPage(), - ); - } -}