refactor(router): Migrate to AutoRouter v6

This commit is contained in:
Inex Code 2023-03-22 14:38:18 +03:00 committed by Gitea
parent 3366585d76
commit af7196d84b
26 changed files with 568 additions and 614 deletions

View file

@ -12,7 +12,8 @@ class NavigationService {
if (context == null) { if (context == null) {
showSnackBar( showSnackBar(
'Could not show dialog. This should not happen, please report this.'); 'Could not show dialog. This should not happen, please report this.',
);
return; return;
} }

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
@ -13,6 +14,7 @@ import 'package:selfprivacy/ui/helpers/modals.dart';
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
@RoutePage()
class BackupDetailsPage extends StatefulWidget { class BackupDetailsPage extends StatefulWidget {
const BackupDetailsPage({super.key}); const BackupDetailsPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:cubit_form/cubit_form.dart'; import 'package:cubit_form/cubit_form.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -10,6 +11,7 @@ import 'package:selfprivacy/ui/components/info_box/info_box.dart';
import 'package:selfprivacy/ui/pages/devices/new_device.dart'; import 'package:selfprivacy/ui/pages/devices/new_device.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart';
@RoutePage()
class DevicesScreen extends StatefulWidget { class DevicesScreen extends StatefulWidget {
const DevicesScreen({super.key}); const DevicesScreen({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:selfprivacy/config/get_it_config.dart'; import 'package:selfprivacy/config/get_it_config.dart';
@ -8,6 +9,7 @@ import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
import 'package:selfprivacy/utils/network_utils.dart'; import 'package:selfprivacy/utils/network_utils.dart';
@RoutePage()
class DnsDetailsPage extends StatefulWidget { class DnsDetailsPage extends StatefulWidget {
const DnsDetailsPage({super.key}); const DnsDetailsPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart'; import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
@ -8,6 +9,7 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@RoutePage()
class AboutApplicationPage extends StatelessWidget { class AboutApplicationPage extends StatelessWidget {
const AboutApplicationPage({super.key}); const AboutApplicationPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart'; import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
@ -6,6 +7,7 @@ import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart';
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
@RoutePage()
class AppSettingsPage extends StatefulWidget { class AppSettingsPage extends StatefulWidget {
const AppSettingsPage({super.key}); const AppSettingsPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:selfprivacy/logic/api_maps/staging_options.dart'; import 'package:selfprivacy/logic/api_maps/staging_options.dart';
import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart'; import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart';
@ -6,6 +7,7 @@ import 'package:selfprivacy/logic/cubit/recovery_key/recovery_key_cubit.dart';
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
@RoutePage()
class DeveloperSettingsPage extends StatefulWidget { class DeveloperSettingsPage extends StatefulWidget {
const DeveloperSettingsPage({super.key}); const DeveloperSettingsPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'dart:collection'; import 'dart:collection';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
@ -7,6 +8,7 @@ import 'package:selfprivacy/config/get_it_config.dart';
import 'package:selfprivacy/logic/models/message.dart'; import 'package:selfprivacy/logic/models/message.dart';
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart'; import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
@RoutePage()
class ConsolePage extends StatefulWidget { class ConsolePage extends StatefulWidget {
const ConsolePage({super.key}); const ConsolePage({super.key});

View file

@ -12,6 +12,7 @@ import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
import 'package:selfprivacy/utils/breakpoints.dart'; import 'package:selfprivacy/utils/breakpoints.dart';
import 'package:selfprivacy/ui/router/router.dart'; import 'package:selfprivacy/ui/router/router.dart';
@RoutePage()
class MorePage extends StatelessWidget { class MorePage extends StatelessWidget {
const MorePage({super.key}); const MorePage({super.key});

View file

@ -5,6 +5,7 @@ import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
import 'package:selfprivacy/ui/router/router.dart'; import 'package:selfprivacy/ui/router/router.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
@RoutePage()
class OnboardingPage extends StatefulWidget { class OnboardingPage extends StatefulWidget {
const OnboardingPage({super.key}); const OnboardingPage({super.key});

View file

@ -16,6 +16,7 @@ import 'package:selfprivacy/utils/breakpoints.dart';
GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
@RoutePage()
class ProvidersPage extends StatefulWidget { class ProvidersPage extends StatefulWidget {
const ProvidersPage({super.key}); const ProvidersPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -11,6 +12,7 @@ import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:selfprivacy/ui/pages/recovery_key/recovery_key_receiving.dart'; import 'package:selfprivacy/ui/pages/recovery_key/recovery_key_receiving.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart';
@RoutePage()
class RecoveryKeyPage extends StatefulWidget { class RecoveryKeyPage extends StatefulWidget {
const RecoveryKeyPage({super.key}); const RecoveryKeyPage({super.key});

View file

@ -8,6 +8,7 @@ import 'package:selfprivacy/ui/router/root_destinations.dart';
import 'package:selfprivacy/ui/router/router.dart'; import 'package:selfprivacy/ui/router/router.dart';
@RoutePage()
class RootPage extends StatefulWidget implements AutoRouteWrapper { class RootPage extends StatefulWidget implements AutoRouteWrapper {
const RootPage({super.key}); const RootPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:cubit_form/cubit_form.dart'; import 'package:cubit_form/cubit_form.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -32,6 +33,7 @@ part 'time_zone/time_zone.dart';
var navigatorKey = GlobalKey<NavigatorState>(); var navigatorKey = GlobalKey<NavigatorState>();
@RoutePage()
class ServerDetailsScreen extends StatefulWidget { class ServerDetailsScreen extends StatefulWidget {
const ServerDetailsScreen({super.key}); const ServerDetailsScreen({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart';
@ -16,6 +17,7 @@ import 'package:selfprivacy/ui/helpers/modals.dart';
import 'package:selfprivacy/ui/pages/root_route.dart'; import 'package:selfprivacy/ui/pages/root_route.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart';
@RoutePage()
class ServicesMigrationPage extends StatefulWidget { class ServicesMigrationPage extends StatefulWidget {
const ServicesMigrationPage({ const ServicesMigrationPage({
required this.services, required this.services,

View file

@ -10,6 +10,7 @@ import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:selfprivacy/logic/models/disk_status.dart'; import 'package:selfprivacy/logic/models/disk_status.dart';
@RoutePage()
class ExtendingVolumePage extends StatefulWidget { class ExtendingVolumePage extends StatefulWidget {
const ExtendingVolumePage({ const ExtendingVolumePage({
required this.diskVolumeToResize, required this.diskVolumeToResize,

View file

@ -11,6 +11,7 @@ import 'package:selfprivacy/logic/models/disk_status.dart';
import 'package:selfprivacy/ui/components/storage_list_items/server_storage_list_item.dart'; import 'package:selfprivacy/ui/components/storage_list_items/server_storage_list_item.dart';
import 'package:selfprivacy/ui/router/router.dart'; import 'package:selfprivacy/ui/router/router.dart';
@RoutePage()
class ServerStoragePage extends StatefulWidget { class ServerStoragePage extends StatefulWidget {
const ServerStoragePage({ const ServerStoragePage({
required this.diskStatus, required this.diskStatus,

View file

@ -12,6 +12,7 @@ import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart';
import 'package:selfprivacy/ui/router/router.dart'; import 'package:selfprivacy/ui/router/router.dart';
import 'package:selfprivacy/utils/launch_url.dart'; import 'package:selfprivacy/utils/launch_url.dart';
@RoutePage()
class ServicePage extends StatefulWidget { class ServicePage extends StatefulWidget {
const ServicePage({required this.serviceId, super.key}); const ServicePage({required this.serviceId, super.key});

View file

@ -16,6 +16,7 @@ import 'package:selfprivacy/utils/breakpoints.dart';
import 'package:selfprivacy/utils/launch_url.dart'; import 'package:selfprivacy/utils/launch_url.dart';
import 'package:selfprivacy/utils/ui_helpers.dart'; import 'package:selfprivacy/utils/ui_helpers.dart';
@RoutePage()
class ServicesPage extends StatefulWidget { class ServicesPage extends StatefulWidget {
const ServicesPage({super.key}); const ServicesPage({super.key});

View file

@ -23,6 +23,7 @@ import 'package:selfprivacy/ui/pages/setup/recovering/recovery_routing.dart';
import 'package:selfprivacy/ui/router/router.dart'; import 'package:selfprivacy/ui/router/router.dart';
import 'package:selfprivacy/utils/breakpoints.dart'; import 'package:selfprivacy/utils/breakpoints.dart';
@RoutePage()
class InitializingPage extends StatelessWidget { class InitializingPage extends StatelessWidget {
const InitializingPage({super.key}); const InitializingPage({super.key});

View file

@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:cubit_form/cubit_form.dart'; import 'package:cubit_form/cubit_form.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -17,6 +18,7 @@ import 'package:selfprivacy/ui/pages/setup/recovering/recovery_server_provider_c
import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_select.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recovery_method_select.dart';
import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart';
@RoutePage()
class RecoveryRouting extends StatelessWidget { class RecoveryRouting extends StatelessWidget {
const RecoveryRouting({super.key}); const RecoveryRouting({super.key});

View file

@ -1,5 +1,6 @@
part of 'users.dart'; part of 'users.dart';
@RoutePage()
class NewUserPage extends StatelessWidget { class NewUserPage extends StatelessWidget {
const NewUserPage({super.key}); const NewUserPage({super.key});

View file

@ -1,5 +1,6 @@
part of 'users.dart'; part of 'users.dart';
@RoutePage()
class UserDetailsPage extends StatelessWidget { class UserDetailsPage extends StatelessWidget {
const UserDetailsPage({ const UserDetailsPage({
required this.login, required this.login,

View file

@ -33,6 +33,7 @@ part 'user.dart';
part 'user_details.dart'; part 'user_details.dart';
part 'reset_password.dart'; part 'reset_password.dart';
@RoutePage()
class UsersPage extends StatelessWidget { class UsersPage extends StatelessWidget {
const UsersPage({super.key}); const UsersPage({super.key});

View file

@ -41,65 +41,67 @@ Widget fadeThroughTransition(
child: child, child: child,
); );
@MaterialAutoRouter( @AutoRouterConfig(
// transitionsBuilder: fadeThroughTransition, // transitionsBuilder: fadeThroughTransition,
replaceInRouteName: 'Page|Screen|Routing,Route', replaceInRouteName: 'Page|Screen|Routing,Route',
routes: <AutoRoute>[
AutoRoute(
page: OnboardingPage,
),
AutoRoute(page: InitializingPage),
AutoRoute(page: RecoveryRouting),
AutoRoute(
page: RootPage,
initial: true,
children: [
CustomRoute(
page: ProvidersPage,
usesPathAsKey: true,
initial: true,
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
CustomRoute(
page: ServicesPage,
usesPathAsKey: true,
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
CustomRoute(
page: UsersPage,
usesPathAsKey: true,
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
CustomRoute(
page: MorePage,
usesPathAsKey: true,
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
AutoRoute(page: AppSettingsPage),
AutoRoute(page: UserDetailsPage),
AutoRoute(page: NewUserPage),
AutoRoute(page: RecoveryKeyPage),
AutoRoute(page: DevicesScreen),
AutoRoute(page: AboutApplicationPage),
AutoRoute(page: DeveloperSettingsPage),
AutoRoute(page: ServicePage),
AutoRoute(page: ServerDetailsScreen),
AutoRoute(page: DnsDetailsPage),
AutoRoute(page: BackupDetailsPage),
AutoRoute(page: ServerStoragePage),
AutoRoute(page: ExtendingVolumePage),
],
),
AutoRoute(page: ServicesMigrationPage),
AutoRoute(page: ConsolePage),
],
) )
class RootRouter extends _$RootRouter { class RootRouter extends _$RootRouter {
RootRouter(GlobalKey<NavigatorState> super.navigatorKey); RootRouter(GlobalKey<NavigatorState> super.navigatorKey);
@override
RouteType get defaultRouteType => const RouteType.material();
@override
final List<AutoRoute> routes = [
AutoRoute(page: OnboardingRoute.page),
AutoRoute(page: InitializingRoute.page),
AutoRoute(page: RecoveryRoute.page),
AutoRoute(
page: RootRoute.page,
path: '/',
children: [
CustomRoute(
page: ProvidersRoute.page,
usesPathAsKey: true,
path: '',
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
CustomRoute(
page: ServicesRoute.page,
usesPathAsKey: true,
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
CustomRoute(
page: UsersRoute.page,
usesPathAsKey: true,
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
CustomRoute(
page: MoreRoute.page,
usesPathAsKey: true,
transitionsBuilder: fadeThroughTransition,
durationInMilliseconds: 400,
),
AutoRoute(page: AppSettingsRoute.page),
AutoRoute(page: UserDetailsRoute.page),
AutoRoute(page: NewUserRoute.page),
AutoRoute(page: RecoveryKeyRoute.page),
AutoRoute(page: DevicesRoute.page),
AutoRoute(page: AboutApplicationRoute.page),
AutoRoute(page: DeveloperSettingsRoute.page),
AutoRoute(page: ServiceRoute.page),
AutoRoute(page: ServerDetailsRoute.page),
AutoRoute(page: DnsDetailsRoute.page),
AutoRoute(page: BackupDetailsRoute.page),
AutoRoute(page: ServerStorageRoute.page),
AutoRoute(page: ExtendingVolumeRoute.page),
],
),
AutoRoute(page: ServicesMigrationRoute.page),
AutoRoute(page: ConsoleRoute.page),
];
} }
// Function to map route names to route titles // Function to map route names to route titles

File diff suppressed because it is too large Load diff