This commit is contained in:
problematicconsumer
2023-07-06 17:18:41 +03:30
commit b617c95f62
352 changed files with 21017 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hiddify/core/router/routes/shared_routes.dart';
import 'package:hiddify/features/logs/view/view.dart';
import 'package:hiddify/features/settings/view/view.dart';
import 'package:hiddify/features/wrapper/wrapper.dart';
part 'desktop_routes.g.dart';
@TypedShellRoute<DesktopWrapperRoute>(
routes: [
TypedGoRoute<HomeRoute>(
path: HomeRoute.path,
routes: [
TypedGoRoute<ProfilesRoute>(path: ProfilesRoute.path),
TypedGoRoute<NewProfileRoute>(path: NewProfileRoute.path),
TypedGoRoute<ProfileDetailsRoute>(path: ProfileDetailsRoute.path),
],
),
TypedGoRoute<ProxiesRoute>(path: ProxiesRoute.path),
TypedGoRoute<LogsRoute>(path: LogsRoute.path),
TypedGoRoute<SettingsRoute>(path: SettingsRoute.path),
],
)
class DesktopWrapperRoute extends ShellRouteData {
const DesktopWrapperRoute();
@override
Widget builder(BuildContext context, GoRouterState state, Widget navigator) {
return DesktopWrapper(navigator);
}
}
class LogsRoute extends GoRouteData {
const LogsRoute();
static const path = '/logs';
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return const NoTransitionPage(child: LogsPage());
}
}
class SettingsRoute extends GoRouteData {
const SettingsRoute();
static const path = '/settings';
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return const NoTransitionPage(child: SettingsPage());
}
}

View File

@@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hiddify/core/router/routes/shared_routes.dart';
import 'package:hiddify/features/logs/view/view.dart';
import 'package:hiddify/features/settings/view/view.dart';
import 'package:hiddify/features/wrapper/wrapper.dart';
part 'mobile_routes.g.dart';
@TypedShellRoute<MobileWrapperRoute>(
routes: [
TypedGoRoute<HomeRoute>(
path: HomeRoute.path,
routes: [
TypedGoRoute<ProfilesRoute>(path: ProfilesRoute.path),
TypedGoRoute<NewProfileRoute>(path: NewProfileRoute.path),
TypedGoRoute<ProfileDetailsRoute>(path: ProfileDetailsRoute.path),
],
),
TypedGoRoute<ProxiesRoute>(path: ProxiesRoute.path),
],
)
class MobileWrapperRoute extends ShellRouteData {
const MobileWrapperRoute();
@override
Widget builder(BuildContext context, GoRouterState state, Widget navigator) {
return MobileWrapper(navigator);
}
}
@TypedGoRoute<LogsRoute>(path: LogsRoute.path)
class LogsRoute extends GoRouteData {
const LogsRoute();
static const path = '/logs';
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return const MaterialPage(
fullscreenDialog: true,
child: LogsPage(),
);
}
}
@TypedGoRoute<SettingsRoute>(path: SettingsRoute.path)
class SettingsRoute extends GoRouteData {
const SettingsRoute();
static const path = '/settings';
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return const MaterialPage(
fullscreenDialog: true,
child: SettingsPage(),
);
}
}

View File

@@ -0,0 +1,16 @@
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;
List<RouteBase> get $routes => [
if (PlatformUtils.isDesktop)
...desktop.$appRoutes
else
...mobile.$appRoutes,
...shared.$appRoutes,
];

View File

@@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hiddify/features/common/common.dart';
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/utils/utils.dart';
part 'shared_routes.g.dart';
List<RouteBase> get $sharedRoutes => $appRoutes;
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
class HomeRoute extends GoRouteData {
const HomeRoute();
static const path = '/';
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return const NoTransitionPage(child: HomePage());
}
}
class ProxiesRoute extends GoRouteData {
const ProxiesRoute();
static const path = '/proxies';
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return const NoTransitionPage(child: ProxiesPage());
}
}
@TypedGoRoute<AddProfileRoute>(path: AddProfileRoute.path)
class AddProfileRoute extends GoRouteData {
const AddProfileRoute();
static const path = '/add';
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return BottomSheetPage(
fixed: true,
builder: (controller) => AddProfileModal(scrollController: controller),
);
}
}
class ProfilesRoute extends GoRouteData {
const ProfilesRoute();
static const path = 'profiles';
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return BottomSheetPage(
builder: (controller) => ProfilesModal(scrollController: controller),
);
}
}
class NewProfileRoute extends GoRouteData {
const NewProfileRoute({this.url, this.name});
static const path = 'profiles/new';
final String? url;
final String? name;
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return MaterialPage(
fullscreenDialog: true,
child: ProfileDetailPage(
"new",
url: url,
name: name,
),
);
}
}
class ProfileDetailsRoute extends GoRouteData {
const ProfileDetailsRoute(this.id);
final String id;
static const path = 'profiles/:id';
static final GlobalKey<NavigatorState> $parentNavigatorKey = rootNavigatorKey;
@override
Page<void> buildPage(BuildContext context, GoRouterState state) {
return MaterialPage(
fullscreenDialog: true,
child: ProfileDetailPage(id),
);
}
}