516 lines
18 KiB
Dart
516 lines
18 KiB
Dart
import 'package:account/account.dart';
|
|
import 'package:activity/activity.dart';
|
|
import 'package:auth/auth.dart';
|
|
import 'package:legacy_auth/legacy_auth.dart';
|
|
import 'package:customer_service/customer_service.dart';
|
|
import 'package:dashboard_shell/dashboard_builder.dart';
|
|
import 'package:device_management/device_management.dart';
|
|
import 'package:control_panel/control_panel.dart';
|
|
import 'package:legacy_dashboard_shell/legacy_dashboard_builder.dart';
|
|
import 'package:location/location.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:home/home.dart';
|
|
import 'package:navigation/navigation.dart';
|
|
import 'package:notifications/notifications.dart';
|
|
import 'package:payments/payments.dart';
|
|
import 'package:profile/profile.dart';
|
|
import 'package:settings/settings.dart';
|
|
import 'package:splash/splash.dart';
|
|
|
|
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
final _legacyControlPanelNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'legacyControlPanel');
|
|
final _legacyDeviceMgmtNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'legacyDeviceMgmt');
|
|
final _legacyLocationNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'legacyLocation');
|
|
final _legacyChatNavKey = GlobalKey<NavigatorState>(debugLabel: 'legacyChat');
|
|
final _legacySettingsNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'legacySettings');
|
|
|
|
final _dashboardHomeNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'dashboardHome');
|
|
final _dashboardActivityNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'dashboardActivity');
|
|
final _dashboardNotificationsNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'dashboardNotifications');
|
|
final _dashboardProfileNavKey =
|
|
GlobalKey<NavigatorState>(debugLabel: 'dashboardProfile');
|
|
|
|
late final GoRouter appRouter;
|
|
|
|
void configureAppRouter() {
|
|
appRouter = GoRouter(
|
|
navigatorKey: rootNavigatorKey,
|
|
initialLocation: AppRoutes.splash,
|
|
debugLogDiagnostics: true,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.splash,
|
|
name: 'splash',
|
|
pageBuilder: SplashBuilder().buildPage,
|
|
),
|
|
StatefulShellRoute.indexedStack(
|
|
builder: (context, state, navShell) {
|
|
return LegacyDashboardBuilder().build(context, navShell);
|
|
},
|
|
branches: [
|
|
StatefulShellBranch(
|
|
navigatorKey: _legacyControlPanelNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.controlPanel,
|
|
name: 'control_panel',
|
|
pageBuilder: const ControlPanelBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'customer_service',
|
|
name: 'customer_service',
|
|
pageBuilder: CustomerServiceBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'account_settings',
|
|
name: 'account_settings',
|
|
pageBuilder: AccountSettingsBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'personal_data',
|
|
name: 'personal_data',
|
|
pageBuilder: PersonalDataBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'change_password',
|
|
name: 'change_password',
|
|
pageBuilder: ChangePasswordBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'linked_devices',
|
|
name: 'linked_devices',
|
|
pageBuilder: LinkedDevicesBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'app_users',
|
|
name: 'app_users',
|
|
pageBuilder: AppUsersBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'delete_account',
|
|
name: 'delete_account',
|
|
pageBuilder: DeleteAccountBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
navigatorKey: _legacyDeviceMgmtNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.deviceManagement,
|
|
name: 'device_management',
|
|
pageBuilder: DeviceManagementBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'scheduled_activities',
|
|
name: 'scheduled_activities',
|
|
pageBuilder: const ScheduledActivitiesBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'contacts',
|
|
name: 'contacts',
|
|
pageBuilder: const ContactsBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'edit/:contactId',
|
|
name: 'edit_contact',
|
|
pageBuilder: const EditContactBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
GoRoute(
|
|
path: 'health',
|
|
name: 'health',
|
|
pageBuilder: const HealthBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'remote_connection',
|
|
name: 'remote_connection',
|
|
pageBuilder: RemoteConnectionBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'locate_device',
|
|
name: 'locate_device',
|
|
pageBuilder: LocateDeviceBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'rewards',
|
|
name: 'rewards',
|
|
pageBuilder: RewardsBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'activity_meter',
|
|
name: 'activity_meter',
|
|
pageBuilder: const ActivityMeterBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'apps_use',
|
|
name: 'apps_use',
|
|
pageBuilder: const AppsUseBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'volume_control',
|
|
name: 'volume_control',
|
|
pageBuilder: const VolumeControlBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'call_history',
|
|
name: 'call_history',
|
|
pageBuilder: const CallHistoryBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
navigatorKey: _legacyLocationNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.legacyLocation,
|
|
name: 'legacy_location',
|
|
pageBuilder: const LocationBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
// TODO: Añadir branch para Chat (tab 4)
|
|
StatefulShellBranch(
|
|
navigatorKey: _legacyChatNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: '${AppRoutes.legacyDashboard}/chat',
|
|
name: 'legacy_chat',
|
|
pageBuilder: (context, state) => MaterialPage<void>(
|
|
key: state.pageKey,
|
|
child: const Scaffold(
|
|
body: Center(child: Text('Chat - Coming soon')),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
navigatorKey: _legacySettingsNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.settings,
|
|
name: 'settings',
|
|
pageBuilder: SettingsBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'alarm',
|
|
name: 'alarm',
|
|
pageBuilder: AlarmBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'remote_management',
|
|
name: 'remote_management',
|
|
pageBuilder: RemoteManagementBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'sos_agenda',
|
|
name: 'sos_agenda',
|
|
pageBuilder: SosContactsBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'sound',
|
|
name: 'sound',
|
|
pageBuilder: SoundBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'sync_clock',
|
|
name: 'sync_clock',
|
|
pageBuilder: SyncClockBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'app_store',
|
|
name: 'app_store',
|
|
pageBuilder: AppStoreBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'battery',
|
|
name: 'battery',
|
|
pageBuilder: BatteryBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'block_phone',
|
|
name: 'block_phone',
|
|
pageBuilder: BlockPhoneBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'disable_functions',
|
|
name: 'disable_functions',
|
|
pageBuilder: DisableFunctionsBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'language',
|
|
name: 'language',
|
|
pageBuilder: LanguageBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'legacy_notifications',
|
|
name: 'legacy_notifications',
|
|
pageBuilder: LegacyNotificationsBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'remote_on_off',
|
|
name: 'remote_on_off',
|
|
pageBuilder: RemoteOnOffBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'sms_alert',
|
|
name: 'sms_alert',
|
|
pageBuilder: SmsAlertBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'timezone',
|
|
name: 'timezone',
|
|
pageBuilder: TimezoneBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'wifi_settings',
|
|
name: 'wifi_settings',
|
|
pageBuilder: WifiSettingsBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
|
|
GoRoute(
|
|
path: AppRoutes.login,
|
|
name: 'login',
|
|
pageBuilder: LoginBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.scaTreezor,
|
|
name: 'sca_treezor',
|
|
pageBuilder: SCATreezorBuilder().buildPage,
|
|
),
|
|
|
|
GoRoute(
|
|
path: AppRoutes.signup,
|
|
name: 'signup',
|
|
pageBuilder: SignupBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.onboarding,
|
|
name: 'onboarding',
|
|
pageBuilder: OnboardingBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.linkPhone,
|
|
name: 'request_link_phone',
|
|
pageBuilder: RequestLinkPhoneBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.phoneCode,
|
|
name: 'Verify_link_phone_code',
|
|
pageBuilder: VerifyLinkPhoneCodeBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.recoverPassword,
|
|
name: 'recover_password',
|
|
pageBuilder: RequestRecoveryBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.deviceSetup,
|
|
name: 'device_setup',
|
|
pageBuilder: DeviceSetupBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.legacyLogin,
|
|
name: 'legacy_login',
|
|
pageBuilder: LegacyLoginBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.legacySignup,
|
|
name: 'legacy_signup',
|
|
pageBuilder: LegacySignupBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.legacyOnboarding,
|
|
name: 'legacy_onboarding',
|
|
pageBuilder: LegacyOnboardingBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.legacyLinkPhone,
|
|
name: 'legacy_request_link_phone',
|
|
pageBuilder: LegacyRequestLinkPhoneBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.legacyPhoneCode,
|
|
name: 'legacy_verify_link_phone_code',
|
|
pageBuilder: LegacyVerifyLinkPhoneCodeBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.legacyRecoverPassword,
|
|
name: 'legacy_recover_password',
|
|
pageBuilder: LegacyRequestRecoveryBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.legacyDeviceSetup,
|
|
name: 'legacy_device_setup',
|
|
pageBuilder: LegacyDeviceSetupBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.hipayWebView,
|
|
name: 'hipay_webview',
|
|
pageBuilder: const HiPayWebViewBuilder().buildPage,
|
|
),
|
|
StatefulShellRoute.indexedStack(
|
|
builder: (context, state, navShell) {
|
|
return DashboardBuilder().build(context, navShell);
|
|
},
|
|
branches: [
|
|
StatefulShellBranch(
|
|
navigatorKey: _dashboardHomeNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.dashboardHome,
|
|
name: 'home',
|
|
pageBuilder: const HomeBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'child-wallet/:childWalletId',
|
|
name: 'home_child_wallet',
|
|
pageBuilder: const ChildWalletBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'allowance',
|
|
name: 'home_allowance',
|
|
pageBuilder: const AllowanceBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'deposit',
|
|
name: 'home_deposit',
|
|
pageBuilder: const DepositBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'lock-card',
|
|
name: 'home_lock_card',
|
|
pageBuilder: const LockCardBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'limits',
|
|
name: 'home_limits',
|
|
pageBuilder: const LimitsBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'goals',
|
|
name: 'home_goals',
|
|
pageBuilder: const GoalsBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'extract',
|
|
name: 'home_extract',
|
|
pageBuilder: const ExtractBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'edit',
|
|
name: 'home_edit_child_profile',
|
|
pageBuilder:
|
|
const EditChildProfileBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'set-pin',
|
|
name: 'home_set_card_pin',
|
|
pageBuilder:
|
|
const SetCardPinBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'change-pin',
|
|
name: 'home_change_card_pin',
|
|
pageBuilder:
|
|
const ChangeCardPinBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'renew-card',
|
|
name: 'home_renew_card',
|
|
pageBuilder:
|
|
const RenewCardBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
navigatorKey: _dashboardActivityNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.dashboardActivity,
|
|
name: 'activity',
|
|
pageBuilder: const ActivityBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
navigatorKey: _dashboardNotificationsNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.dashboardNotifications,
|
|
name: 'notifications',
|
|
pageBuilder: const NotificationsBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
StatefulShellBranch(
|
|
navigatorKey: _dashboardProfileNavKey,
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.dashboardProfile,
|
|
name: 'profile',
|
|
pageBuilder: const ProfileBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'payout',
|
|
name: 'profile_payout',
|
|
pageBuilder: const PayoutBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'settings',
|
|
name: 'profile_settings',
|
|
pageBuilder: const ProfileSettingsBuilder().buildPage,
|
|
routes: [
|
|
GoRoute(
|
|
path: 'edit-personal-data',
|
|
name: 'profile_edit_personal_data',
|
|
pageBuilder:
|
|
const EditPersonalDataBuilder().buildPage,
|
|
),
|
|
GoRoute(
|
|
path: 'payment-methods',
|
|
name: 'profile_payment_methods',
|
|
pageBuilder: const PaymentMethodsBuilder().buildPage,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
|
|
GetIt.I<NavigationContract>().setRouter(appRouter);
|
|
}
|