From 644d1c2abee4db3b4cef3d53ff97d5476ab9a466 Mon Sep 17 00:00:00 2001 From: JulianAlcala Date: Mon, 9 Mar 2026 02:28:31 +0100 Subject: [PATCH] Legacy modules refactor: auth, control panel, location module, and session persistence --- .idea/modules.xml | 1 + apps/mobile_app/config/staging.json | 4 +- .../mobile_app/lib/navigation/app_router.dart | 27 +- apps/mobile_app/pubspec.lock | 7 + apps/mobile_app/pubspec.yaml | 2 + apps/mobile_app/pubspec_overrides.yaml | 4 +- .../control_panel/lib/control_panel.dart | 4 +- .../control_panel_remote_datasource.dart | 4 +- .../control_panel_remote_datasource_impl.dart | 188 +-- .../models/get_devices_response_model.dart | 76 +- .../get_devices_response_model.freezed.dart | 162 +- .../models/get_devices_response_model.g.dart | 40 +- .../latest_positions_response_model.dart | 6 +- .../control_panel_repository_impl.dart | 6 +- .../domain/entities/address_entity.dart | 0 .../entities/address_entity.freezed.dart | 0 .../domain/entities/network_entity.dart | 0 .../entities/network_entity.freezed.dart | 0 .../domain/entities/position_entity.dart | 4 +- .../entities/position_entity.freezed.dart | 0 .../control_panel_repository.dart | 5 +- .../lib/src/core/utils/battery_utils.dart | 11 + .../lib/src/core/utils/date_format_utils.dart | 9 + .../lib/src/core/utils/dio_error_mapper.dart | 57 + .../control_panel/control_panel_builder.dart | 2 +- .../entities/get_devices_request_entity.dart | 10 - .../get_devices_request_entity.freezed.dart | 271 ---- .../domain/get_devices_use_case.dart | 5 - .../domain/get_devices_use_case_impl.dart | 13 - .../domain/get_latest_positions_use_case.dart | 5 - .../get_latest_positions_use_case_impl.dart | 14 - .../presentation/control_panel_screen.dart | 197 +-- .../get_devices_use_case_provider.dart | 10 - ...et_latest_positions_use_case_provider.dart | 10 - .../state/control_panel_view_model.dart | 140 +- .../state/control_panel_view_state.dart | 6 +- .../control_panel_view_state.freezed.dart | 46 +- .../lib/src/shared/widgets/device_map.dart | 198 +++ .../datasource/auth_remote_datasource.dart | 36 - .../auth_remote_datasource_impl.dart | 345 +--- .../device_setup_remote_datasource.dart | 13 + .../device_setup_remote_datasource_impl.dart | 45 + .../datasource/login_remote_datasource.dart | 21 + .../login_remote_datasource_impl.dart | 77 + .../datasource/sign_up_remote_datasource.dart | 8 + .../sign_up_remote_datasource_impl.dart | 43 + .../models/child_profile_response_model.dart | 56 - .../child_profile_response_model.freezed.dart | 588 ------- .../child_profile_response_model.g.dart | 50 - .../data/models/device_response_model.dart | 41 + .../models/device_response_model.freezed.dart | 626 ++++++++ .../data/models/device_response_model.g.dart | 62 + .../data/models/sign_up_response_model.dart | 13 +- .../sign_up_response_model.freezed.dart | 303 +--- .../data/models/sign_up_response_model.g.dart | 12 +- .../repositories/auth_repository_impl.dart | 108 -- .../device_setup_repository_impl.dart | 33 + .../repositories/login_repository_impl.dart | 37 + .../repositories/sign_up_repository_impl.dart | 21 + .../domain/repositories/auth_repository.dart | 34 - .../repositories/device_setup_repository.dart | 11 + .../domain/repositories/login_repository.dart | 21 + .../repositories/sign_up_repository.dart} | 6 +- ...vice_setup_remote_datasource_provider.dart | 10 + .../device_setup_repository_provider.dart | 10 + .../login_remote_datasource_provider.dart | 10 + .../providers/login_repository_provider.dart | 9 + .../sign_up_remote_datasource_provider.dart | 10 + .../sign_up_repository_provider.dart | 9 + .../lib/src/core/utils/date_format_utils.dart | 25 + .../lib/src/core/utils/dio_error_mapper.dart | 57 + .../lib/src/core/utils/text_format_utils.dart | 34 + .../domain/create_child_profile_use_case.dart | 17 - .../create_child_profile_use_case_impl.dart | 38 - .../domain/entities/child_profile_entity.dart | 27 - .../child_profile_entity.freezed.dart | 576 ------- .../presentation/add_kid_step_mapper.dart | 19 - .../presentation/contact_screen.dart | 74 - .../presentation/device_setup_screen.dart | 73 +- .../presentation/enums/add_kid_main_step.dart | 1 - .../presentation/enums/add_kid_step.dart | 21 +- .../presentation/enums/scan_link_step.dart | 1 - ...reate_child_profile_use_case_provider.dart | 10 - .../state/device_setup_view_model.dart | 224 +-- .../state/device_setup_view_state.dart | 9 +- .../device_setup_view_state.freezed.dart | 72 +- .../device_setup/presentation/step_body.dart | 10 +- .../presentation/steps/allowance_step.dart | 40 - .../presentation/steps/intro_step.dart | 43 +- .../presentation/steps/link_info_step.dart | 18 +- .../presentation/steps/profile_step.dart | 82 +- .../steps/scan_strap_and_watch_step.dart | 210 --- .../presentation/steps/scan_watch_step.dart | 113 ++ .../presentation/steps/success_step.dart | 66 - .../presentation/success_screen.dart | 43 +- .../presentation/widgets/flow_footer.dart | 13 +- .../presentation/widgets/link_info_item.dart | 10 +- .../presentation/widgets/number_circle.dart | 17 +- .../presentation/widgets/numbered_steps.dart | 51 +- .../widgets/scan_link_steps_indicator.dart | 60 - .../presentation/widgets/step_circle.dart | 34 - .../features/login/domain/login_use_case.dart | 8 - .../login/domain/login_use_case_impl.dart | 17 - .../domain/two_fa_request_code_use_case.dart | 6 - .../two_fa_request_code_use_case_impl.dart | 16 - .../domain/two_fa_send_code_use_case.dart | 7 - .../two_fa_send_code_use_case_impl.dart | 21 - .../login/presentation/login_screen.dart | 7 +- .../mixins/login_form_validation.dart | 29 + .../providers/login_provider.dart | 9 - .../two_fa_request_code_provider.dart | 10 - .../providers/two_fa_send_code_provider.dart | 11 - .../presentation/state/login_view_model.dart | 90 +- .../presentation/state/login_view_state.dart | 1 + .../state/login_view_state.freezed.dart | 39 +- .../presentation/onboarding_screen.dart | 19 +- .../presentation/onboarding_view_model.dart | 14 +- .../presentation/onboarding_view_state.dart | 2 + .../onboarding_view_state.freezed.dart | 46 +- .../generate_two_fa_sign_up_use_case.dart | 5 - ...generate_two_fa_sign_up_use_case_impl.dart | 16 - .../sign_up/domain/sign_up_use_case_impl.dart | 15 - .../verify_two_fa_code_sign_up_use_case.dart | 6 - ...ify_two_fa_code_sign_up_use_case_impl.dart | 15 - .../mappers/sign_up_view_state_mapper.dart | 44 - .../mixins/sign_up_form_validation.dart | 61 + .../generate_two_fa_sign_up_provider.dart | 10 - .../providers/sign_up_provider.dart | 9 - .../verify_two_fa_code_sign_up_provider.dart | 10 - .../screens/secret_code_screen.dart | 281 ---- .../screens/sign_up_password_screen.dart | 97 +- .../sign_up/presentation/sign_up_screen.dart | 1 + .../sign_up/presentation/sign_up_steps.dart | 1 + .../state/sign_up_view_model.dart | 665 ++++---- .../src/widgets/layouts/sign_up_layout.dart | 15 + .../legacy/modules/legacy_auth/pubspec.yaml | 2 - .../legacy/modules/location/lib/location.dart | 1 + .../features/location/location_builder.dart | 14 + .../presentation/location_screen.dart | 54 + .../modules/location/melos_location.iml | 29 + modules/legacy/modules/location/pubspec.lock | 1407 +++++++++++++++++ modules/legacy/modules/location/pubspec.yaml | 30 + .../modules/location/pubspec_overrides.yaml | 40 + .../legacy_shared_remote_datasource.dart | 2 +- .../legacy_shared_remote_datasource_impl.dart | 60 +- .../get_logged_user_response_model.dart | 23 +- ...et_logged_user_response_model.freezed.dart | 50 +- .../get_logged_user_response_model.g.dart | 10 +- .../legacy_shared_repository.dart | 2 +- .../legacy_shared_repository_impl.dart | 4 +- .../src/providers/logged_user_provider.dart | 2 +- .../lib/src/widgets/layouts/page_layout.dart | 6 +- .../packages/legacy_shared/pubspec.lock | 6 +- .../packages/legacy_shared/pubspec.yaml | 5 + .../lib/src/dropdowns/dropdown.dart | 3 + .../antelop/antelop/maven-metadata.xml | 2 +- .../antelop/antelop/maven-metadata.xml.md5 | 2 +- .../antelop/antelop/maven-metadata.xml.sha1 | 2 +- packages/navigation/lib/app_routes.dart | 1 + .../network/treezor_token_interceptor.dart | 9 +- packages/sf_localizations/assets/l10n/de.json | 25 +- packages/sf_localizations/assets/l10n/en.json | 25 +- packages/sf_localizations/assets/l10n/es.json | 25 +- packages/sf_localizations/assets/l10n/fr.json | 25 +- packages/sf_localizations/assets/l10n/it.json | 25 +- packages/sf_localizations/assets/l10n/pt.json | 25 +- .../lib/src/generated/i18n.dart | 27 + 167 files changed, 4811 insertions(+), 5035 deletions(-) rename modules/legacy/modules/control_panel/lib/src/{features/control_panel => core}/domain/entities/address_entity.dart (100%) rename modules/legacy/modules/control_panel/lib/src/{features/control_panel => core}/domain/entities/address_entity.freezed.dart (100%) rename modules/legacy/modules/control_panel/lib/src/{features/control_panel => core}/domain/entities/network_entity.dart (100%) rename modules/legacy/modules/control_panel/lib/src/{features/control_panel => core}/domain/entities/network_entity.freezed.dart (100%) rename modules/legacy/modules/control_panel/lib/src/{features/control_panel => core}/domain/entities/position_entity.dart (79%) rename modules/legacy/modules/control_panel/lib/src/{features/control_panel => core}/domain/entities/position_entity.freezed.dart (100%) create mode 100644 modules/legacy/modules/control_panel/lib/src/core/utils/battery_utils.dart create mode 100644 modules/legacy/modules/control_panel/lib/src/core/utils/date_format_utils.dart create mode 100644 modules/legacy/modules/control_panel/lib/src/core/utils/dio_error_mapper.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.freezed.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case_impl.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case_impl.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_devices_use_case_provider.dart delete mode 100644 modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_latest_positions_use_case_provider.dart create mode 100644 modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource_impl.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource_impl.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.freezed.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.g.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.freezed.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.g.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/login_repository_impl.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/sign_up_repository_impl.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/login_repository.dart rename modules/legacy/modules/legacy_auth/lib/src/{features/sign_up/domain/sign_up_use_case.dart => core/domain/repositories/sign_up_repository.dart} (58%) create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_remote_datasource_provider.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_repository_provider.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/providers/login_remote_datasource_provider.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/providers/login_repository_provider.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_remote_datasource_provider.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_repository_provider.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/utils/date_format_utils.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/utils/dio_error_mapper.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/core/utils/text_format_utils.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case_impl.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.freezed.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/add_kid_step_mapper.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/contact_screen.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_main_step.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/scan_link_step.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/providers/create_child_profile_use_case_provider.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/allowance_step.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_strap_and_watch_step.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_watch_step.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/success_step.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/scan_link_steps_indicator.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/step_circle.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case_impl.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case_impl.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case_impl.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/mixins/login_form_validation.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/login_provider.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_request_code_provider.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_send_code_provider.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case_impl.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/sign_up_use_case_impl.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case_impl.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mappers/sign_up_view_state_mapper.dart create mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mixins/sign_up_form_validation.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/generate_two_fa_sign_up_provider.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/sign_up_provider.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/verify_two_fa_code_sign_up_provider.dart delete mode 100644 modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/secret_code_screen.dart create mode 100644 modules/legacy/modules/location/lib/location.dart create mode 100644 modules/legacy/modules/location/lib/src/features/location/location_builder.dart create mode 100644 modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart create mode 100644 modules/legacy/modules/location/melos_location.iml create mode 100644 modules/legacy/modules/location/pubspec.lock create mode 100644 modules/legacy/modules/location/pubspec.yaml create mode 100644 modules/legacy/modules/location/pubspec_overrides.yaml diff --git a/.idea/modules.xml b/.idea/modules.xml index 523fb975..ba0bef40 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -18,6 +18,7 @@ + diff --git a/apps/mobile_app/config/staging.json b/apps/mobile_app/config/staging.json index 9c7b64fa..86a4cc7a 100644 --- a/apps/mobile_app/config/staging.json +++ b/apps/mobile_app/config/staging.json @@ -1,5 +1,5 @@ { "env": "staging", - "apiBaseUrl": "https://api-neki-b2b.neki.es/gateway/api/", - "apiOrigin": "https://neki-b2b.neki.es" + "apiBaseUrl": "https://api-platform.pre.savefamilygps.net/gateway/api/", + "apiOrigin": "https://platform.pre.savefamilygps.net/" } diff --git a/apps/mobile_app/lib/navigation/app_router.dart b/apps/mobile_app/lib/navigation/app_router.dart index 2ede078f..b74445aa 100644 --- a/apps/mobile_app/lib/navigation/app_router.dart +++ b/apps/mobile_app/lib/navigation/app_router.dart @@ -7,6 +7,7 @@ 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'; @@ -24,7 +25,7 @@ late final GoRouter appRouter; void configureAppRouter() { appRouter = GoRouter( navigatorKey: rootNavigatorKey, - initialLocation: AppRoutes.legacyLogin, + initialLocation: AppRoutes.legacyOnboarding, debugLogDiagnostics: true, routes: [ GoRoute( @@ -111,6 +112,30 @@ void configureAppRouter() { ), ], ), + StatefulShellBranch( + routes: [ + GoRoute( + path: AppRoutes.legacyLocation, + name: 'legacy_location', + pageBuilder: const LocationBuilder().buildPage, + ), + ], + ), + // TODO: Añadir branch para Chat (tab 4) + StatefulShellBranch( + routes: [ + GoRoute( + path: '${ AppRoutes.legacyDashboard}/chat', + name: 'legacy_chat', + pageBuilder: (context, state) => MaterialPage( + key: state.pageKey, + child: const Scaffold( + body: Center(child: Text('Chat - Coming soon')), + ), + ), + ), + ], + ), ], ), GoRoute( diff --git a/apps/mobile_app/pubspec.lock b/apps/mobile_app/pubspec.lock index 5a913152..ba2d4ca1 100644 --- a/apps/mobile_app/pubspec.lock +++ b/apps/mobile_app/pubspec.lock @@ -727,6 +727,13 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + location: + dependency: "direct main" + description: + path: "../../modules/legacy/modules/location" + relative: true + source: path + version: "1.0.0+1" logger: dependency: transitive description: diff --git a/apps/mobile_app/pubspec.yaml b/apps/mobile_app/pubspec.yaml index d8968f64..cae23142 100644 --- a/apps/mobile_app/pubspec.yaml +++ b/apps/mobile_app/pubspec.yaml @@ -61,6 +61,8 @@ dependencies: path: ../../modules/legacy/modules/account device_management: path: ../../modules/legacy/modules/device_management + location: + path: ../../modules/legacy/modules/location legacy_auth: path: ../../modules/legacy/modules/legacy_auth #packages dependencies go here diff --git a/apps/mobile_app/pubspec_overrides.yaml b/apps/mobile_app/pubspec_overrides.yaml index 2a761c30..4b31be77 100644 --- a/apps/mobile_app/pubspec_overrides.yaml +++ b/apps/mobile_app/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: account,activity,auth,customer_service,dashboard_shell,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_dashboard_shell,legacy_shared,navigation,notifications,payments,profile,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,splash,utils,control_panel,device_management,legacy_auth +# melos_managed_dependency_overrides: account,activity,auth,customer_service,dashboard_shell,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_dashboard_shell,legacy_shared,navigation,notifications,payments,profile,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,splash,utils,control_panel,device_management,legacy_auth,location dependency_overrides: account: path: ../../modules/legacy/modules/account @@ -28,6 +28,8 @@ dependency_overrides: path: ../../modules/legacy/modules/legacy_dashboard_shell legacy_shared: path: ../../modules/legacy/packages/legacy_shared + location: + path: ../../modules/legacy/modules/location navigation: path: ../../packages/navigation notifications: diff --git a/modules/legacy/modules/control_panel/lib/control_panel.dart b/modules/legacy/modules/control_panel/lib/control_panel.dart index f25a06fe..3935eb08 100644 --- a/modules/legacy/modules/control_panel/lib/control_panel.dart +++ b/modules/legacy/modules/control_panel/lib/control_panel.dart @@ -1 +1,3 @@ -export 'src/features/control_panel/control_panel_builder.dart'; \ No newline at end of file +export 'src/features/control_panel/control_panel_builder.dart'; +export 'src/features/control_panel/presentation/state/control_panel_view_model.dart'; +export 'src/shared/widgets/device_map.dart'; \ No newline at end of file diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource.dart b/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource.dart index bf947107..d61755e0 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource.dart @@ -1,8 +1,8 @@ -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; import 'package:legacy_shared/legacy_shared.dart'; abstract class ControlPanelRemoteDatasource { - Future> getDevices({required String userId}); + Future> getDevices(); Future> getLatestPositions({required String deviceId}); } diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart b/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart index 1dfb9609..96204fdd 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/datasource/control_panel_remote_datasource_impl.dart @@ -1,10 +1,9 @@ -import 'dart:convert'; - -import 'package:dio/dio.dart'; import 'package:control_panel/src/core/data/datasource/control_panel_remote_datasource.dart'; +import 'package:dio/dio.dart'; import 'package:control_panel/src/core/data/models/get_devices_response_model.dart'; import 'package:control_panel/src/core/data/models/latest_positions_response_model.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/utils/dio_error_mapper.dart'; import 'package:legacy_shared/legacy_shared.dart'; import 'package:sf_infrastructure/sf_infrastructure.dart'; @@ -14,181 +13,40 @@ class ControlPanelRemoteDatasourceImpl implements ControlPanelRemoteDatasource { final QuestiaRepository _repository; @override - Future> getDevices({required String userId}) async { - try { - /*final response = await _repository.get>( - '/$userId/devices', - ); - final data = response.data!['items']; - if (data == null || data.isEmpty) { - throw Exception('Empty response from /:userId/devices'); - } + Future> getDevices() async { + final response = await safeCall( + () => _repository.get>('/devices'), + 'Error getting devices', + ); - final model = GetDevicesResponseModel.fromJson(data);*/ - final model = GetDevicesResponseModel(items: [ - GetDevicesItemResponseModel( - id: '1', - identificator: '1111', - carrierName: 'Carlos', - phone: '111111111', - settings: GetDevicesSettingsResponseModel( - frequency: 0, - frequencyHeartRate: 0, - timezone: 0, - pedometer: true, - language: 'es', - alerts: [] - ), - protocol: '', - type: '', - connectionServer: '', - createdAt: 0, - flags: GetDevicesFlagsResponseModel( - isInOrOut: 'out', - geofenceId: '1', - isBatteryLow: false, - isDisconnect: false - ) - ), - GetDevicesItemResponseModel( - id: '2', - identificator: '1112', - carrierName: 'Ana', - phone: '222222222', - settings: GetDevicesSettingsResponseModel( - frequency: 0, - frequencyHeartRate: 0, - timezone: 0, - pedometer: true, - language: 'es', - alerts: [] - ), - protocol: '', - type: '', - connectionServer: '', - createdAt: 0, - flags: GetDevicesFlagsResponseModel( - isInOrOut: 'out', - geofenceId: '2', - isBatteryLow: false, - isDisconnect: false - ) - ), - ]); - return model.toEntity(); - } on DioException catch (error) { - throw _mapDioError( - error, - defaultMessage: error.message ?? 'Error getting devices', - ); + final data = response.data; + if (data == null || data.isEmpty) { + throw Exception('Empty response from /devices'); } + + final model = GetDevicesResponseModel.fromJson(data); + return model.toEntity(); } @override - Future> getLatestPositions({required String deviceId}) async { + Future> getLatestPositions({ + required String deviceId, + }) async { try { final response = await _repository.get>( '/positions/identificator/$deviceId/positions', ); - final data = response.data?['items'] ?? []; + + final data = response.data; if (data == null || data.isEmpty) { - throw Exception('Empty response from /identificator/:deviceId/positions'); + return []; } final model = LatestPositionsResponseModel.fromJson(data); - /*final model = LatestPositionsResponseModel(items: [ - LatestPositionsItemResponseModel( - latitude: 43.327116830678186, - longitude: -3.083269100434551, - address: LatestPositionsAddressResponseModel( - street: 'street', - city: 'city', - province: 'province', - state: 'state', - country: 'country', - ), - positionDate: DateTime.now().millisecondsSinceEpoch, - frequentPlace: false, - frequentPlaceName: '', - id: '1', - deviceIdentificator: deviceId, - hpe: 0, - ncell: 65, - type: 0, - createdAt: DateTime.now().millisecondsSinceEpoch, - positionDateOriginal: null, - message: '', - networks: [LatestPositionsNetworkResponseModel(SSID: 'SSID', BSSID: 'BSSID', signal: 'signal')], - ignore: false, - suspect: false - ), - LatestPositionsItemResponseModel( - latitude: 43.32729043118528, - longitude: -3.08320596406992, - address: LatestPositionsAddressResponseModel( - street: 'street', - city: 'city', - province: 'province', - state: 'state', - country: 'country', - ), - positionDate: DateTime.now().millisecondsSinceEpoch, - frequentPlace: true, - frequentPlaceName: 'La cafetería', - id: '2', - deviceIdentificator: deviceId, - hpe: 0, - ncell: 65, - type: 0, - createdAt: DateTime.now().millisecondsSinceEpoch, - positionDateOriginal: null, - message: '', - networks: [], - ignore: false, - suspect: false - ), - ]);*/ return model.toEntity(); - } on DioException catch (error) { - throw _mapDioError( - error, - defaultMessage: error.message ?? 'Error getting latest position', - ); + } on DioException catch (e) { + if (e.response?.statusCode == 404) return []; + throw mapDioError(e, defaultMessage: 'Error getting latest position'); } } } - -Exception _mapDioError(DioException error, {required String defaultMessage}) { - final apiMsg = _extractApiMessage(error.response?.data); - final msg = apiMsg ?? error.message ?? defaultMessage; - return Exception(msg); -} - -String? _extractApiMessage(Object? data) { - if (data == null) return null; - - if (data is Map) { - final errorObj = data['error']; - if (errorObj is Map && errorObj['message'] is String) { - return (errorObj['message'] as String).trim(); - } - if (data['message'] is String) { - return (data['message'] as String).trim(); - } - return null; - } - - if (data is String) { - final raw = data.trim(); - if (raw.isEmpty) return null; - - try { - final decoded = jsonDecode(raw); - return _extractApiMessage(decoded); - } catch (_) { - return raw; - } - } - - return null; -} diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.dart b/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.dart index 523daef1..d094b12e 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.dart @@ -1,4 +1,4 @@ -import 'package:legacy_shared/src/data/models/entities/device_entity.dart'; +import 'package:legacy_shared/legacy_shared.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'get_devices_response_model.freezed.dart'; @@ -17,18 +17,23 @@ abstract class GetDevicesResponseModel with _$GetDevicesResponseModel { @freezed abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel { const factory GetDevicesItemResponseModel({ - required String identificator, - required String carrierName, - required String phone, required String id, + required String identificator, + int? battery, + String? userId, + required GetDevicesFlagsResponseModel flags, + String? carrierGenre, + int? carrierBirthday, + int? carrierWeight, + int? carrierStepLength, + required String carrierName, + String? phone, required GetDevicesSettingsResponseModel settings, + required String connectionServer, required String protocol, required String type, - required String connectionServer, required int createdAt, - required GetDevicesFlagsResponseModel flags, - }) = - _GetDevicesItemResponseModel; + }) = _GetDevicesItemResponseModel; factory GetDevicesItemResponseModel.fromJson(Map json) => _$GetDevicesItemResponseModelFromJson(json); @@ -36,23 +41,34 @@ abstract class GetDevicesItemResponseModel with _$GetDevicesItemResponseModel { extension GetDevicesResponseModelMapper on GetDevicesResponseModel { List toEntity() { - return items.map((GetDevicesItemResponseModel item) => DeviceEntity( - identificator: item.identificator, - carrierName: item.carrierName, - phone: item.phone, - id: item.id, - settings: item.settings.toEntity(), - protocol: item.protocol, - type: item.type, - connectionServer: item.connectionServer, - createdAt: item.createdAt, - flags: item.flags.toEntity(), - )).toList(); + return items + .map( + (item) => DeviceEntity( + id: item.id, + identificator: item.identificator, + battery: item.battery, + userId: item.userId, + flags: item.flags.toEntity(), + carrierGenre: item.carrierGenre, + carrierBirthday: item.carrierBirthday, + carrierWeight: item.carrierWeight, + carrierStepLength: item.carrierStepLength, + carrierName: item.carrierName, + phone: item.phone, + settings: item.settings.toEntity(), + connectionServer: item.connectionServer, + protocol: item.protocol, + type: item.type, + createdAt: item.createdAt, + ), + ) + .toList(); } } @freezed -abstract class GetDevicesSettingsResponseModel with _$GetDevicesSettingsResponseModel { +abstract class GetDevicesSettingsResponseModel + with _$GetDevicesSettingsResponseModel { const factory GetDevicesSettingsResponseModel({ required int frequency, required int frequencyHeartRate, @@ -62,11 +78,14 @@ abstract class GetDevicesSettingsResponseModel with _$GetDevicesSettingsResponse required List alerts, }) = _GetDevicesSettingsResponseModel; - factory GetDevicesSettingsResponseModel.fromJson(Map json) => + factory GetDevicesSettingsResponseModel.fromJson( + Map json, + ) => _$GetDevicesSettingsResponseModelFromJson(json); } -extension GetDevicesSettingsResponseModelMapper on GetDevicesSettingsResponseModel { +extension GetDevicesSettingsResponseModelMapper + on GetDevicesSettingsResponseModel { DeviceSettingsEntity toEntity() { return DeviceSettingsEntity( frequency: frequency, @@ -80,15 +99,18 @@ extension GetDevicesSettingsResponseModelMapper on GetDevicesSettingsResponseMod } @freezed -abstract class GetDevicesFlagsResponseModel with _$GetDevicesFlagsResponseModel { +abstract class GetDevicesFlagsResponseModel + with _$GetDevicesFlagsResponseModel { const factory GetDevicesFlagsResponseModel({ required String isInOrOut, - required String geofenceId, + String? geofenceId, required bool isBatteryLow, required bool isDisconnect, }) = _GetDevicesFlagsResponseModel; - factory GetDevicesFlagsResponseModel.fromJson(Map json) => + factory GetDevicesFlagsResponseModel.fromJson( + Map json, + ) => _$GetDevicesFlagsResponseModelFromJson(json); } @@ -101,4 +123,4 @@ extension GetDevicesFlagsResponseModelMapper on GetDevicesFlagsResponseModel { isDisconnect: isDisconnect, ); } -} \ No newline at end of file +} diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.freezed.dart b/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.freezed.dart index 2473d450..3171ada7 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.freezed.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.freezed.dart @@ -284,7 +284,7 @@ as List, /// @nodoc mixin _$GetDevicesItemResponseModel { - String get identificator; String get carrierName; String get phone; String get id; GetDevicesSettingsResponseModel get settings; String get protocol; String get type; String get connectionServer; int get createdAt; GetDevicesFlagsResponseModel get flags; + String get id; String get identificator; int? get battery; String? get userId; GetDevicesFlagsResponseModel get flags; String? get carrierGenre; int? get carrierBirthday; int? get carrierWeight; int? get carrierStepLength; String get carrierName; String? get phone; GetDevicesSettingsResponseModel get settings; String get connectionServer; String get protocol; String get type; int get createdAt; /// Create a copy of GetDevicesItemResponseModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -297,16 +297,16 @@ $GetDevicesItemResponseModelCopyWith get copyWith = @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesItemResponseModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.id, id) || other.id == id)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.flags, flags) || other.flags == flags)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.flags, flags) || other.flags == flags)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,settings,protocol,type,connectionServer,createdAt,flags); +int get hashCode => Object.hash(runtimeType,id,identificator,battery,userId,flags,carrierGenre,carrierBirthday,carrierWeight,carrierStepLength,carrierName,phone,settings,connectionServer,protocol,type,createdAt); @override String toString() { - return 'GetDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)'; + return 'GetDevicesItemResponseModel(id: $id, identificator: $identificator, battery: $battery, userId: $userId, flags: $flags, carrierGenre: $carrierGenre, carrierBirthday: $carrierBirthday, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierName: $carrierName, phone: $phone, settings: $settings, connectionServer: $connectionServer, protocol: $protocol, type: $type, createdAt: $createdAt)'; } @@ -317,11 +317,11 @@ abstract mixin class $GetDevicesItemResponseModelCopyWith<$Res> { factory $GetDevicesItemResponseModelCopyWith(GetDevicesItemResponseModel value, $Res Function(GetDevicesItemResponseModel) _then) = _$GetDevicesItemResponseModelCopyWithImpl; @useResult $Res call({ - String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags + String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt }); -$GetDevicesSettingsResponseModelCopyWith<$Res> get settings;$GetDevicesFlagsResponseModelCopyWith<$Res> get flags; +$GetDevicesFlagsResponseModelCopyWith<$Res> get flags;$GetDevicesSettingsResponseModelCopyWith<$Res> get settings; } /// @nodoc @@ -334,39 +334,45 @@ class _$GetDevicesItemResponseModelCopyWithImpl<$Res> /// Create a copy of GetDevicesItemResponseModel /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? identificator = null,Object? carrierName = null,Object? phone = null,Object? id = null,Object? settings = null,Object? protocol = null,Object? type = null,Object? connectionServer = null,Object? createdAt = null,Object? flags = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? identificator = null,Object? battery = freezed,Object? userId = freezed,Object? flags = null,Object? carrierGenre = freezed,Object? carrierBirthday = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierName = null,Object? phone = freezed,Object? settings = null,Object? connectionServer = null,Object? protocol = null,Object? type = null,Object? createdAt = null,}) { return _then(_self.copyWith( -identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable -as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable -as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable -as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable -as GetDevicesSettingsResponseModel,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable +as String,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable +as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable +as String?,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable +as GetDevicesFlagsResponseModel,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable +as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable +as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable +as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable +as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable +as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable +as GetDevicesSettingsResponseModel,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable +as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as int,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable -as GetDevicesFlagsResponseModel, +as int, )); } /// Create a copy of GetDevicesItemResponseModel /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$GetDevicesSettingsResponseModelCopyWith<$Res> get settings { - - return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) { - return _then(_self.copyWith(settings: value)); - }); -}/// Create a copy of GetDevicesItemResponseModel -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') $GetDevicesFlagsResponseModelCopyWith<$Res> get flags { return $GetDevicesFlagsResponseModelCopyWith<$Res>(_self.flags, (value) { return _then(_self.copyWith(flags: value)); }); +}/// Create a copy of GetDevicesItemResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$GetDevicesSettingsResponseModelCopyWith<$Res> get settings { + + return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) { + return _then(_self.copyWith(settings: value)); + }); } } @@ -449,10 +455,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _GetDevicesItemResponseModel() when $default != null: -return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _: +return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _: return orElse(); } @@ -470,10 +476,10 @@ return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt) $default,) {final _that = this; switch (_that) { case _GetDevicesItemResponseModel(): -return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _: +return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _: throw StateError('Unexpected subclass'); } @@ -490,10 +496,10 @@ return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt)? $default,) {final _that = this; switch (_that) { case _GetDevicesItemResponseModel() when $default != null: -return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that.settings,_that.protocol,_that.type,_that.connectionServer,_that.createdAt,_that.flags);case _: +return $default(_that.id,_that.identificator,_that.battery,_that.userId,_that.flags,_that.carrierGenre,_that.carrierBirthday,_that.carrierWeight,_that.carrierStepLength,_that.carrierName,_that.phone,_that.settings,_that.connectionServer,_that.protocol,_that.type,_that.createdAt);case _: return null; } @@ -505,19 +511,25 @@ return $default(_that.identificator,_that.carrierName,_that.phone,_that.id,_that @JsonSerializable() class _GetDevicesItemResponseModel implements GetDevicesItemResponseModel { - const _GetDevicesItemResponseModel({required this.identificator, required this.carrierName, required this.phone, required this.id, required this.settings, required this.protocol, required this.type, required this.connectionServer, required this.createdAt, required this.flags}); + const _GetDevicesItemResponseModel({required this.id, required this.identificator, this.battery, this.userId, required this.flags, this.carrierGenre, this.carrierBirthday, this.carrierWeight, this.carrierStepLength, required this.carrierName, this.phone, required this.settings, required this.connectionServer, required this.protocol, required this.type, required this.createdAt}); factory _GetDevicesItemResponseModel.fromJson(Map json) => _$GetDevicesItemResponseModelFromJson(json); -@override final String identificator; -@override final String carrierName; -@override final String phone; @override final String id; +@override final String identificator; +@override final int? battery; +@override final String? userId; +@override final GetDevicesFlagsResponseModel flags; +@override final String? carrierGenre; +@override final int? carrierBirthday; +@override final int? carrierWeight; +@override final int? carrierStepLength; +@override final String carrierName; +@override final String? phone; @override final GetDevicesSettingsResponseModel settings; +@override final String connectionServer; @override final String protocol; @override final String type; -@override final String connectionServer; @override final int createdAt; -@override final GetDevicesFlagsResponseModel flags; /// Create a copy of GetDevicesItemResponseModel /// with the given fields replaced by the non-null parameter values. @@ -532,16 +544,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesItemResponseModel&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.id, id) || other.id == id)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.flags, flags) || other.flags == flags)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.flags, flags) || other.flags == flags)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.settings, settings) || other.settings == settings)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.type, type) || other.type == type)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,identificator,carrierName,phone,id,settings,protocol,type,connectionServer,createdAt,flags); +int get hashCode => Object.hash(runtimeType,id,identificator,battery,userId,flags,carrierGenre,carrierBirthday,carrierWeight,carrierStepLength,carrierName,phone,settings,connectionServer,protocol,type,createdAt); @override String toString() { - return 'GetDevicesItemResponseModel(identificator: $identificator, carrierName: $carrierName, phone: $phone, id: $id, settings: $settings, protocol: $protocol, type: $type, connectionServer: $connectionServer, createdAt: $createdAt, flags: $flags)'; + return 'GetDevicesItemResponseModel(id: $id, identificator: $identificator, battery: $battery, userId: $userId, flags: $flags, carrierGenre: $carrierGenre, carrierBirthday: $carrierBirthday, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierName: $carrierName, phone: $phone, settings: $settings, connectionServer: $connectionServer, protocol: $protocol, type: $type, createdAt: $createdAt)'; } @@ -552,11 +564,11 @@ abstract mixin class _$GetDevicesItemResponseModelCopyWith<$Res> implements $Get factory _$GetDevicesItemResponseModelCopyWith(_GetDevicesItemResponseModel value, $Res Function(_GetDevicesItemResponseModel) _then) = __$GetDevicesItemResponseModelCopyWithImpl; @override @useResult $Res call({ - String identificator, String carrierName, String phone, String id, GetDevicesSettingsResponseModel settings, String protocol, String type, String connectionServer, int createdAt, GetDevicesFlagsResponseModel flags + String id, String identificator, int? battery, String? userId, GetDevicesFlagsResponseModel flags, String? carrierGenre, int? carrierBirthday, int? carrierWeight, int? carrierStepLength, String carrierName, String? phone, GetDevicesSettingsResponseModel settings, String connectionServer, String protocol, String type, int createdAt }); -@override $GetDevicesSettingsResponseModelCopyWith<$Res> get settings;@override $GetDevicesFlagsResponseModelCopyWith<$Res> get flags; +@override $GetDevicesFlagsResponseModelCopyWith<$Res> get flags;@override $GetDevicesSettingsResponseModelCopyWith<$Res> get settings; } /// @nodoc @@ -569,19 +581,25 @@ class __$GetDevicesItemResponseModelCopyWithImpl<$Res> /// Create a copy of GetDevicesItemResponseModel /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? identificator = null,Object? carrierName = null,Object? phone = null,Object? id = null,Object? settings = null,Object? protocol = null,Object? type = null,Object? connectionServer = null,Object? createdAt = null,Object? flags = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? identificator = null,Object? battery = freezed,Object? userId = freezed,Object? flags = null,Object? carrierGenre = freezed,Object? carrierBirthday = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierName = null,Object? phone = freezed,Object? settings = null,Object? connectionServer = null,Object? protocol = null,Object? type = null,Object? createdAt = null,}) { return _then(_GetDevicesItemResponseModel( -identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable -as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable -as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable -as String,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable -as GetDevicesSettingsResponseModel,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable +as String,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable +as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable +as String?,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable +as GetDevicesFlagsResponseModel,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable +as String?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable +as int?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable +as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable +as int?,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable +as String,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable +as GetDevicesSettingsResponseModel,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable +as String,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable -as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as int,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable -as GetDevicesFlagsResponseModel, +as int, )); } @@ -589,19 +607,19 @@ as GetDevicesFlagsResponseModel, /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$GetDevicesSettingsResponseModelCopyWith<$Res> get settings { +$GetDevicesFlagsResponseModelCopyWith<$Res> get flags { - return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) { - return _then(_self.copyWith(settings: value)); + return $GetDevicesFlagsResponseModelCopyWith<$Res>(_self.flags, (value) { + return _then(_self.copyWith(flags: value)); }); }/// Create a copy of GetDevicesItemResponseModel /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') -$GetDevicesFlagsResponseModelCopyWith<$Res> get flags { +$GetDevicesSettingsResponseModelCopyWith<$Res> get settings { - return $GetDevicesFlagsResponseModelCopyWith<$Res>(_self.flags, (value) { - return _then(_self.copyWith(flags: value)); + return $GetDevicesSettingsResponseModelCopyWith<$Res>(_self.settings, (value) { + return _then(_self.copyWith(settings: value)); }); } } @@ -894,7 +912,7 @@ as List, /// @nodoc mixin _$GetDevicesFlagsResponseModel { - String get isInOrOut; String get geofenceId; bool get isBatteryLow; bool get isDisconnect; + String get isInOrOut; String? get geofenceId; bool get isBatteryLow; bool get isDisconnect; /// Create a copy of GetDevicesFlagsResponseModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -927,7 +945,7 @@ abstract mixin class $GetDevicesFlagsResponseModelCopyWith<$Res> { factory $GetDevicesFlagsResponseModelCopyWith(GetDevicesFlagsResponseModel value, $Res Function(GetDevicesFlagsResponseModel) _then) = _$GetDevicesFlagsResponseModelCopyWithImpl; @useResult $Res call({ - String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect + String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect }); @@ -944,11 +962,11 @@ class _$GetDevicesFlagsResponseModelCopyWithImpl<$Res> /// Create a copy of GetDevicesFlagsResponseModel /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? isInOrOut = null,Object? geofenceId = null,Object? isBatteryLow = null,Object? isDisconnect = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? isInOrOut = null,Object? geofenceId = freezed,Object? isBatteryLow = null,Object? isDisconnect = null,}) { return _then(_self.copyWith( isInOrOut: null == isInOrOut ? _self.isInOrOut : isInOrOut // ignore: cast_nullable_to_non_nullable -as String,geofenceId: null == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable -as String,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable +as String,geofenceId: freezed == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable +as String?,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable as bool,isDisconnect: null == isDisconnect ? _self.isDisconnect : isDisconnect // ignore: cast_nullable_to_non_nullable as bool, )); @@ -1035,7 +1053,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _GetDevicesFlagsResponseModel() when $default != null: return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisconnect);case _: @@ -1056,7 +1074,7 @@ return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisc /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect) $default,) {final _that = this; switch (_that) { case _GetDevicesFlagsResponseModel(): return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisconnect);case _: @@ -1076,7 +1094,7 @@ return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisc /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect)? $default,) {final _that = this; switch (_that) { case _GetDevicesFlagsResponseModel() when $default != null: return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisconnect);case _: @@ -1091,11 +1109,11 @@ return $default(_that.isInOrOut,_that.geofenceId,_that.isBatteryLow,_that.isDisc @JsonSerializable() class _GetDevicesFlagsResponseModel implements GetDevicesFlagsResponseModel { - const _GetDevicesFlagsResponseModel({required this.isInOrOut, required this.geofenceId, required this.isBatteryLow, required this.isDisconnect}); + const _GetDevicesFlagsResponseModel({required this.isInOrOut, this.geofenceId, required this.isBatteryLow, required this.isDisconnect}); factory _GetDevicesFlagsResponseModel.fromJson(Map json) => _$GetDevicesFlagsResponseModelFromJson(json); @override final String isInOrOut; -@override final String geofenceId; +@override final String? geofenceId; @override final bool isBatteryLow; @override final bool isDisconnect; @@ -1132,7 +1150,7 @@ abstract mixin class _$GetDevicesFlagsResponseModelCopyWith<$Res> implements $Ge factory _$GetDevicesFlagsResponseModelCopyWith(_GetDevicesFlagsResponseModel value, $Res Function(_GetDevicesFlagsResponseModel) _then) = __$GetDevicesFlagsResponseModelCopyWithImpl; @override @useResult $Res call({ - String isInOrOut, String geofenceId, bool isBatteryLow, bool isDisconnect + String isInOrOut, String? geofenceId, bool isBatteryLow, bool isDisconnect }); @@ -1149,11 +1167,11 @@ class __$GetDevicesFlagsResponseModelCopyWithImpl<$Res> /// Create a copy of GetDevicesFlagsResponseModel /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? isInOrOut = null,Object? geofenceId = null,Object? isBatteryLow = null,Object? isDisconnect = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? isInOrOut = null,Object? geofenceId = freezed,Object? isBatteryLow = null,Object? isDisconnect = null,}) { return _then(_GetDevicesFlagsResponseModel( isInOrOut: null == isInOrOut ? _self.isInOrOut : isInOrOut // ignore: cast_nullable_to_non_nullable -as String,geofenceId: null == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable -as String,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable +as String,geofenceId: freezed == geofenceId ? _self.geofenceId : geofenceId // ignore: cast_nullable_to_non_nullable +as String?,isBatteryLow: null == isBatteryLow ? _self.isBatteryLow : isBatteryLow // ignore: cast_nullable_to_non_nullable as bool,isDisconnect: null == isDisconnect ? _self.isDisconnect : isDisconnect // ignore: cast_nullable_to_non_nullable as bool, )); diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.g.dart b/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.g.dart index 258ecfad..b6912e7d 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.g.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/models/get_devices_response_model.g.dart @@ -23,35 +23,47 @@ Map _$GetDevicesResponseModelToJson( _GetDevicesItemResponseModel _$GetDevicesItemResponseModelFromJson( Map json, ) => _GetDevicesItemResponseModel( - identificator: json['identificator'] as String, - carrierName: json['carrierName'] as String, - phone: json['phone'] as String, id: json['id'] as String, - settings: GetDevicesSettingsResponseModel.fromJson( - json['settings'] as Map, - ), - protocol: json['protocol'] as String, - type: json['type'] as String, - connectionServer: json['connectionServer'] as String, - createdAt: (json['createdAt'] as num).toInt(), + identificator: json['identificator'] as String, + battery: (json['battery'] as num?)?.toInt(), + userId: json['userId'] as String?, flags: GetDevicesFlagsResponseModel.fromJson( json['flags'] as Map, ), + carrierGenre: json['carrierGenre'] as String?, + carrierBirthday: (json['carrierBirthday'] as num?)?.toInt(), + carrierWeight: (json['carrierWeight'] as num?)?.toInt(), + carrierStepLength: (json['carrierStepLength'] as num?)?.toInt(), + carrierName: json['carrierName'] as String, + phone: json['phone'] as String?, + settings: GetDevicesSettingsResponseModel.fromJson( + json['settings'] as Map, + ), + connectionServer: json['connectionServer'] as String, + protocol: json['protocol'] as String, + type: json['type'] as String, + createdAt: (json['createdAt'] as num).toInt(), ); Map _$GetDevicesItemResponseModelToJson( _GetDevicesItemResponseModel instance, ) => { + 'id': instance.id, 'identificator': instance.identificator, + 'battery': instance.battery, + 'userId': instance.userId, + 'flags': instance.flags, + 'carrierGenre': instance.carrierGenre, + 'carrierBirthday': instance.carrierBirthday, + 'carrierWeight': instance.carrierWeight, + 'carrierStepLength': instance.carrierStepLength, 'carrierName': instance.carrierName, 'phone': instance.phone, - 'id': instance.id, 'settings': instance.settings, + 'connectionServer': instance.connectionServer, 'protocol': instance.protocol, 'type': instance.type, - 'connectionServer': instance.connectionServer, 'createdAt': instance.createdAt, - 'flags': instance.flags, }; _GetDevicesSettingsResponseModel _$GetDevicesSettingsResponseModelFromJson( @@ -80,7 +92,7 @@ _GetDevicesFlagsResponseModel _$GetDevicesFlagsResponseModelFromJson( Map json, ) => _GetDevicesFlagsResponseModel( isInOrOut: json['isInOrOut'] as String, - geofenceId: json['geofenceId'] as String, + geofenceId: json['geofenceId'] as String?, isBatteryLow: json['isBatteryLow'] as bool, isDisconnect: json['isDisconnect'] as bool, ); diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart index 2b73e8ac..beb3b1e8 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/models/latest_positions_response_model.dart @@ -1,7 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/address_entity.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/network_entity.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/domain/entities/address_entity.dart'; +import 'package:control_panel/src/core/domain/entities/network_entity.dart'; +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; part 'latest_positions_response_model.freezed.dart'; part 'latest_positions_response_model.g.dart'; diff --git a/modules/legacy/modules/control_panel/lib/src/core/data/repositories/control_panel_repository_impl.dart b/modules/legacy/modules/control_panel/lib/src/core/data/repositories/control_panel_repository_impl.dart index 359e522e..123f97c4 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/data/repositories/control_panel_repository_impl.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/data/repositories/control_panel_repository_impl.dart @@ -1,6 +1,6 @@ import 'package:control_panel/src/core/data/datasource/control_panel_remote_datasource.dart'; import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; import 'package:legacy_shared/legacy_shared.dart'; class ControlPanelRepositoryImpl implements ControlPanelRepository { @@ -9,8 +9,8 @@ class ControlPanelRepositoryImpl implements ControlPanelRepository { final ControlPanelRemoteDatasource _remote; @override - Future> getDevices({required String userId}) async { - return _remote.getDevices(userId: userId); + Future> getDevices() async { + return _remote.getDevices(); } @override diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/address_entity.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/address_entity.dart similarity index 100% rename from modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/address_entity.dart rename to modules/legacy/modules/control_panel/lib/src/core/domain/entities/address_entity.dart diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/address_entity.freezed.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/address_entity.freezed.dart similarity index 100% rename from modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/address_entity.freezed.dart rename to modules/legacy/modules/control_panel/lib/src/core/domain/entities/address_entity.freezed.dart diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/network_entity.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/network_entity.dart similarity index 100% rename from modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/network_entity.dart rename to modules/legacy/modules/control_panel/lib/src/core/domain/entities/network_entity.dart diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/network_entity.freezed.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/network_entity.freezed.dart similarity index 100% rename from modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/network_entity.freezed.dart rename to modules/legacy/modules/control_panel/lib/src/core/domain/entities/network_entity.freezed.dart diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/position_entity.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.dart similarity index 79% rename from modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/position_entity.dart rename to modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.dart index 3d6e72d0..3bd0d5f3 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/position_entity.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.dart @@ -1,6 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/address_entity.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/network_entity.dart'; +import 'package:control_panel/src/core/domain/entities/address_entity.dart'; +import 'package:control_panel/src/core/domain/entities/network_entity.dart'; part 'position_entity.freezed.dart'; diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/position_entity.freezed.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.freezed.dart similarity index 100% rename from modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/position_entity.freezed.dart rename to modules/legacy/modules/control_panel/lib/src/core/domain/entities/position_entity.freezed.dart diff --git a/modules/legacy/modules/control_panel/lib/src/core/domain/repositories/control_panel_repository.dart b/modules/legacy/modules/control_panel/lib/src/core/domain/repositories/control_panel_repository.dart index 66a158d3..03b3e9ce 100644 --- a/modules/legacy/modules/control_panel/lib/src/core/domain/repositories/control_panel_repository.dart +++ b/modules/legacy/modules/control_panel/lib/src/core/domain/repositories/control_panel_repository.dart @@ -1,9 +1,8 @@ -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; import 'package:legacy_shared/legacy_shared.dart'; abstract class ControlPanelRepository { - Future> getDevices({required String userId}); + Future> getDevices(); Future> getLatestPositions({required String deviceId}); - } diff --git a/modules/legacy/modules/control_panel/lib/src/core/utils/battery_utils.dart b/modules/legacy/modules/control_panel/lib/src/core/utils/battery_utils.dart new file mode 100644 index 00000000..64cce8b4 --- /dev/null +++ b/modules/legacy/modules/control_panel/lib/src/core/utils/battery_utils.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; + +IconData toBatteryIcon(int battery) { + if (battery < 15) return Icons.battery_0_bar; + if (battery < 30) return Icons.battery_1_bar; + if (battery < 45) return Icons.battery_2_bar; + if (battery < 60) return Icons.battery_3_bar; + if (battery < 75) return Icons.battery_4_bar; + if (battery < 90) return Icons.battery_5_bar; + return Icons.battery_6_bar; +} diff --git a/modules/legacy/modules/control_panel/lib/src/core/utils/date_format_utils.dart b/modules/legacy/modules/control_panel/lib/src/core/utils/date_format_utils.dart new file mode 100644 index 00000000..2040c143 --- /dev/null +++ b/modules/legacy/modules/control_panel/lib/src/core/utils/date_format_utils.dart @@ -0,0 +1,9 @@ +String formatPositionDate(int millisSinceEpoch) { + final d = DateTime.fromMillisecondsSinceEpoch(millisSinceEpoch); + final mm = d.month.toString().padLeft(2, '0'); + final dd = d.day.toString().padLeft(2, '0'); + final hh = d.hour.toString().padLeft(2, '0'); + final min = d.minute.toString().padLeft(2, '0'); + final ss = d.second.toString().padLeft(2, '0'); + return '$mm-$dd $hh:$min:$ss'; +} diff --git a/modules/legacy/modules/control_panel/lib/src/core/utils/dio_error_mapper.dart b/modules/legacy/modules/control_panel/lib/src/core/utils/dio_error_mapper.dart new file mode 100644 index 00000000..333d34d4 --- /dev/null +++ b/modules/legacy/modules/control_panel/lib/src/core/utils/dio_error_mapper.dart @@ -0,0 +1,57 @@ +import 'dart:convert'; + +import 'package:dio/dio.dart'; + +Future safeCall( + Future Function() call, + String fallbackMsg, +) async { + try { + return await call(); + } on DioException catch (error) { + throw mapDioError(error, defaultMessage: fallbackMsg); + } +} + +Exception mapDioError(DioException error, {required String defaultMessage}) { + final apiMsg = _extractApiMessage(error.response?.data); + final msg = apiMsg ?? error.message ?? defaultMessage; + return Exception(msg); +} + +String? _extractApiMessage(Object? data) { + if (data == null) return null; + + if (data is Map) { + final errorObj = data['error']; + if (errorObj is Map && errorObj['message'] is String) { + return (errorObj['message'] as String).trim(); + } + if (data['message'] is String) { + return (data['message'] as String).trim(); + } + return null; + } + + if (data is String) { + final raw = data.trim(); + if (raw.isEmpty) return null; + + try { + final decoded = jsonDecode(raw); + return _extractApiMessage(decoded); + } catch (_) { + return raw; + } + } + + return null; +} + +String formatErrorMessage(Object error) { + final raw = error.toString(); + if (raw.startsWith('Exception: ')) { + return raw.substring('Exception: '.length); + } + return raw; +} diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/control_panel_builder.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/control_panel_builder.dart index 934bd4a0..511cebe5 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/control_panel_builder.dart +++ b/modules/legacy/modules/control_panel/lib/src/features/control_panel/control_panel_builder.dart @@ -12,7 +12,7 @@ class ControlPanelBuilder { return MaterialPage( key: state.pageKey, - child: ControlPanelScreen(navigationContract: navigationContract, routerState: state), + child: ControlPanelScreen(navigationContract: navigationContract), ); } } diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.dart deleted file mode 100644 index b0adfb6a..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'get_devices_request_entity.freezed.dart'; - -@freezed -abstract class GetDevicesRequestEntity with _$GetDevicesRequestEntity { - const factory GetDevicesRequestEntity({ - required String userId, - }) = _GetDevicesRequestEntity; -} diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.freezed.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.freezed.dart deleted file mode 100644 index 5319aa3e..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/entities/get_devices_request_entity.freezed.dart +++ /dev/null @@ -1,271 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND -// coverage:ignore-file -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'get_devices_request_entity.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; -/// @nodoc -mixin _$GetDevicesRequestEntity { - - String get userId; -/// Create a copy of GetDevicesRequestEntity -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$GetDevicesRequestEntityCopyWith get copyWith => _$GetDevicesRequestEntityCopyWithImpl(this as GetDevicesRequestEntity, _$identity); - - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is GetDevicesRequestEntity&&(identical(other.userId, userId) || other.userId == userId)); -} - - -@override -int get hashCode => Object.hash(runtimeType,userId); - -@override -String toString() { - return 'GetDevicesRequestEntity(userId: $userId)'; -} - - -} - -/// @nodoc -abstract mixin class $GetDevicesRequestEntityCopyWith<$Res> { - factory $GetDevicesRequestEntityCopyWith(GetDevicesRequestEntity value, $Res Function(GetDevicesRequestEntity) _then) = _$GetDevicesRequestEntityCopyWithImpl; -@useResult -$Res call({ - String userId -}); - - - - -} -/// @nodoc -class _$GetDevicesRequestEntityCopyWithImpl<$Res> - implements $GetDevicesRequestEntityCopyWith<$Res> { - _$GetDevicesRequestEntityCopyWithImpl(this._self, this._then); - - final GetDevicesRequestEntity _self; - final $Res Function(GetDevicesRequestEntity) _then; - -/// Create a copy of GetDevicesRequestEntity -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? userId = null,}) { - return _then(_self.copyWith( -userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable -as String, - )); -} - -} - - -/// Adds pattern-matching-related methods to [GetDevicesRequestEntity]. -extension GetDevicesRequestEntityPatterns on GetDevicesRequestEntity { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _GetDevicesRequestEntity value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _GetDevicesRequestEntity() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _GetDevicesRequestEntity value) $default,){ -final _that = this; -switch (_that) { -case _GetDevicesRequestEntity(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _GetDevicesRequestEntity value)? $default,){ -final _that = this; -switch (_that) { -case _GetDevicesRequestEntity() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( String userId)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _GetDevicesRequestEntity() when $default != null: -return $default(_that.userId);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( String userId) $default,) {final _that = this; -switch (_that) { -case _GetDevicesRequestEntity(): -return $default(_that.userId);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String userId)? $default,) {final _that = this; -switch (_that) { -case _GetDevicesRequestEntity() when $default != null: -return $default(_that.userId);case _: - return null; - -} -} - -} - -/// @nodoc - - -class _GetDevicesRequestEntity implements GetDevicesRequestEntity { - const _GetDevicesRequestEntity({required this.userId}); - - -@override final String userId; - -/// Create a copy of GetDevicesRequestEntity -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$GetDevicesRequestEntityCopyWith<_GetDevicesRequestEntity> get copyWith => __$GetDevicesRequestEntityCopyWithImpl<_GetDevicesRequestEntity>(this, _$identity); - - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetDevicesRequestEntity&&(identical(other.userId, userId) || other.userId == userId)); -} - - -@override -int get hashCode => Object.hash(runtimeType,userId); - -@override -String toString() { - return 'GetDevicesRequestEntity(userId: $userId)'; -} - - -} - -/// @nodoc -abstract mixin class _$GetDevicesRequestEntityCopyWith<$Res> implements $GetDevicesRequestEntityCopyWith<$Res> { - factory _$GetDevicesRequestEntityCopyWith(_GetDevicesRequestEntity value, $Res Function(_GetDevicesRequestEntity) _then) = __$GetDevicesRequestEntityCopyWithImpl; -@override @useResult -$Res call({ - String userId -}); - - - - -} -/// @nodoc -class __$GetDevicesRequestEntityCopyWithImpl<$Res> - implements _$GetDevicesRequestEntityCopyWith<$Res> { - __$GetDevicesRequestEntityCopyWithImpl(this._self, this._then); - - final _GetDevicesRequestEntity _self; - final $Res Function(_GetDevicesRequestEntity) _then; - -/// Create a copy of GetDevicesRequestEntity -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? userId = null,}) { - return _then(_GetDevicesRequestEntity( -userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable -as String, - )); -} - - -} - -// dart format on diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case.dart deleted file mode 100644 index aa5d3efd..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:legacy_shared/legacy_shared.dart'; - -abstract class GetDevicesUseCase { - Future> getDevices({required String userId}); -} diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case_impl.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case_impl.dart deleted file mode 100644 index b0cad8be..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_devices_use_case_impl.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case.dart'; -import 'package:legacy_shared/legacy_shared.dart'; - -class GetDevicesUseCaseImpl implements GetDevicesUseCase { - GetDevicesUseCaseImpl(this._repository); - - final ControlPanelRepository _repository; - @override - Future> getDevices({required String userId}) async { - return _repository.getDevices(userId: userId); - } -} \ No newline at end of file diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case.dart deleted file mode 100644 index ed31d6ed..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; - -abstract class GetLatestPositionsUseCase { - Future> getLatestPositions({required String deviceId}); -} diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case_impl.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case_impl.dart deleted file mode 100644 index 9ec47d08..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/domain/get_latest_positions_use_case_impl.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case.dart'; - -class GetLatestPositionsUseCaseImpl implements GetLatestPositionsUseCase { - GetLatestPositionsUseCaseImpl(this._repository); - - final ControlPanelRepository _repository; - @override - Future> getLatestPositions({required String deviceId}) async { - await Future.delayed(const Duration(milliseconds: 2000)); - return _repository.getLatestPositions(deviceId: deviceId); - } -} diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart index 972c318b..d3c14cdc 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart +++ b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/control_panel_screen.dart @@ -1,11 +1,9 @@ import 'package:flutter_svg/svg.dart'; -import 'package:go_router/go_router.dart'; import 'package:control_panel/src/features/control_panel/presentation/state/control_panel_view_model.dart'; +import 'package:control_panel/src/shared/widgets/device_map.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong2/latlong.dart'; import 'package:legacy_shared/legacy_shared.dart'; import 'package:navigation/navigation.dart'; import 'package:sf_localizations/sf_localizations.dart'; @@ -13,17 +11,36 @@ import 'package:utils/utils.dart'; class ControlPanelScreen extends ConsumerWidget { final NavigationContract navigationContract; - final GoRouterState routerState; const ControlPanelScreen({ super.key, required this.navigationContract, - required this.routerState, }); @override Widget build(BuildContext context, WidgetRef ref) { final theme = ref.watch(themePortProvider); + final state = ref.watch(controlPanelViewModelProvider); + + ref.listen( + controlPanelViewModelProvider.select((s) => s.errorMessage), + (previous, next) { + if (next.isNotEmpty) { + showTopSnackbar( + context, + message: next, + type: MessageType.error, + ); + } + }, + ); + + if (state.isLoading) { + return Scaffold( + backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary), + body: const Center(child: CircularProgressIndicator()), + ); + } return Scaffold( backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary), @@ -69,11 +86,11 @@ class _Header extends ConsumerWidget { final vm = ref.read(controlPanelViewModelProvider.notifier); return Stack( + alignment: Alignment.center, children: [ - SizedBox( - height: SizeUtils.getByScreen(small: 36, big: 36), + Padding( + padding: EdgeInsets.only(top: SizeUtils.getByScreen(small: 14, big: 14)), child: Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ Image.asset( 'assets/shared/images/iso_sf.png', @@ -81,13 +98,15 @@ class _Header extends ConsumerWidget { ), SizedBox(width: SizeUtils.getByScreen(small: 8, big: 4)), SizedBox( - width: SizeUtils.getByScreen(small: 104, big: 100), + width: SizeUtils.getByScreen(small: 130, big: 140), height: 32, child: CustomDropdown( items: state.devices .map( (DeviceEntity device) => Text( - device.carrierName, + device.carrierName.length > 10 + ? '${device.carrierName.substring(0, 10)}...' + : device.carrierName, overflow: TextOverflow.ellipsis, ), ) @@ -100,16 +119,15 @@ class _Header extends ConsumerWidget { height: 32, color: Colors.transparent, padding: EdgeInsets.zero, + showIcon: false, ), ), ], ), ), - Center( - child: SvgPicture.asset( - 'assets/shared/images/logo_sf.svg', - height: SizeUtils.getByScreen(small: 36, big: 36), - ), + SvgPicture.asset( + 'assets/shared/images/logo_sf.svg', + height: SizeUtils.getByScreen(small: 36, big: 36), ), ], ); @@ -157,6 +175,7 @@ class _MenuSection extends ConsumerWidget { text: I18n.accountSettings, ), SizedBox(height: SizeUtils.getByScreen(small: 8, big: 7)), + // TODO: Implementar navegación a Device Settings _SectionButton( onPressed: () {}, icon: Icons.settings_outlined, @@ -208,6 +227,7 @@ class _MapSection extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final theme = ref.read(themePortProvider); + final state = ref.watch(controlPanelViewModelProvider); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -223,151 +243,12 @@ class _MapSection extends ConsumerWidget { SizedBox(height: SizeUtils.getByScreen(small: 4, big: 8)), SizedBox( height: SizeUtils.getByScreen(small: 200, big: 300), - child: _Minimap(), + child: DeviceMap( + selectedPosition: state.selectedPosition, + selectedDevice: state.selectedDevice, + ), ), ], ); } } - -class _Minimap extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - final theme = ref.watch(themePortProvider); - - final viewState = ref.watch(controlPanelViewModelProvider); - final viewModel = ref.read(controlPanelViewModelProvider.notifier); - - return FlutterMap( - mapController: viewModel.mapController, - options: MapOptions( - initialCenter: LatLng(45.32833189648895, -3.0830872665435085), - initialZoom: 15, - keepAlive: true, - ), - children: [ - TileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - userAgentPackageName: 'com.savefamily.sf_platform', - ), - MarkerLayer( - markers: [ - if (viewState.selectedPosition != null) - Marker( - point: LatLng( - viewState.selectedPosition!.latitude, - viewState.selectedPosition!.longitude, - ), - width: 200, - height: 145, - child: Align( - alignment: Alignment.topCenter, - child: SvgPicture.asset( - 'assets/images/ui/location.svg', - height: 80, - ), - ), - rotate: true, - ), - ], - ), - if (viewState.selectedPosition != null) - Align(alignment: Alignment.bottomCenter, child: _LocationBanner()), - ], - ); - } -} - -class _LocationBanner extends ConsumerWidget { - IconData toBatteryIcon(int battery) { - if (battery < 15) return Icons.battery_0_bar; - if (battery < 30) return Icons.battery_1_bar; - if (battery < 45) return Icons.battery_2_bar; - if (battery < 60) return Icons.battery_3_bar; - if (battery < 75) return Icons.battery_4_bar; - if (battery < 90) return Icons.battery_5_bar; - return Icons.battery_6_bar; - } - - const _LocationBanner(); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final theme = ref.read(themePortProvider); - - final viewState = ref.watch(controlPanelViewModelProvider); - - final battery = viewState.selectedPosition?.ncell ?? 0; - final IconData batteryIcon = toBatteryIcon(battery); - - final positionDate = DateTime.fromMillisecondsSinceEpoch( - viewState.selectedPosition?.positionDate ?? 0, - ); - - return Container( - height: SizeUtils.getByScreen(small: 60, big: 58), - width: SizeUtils.getByScreen(small: 300, big: 298), - margin: EdgeInsets.only( - bottom: SizeUtils.getByScreen(small: 20, big: 16), - ), - decoration: BoxDecoration( - color: theme.getColorFor(ThemeCode.backgroundPrimary), - borderRadius: BorderRadius.all( - Radius.circular(SizeUtils.getByScreen(small: 9, big: 8)), - ), - ), - child: Row( - children: [ - Icon( - SFIcons.location, - size: SizeUtils.getByScreen(small: 40, big: 38), - color: theme.getColorFor(ThemeCode.legacyPrimary), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: SizeUtils.getByScreen(small: 250, big: 248), - child: Text( - '${viewState.selectedPosition!.address?.street}, ' - '${viewState.selectedPosition!.address?.province}, ' - '${viewState.selectedPosition!.address?.country}', - overflow: TextOverflow.ellipsis, - ), - ), - Row( - children: [ - Text( - '${positionDate.month.toString().padLeft(2, '0')}-' - '${positionDate.day.toString().padLeft(2, '0')} ' - '${positionDate.hour.toString().padLeft(2, '0')}:' - '${positionDate.minute.toString().padLeft(2, '0')}:' - '${positionDate.second.toString().padLeft(2, '0')}', - style: TextStyle( - fontSize: SizeUtils.getByScreen(small: 12, big: 11), - ), - ), - if (viewState.selectedPosition!.networks.isNotEmpty) - Text( - ' | ${viewState.selectedPosition!.networks.first.signal}', - style: TextStyle( - fontSize: SizeUtils.getByScreen(small: 12, big: 11), - ), - ), - Icon(batteryIcon), - Text( - '${viewState.selectedPosition!.ncell ?? 0}%', - style: TextStyle( - fontSize: SizeUtils.getByScreen(small: 12, big: 11), - ), - ), - ], - ), - ], - ), - ], - ), - ); - } -} diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_devices_use_case_provider.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_devices_use_case_provider.dart deleted file mode 100644 index 2b7048db..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_devices_use_case_provider.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:control_panel/src/core/providers/control_panel_repository_provider.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final getDevicesUseCaseProvider = -Provider.autoDispose((ref) { - final authRepository = ref.read(controlPanelRepositoryProvider); - return GetDevicesUseCaseImpl(authRepository); -}); diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_latest_positions_use_case_provider.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_latest_positions_use_case_provider.dart deleted file mode 100644 index 57e802a0..00000000 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/providers/get_latest_positions_use_case_provider.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:control_panel/src/core/providers/control_panel_repository_provider.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case_impl.dart'; - -final getLatestPositionsUseCaseProvider = -Provider.autoDispose((ref) { - final authRepository = ref.read(controlPanelRepositoryProvider); - return GetLatestPositionsUseCaseImpl(authRepository); -}); diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart index e3bdada8..838db8b1 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart +++ b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_model.dart @@ -1,93 +1,97 @@ -import 'dart:async'; - -import 'package:flutter_map/flutter_map.dart'; -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_devices_use_case.dart'; -import 'package:control_panel/src/features/control_panel/domain/get_latest_positions_use_case.dart'; -import 'package:control_panel/src/features/control_panel/presentation/providers/get_devices_use_case_provider.dart'; -import 'package:control_panel/src/features/control_panel/presentation/providers/get_latest_positions_use_case_provider.dart'; +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/domain/repositories/control_panel_repository.dart'; +import 'package:control_panel/src/core/providers/control_panel_repository_provider.dart'; +import 'package:control_panel/src/core/utils/dio_error_mapper.dart'; import 'package:control_panel/src/features/control_panel/presentation/state/control_panel_view_state.dart'; import 'package:legacy_shared/legacy_shared.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:latlong2/latlong.dart'; final controlPanelViewModelProvider = -NotifierProvider.autoDispose( + NotifierProvider.autoDispose( ControlPanelViewModel.new, ); class ControlPanelViewModel extends Notifier { - late final GetDevicesUseCase _getDevicesUseCase; - late final GetLatestPositionsUseCase _getLatestPositionsUseCase; - - late final SelectedDeviceNotifier selectedDeviceNotifier; - - late final MapController mapController; + late final ControlPanelRepository _repository; + late final SelectedDeviceNotifier _selectedDeviceNotifier; @override ControlPanelViewState build() { - _getDevicesUseCase = ref.read(getDevicesUseCaseProvider); - _getLatestPositionsUseCase = ref.read(getLatestPositionsUseCaseProvider); - - selectedDeviceNotifier = ref.read(selectedDeviceProvider.notifier); - - mapController = MapControllerImpl(); - - ref.read(loggedUserProvider.future) - .then((loggedUser) { - state = state.copyWith(loggedUser: loggedUser); - return _getDevicesUseCase.getDevices( - userId: loggedUser.id - ); - }).then((List res){ - state = state.copyWith( - devices: res, - selectedDevice: res.first - ); - return Future.wait(res.map((device) => - _getLatestPositionsUseCase.getLatestPositions( - deviceId: device.identificator - ) - )); - }).then( - (List> res) { - setPositions(res); - } - ); - - ref.onDispose(disposeControllers); - - return ControlPanelViewState(); + _repository = ref.read(controlPanelRepositoryProvider); + _selectedDeviceNotifier = ref.read(selectedDeviceProvider.notifier); + _init(); + return const ControlPanelViewState(); } - void setPositions(List> positions) { - final devicePositions = positions.map((List devicePositions)=>devicePositions[0]).toList(); - final selectedPosition = devicePositions.where((p)=> - p.deviceIdentificator == state.selectedDevice!.identificator).firstOrNull; - state = state.copyWith( - positions: devicePositions, - selectedPosition: selectedPosition, - ); - if (selectedPosition != null) { - mapController.move(LatLng( - selectedPosition.latitude, - selectedPosition.longitude, - ), 15); + Future _init() async { + try { + final loggedUser = await ref.read(loggedUserProvider.future); + if (!ref.mounted) return; + state = state.copyWith(loggedUser: loggedUser); + + final devices = await _repository.getDevices(); + if (!ref.mounted) return; + + if (devices.isEmpty) { + state = state.copyWith(isLoading: false); + return; + } + + state = state.copyWith( + devices: devices, + selectedDevice: devices.first, + ); + + final positionLists = await Future.wait( + devices.map( + (d) => _repository.getLatestPositions(deviceId: d.identificator), + ), + ); + if (!ref.mounted) return; + + _applyPositions(positionLists); + state = state.copyWith(isLoading: false); + } catch (e) { + if (!ref.mounted) return; + state = state.copyWith( + isLoading: false, + errorMessage: formatErrorMessage(e), + ); } } + void _applyPositions(List> positionLists) { + final latestPositions = positionLists + .where((list) => list.isNotEmpty) + .map((list) => list.first) + .toList(); + + final selectedPosition = state.selectedDevice != null + ? latestPositions + .where( + (p) => + p.deviceIdentificator == + state.selectedDevice!.identificator, + ) + .firstOrNull + : null; + + state = state.copyWith( + positions: latestPositions, + selectedPosition: selectedPosition, + ); + } + void setSelectedDevice(DeviceEntity device) { - final selectedPosition = state.positions.where((p)=> - p.deviceIdentificator == device.identificator).firstOrNull; + final selectedPosition = state.positions + .where((p) => p.deviceIdentificator == device.identificator) + .firstOrNull; + state = state.copyWith( selectedDevice: device, selectedPosition: selectedPosition, ); - selectedDeviceNotifier.setSelectedDevice(device); - } - - void disposeControllers(){ - mapController.dispose(); + _selectedDeviceNotifier.setSelectedDevice(device); } } diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.dart index e511e5b2..5a5dedb6 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.dart +++ b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.dart @@ -1,4 +1,4 @@ -import 'package:control_panel/src/features/control_panel/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:legacy_shared/legacy_shared.dart'; @@ -11,6 +11,8 @@ abstract class ControlPanelViewState with _$ControlPanelViewState { @Default([]) List devices, DeviceEntity? selectedDevice, @Default([]) List positions, - PositionEntity? selectedPosition + PositionEntity? selectedPosition, + @Default(true) bool isLoading, + @Default('') String errorMessage, }) = _ControlPanelViewState; } diff --git a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.freezed.dart b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.freezed.dart index 40acd0a9..29c383d8 100644 --- a/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.freezed.dart +++ b/modules/legacy/modules/control_panel/lib/src/features/control_panel/presentation/state/control_panel_view_state.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$ControlPanelViewState { - UserEntity? get loggedUser; List get devices; DeviceEntity? get selectedDevice; List get positions; PositionEntity? get selectedPosition; + UserEntity? get loggedUser; List get devices; DeviceEntity? get selectedDevice; List get positions; PositionEntity? get selectedPosition; bool get isLoading; String get errorMessage; /// Create a copy of ControlPanelViewState /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -25,16 +25,16 @@ $ControlPanelViewStateCopyWith get copyWith => _$ControlP @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other.devices, devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other.positions, positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other.devices, devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other.positions, positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); } @override -int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(devices),selectedDevice,const DeepCollectionEquality().hash(positions),selectedPosition); +int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(devices),selectedDevice,const DeepCollectionEquality().hash(positions),selectedPosition,isLoading,errorMessage); @override String toString() { - return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition)'; + return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, isLoading: $isLoading, errorMessage: $errorMessage)'; } @@ -45,7 +45,7 @@ abstract mixin class $ControlPanelViewStateCopyWith<$Res> { factory $ControlPanelViewStateCopyWith(ControlPanelViewState value, $Res Function(ControlPanelViewState) _then) = _$ControlPanelViewStateCopyWithImpl; @useResult $Res call({ - UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition + UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage }); @@ -62,14 +62,16 @@ class _$ControlPanelViewStateCopyWithImpl<$Res> /// Create a copy of ControlPanelViewState /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? isLoading = null,Object? errorMessage = null,}) { return _then(_self.copyWith( loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable as UserEntity?,devices: null == devices ? _self.devices : devices // ignore: cast_nullable_to_non_nullable as List,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable as DeviceEntity?,positions: null == positions ? _self.positions : positions // ignore: cast_nullable_to_non_nullable as List,selectedPosition: freezed == selectedPosition ? _self.selectedPosition : selectedPosition // ignore: cast_nullable_to_non_nullable -as PositionEntity?, +as PositionEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable +as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable +as String, )); } /// Create a copy of ControlPanelViewState @@ -190,10 +192,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _ControlPanelViewState() when $default != null: -return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition);case _: +return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.isLoading,_that.errorMessage);case _: return orElse(); } @@ -211,10 +213,10 @@ return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positi /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage) $default,) {final _that = this; switch (_that) { case _ControlPanelViewState(): -return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition);case _: +return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.isLoading,_that.errorMessage);case _: throw StateError('Unexpected subclass'); } @@ -231,10 +233,10 @@ return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positi /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage)? $default,) {final _that = this; switch (_that) { case _ControlPanelViewState() when $default != null: -return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition);case _: +return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positions,_that.selectedPosition,_that.isLoading,_that.errorMessage);case _: return null; } @@ -246,7 +248,7 @@ return $default(_that.loggedUser,_that.devices,_that.selectedDevice,_that.positi class _ControlPanelViewState implements ControlPanelViewState { - const _ControlPanelViewState({this.loggedUser, final List devices = const [], this.selectedDevice, final List positions = const [], this.selectedPosition}): _devices = devices,_positions = positions; + const _ControlPanelViewState({this.loggedUser, final List devices = const [], this.selectedDevice, final List positions = const [], this.selectedPosition, this.isLoading = true, this.errorMessage = ''}): _devices = devices,_positions = positions; @override final UserEntity? loggedUser; @@ -266,6 +268,8 @@ class _ControlPanelViewState implements ControlPanelViewState { } @override final PositionEntity? selectedPosition; +@override@JsonKey() final bool isLoading; +@override@JsonKey() final String errorMessage; /// Create a copy of ControlPanelViewState /// with the given fields replaced by the non-null parameter values. @@ -277,16 +281,16 @@ _$ControlPanelViewStateCopyWith<_ControlPanelViewState> get copyWith => __$Contr @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other._devices, _devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other._positions, _positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ControlPanelViewState&&(identical(other.loggedUser, loggedUser) || other.loggedUser == loggedUser)&&const DeepCollectionEquality().equals(other._devices, _devices)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other._positions, _positions)&&(identical(other.selectedPosition, selectedPosition) || other.selectedPosition == selectedPosition)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); } @override -int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(_devices),selectedDevice,const DeepCollectionEquality().hash(_positions),selectedPosition); +int get hashCode => Object.hash(runtimeType,loggedUser,const DeepCollectionEquality().hash(_devices),selectedDevice,const DeepCollectionEquality().hash(_positions),selectedPosition,isLoading,errorMessage); @override String toString() { - return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition)'; + return 'ControlPanelViewState(loggedUser: $loggedUser, devices: $devices, selectedDevice: $selectedDevice, positions: $positions, selectedPosition: $selectedPosition, isLoading: $isLoading, errorMessage: $errorMessage)'; } @@ -297,7 +301,7 @@ abstract mixin class _$ControlPanelViewStateCopyWith<$Res> implements $ControlPa factory _$ControlPanelViewStateCopyWith(_ControlPanelViewState value, $Res Function(_ControlPanelViewState) _then) = __$ControlPanelViewStateCopyWithImpl; @override @useResult $Res call({ - UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition + UserEntity? loggedUser, List devices, DeviceEntity? selectedDevice, List positions, PositionEntity? selectedPosition, bool isLoading, String errorMessage }); @@ -314,14 +318,16 @@ class __$ControlPanelViewStateCopyWithImpl<$Res> /// Create a copy of ControlPanelViewState /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? loggedUser = freezed,Object? devices = null,Object? selectedDevice = freezed,Object? positions = null,Object? selectedPosition = freezed,Object? isLoading = null,Object? errorMessage = null,}) { return _then(_ControlPanelViewState( loggedUser: freezed == loggedUser ? _self.loggedUser : loggedUser // ignore: cast_nullable_to_non_nullable as UserEntity?,devices: null == devices ? _self._devices : devices // ignore: cast_nullable_to_non_nullable as List,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable as DeviceEntity?,positions: null == positions ? _self._positions : positions // ignore: cast_nullable_to_non_nullable as List,selectedPosition: freezed == selectedPosition ? _self.selectedPosition : selectedPosition // ignore: cast_nullable_to_non_nullable -as PositionEntity?, +as PositionEntity?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable +as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable +as String, )); } diff --git a/modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart b/modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart new file mode 100644 index 00000000..fd38d112 --- /dev/null +++ b/modules/legacy/modules/control_panel/lib/src/shared/widgets/device_map.dart @@ -0,0 +1,198 @@ +import 'package:control_panel/src/core/domain/entities/position_entity.dart'; +import 'package:control_panel/src/core/utils/battery_utils.dart'; +import 'package:control_panel/src/core/utils/date_format_utils.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:latlong2/latlong.dart'; +import 'package:legacy_shared/legacy_shared.dart'; +import 'package:utils/utils.dart'; + +const _defaultCenter = LatLng(40.4168, -3.7038); +const _defaultZoom = 15.0; +const _tileServerUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'; + +class DeviceMap extends ConsumerStatefulWidget { + final PositionEntity? selectedPosition; + final DeviceEntity? selectedDevice; + + const DeviceMap({ + super.key, + required this.selectedPosition, + required this.selectedDevice, + }); + + @override + ConsumerState createState() => _DeviceMapState(); +} + +class _DeviceMapState extends ConsumerState { + late final MapController _mapController; + + @override + void initState() { + super.initState(); + _mapController = MapControllerImpl(); + } + + @override + void dispose() { + _mapController.dispose(); + super.dispose(); + } + + @override + void didUpdateWidget(DeviceMap oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.selectedPosition != null && + widget.selectedPosition != oldWidget.selectedPosition) { + _mapController.move( + LatLng( + widget.selectedPosition!.latitude, + widget.selectedPosition!.longitude, + ), + _defaultZoom, + ); + } + } + + @override + Widget build(BuildContext context) { + final initialCenter = widget.selectedPosition != null + ? LatLng( + widget.selectedPosition!.latitude, + widget.selectedPosition!.longitude, + ) + : _defaultCenter; + + return FlutterMap( + mapController: _mapController, + options: MapOptions( + initialCenter: initialCenter, + initialZoom: _defaultZoom, + keepAlive: true, + ), + children: [ + TileLayer( + urlTemplate: _tileServerUrl, + userAgentPackageName: 'com.savefamily.sf_platform', + ), + MarkerLayer( + markers: [ + if (widget.selectedPosition != null) + Marker( + point: LatLng( + widget.selectedPosition!.latitude, + widget.selectedPosition!.longitude, + ), + width: 200, + height: 145, + child: Align( + alignment: Alignment.topCenter, + child: SvgPicture.asset( + 'assets/images/ui/location.svg', + height: 80, + ), + ), + rotate: true, + ), + ], + ), + if (widget.selectedPosition != null) + Align( + alignment: Alignment.bottomCenter, + child: LocationBanner( + position: widget.selectedPosition!, + battery: widget.selectedDevice?.battery ?? 0, + ), + ), + ], + ); + } +} + +class LocationBanner extends ConsumerWidget { + final PositionEntity position; + final int battery; + + const LocationBanner({ + super.key, + required this.position, + required this.battery, + }); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final theme = ref.read(themePortProvider); + final batteryIcon = toBatteryIcon(battery); + final dateText = formatPositionDate(position.positionDate); + + final addressText = [ + position.address?.street, + position.address?.province, + position.address?.country, + ].whereType().where((s) => s.isNotEmpty).join(', '); + + return Container( + height: SizeUtils.getByScreen(small: 60, big: 58), + width: SizeUtils.getByScreen(small: 300, big: 298), + margin: EdgeInsets.only( + bottom: SizeUtils.getByScreen(small: 20, big: 16), + ), + decoration: BoxDecoration( + color: theme.getColorFor(ThemeCode.backgroundPrimary), + borderRadius: BorderRadius.all( + Radius.circular(SizeUtils.getByScreen(small: 9, big: 8)), + ), + ), + child: Row( + children: [ + Icon( + SFIcons.location, + size: SizeUtils.getByScreen(small: 40, big: 38), + color: theme.getColorFor(ThemeCode.legacyPrimary), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: SizeUtils.getByScreen(small: 250, big: 248), + child: Text( + addressText, + overflow: TextOverflow.ellipsis, + ), + ), + Row( + children: [ + Text( + dateText, + style: TextStyle( + fontSize: SizeUtils.getByScreen(small: 12, big: 11), + ), + ), + if (position.networks.isNotEmpty) + Text( + ' | ${position.networks.first.signal}', + style: TextStyle( + fontSize: SizeUtils.getByScreen(small: 12, big: 11), + ), + ), + Icon(batteryIcon), + Text( + '$battery%', + style: TextStyle( + fontSize: SizeUtils.getByScreen(small: 12, big: 11), + ), + ), + ], + ), + ], + ), + ], + ), + ); + } +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource.dart index 3d7bb231..10eb1644 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource.dart @@ -1,32 +1,10 @@ -import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart'; -import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart'; -import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart'; import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart'; -import 'package:legacy_auth/src/core/data/models/login_response_model.dart'; abstract class LegacyAuthRemoteDatasource { Future requestPhoneCode({required String phone}); Future verifyPhoneCode({required String phone, required String code}); - Future login({ - required String email, - required String password, - }); - Future twoFARequestCode({ - required String token, - required String methodType, - }); - Future twoFASendCode({ - required String token, - required String code, - required String methodType, - }); - - // Future totpLogin({required String token, required String code}); - - Future signUp({required LegacySignUpRequestModel request}); - Future generateTwoFASignUp({required String token}); Future verifyTwoFACodeSignUp({ @@ -39,18 +17,4 @@ abstract class LegacyAuthRemoteDatasource { Future recoverPassword({required newPassword, required token}); Future logout(); - - Future createChildProfile({ - required String id, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String genrer, - required String relationType, - required String address, - required String cardPublicKey, - required String deviceActivationCode, - required String scaProof, - }); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource_impl.dart index b51da51a..94637546 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource_impl.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/auth_remote_datasource_impl.dart @@ -1,13 +1,6 @@ -import 'dart:convert'; - -import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart'; -import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart'; -import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart'; import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart'; -import 'package:dio/dio.dart'; -import 'package:flutter/material.dart'; +import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart'; import 'package:sf_infrastructure/sf_infrastructure.dart'; -import 'package:legacy_auth/src/core/data/models/login_response_model.dart'; import 'auth_remote_datasource.dart'; @@ -17,180 +10,46 @@ class LegacyAuthRemoteDatasourceImpl implements LegacyAuthRemoteDatasource { final QuestiaRepository _repository; @override - Future requestPhoneCode({required String phone}) async { - try { - await _repository.post( - '/auth/link-phone/request-code', - body: {'phone': phone}, + Future requestPhoneCode({required String phone}) => + safeCall( + () => _repository.post( + '/auth/link-phone/request-code', + body: {'phone': phone}, + ), + 'Error to request phone code', ); - } on DioException catch (error) { - throw _mapDioError( - error, - defaultMessage: error.response?.data ?? 'Error to request phone code', - ); - } - } @override Future verifyPhoneCode({ required String phone, required String code, - }) async { - try { - await _repository.post( - '/auth/link-phone/verify-code', - body: {'phone': phone, 'code': code}, + }) => + safeCall( + () => _repository.post( + '/auth/link-phone/verify-code', + body: {'phone': phone, 'code': code}, + ), + 'Error in verification code', ); - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in verification code'); - } - } - - @override - Future login({ - required String email, - required String password, - }) async { - try { - final response = await _repository.post>( - '/auth/login', - body: {'email': email, 'password': password}, - ); - - final data = response.data; - if (data == null || data.isEmpty) { - throw Exception('Empty response from /auth/login'); - } - - final parsed = LegacyLoginResponseModel.fromJson(data); - - return parsed; - } on DioException catch (error) { - throw _mapDioError( - error, - defaultMessage: error.message ?? 'Error in login', - ); - } - } - - @override - Future twoFARequestCode({ - //this gonna send a request to the backend to send email code to the user for default - required String token, - required String methodType, - }) async { - try { - await _repository.post( - '/auth/2fa/request-code', - body: {'token': token, 'methodType': methodType}, - ); - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in twoFARequestCode'); - } - } - - @override - Future twoFASendCode({ - required String token, - required String code, - required String methodType, - }) async { - try { - await _repository.post( - '/auth/twofa/login', - body: { - 'token': token, - 'code': code, - 'methodType': methodType, - 'rememberMe': true, - }, - ); - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in twoFASendCode'); - } - } - - // @override - // Future totpLogin({ - // required String token, - // required String code, - // }) async { - // try { - // final response = await _repository.post( - // '/auth/totp/login', - // body: { - // 'token': token, - // 'code': code, - // 'rememberMe': true, - // }, - // ); - - // final data = response.data; - // if (data == null || data.isEmpty) { - // throw Exception('Empty response from /auth/totp/login'); - // } - - // return data; - // } on DioException catch (error) { - // throw _mapDioError(error, defaultMessage: 'Error in totpLogin'); - // } - // } - - @override - Future signUp({ - required LegacySignUpRequestModel request, - }) async { - try { - final body = request.toJson(); - debugPrint(const JsonEncoder.withIndent(' ').convert(body)); - - final response = await _repository.post>( - '/auth/signup', - body: body, - ); - - final data = response.data; - if (data == null || data.isEmpty) { - throw Exception('Empty response from /auth/signup'); - } - - final parsed = LegacySignUpResponseModel.fromJson(data); - - if (!parsed.isCreated) { - throw Exception('Sign up failed: isCreated=false'); - } - - final userId = parsed.item.userId.trim(); - if (userId.isEmpty) { - throw Exception('Sign up response has empty userId'); - } - - return parsed; - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in signUp'); - } - } @override Future generateTwoFASignUp({ required String token, }) async { - try { - final response = await _repository.post>( + final response = await safeCall( + () => _repository.post>( '/auth/totp/secret', body: {'token': token}, - ); + ), + 'Error in twoFASignUp', + ); - final data = response.data; - if (data == null || data.isEmpty) { - throw Exception('Empty response from /auth/totp/secret'); - } - - final model = LegacyTwoFASecretResponseModel.fromJson(data); - return model; - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in twoFASignUp'); + final data = response.data; + if (data == null || data.isEmpty) { + throw Exception('Empty response from /auth/totp/secret'); } + + return LegacyTwoFASecretResponseModel.fromJson(data); } @override @@ -198,146 +57,54 @@ class LegacyAuthRemoteDatasourceImpl implements LegacyAuthRemoteDatasource { required String token, required String code, }) async { - try { - final response = await _repository.post( + final response = await safeCall( + () => _repository.post( '/auth/totp/code', body: {'token': token, 'code': code}, - ); + ), + 'Error in twoFaCodeSignUp', + ); - final data = response.data; - if (data == null || data.isEmpty) { - throw Exception('Empty response from /auth/totp/code'); - } - - return data; - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in twoFaCodeSignUp'); + final data = response.data; + if (data == null || data.isEmpty) { + throw Exception('Empty response from /auth/totp/code'); } + + return data; } @override Future requestPasswordReset({required String email}) async { - try { - late final Map body; - body = {'email': email}; - - final response = await _repository.put( + final response = await safeCall( + () => _repository.put( '/auth/reset-password', - body: body, - ); - final data = response.data; - if (data == null || data.isEmpty) { - throw Exception('Empty response from /auth/totp/code'); - } + body: {'email': email}, + ), + 'Error to request password reset', + ); - return data; - } on DioException catch (error) { - throw _mapDioError( - error, - defaultMessage: 'Error to request password reset', - ); + final data = response.data; + if (data == null || data.isEmpty) { + throw Exception('Empty response from /auth/reset-password'); } + + return data; } @override - Future recoverPassword({required newPassword, required token}) async { - try { - await _repository.put( - '/auth/recovery-password', - body: {'newPassword': newPassword, 'token': token}, + Future recoverPassword({required newPassword, required token}) => + safeCall( + () => _repository.put( + '/auth/recovery-password', + body: {'newPassword': newPassword, 'token': token}, + ), + 'Error to request password recovery', ); - } on DioException catch (error) { - throw _mapDioError( - error, - defaultMessage: 'Error to request password recovery', - ); - } - } @override - Future logout() async { - try { - await _repository.post('/auth/logout'); - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in logout'); - } - } - - @override - Future createChildProfile({ - required String id, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String genrer, - required String relationType, - required String address, - required String cardPublicKey, - required String deviceActivationCode, - required String scaProof, - }) async { - try { - final response = await _repository.post>( - '/child-profiles', - body: { - 'address': address, - 'bornAt': bornAt, - 'cardPublicKey': cardPublicKey, - 'deviceActivationCode': deviceActivationCode, - 'firstName': firstName, - 'genre': genrer, - 'id': id, - 'lastName': lastName, - 'parentId': parentId, - 'relationType': relationType, - 'scaProof': scaProof, - }, + Future logout() => safeCall( + () => _repository.post('/auth/logout'), + 'Error in logout', ); - final data = response.data; - if (data == null || data.isEmpty) { - throw Exception('Empty response from /auth/child-profiles'); - } - - return LegacyChildProfileResponseModel.fromJson(data); - } on DioException catch (error) { - throw _mapDioError(error, defaultMessage: 'Error in createChildProfile'); - } - } -} - -Exception _mapDioError(DioException error, {required String defaultMessage}) { - final apiMsg = _extractApiMessage(error.response?.data); - final msg = apiMsg ?? error.message ?? defaultMessage; - return Exception(msg); -} - -String? _extractApiMessage(Object? data) { - if (data == null) return null; - - if (data is Map) { - final errorObj = data['error']; - if (errorObj is Map && errorObj['message'] is String) { - return (errorObj['message'] as String).trim(); - } - if (data['message'] is String) { - return (data['message'] as String).trim(); - } - return null; - } - - if (data is String) { - final raw = data.trim(); - if (raw.isEmpty) return null; - - try { - final decoded = jsonDecode(raw); - return _extractApiMessage(decoded); - } catch (_) { - return raw; - } - } - - return null; } diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart new file mode 100644 index 00000000..ca1f0b96 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource.dart @@ -0,0 +1,13 @@ +import 'package:legacy_auth/src/core/data/models/device_response_model.dart'; + +abstract class LegacyDeviceSetupRemoteDatasource { + Future createDevice({ + required String name, + required String genrer, + required int weight, + required int stepLength, + required int bornAt, + required String relationType, + required String activationKey, + }); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart new file mode 100644 index 00000000..a853b57e --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/device_setup_remote_datasource_impl.dart @@ -0,0 +1,45 @@ +import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource.dart'; +import 'package:legacy_auth/src/core/data/models/device_response_model.dart'; +import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart'; +import 'package:sf_infrastructure/sf_infrastructure.dart'; + +class LegacyDeviceSetupRemoteDatasourceImpl + implements LegacyDeviceSetupRemoteDatasource { + LegacyDeviceSetupRemoteDatasourceImpl(this._repository); + + final QuestiaRepository _repository; + + @override + Future createDevice({ + required String name, + required String genrer, + required int weight, + required int stepLength, + required int bornAt, + required String relationType, + required String activationKey, + }) async { + final response = await safeCall( + () => _repository.post>( + '/devices', + body: { + 'name': name, + 'genre': genrer, + 'weight': weight, + 'stepLength': stepLength, + 'bornAt': bornAt, + 'relationType': relationType, + 'activationKey': activationKey, + }, + ), + 'Error in createDevice', + ); + + final data = response.data; + if (data == null || data.isEmpty) { + throw Exception('Empty response from /devices'); + } + + return LegacyDeviceResponseModel.fromJson(data); + } +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource.dart new file mode 100644 index 00000000..57f9d590 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource.dart @@ -0,0 +1,21 @@ +import 'package:legacy_auth/src/core/data/models/login_response_model.dart'; + +abstract class LegacyLoginRemoteDatasource { + Future login({ + required String email, + required String password, + }); + + Future twoFARequestCode({ + required String token, + required String methodType, + }); + + Future twoFASendCode({ + required String token, + required String code, + required String methodType, + }); + + Future hasDevices(); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource_impl.dart new file mode 100644 index 00000000..adcde8ff --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/login_remote_datasource_impl.dart @@ -0,0 +1,77 @@ +import 'package:sf_infrastructure/sf_infrastructure.dart'; +import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource.dart'; +import 'package:legacy_auth/src/core/data/models/login_response_model.dart'; +import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart'; + +class LegacyLoginRemoteDatasourceImpl implements LegacyLoginRemoteDatasource { + const LegacyLoginRemoteDatasourceImpl(this._repository); + + final QuestiaRepository _repository; + + @override + Future login({ + required String email, + required String password, + }) async { + final response = await safeCall( + () => _repository.post>( + '/auth/login', + body: {'email': email, 'password': password}, + ), + 'Error in login', + ); + + final data = response.data; + if (data == null || data.isEmpty) { + throw Exception('Empty response from /auth/login'); + } + + return LegacyLoginResponseModel.fromJson(data); + } + + @override + Future twoFARequestCode({ + required String token, + required String methodType, + }) => + safeCall( + () => _repository.post( + '/auth/2fa/request-code', + body: {'token': token, 'methodType': methodType}, + ), + 'Error in twoFARequestCode', + ); + + @override + Future twoFASendCode({ + required String token, + required String code, + required String methodType, + }) => + safeCall( + () => _repository.post( + '/auth/twofa/login', + body: { + 'token': token, + 'code': code, + 'methodType': methodType, + 'rememberMe': true, + }, + ), + 'Error in twoFASendCode', + ); + + @override + Future hasDevices() async { + final response = await safeCall( + () => _repository.get>('/devices'), + 'Error fetching devices', + ); + + final data = response.data; + if (data == null) return false; + + final total = data['total'] as int? ?? 0; + return total > 0; + } +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource.dart new file mode 100644 index 00000000..a493ae47 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource.dart @@ -0,0 +1,8 @@ +import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart'; +import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart'; + +abstract class LegacySignUpRemoteDatasource { + Future signUp({ + required LegacySignUpRequestModel request, + }); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource_impl.dart new file mode 100644 index 00000000..8cdbf74b --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/datasource/sign_up_remote_datasource_impl.dart @@ -0,0 +1,43 @@ +import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart'; +import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart'; +import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart'; +import 'package:sf_infrastructure/sf_infrastructure.dart'; + +import 'sign_up_remote_datasource.dart'; + +class LegacySignUpRemoteDatasourceImpl implements LegacySignUpRemoteDatasource { + const LegacySignUpRemoteDatasourceImpl(this._repository); + + final QuestiaRepository _repository; + + @override + Future signUp({ + required LegacySignUpRequestModel request, + }) => + safeCall(() async { + final body = request.toJson(); + + final response = await _repository.post>( + '/auth/signup', + body: body, + ); + + final data = response.data; + if (data == null || data.isEmpty) { + throw Exception('Empty response from /auth/signup'); + } + + final parsed = LegacySignUpResponseModel.fromJson(data); + + if (!parsed.isCreated) { + throw Exception('Sign up failed: isCreated=false'); + } + + final userId = parsed.item.trim(); + if (userId.isEmpty) { + throw Exception('Sign up response has empty userId'); + } + + return parsed; + }, 'Error in signUp'); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.dart deleted file mode 100644 index ef82fe70..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.dart +++ /dev/null @@ -1,56 +0,0 @@ -import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'child_profile_response_model.freezed.dart'; -part 'child_profile_response_model.g.dart'; - -@freezed -abstract class LegacyChildProfileResponseModel with _$LegacyChildProfileResponseModel { - const factory LegacyChildProfileResponseModel({ - required bool isCreated, - required LegacyChildProfileItemResponseModel item, - }) = _LegacyChildProfileResponseModel; - - factory LegacyChildProfileResponseModel.fromJson(Map json) => - _$LegacyChildProfileResponseModelFromJson(json); -} - -@freezed -abstract class LegacyChildProfileItemResponseModel - with _$LegacyChildProfileItemResponseModel { - const factory LegacyChildProfileItemResponseModel({ - required String id, - required String deviceIdentificator, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String address, - required int createdAt, - int? updatedAt, - String? profileImageId, - }) = _LegacyChildProfileItemResponseModel; - - factory LegacyChildProfileItemResponseModel.fromJson(Map json) => - _$LegacyChildProfileItemResponseModelFromJson(json); -} - -extension LegacyChildProfileResponseModelMapper on LegacyChildProfileResponseModel { - LegacyChildProfileEntity toEntity() { - return LegacyChildProfileEntity( - isCreated: isCreated, - item: LegacyChildProfileItemEntity( - id: item.id, - deviceIdentificator: item.deviceIdentificator, - parentId: item.parentId, - firstName: item.firstName, - lastName: item.lastName, - bornAt: item.bornAt, - address: item.address, - createdAt: item.createdAt, - updatedAt: item.updatedAt, - profileImageId: item.profileImageId, - ), - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.freezed.dart deleted file mode 100644 index 7417d3d5..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.freezed.dart +++ /dev/null @@ -1,588 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND -// coverage:ignore-file -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'child_profile_response_model.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; - -/// @nodoc -mixin _$LegacyChildProfileResponseModel { - - bool get isCreated; LegacyChildProfileItemResponseModel get item; -/// Create a copy of LegacyChildProfileResponseModel -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$LegacyChildProfileResponseModelCopyWith get copyWith => _$LegacyChildProfileResponseModelCopyWithImpl(this as LegacyChildProfileResponseModel, _$identity); - - /// Serializes this LegacyChildProfileResponseModel to a JSON map. - Map toJson(); - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,isCreated,item); - -@override -String toString() { - return 'LegacyChildProfileResponseModel(isCreated: $isCreated, item: $item)'; -} - - -} - -/// @nodoc -abstract mixin class $LegacyChildProfileResponseModelCopyWith<$Res> { - factory $LegacyChildProfileResponseModelCopyWith(LegacyChildProfileResponseModel value, $Res Function(LegacyChildProfileResponseModel) _then) = _$LegacyChildProfileResponseModelCopyWithImpl; -@useResult -$Res call({ - bool isCreated, LegacyChildProfileItemResponseModel item -}); - - -$LegacyChildProfileItemResponseModelCopyWith<$Res> get item; - -} -/// @nodoc -class _$LegacyChildProfileResponseModelCopyWithImpl<$Res> - implements $LegacyChildProfileResponseModelCopyWith<$Res> { - _$LegacyChildProfileResponseModelCopyWithImpl(this._self, this._then); - - final LegacyChildProfileResponseModel _self; - final $Res Function(LegacyChildProfileResponseModel) _then; - -/// Create a copy of LegacyChildProfileResponseModel -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) { - return _then(_self.copyWith( -isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable -as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable -as LegacyChildProfileItemResponseModel, - )); -} -/// Create a copy of LegacyChildProfileResponseModel -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$LegacyChildProfileItemResponseModelCopyWith<$Res> get item { - - return $LegacyChildProfileItemResponseModelCopyWith<$Res>(_self.item, (value) { - return _then(_self.copyWith(item: value)); - }); -} -} - - -/// Adds pattern-matching-related methods to [LegacyChildProfileResponseModel]. -extension LegacyChildProfileResponseModelPatterns on LegacyChildProfileResponseModel { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _LegacyChildProfileResponseModel value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _LegacyChildProfileResponseModel() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _LegacyChildProfileResponseModel value) $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileResponseModel(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LegacyChildProfileResponseModel value)? $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileResponseModel() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( bool isCreated, LegacyChildProfileItemResponseModel item)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _LegacyChildProfileResponseModel() when $default != null: -return $default(_that.isCreated,_that.item);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( bool isCreated, LegacyChildProfileItemResponseModel item) $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileResponseModel(): -return $default(_that.isCreated,_that.item);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isCreated, LegacyChildProfileItemResponseModel item)? $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileResponseModel() when $default != null: -return $default(_that.isCreated,_that.item);case _: - return null; - -} -} - -} - -/// @nodoc -@JsonSerializable() - -class _LegacyChildProfileResponseModel implements LegacyChildProfileResponseModel { - const _LegacyChildProfileResponseModel({required this.isCreated, required this.item}); - factory _LegacyChildProfileResponseModel.fromJson(Map json) => _$LegacyChildProfileResponseModelFromJson(json); - -@override final bool isCreated; -@override final LegacyChildProfileItemResponseModel item; - -/// Create a copy of LegacyChildProfileResponseModel -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$LegacyChildProfileResponseModelCopyWith<_LegacyChildProfileResponseModel> get copyWith => __$LegacyChildProfileResponseModelCopyWithImpl<_LegacyChildProfileResponseModel>(this, _$identity); - -@override -Map toJson() { - return _$LegacyChildProfileResponseModelToJson(this, ); -} - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,isCreated,item); - -@override -String toString() { - return 'LegacyChildProfileResponseModel(isCreated: $isCreated, item: $item)'; -} - - -} - -/// @nodoc -abstract mixin class _$LegacyChildProfileResponseModelCopyWith<$Res> implements $LegacyChildProfileResponseModelCopyWith<$Res> { - factory _$LegacyChildProfileResponseModelCopyWith(_LegacyChildProfileResponseModel value, $Res Function(_LegacyChildProfileResponseModel) _then) = __$LegacyChildProfileResponseModelCopyWithImpl; -@override @useResult -$Res call({ - bool isCreated, LegacyChildProfileItemResponseModel item -}); - - -@override $LegacyChildProfileItemResponseModelCopyWith<$Res> get item; - -} -/// @nodoc -class __$LegacyChildProfileResponseModelCopyWithImpl<$Res> - implements _$LegacyChildProfileResponseModelCopyWith<$Res> { - __$LegacyChildProfileResponseModelCopyWithImpl(this._self, this._then); - - final _LegacyChildProfileResponseModel _self; - final $Res Function(_LegacyChildProfileResponseModel) _then; - -/// Create a copy of LegacyChildProfileResponseModel -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) { - return _then(_LegacyChildProfileResponseModel( -isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable -as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable -as LegacyChildProfileItemResponseModel, - )); -} - -/// Create a copy of LegacyChildProfileResponseModel -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$LegacyChildProfileItemResponseModelCopyWith<$Res> get item { - - return $LegacyChildProfileItemResponseModelCopyWith<$Res>(_self.item, (value) { - return _then(_self.copyWith(item: value)); - }); -} -} - - -/// @nodoc -mixin _$LegacyChildProfileItemResponseModel { - - String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get address; int get createdAt; int? get updatedAt; String? get profileImageId; -/// Create a copy of LegacyChildProfileItemResponseModel -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$LegacyChildProfileItemResponseModelCopyWith get copyWith => _$LegacyChildProfileItemResponseModelCopyWithImpl(this as LegacyChildProfileItemResponseModel, _$identity); - - /// Serializes this LegacyChildProfileItemResponseModel to a JSON map. - Map toJson(); - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId); - -@override -String toString() { - return 'LegacyChildProfileItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)'; -} - - -} - -/// @nodoc -abstract mixin class $LegacyChildProfileItemResponseModelCopyWith<$Res> { - factory $LegacyChildProfileItemResponseModelCopyWith(LegacyChildProfileItemResponseModel value, $Res Function(LegacyChildProfileItemResponseModel) _then) = _$LegacyChildProfileItemResponseModelCopyWithImpl; -@useResult -$Res call({ - String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId -}); - - - - -} -/// @nodoc -class _$LegacyChildProfileItemResponseModelCopyWithImpl<$Res> - implements $LegacyChildProfileItemResponseModelCopyWith<$Res> { - _$LegacyChildProfileItemResponseModelCopyWithImpl(this._self, this._then); - - final LegacyChildProfileItemResponseModel _self; - final $Res Function(LegacyChildProfileItemResponseModel) _then; - -/// Create a copy of LegacyChildProfileItemResponseModel -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) { - return _then(_self.copyWith( -id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable -as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable -as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable -as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable -as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable -as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable -as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable -as String?, - )); -} - -} - - -/// Adds pattern-matching-related methods to [LegacyChildProfileItemResponseModel]. -extension LegacyChildProfileItemResponseModelPatterns on LegacyChildProfileItemResponseModel { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _LegacyChildProfileItemResponseModel value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _LegacyChildProfileItemResponseModel() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _LegacyChildProfileItemResponseModel value) $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileItemResponseModel(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LegacyChildProfileItemResponseModel value)? $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileItemResponseModel() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _LegacyChildProfileItemResponseModel() when $default != null: -return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId) $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileItemResponseModel(): -return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileItemResponseModel() when $default != null: -return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _: - return null; - -} -} - -} - -/// @nodoc -@JsonSerializable() - -class _LegacyChildProfileItemResponseModel implements LegacyChildProfileItemResponseModel { - const _LegacyChildProfileItemResponseModel({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.address, required this.createdAt, this.updatedAt, this.profileImageId}); - factory _LegacyChildProfileItemResponseModel.fromJson(Map json) => _$LegacyChildProfileItemResponseModelFromJson(json); - -@override final String id; -@override final String deviceIdentificator; -@override final String parentId; -@override final String firstName; -@override final String lastName; -@override final int bornAt; -@override final String address; -@override final int createdAt; -@override final int? updatedAt; -@override final String? profileImageId; - -/// Create a copy of LegacyChildProfileItemResponseModel -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$LegacyChildProfileItemResponseModelCopyWith<_LegacyChildProfileItemResponseModel> get copyWith => __$LegacyChildProfileItemResponseModelCopyWithImpl<_LegacyChildProfileItemResponseModel>(this, _$identity); - -@override -Map toJson() { - return _$LegacyChildProfileItemResponseModelToJson(this, ); -} - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId); - -@override -String toString() { - return 'LegacyChildProfileItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)'; -} - - -} - -/// @nodoc -abstract mixin class _$LegacyChildProfileItemResponseModelCopyWith<$Res> implements $LegacyChildProfileItemResponseModelCopyWith<$Res> { - factory _$LegacyChildProfileItemResponseModelCopyWith(_LegacyChildProfileItemResponseModel value, $Res Function(_LegacyChildProfileItemResponseModel) _then) = __$LegacyChildProfileItemResponseModelCopyWithImpl; -@override @useResult -$Res call({ - String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId -}); - - - - -} -/// @nodoc -class __$LegacyChildProfileItemResponseModelCopyWithImpl<$Res> - implements _$LegacyChildProfileItemResponseModelCopyWith<$Res> { - __$LegacyChildProfileItemResponseModelCopyWithImpl(this._self, this._then); - - final _LegacyChildProfileItemResponseModel _self; - final $Res Function(_LegacyChildProfileItemResponseModel) _then; - -/// Create a copy of LegacyChildProfileItemResponseModel -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) { - return _then(_LegacyChildProfileItemResponseModel( -id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable -as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable -as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable -as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable -as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable -as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable -as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable -as String?, - )); -} - - -} - -// dart format on diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.g.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.g.dart deleted file mode 100644 index 719be6cb..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/child_profile_response_model.g.dart +++ /dev/null @@ -1,50 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'child_profile_response_model.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_LegacyChildProfileResponseModel _$LegacyChildProfileResponseModelFromJson( - Map json, -) => _LegacyChildProfileResponseModel( - isCreated: json['isCreated'] as bool, - item: LegacyChildProfileItemResponseModel.fromJson( - json['item'] as Map, - ), -); - -Map _$LegacyChildProfileResponseModelToJson( - _LegacyChildProfileResponseModel instance, -) => {'isCreated': instance.isCreated, 'item': instance.item}; - -_LegacyChildProfileItemResponseModel -_$LegacyChildProfileItemResponseModelFromJson(Map json) => - _LegacyChildProfileItemResponseModel( - id: json['id'] as String, - deviceIdentificator: json['deviceIdentificator'] as String, - parentId: json['parentId'] as String, - firstName: json['firstName'] as String, - lastName: json['lastName'] as String, - bornAt: (json['bornAt'] as num).toInt(), - address: json['address'] as String, - createdAt: (json['createdAt'] as num).toInt(), - updatedAt: (json['updatedAt'] as num?)?.toInt(), - profileImageId: json['profileImageId'] as String?, - ); - -Map _$LegacyChildProfileItemResponseModelToJson( - _LegacyChildProfileItemResponseModel instance, -) => { - 'id': instance.id, - 'deviceIdentificator': instance.deviceIdentificator, - 'parentId': instance.parentId, - 'firstName': instance.firstName, - 'lastName': instance.lastName, - 'bornAt': instance.bornAt, - 'address': instance.address, - 'createdAt': instance.createdAt, - 'updatedAt': instance.updatedAt, - 'profileImageId': instance.profileImageId, -}; diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.dart new file mode 100644 index 00000000..c5ce0d9f --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.dart @@ -0,0 +1,41 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'device_response_model.freezed.dart'; +part 'device_response_model.g.dart'; + +@freezed +abstract class LegacyDeviceResponseModel with _$LegacyDeviceResponseModel { + const factory LegacyDeviceResponseModel({ + required bool isCreated, + required LegacyDeviceItemResponseModel item, + }) = _LegacyDeviceResponseModel; + + factory LegacyDeviceResponseModel.fromJson(Map json) => + _$LegacyDeviceResponseModelFromJson(json); +} + +@freezed +abstract class LegacyDeviceItemResponseModel + with _$LegacyDeviceItemResponseModel { + const factory LegacyDeviceItemResponseModel({ + required String id, + required String identificator, + required String carrierName, + String? carrierGenre, + int? carrierWeight, + int? carrierStepLength, + int? carrierBirthday, + String? userId, + int? battery, + required String protocol, + required String connectionServer, + required String type, + @Default({}) Map flags, + @Default({}) Map settings, + Map? capabilities, + required int createdAt, + }) = _LegacyDeviceItemResponseModel; + + factory LegacyDeviceItemResponseModel.fromJson(Map json) => + _$LegacyDeviceItemResponseModelFromJson(json); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.freezed.dart new file mode 100644 index 00000000..31020993 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.freezed.dart @@ -0,0 +1,626 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'device_response_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$LegacyDeviceResponseModel { + + bool get isCreated; LegacyDeviceItemResponseModel get item; +/// Create a copy of LegacyDeviceResponseModel +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LegacyDeviceResponseModelCopyWith get copyWith => _$LegacyDeviceResponseModelCopyWithImpl(this as LegacyDeviceResponseModel, _$identity); + + /// Serializes this LegacyDeviceResponseModel to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,isCreated,item); + +@override +String toString() { + return 'LegacyDeviceResponseModel(isCreated: $isCreated, item: $item)'; +} + + +} + +/// @nodoc +abstract mixin class $LegacyDeviceResponseModelCopyWith<$Res> { + factory $LegacyDeviceResponseModelCopyWith(LegacyDeviceResponseModel value, $Res Function(LegacyDeviceResponseModel) _then) = _$LegacyDeviceResponseModelCopyWithImpl; +@useResult +$Res call({ + bool isCreated, LegacyDeviceItemResponseModel item +}); + + +$LegacyDeviceItemResponseModelCopyWith<$Res> get item; + +} +/// @nodoc +class _$LegacyDeviceResponseModelCopyWithImpl<$Res> + implements $LegacyDeviceResponseModelCopyWith<$Res> { + _$LegacyDeviceResponseModelCopyWithImpl(this._self, this._then); + + final LegacyDeviceResponseModel _self; + final $Res Function(LegacyDeviceResponseModel) _then; + +/// Create a copy of LegacyDeviceResponseModel +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) { + return _then(_self.copyWith( +isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable +as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable +as LegacyDeviceItemResponseModel, + )); +} +/// Create a copy of LegacyDeviceResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LegacyDeviceItemResponseModelCopyWith<$Res> get item { + + return $LegacyDeviceItemResponseModelCopyWith<$Res>(_self.item, (value) { + return _then(_self.copyWith(item: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [LegacyDeviceResponseModel]. +extension LegacyDeviceResponseModelPatterns on LegacyDeviceResponseModel { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _LegacyDeviceResponseModel value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LegacyDeviceResponseModel() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _LegacyDeviceResponseModel value) $default,){ +final _that = this; +switch (_that) { +case _LegacyDeviceResponseModel(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LegacyDeviceResponseModel value)? $default,){ +final _that = this; +switch (_that) { +case _LegacyDeviceResponseModel() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( bool isCreated, LegacyDeviceItemResponseModel item)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LegacyDeviceResponseModel() when $default != null: +return $default(_that.isCreated,_that.item);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( bool isCreated, LegacyDeviceItemResponseModel item) $default,) {final _that = this; +switch (_that) { +case _LegacyDeviceResponseModel(): +return $default(_that.isCreated,_that.item);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isCreated, LegacyDeviceItemResponseModel item)? $default,) {final _that = this; +switch (_that) { +case _LegacyDeviceResponseModel() when $default != null: +return $default(_that.isCreated,_that.item);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _LegacyDeviceResponseModel implements LegacyDeviceResponseModel { + const _LegacyDeviceResponseModel({required this.isCreated, required this.item}); + factory _LegacyDeviceResponseModel.fromJson(Map json) => _$LegacyDeviceResponseModelFromJson(json); + +@override final bool isCreated; +@override final LegacyDeviceItemResponseModel item; + +/// Create a copy of LegacyDeviceResponseModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LegacyDeviceResponseModelCopyWith<_LegacyDeviceResponseModel> get copyWith => __$LegacyDeviceResponseModelCopyWithImpl<_LegacyDeviceResponseModel>(this, _$identity); + +@override +Map toJson() { + return _$LegacyDeviceResponseModelToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyDeviceResponseModel&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,isCreated,item); + +@override +String toString() { + return 'LegacyDeviceResponseModel(isCreated: $isCreated, item: $item)'; +} + + +} + +/// @nodoc +abstract mixin class _$LegacyDeviceResponseModelCopyWith<$Res> implements $LegacyDeviceResponseModelCopyWith<$Res> { + factory _$LegacyDeviceResponseModelCopyWith(_LegacyDeviceResponseModel value, $Res Function(_LegacyDeviceResponseModel) _then) = __$LegacyDeviceResponseModelCopyWithImpl; +@override @useResult +$Res call({ + bool isCreated, LegacyDeviceItemResponseModel item +}); + + +@override $LegacyDeviceItemResponseModelCopyWith<$Res> get item; + +} +/// @nodoc +class __$LegacyDeviceResponseModelCopyWithImpl<$Res> + implements _$LegacyDeviceResponseModelCopyWith<$Res> { + __$LegacyDeviceResponseModelCopyWithImpl(this._self, this._then); + + final _LegacyDeviceResponseModel _self; + final $Res Function(_LegacyDeviceResponseModel) _then; + +/// Create a copy of LegacyDeviceResponseModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) { + return _then(_LegacyDeviceResponseModel( +isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable +as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable +as LegacyDeviceItemResponseModel, + )); +} + +/// Create a copy of LegacyDeviceResponseModel +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LegacyDeviceItemResponseModelCopyWith<$Res> get item { + + return $LegacyDeviceItemResponseModelCopyWith<$Res>(_self.item, (value) { + return _then(_self.copyWith(item: value)); + }); +} +} + + +/// @nodoc +mixin _$LegacyDeviceItemResponseModel { + + String get id; String get identificator; String get carrierName; String? get carrierGenre; int? get carrierWeight; int? get carrierStepLength; int? get carrierBirthday; String? get userId; int? get battery; String get protocol; String get connectionServer; String get type; Map get flags; Map get settings; Map? get capabilities; int get createdAt; +/// Create a copy of LegacyDeviceItemResponseModel +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LegacyDeviceItemResponseModelCopyWith get copyWith => _$LegacyDeviceItemResponseModelCopyWithImpl(this as LegacyDeviceItemResponseModel, _$identity); + + /// Serializes this LegacyDeviceItemResponseModel to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other.flags, flags)&&const DeepCollectionEquality().equals(other.settings, settings)&&const DeepCollectionEquality().equals(other.capabilities, capabilities)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,identificator,carrierName,carrierGenre,carrierWeight,carrierStepLength,carrierBirthday,userId,battery,protocol,connectionServer,type,const DeepCollectionEquality().hash(flags),const DeepCollectionEquality().hash(settings),const DeepCollectionEquality().hash(capabilities),createdAt); + +@override +String toString() { + return 'LegacyDeviceItemResponseModel(id: $id, identificator: $identificator, carrierName: $carrierName, carrierGenre: $carrierGenre, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierBirthday: $carrierBirthday, userId: $userId, battery: $battery, protocol: $protocol, connectionServer: $connectionServer, type: $type, flags: $flags, settings: $settings, capabilities: $capabilities, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class $LegacyDeviceItemResponseModelCopyWith<$Res> { + factory $LegacyDeviceItemResponseModelCopyWith(LegacyDeviceItemResponseModel value, $Res Function(LegacyDeviceItemResponseModel) _then) = _$LegacyDeviceItemResponseModelCopyWithImpl; +@useResult +$Res call({ + String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map flags, Map settings, Map? capabilities, int createdAt +}); + + + + +} +/// @nodoc +class _$LegacyDeviceItemResponseModelCopyWithImpl<$Res> + implements $LegacyDeviceItemResponseModelCopyWith<$Res> { + _$LegacyDeviceItemResponseModelCopyWithImpl(this._self, this._then); + + final LegacyDeviceItemResponseModel _self; + final $Res Function(LegacyDeviceItemResponseModel) _then; + +/// Create a copy of LegacyDeviceItemResponseModel +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? identificator = null,Object? carrierName = null,Object? carrierGenre = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierBirthday = freezed,Object? userId = freezed,Object? battery = freezed,Object? protocol = null,Object? connectionServer = null,Object? type = null,Object? flags = null,Object? settings = null,Object? capabilities = freezed,Object? createdAt = null,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable +as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable +as String,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable +as String?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable +as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable +as int?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable +as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable +as String?,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable +as int?,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable +as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable +as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String,flags: null == flags ? _self.flags : flags // ignore: cast_nullable_to_non_nullable +as Map,settings: null == settings ? _self.settings : settings // ignore: cast_nullable_to_non_nullable +as Map,capabilities: freezed == capabilities ? _self.capabilities : capabilities // ignore: cast_nullable_to_non_nullable +as Map?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} + + +/// Adds pattern-matching-related methods to [LegacyDeviceItemResponseModel]. +extension LegacyDeviceItemResponseModelPatterns on LegacyDeviceItemResponseModel { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _LegacyDeviceItemResponseModel value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LegacyDeviceItemResponseModel() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _LegacyDeviceItemResponseModel value) $default,){ +final _that = this; +switch (_that) { +case _LegacyDeviceItemResponseModel(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LegacyDeviceItemResponseModel value)? $default,){ +final _that = this; +switch (_that) { +case _LegacyDeviceItemResponseModel() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map flags, Map settings, Map? capabilities, int createdAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LegacyDeviceItemResponseModel() when $default != null: +return $default(_that.id,_that.identificator,_that.carrierName,_that.carrierGenre,_that.carrierWeight,_that.carrierStepLength,_that.carrierBirthday,_that.userId,_that.battery,_that.protocol,_that.connectionServer,_that.type,_that.flags,_that.settings,_that.capabilities,_that.createdAt);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map flags, Map settings, Map? capabilities, int createdAt) $default,) {final _that = this; +switch (_that) { +case _LegacyDeviceItemResponseModel(): +return $default(_that.id,_that.identificator,_that.carrierName,_that.carrierGenre,_that.carrierWeight,_that.carrierStepLength,_that.carrierBirthday,_that.userId,_that.battery,_that.protocol,_that.connectionServer,_that.type,_that.flags,_that.settings,_that.capabilities,_that.createdAt);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map flags, Map settings, Map? capabilities, int createdAt)? $default,) {final _that = this; +switch (_that) { +case _LegacyDeviceItemResponseModel() when $default != null: +return $default(_that.id,_that.identificator,_that.carrierName,_that.carrierGenre,_that.carrierWeight,_that.carrierStepLength,_that.carrierBirthday,_that.userId,_that.battery,_that.protocol,_that.connectionServer,_that.type,_that.flags,_that.settings,_that.capabilities,_that.createdAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _LegacyDeviceItemResponseModel implements LegacyDeviceItemResponseModel { + const _LegacyDeviceItemResponseModel({required this.id, required this.identificator, required this.carrierName, this.carrierGenre, this.carrierWeight, this.carrierStepLength, this.carrierBirthday, this.userId, this.battery, required this.protocol, required this.connectionServer, required this.type, final Map flags = const {}, final Map settings = const {}, final Map? capabilities, required this.createdAt}): _flags = flags,_settings = settings,_capabilities = capabilities; + factory _LegacyDeviceItemResponseModel.fromJson(Map json) => _$LegacyDeviceItemResponseModelFromJson(json); + +@override final String id; +@override final String identificator; +@override final String carrierName; +@override final String? carrierGenre; +@override final int? carrierWeight; +@override final int? carrierStepLength; +@override final int? carrierBirthday; +@override final String? userId; +@override final int? battery; +@override final String protocol; +@override final String connectionServer; +@override final String type; + final Map _flags; +@override@JsonKey() Map get flags { + if (_flags is EqualUnmodifiableMapView) return _flags; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_flags); +} + + final Map _settings; +@override@JsonKey() Map get settings { + if (_settings is EqualUnmodifiableMapView) return _settings; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_settings); +} + + final Map? _capabilities; +@override Map? get capabilities { + final value = _capabilities; + if (value == null) return null; + if (_capabilities is EqualUnmodifiableMapView) return _capabilities; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); +} + +@override final int createdAt; + +/// Create a copy of LegacyDeviceItemResponseModel +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LegacyDeviceItemResponseModelCopyWith<_LegacyDeviceItemResponseModel> get copyWith => __$LegacyDeviceItemResponseModelCopyWithImpl<_LegacyDeviceItemResponseModel>(this, _$identity); + +@override +Map toJson() { + return _$LegacyDeviceItemResponseModelToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyDeviceItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.identificator, identificator) || other.identificator == identificator)&&(identical(other.carrierName, carrierName) || other.carrierName == carrierName)&&(identical(other.carrierGenre, carrierGenre) || other.carrierGenre == carrierGenre)&&(identical(other.carrierWeight, carrierWeight) || other.carrierWeight == carrierWeight)&&(identical(other.carrierStepLength, carrierStepLength) || other.carrierStepLength == carrierStepLength)&&(identical(other.carrierBirthday, carrierBirthday) || other.carrierBirthday == carrierBirthday)&&(identical(other.userId, userId) || other.userId == userId)&&(identical(other.battery, battery) || other.battery == battery)&&(identical(other.protocol, protocol) || other.protocol == protocol)&&(identical(other.connectionServer, connectionServer) || other.connectionServer == connectionServer)&&(identical(other.type, type) || other.type == type)&&const DeepCollectionEquality().equals(other._flags, _flags)&&const DeepCollectionEquality().equals(other._settings, _settings)&&const DeepCollectionEquality().equals(other._capabilities, _capabilities)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,identificator,carrierName,carrierGenre,carrierWeight,carrierStepLength,carrierBirthday,userId,battery,protocol,connectionServer,type,const DeepCollectionEquality().hash(_flags),const DeepCollectionEquality().hash(_settings),const DeepCollectionEquality().hash(_capabilities),createdAt); + +@override +String toString() { + return 'LegacyDeviceItemResponseModel(id: $id, identificator: $identificator, carrierName: $carrierName, carrierGenre: $carrierGenre, carrierWeight: $carrierWeight, carrierStepLength: $carrierStepLength, carrierBirthday: $carrierBirthday, userId: $userId, battery: $battery, protocol: $protocol, connectionServer: $connectionServer, type: $type, flags: $flags, settings: $settings, capabilities: $capabilities, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$LegacyDeviceItemResponseModelCopyWith<$Res> implements $LegacyDeviceItemResponseModelCopyWith<$Res> { + factory _$LegacyDeviceItemResponseModelCopyWith(_LegacyDeviceItemResponseModel value, $Res Function(_LegacyDeviceItemResponseModel) _then) = __$LegacyDeviceItemResponseModelCopyWithImpl; +@override @useResult +$Res call({ + String id, String identificator, String carrierName, String? carrierGenre, int? carrierWeight, int? carrierStepLength, int? carrierBirthday, String? userId, int? battery, String protocol, String connectionServer, String type, Map flags, Map settings, Map? capabilities, int createdAt +}); + + + + +} +/// @nodoc +class __$LegacyDeviceItemResponseModelCopyWithImpl<$Res> + implements _$LegacyDeviceItemResponseModelCopyWith<$Res> { + __$LegacyDeviceItemResponseModelCopyWithImpl(this._self, this._then); + + final _LegacyDeviceItemResponseModel _self; + final $Res Function(_LegacyDeviceItemResponseModel) _then; + +/// Create a copy of LegacyDeviceItemResponseModel +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? identificator = null,Object? carrierName = null,Object? carrierGenre = freezed,Object? carrierWeight = freezed,Object? carrierStepLength = freezed,Object? carrierBirthday = freezed,Object? userId = freezed,Object? battery = freezed,Object? protocol = null,Object? connectionServer = null,Object? type = null,Object? flags = null,Object? settings = null,Object? capabilities = freezed,Object? createdAt = null,}) { + return _then(_LegacyDeviceItemResponseModel( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,identificator: null == identificator ? _self.identificator : identificator // ignore: cast_nullable_to_non_nullable +as String,carrierName: null == carrierName ? _self.carrierName : carrierName // ignore: cast_nullable_to_non_nullable +as String,carrierGenre: freezed == carrierGenre ? _self.carrierGenre : carrierGenre // ignore: cast_nullable_to_non_nullable +as String?,carrierWeight: freezed == carrierWeight ? _self.carrierWeight : carrierWeight // ignore: cast_nullable_to_non_nullable +as int?,carrierStepLength: freezed == carrierStepLength ? _self.carrierStepLength : carrierStepLength // ignore: cast_nullable_to_non_nullable +as int?,carrierBirthday: freezed == carrierBirthday ? _self.carrierBirthday : carrierBirthday // ignore: cast_nullable_to_non_nullable +as int?,userId: freezed == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable +as String?,battery: freezed == battery ? _self.battery : battery // ignore: cast_nullable_to_non_nullable +as int?,protocol: null == protocol ? _self.protocol : protocol // ignore: cast_nullable_to_non_nullable +as String,connectionServer: null == connectionServer ? _self.connectionServer : connectionServer // ignore: cast_nullable_to_non_nullable +as String,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String,flags: null == flags ? _self._flags : flags // ignore: cast_nullable_to_non_nullable +as Map,settings: null == settings ? _self._settings : settings // ignore: cast_nullable_to_non_nullable +as Map,capabilities: freezed == capabilities ? _self._capabilities : capabilities // ignore: cast_nullable_to_non_nullable +as Map?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +// dart format on diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.g.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.g.dart new file mode 100644 index 00000000..45f325c1 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/device_response_model.g.dart @@ -0,0 +1,62 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'device_response_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_LegacyDeviceResponseModel _$LegacyDeviceResponseModelFromJson( + Map json, +) => _LegacyDeviceResponseModel( + isCreated: json['isCreated'] as bool, + item: LegacyDeviceItemResponseModel.fromJson( + json['item'] as Map, + ), +); + +Map _$LegacyDeviceResponseModelToJson( + _LegacyDeviceResponseModel instance, +) => {'isCreated': instance.isCreated, 'item': instance.item}; + +_LegacyDeviceItemResponseModel _$LegacyDeviceItemResponseModelFromJson( + Map json, +) => _LegacyDeviceItemResponseModel( + id: json['id'] as String, + identificator: json['identificator'] as String, + carrierName: json['carrierName'] as String, + carrierGenre: json['carrierGenre'] as String?, + carrierWeight: (json['carrierWeight'] as num?)?.toInt(), + carrierStepLength: (json['carrierStepLength'] as num?)?.toInt(), + carrierBirthday: (json['carrierBirthday'] as num?)?.toInt(), + userId: json['userId'] as String?, + battery: (json['battery'] as num?)?.toInt(), + protocol: json['protocol'] as String, + connectionServer: json['connectionServer'] as String, + type: json['type'] as String, + flags: json['flags'] as Map? ?? const {}, + settings: json['settings'] as Map? ?? const {}, + capabilities: json['capabilities'] as Map?, + createdAt: (json['createdAt'] as num).toInt(), +); + +Map _$LegacyDeviceItemResponseModelToJson( + _LegacyDeviceItemResponseModel instance, +) => { + 'id': instance.id, + 'identificator': instance.identificator, + 'carrierName': instance.carrierName, + 'carrierGenre': instance.carrierGenre, + 'carrierWeight': instance.carrierWeight, + 'carrierStepLength': instance.carrierStepLength, + 'carrierBirthday': instance.carrierBirthday, + 'userId': instance.userId, + 'battery': instance.battery, + 'protocol': instance.protocol, + 'connectionServer': instance.connectionServer, + 'type': instance.type, + 'flags': instance.flags, + 'settings': instance.settings, + 'capabilities': instance.capabilities, + 'createdAt': instance.createdAt, +}; diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.dart index 15f0ccb1..71d73828 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.dart @@ -8,23 +8,14 @@ part 'sign_up_response_model.g.dart'; abstract class LegacySignUpResponseModel with _$LegacySignUpResponseModel { const factory LegacySignUpResponseModel({ required bool isCreated, - required LegacySignUpResponseItemModel item, + required String item, }) = _LegacySignUpResponseModel; factory LegacySignUpResponseModel.fromJson(Map json) => _$LegacySignUpResponseModelFromJson(json); } -@freezed -abstract class LegacySignUpResponseItemModel with _$LegacySignUpResponseItemModel { - const factory LegacySignUpResponseItemModel({required String userId}) = - _LegacySignUpResponseItemModel; - - factory LegacySignUpResponseItemModel.fromJson(Map json) => - _$LegacySignUpResponseItemModelFromJson(json); -} - extension LegacySignUpResponseModelMapper on LegacySignUpResponseModel { LegacySignUpResponseEntity toEntity() => - LegacySignUpResponseEntity(isCreated: isCreated, userId: item.userId); + LegacySignUpResponseEntity(isCreated: isCreated, userId: item); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.freezed.dart index cea6f2a6..29129d3e 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.freezed.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$LegacySignUpResponseModel { - bool get isCreated; LegacySignUpResponseItemModel get item; + bool get isCreated; String get item; /// Create a copy of LegacySignUpResponseModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -48,11 +48,11 @@ abstract mixin class $LegacySignUpResponseModelCopyWith<$Res> { factory $LegacySignUpResponseModelCopyWith(LegacySignUpResponseModel value, $Res Function(LegacySignUpResponseModel) _then) = _$LegacySignUpResponseModelCopyWithImpl; @useResult $Res call({ - bool isCreated, LegacySignUpResponseItemModel item + bool isCreated, String item }); -$LegacySignUpResponseItemModelCopyWith<$Res> get item; + } /// @nodoc @@ -69,19 +69,10 @@ class _$LegacySignUpResponseModelCopyWithImpl<$Res> return _then(_self.copyWith( isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable -as LegacySignUpResponseItemModel, +as String, )); } -/// Create a copy of LegacySignUpResponseModel -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$LegacySignUpResponseItemModelCopyWith<$Res> get item { - - return $LegacySignUpResponseItemModelCopyWith<$Res>(_self.item, (value) { - return _then(_self.copyWith(item: value)); - }); -} + } @@ -163,7 +154,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( bool isCreated, LegacySignUpResponseItemModel item)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( bool isCreated, String item)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _LegacySignUpResponseModel() when $default != null: return $default(_that.isCreated,_that.item);case _: @@ -184,7 +175,7 @@ return $default(_that.isCreated,_that.item);case _: /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( bool isCreated, LegacySignUpResponseItemModel item) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( bool isCreated, String item) $default,) {final _that = this; switch (_that) { case _LegacySignUpResponseModel(): return $default(_that.isCreated,_that.item);case _: @@ -204,7 +195,7 @@ return $default(_that.isCreated,_that.item);case _: /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isCreated, LegacySignUpResponseItemModel item)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isCreated, String item)? $default,) {final _that = this; switch (_that) { case _LegacySignUpResponseModel() when $default != null: return $default(_that.isCreated,_that.item);case _: @@ -223,7 +214,7 @@ class _LegacySignUpResponseModel implements LegacySignUpResponseModel { factory _LegacySignUpResponseModel.fromJson(Map json) => _$LegacySignUpResponseModelFromJson(json); @override final bool isCreated; -@override final LegacySignUpResponseItemModel item; +@override final String item; /// Create a copy of LegacySignUpResponseModel /// with the given fields replaced by the non-null parameter values. @@ -258,11 +249,11 @@ abstract mixin class _$LegacySignUpResponseModelCopyWith<$Res> implements $Legac factory _$LegacySignUpResponseModelCopyWith(_LegacySignUpResponseModel value, $Res Function(_LegacySignUpResponseModel) _then) = __$LegacySignUpResponseModelCopyWithImpl; @override @useResult $Res call({ - bool isCreated, LegacySignUpResponseItemModel item + bool isCreated, String item }); -@override $LegacySignUpResponseItemModelCopyWith<$Res> get item; + } /// @nodoc @@ -279,278 +270,6 @@ class __$LegacySignUpResponseModelCopyWithImpl<$Res> return _then(_LegacySignUpResponseModel( isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable -as LegacySignUpResponseItemModel, - )); -} - -/// Create a copy of LegacySignUpResponseModel -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$LegacySignUpResponseItemModelCopyWith<$Res> get item { - - return $LegacySignUpResponseItemModelCopyWith<$Res>(_self.item, (value) { - return _then(_self.copyWith(item: value)); - }); -} -} - - -/// @nodoc -mixin _$LegacySignUpResponseItemModel { - - String get userId; -/// Create a copy of LegacySignUpResponseItemModel -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$LegacySignUpResponseItemModelCopyWith get copyWith => _$LegacySignUpResponseItemModelCopyWithImpl(this as LegacySignUpResponseItemModel, _$identity); - - /// Serializes this LegacySignUpResponseItemModel to a JSON map. - Map toJson(); - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacySignUpResponseItemModel&&(identical(other.userId, userId) || other.userId == userId)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,userId); - -@override -String toString() { - return 'LegacySignUpResponseItemModel(userId: $userId)'; -} - - -} - -/// @nodoc -abstract mixin class $LegacySignUpResponseItemModelCopyWith<$Res> { - factory $LegacySignUpResponseItemModelCopyWith(LegacySignUpResponseItemModel value, $Res Function(LegacySignUpResponseItemModel) _then) = _$LegacySignUpResponseItemModelCopyWithImpl; -@useResult -$Res call({ - String userId -}); - - - - -} -/// @nodoc -class _$LegacySignUpResponseItemModelCopyWithImpl<$Res> - implements $LegacySignUpResponseItemModelCopyWith<$Res> { - _$LegacySignUpResponseItemModelCopyWithImpl(this._self, this._then); - - final LegacySignUpResponseItemModel _self; - final $Res Function(LegacySignUpResponseItemModel) _then; - -/// Create a copy of LegacySignUpResponseItemModel -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? userId = null,}) { - return _then(_self.copyWith( -userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable -as String, - )); -} - -} - - -/// Adds pattern-matching-related methods to [LegacySignUpResponseItemModel]. -extension LegacySignUpResponseItemModelPatterns on LegacySignUpResponseItemModel { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _LegacySignUpResponseItemModel value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _LegacySignUpResponseItemModel() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _LegacySignUpResponseItemModel value) $default,){ -final _that = this; -switch (_that) { -case _LegacySignUpResponseItemModel(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LegacySignUpResponseItemModel value)? $default,){ -final _that = this; -switch (_that) { -case _LegacySignUpResponseItemModel() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( String userId)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _LegacySignUpResponseItemModel() when $default != null: -return $default(_that.userId);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( String userId) $default,) {final _that = this; -switch (_that) { -case _LegacySignUpResponseItemModel(): -return $default(_that.userId);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String userId)? $default,) {final _that = this; -switch (_that) { -case _LegacySignUpResponseItemModel() when $default != null: -return $default(_that.userId);case _: - return null; - -} -} - -} - -/// @nodoc -@JsonSerializable() - -class _LegacySignUpResponseItemModel implements LegacySignUpResponseItemModel { - const _LegacySignUpResponseItemModel({required this.userId}); - factory _LegacySignUpResponseItemModel.fromJson(Map json) => _$LegacySignUpResponseItemModelFromJson(json); - -@override final String userId; - -/// Create a copy of LegacySignUpResponseItemModel -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$LegacySignUpResponseItemModelCopyWith<_LegacySignUpResponseItemModel> get copyWith => __$LegacySignUpResponseItemModelCopyWithImpl<_LegacySignUpResponseItemModel>(this, _$identity); - -@override -Map toJson() { - return _$LegacySignUpResponseItemModelToJson(this, ); -} - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacySignUpResponseItemModel&&(identical(other.userId, userId) || other.userId == userId)); -} - -@JsonKey(includeFromJson: false, includeToJson: false) -@override -int get hashCode => Object.hash(runtimeType,userId); - -@override -String toString() { - return 'LegacySignUpResponseItemModel(userId: $userId)'; -} - - -} - -/// @nodoc -abstract mixin class _$LegacySignUpResponseItemModelCopyWith<$Res> implements $LegacySignUpResponseItemModelCopyWith<$Res> { - factory _$LegacySignUpResponseItemModelCopyWith(_LegacySignUpResponseItemModel value, $Res Function(_LegacySignUpResponseItemModel) _then) = __$LegacySignUpResponseItemModelCopyWithImpl; -@override @useResult -$Res call({ - String userId -}); - - - - -} -/// @nodoc -class __$LegacySignUpResponseItemModelCopyWithImpl<$Res> - implements _$LegacySignUpResponseItemModelCopyWith<$Res> { - __$LegacySignUpResponseItemModelCopyWithImpl(this._self, this._then); - - final _LegacySignUpResponseItemModel _self; - final $Res Function(_LegacySignUpResponseItemModel) _then; - -/// Create a copy of LegacySignUpResponseItemModel -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? userId = null,}) { - return _then(_LegacySignUpResponseItemModel( -userId: null == userId ? _self.userId : userId // ignore: cast_nullable_to_non_nullable as String, )); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.g.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.g.dart index e3d716e7..1ca2958e 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.g.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/models/sign_up_response_model.g.dart @@ -10,19 +10,9 @@ _LegacySignUpResponseModel _$LegacySignUpResponseModelFromJson( Map json, ) => _LegacySignUpResponseModel( isCreated: json['isCreated'] as bool, - item: LegacySignUpResponseItemModel.fromJson( - json['item'] as Map, - ), + item: json['item'] as String, ); Map _$LegacySignUpResponseModelToJson( _LegacySignUpResponseModel instance, ) => {'isCreated': instance.isCreated, 'item': instance.item}; - -_LegacySignUpResponseItemModel _$LegacySignUpResponseItemModelFromJson( - Map json, -) => _LegacySignUpResponseItemModel(userId: json['userId'] as String); - -Map _$LegacySignUpResponseItemModelToJson( - _LegacySignUpResponseItemModel instance, -) => {'userId': instance.userId}; diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/auth_repository_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/auth_repository_impl.dart index 7bbe43f1..214ad3e1 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/auth_repository_impl.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/auth_repository_impl.dart @@ -1,14 +1,6 @@ import 'package:legacy_auth/src/core/data/datasource/auth_remote_datasource.dart'; -import 'package:legacy_auth/src/core/data/models/child_profile_response_model.dart'; -import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart'; -import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart'; import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart'; import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart'; -import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart'; -import 'package:legacy_auth/src/core/data/models/login_response_model.dart'; class LegacyAuthRepositoryImpl implements LegacyAuthRepository { const LegacyAuthRepositoryImpl(this._remote); @@ -25,51 +17,6 @@ class LegacyAuthRepositoryImpl implements LegacyAuthRepository { return _remote.verifyPhoneCode(phone: phone, code: code); } - @override - Future login({ - required String email, - required String password, - }) async { - final responseModel = await _remote.login(email: email, password: password); - - return LegacyLoginResponseModelMapper(responseModel).toEntity(); - } - - @override - Future twoFARequestCode({ - required String token, - required String methodType, - }) { - return _remote.twoFARequestCode(token: token, methodType: methodType); - } - - @override - Future twoFASendCode({ - required String token, - required String code, - required String methodType, - }) { - return _remote.twoFASendCode( - token: token, - code: code, - methodType: methodType, - ); - } - - // @override - // Future totpLogin({required String token, required String code}) { - // return _remote.totpLogin(token: token, code: code); - // } - - @override - Future signUp({ - required LegacySignUpRequestEntity request, - }) async { - final model = request.toModel(); - final responseModel = await _remote.signUp(request: model); - return responseModel.toEntity(); - } - @override Future generateTwoFASignUp({ required String token, @@ -102,59 +49,4 @@ class LegacyAuthRepositoryImpl implements LegacyAuthRepository { Future logout() { return _remote.logout(); } - - @override - Future createChildProfile({ - required String id, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String genrer, - required String relationType, - required String address, - required String cardPublicKey, - required String deviceActivationCode, - required String scaProof, - }) async { - final model = await _remote.createChildProfile( - id: id, - parentId: parentId, - firstName: firstName, - lastName: lastName, - bornAt: bornAt, - genrer: genrer, - relationType: relationType, - address: address, - cardPublicKey: cardPublicKey, - deviceActivationCode: deviceActivationCode, - scaProof: scaProof, - ); - - if (!model.isCreated) { - throw Exception('Child profile creation failed: isCreated=false'); - } - - return model.toEntity(); - } -} - -extension LegacyLoginResponseModelMapper on LegacyLoginResponseModel { - LegacyLoginResponseEntity toEntity() { - return LegacyLoginResponseEntity( - token: token, - availableMethods: availableMethods - .map( - (m) => LegacyAvailableMethodEntity( - id: m.id, - userId: m.userId, - methodType: m.methodType, - status: m.status, - isDefault: m.isDefault, - createdAt: m.createdAt, - ), - ) - .toList(), - ); - } } diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart new file mode 100644 index 00000000..a964ccde --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/device_setup_repository_impl.dart @@ -0,0 +1,33 @@ +import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource.dart'; +import 'package:legacy_auth/src/core/domain/repositories/device_setup_repository.dart'; + +class LegacyDeviceSetupRepositoryImpl implements LegacyDeviceSetupRepository { + const LegacyDeviceSetupRepositoryImpl(this._remote); + + final LegacyDeviceSetupRemoteDatasource _remote; + + @override + Future createDevice({ + required String name, + required String genrer, + required int weight, + required int stepLength, + required int bornAt, + required String relationType, + required String activationKey, + }) async { + final model = await _remote.createDevice( + name: name, + genrer: genrer, + weight: weight, + stepLength: stepLength, + bornAt: bornAt, + relationType: relationType, + activationKey: activationKey, + ); + + if (!model.isCreated) { + throw Exception('Device creation failed: isCreated=false'); + } + } +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/login_repository_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/login_repository_impl.dart new file mode 100644 index 00000000..263a6c94 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/login_repository_impl.dart @@ -0,0 +1,37 @@ +import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource.dart'; +import 'package:legacy_auth/src/core/data/models/login_response_model.dart'; +import 'package:legacy_auth/src/core/domain/repositories/login_repository.dart'; +import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart'; + +class LegacyLoginRepositoryImpl implements LegacyLoginRepository { + const LegacyLoginRepositoryImpl(this._remote); + + final LegacyLoginRemoteDatasource _remote; + + @override + Future login({ + required String email, + required String password, + }) async { + final model = await _remote.login(email: email, password: password); + return model.toEntity(); + } + + @override + Future twoFARequestCode({ + required String token, + required String methodType, + }) => + _remote.twoFARequestCode(token: token, methodType: methodType); + + @override + Future twoFASendCode({ + required String token, + required String code, + required String methodType, + }) => + _remote.twoFASendCode(token: token, code: code, methodType: methodType); + + @override + Future hasDevices() => _remote.hasDevices(); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/sign_up_repository_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/sign_up_repository_impl.dart new file mode 100644 index 00000000..c547ff8d --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/data/repositories/sign_up_repository_impl.dart @@ -0,0 +1,21 @@ +import 'package:legacy_auth/src/core/data/datasource/sign_up_remote_datasource.dart'; +import 'package:legacy_auth/src/core/data/models/sign_up_request_model.dart'; +import 'package:legacy_auth/src/core/data/models/sign_up_response_model.dart'; +import 'package:legacy_auth/src/core/domain/repositories/sign_up_repository.dart'; +import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart'; +import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart'; + +class LegacySignUpRepositoryImpl implements LegacySignUpRepository { + const LegacySignUpRepositoryImpl(this._remote); + + final LegacySignUpRemoteDatasource _remote; + + @override + Future signUp({ + required LegacySignUpRequestEntity request, + }) async { + final model = request.toModel(); + final responseModel = await _remote.signUp(request: model); + return responseModel.toEntity(); + } +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/auth_repository.dart b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/auth_repository.dart index 4adb66ea..33be88a2 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/auth_repository.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/auth_repository.dart @@ -1,30 +1,10 @@ import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart'; -import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart'; -import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart'; abstract class LegacyAuthRepository { Future requestPhoneCode({required String phone}); Future verifyPhoneCode({required String phone, required String code}); - Future login({ - required String email, - required String password, - }); - Future twoFARequestCode({ - required String token, - required String methodType, - }); - Future twoFASendCode({ - required String token, - required String code, - required String methodType, - }); - - Future signUp({required LegacySignUpRequestEntity request}); - Future generateTwoFASignUp({required String token}); Future verifyTwoFACodeSignUp({ @@ -40,18 +20,4 @@ abstract class LegacyAuthRepository { }); Future logout(); - - Future createChildProfile({ - required String id, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String genrer, - required String relationType, - required String address, - required String cardPublicKey, - required String deviceActivationCode, - required String scaProof, - }); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart new file mode 100644 index 00000000..e79372b8 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/device_setup_repository.dart @@ -0,0 +1,11 @@ +abstract class LegacyDeviceSetupRepository { + Future createDevice({ + required String name, + required String genrer, + required int weight, + required int stepLength, + required int bornAt, + required String relationType, + required String activationKey, + }); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/login_repository.dart b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/login_repository.dart new file mode 100644 index 00000000..48d80c32 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/login_repository.dart @@ -0,0 +1,21 @@ +import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart'; + +abstract class LegacyLoginRepository { + Future login({ + required String email, + required String password, + }); + + Future twoFARequestCode({ + required String token, + required String methodType, + }); + + Future twoFASendCode({ + required String token, + required String code, + required String methodType, + }); + + Future hasDevices(); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/sign_up_use_case.dart b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/sign_up_repository.dart similarity index 58% rename from modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/sign_up_use_case.dart rename to modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/sign_up_repository.dart index ae57b67f..4e1723ae 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/sign_up_use_case.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/core/domain/repositories/sign_up_repository.dart @@ -1,6 +1,8 @@ import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart'; import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart'; -abstract class LegacySignUpUseCase { - Future signUp({required LegacySignUpRequestEntity request}); +abstract class LegacySignUpRepository { + Future signUp({ + required LegacySignUpRequestEntity request, + }); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_remote_datasource_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_remote_datasource_provider.dart new file mode 100644 index 00000000..56c7e4ae --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_remote_datasource_provider.dart @@ -0,0 +1,10 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:sf_infrastructure/sf_infrastructure.dart'; +import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource.dart'; +import 'package:legacy_auth/src/core/data/datasource/device_setup_remote_datasource_impl.dart'; + +final legacyDeviceSetupRemoteDatasourceProvider = + Provider((ref) { + final questiaRepository = getIt(); + return LegacyDeviceSetupRemoteDatasourceImpl(questiaRepository); +}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_repository_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_repository_provider.dart new file mode 100644 index 00000000..8e542f20 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/providers/device_setup_repository_provider.dart @@ -0,0 +1,10 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:legacy_auth/src/core/data/repositories/device_setup_repository_impl.dart'; +import 'package:legacy_auth/src/core/domain/repositories/device_setup_repository.dart'; +import 'package:legacy_auth/src/core/providers/device_setup_remote_datasource_provider.dart'; + +final legacyDeviceSetupRepositoryProvider = + Provider((ref) { + final remote = ref.read(legacyDeviceSetupRemoteDatasourceProvider); + return LegacyDeviceSetupRepositoryImpl(remote); +}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/providers/login_remote_datasource_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/core/providers/login_remote_datasource_provider.dart new file mode 100644 index 00000000..e7cada38 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/providers/login_remote_datasource_provider.dart @@ -0,0 +1,10 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:sf_infrastructure/sf_infrastructure.dart'; +import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource.dart'; +import 'package:legacy_auth/src/core/data/datasource/login_remote_datasource_impl.dart'; + +final legacyLoginRemoteDatasourceProvider = + Provider((ref) { + final questiaRepository = getIt(); + return LegacyLoginRemoteDatasourceImpl(questiaRepository); +}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/providers/login_repository_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/core/providers/login_repository_provider.dart new file mode 100644 index 00000000..0103c907 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/providers/login_repository_provider.dart @@ -0,0 +1,9 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:legacy_auth/src/core/data/repositories/login_repository_impl.dart'; +import 'package:legacy_auth/src/core/domain/repositories/login_repository.dart'; +import 'package:legacy_auth/src/core/providers/login_remote_datasource_provider.dart'; + +final legacyLoginRepositoryProvider = Provider((ref) { + final remote = ref.read(legacyLoginRemoteDatasourceProvider); + return LegacyLoginRepositoryImpl(remote); +}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_remote_datasource_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_remote_datasource_provider.dart new file mode 100644 index 00000000..be98a456 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_remote_datasource_provider.dart @@ -0,0 +1,10 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:legacy_auth/src/core/data/datasource/sign_up_remote_datasource.dart'; +import 'package:legacy_auth/src/core/data/datasource/sign_up_remote_datasource_impl.dart'; +import 'package:sf_infrastructure/sf_infrastructure.dart'; + +final legacySignUpRemoteDatasourceProvider = + Provider((ref) { + final questiaRepository = getIt(); + return LegacySignUpRemoteDatasourceImpl(questiaRepository); +}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_repository_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_repository_provider.dart new file mode 100644 index 00000000..f2d5489e --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/providers/sign_up_repository_provider.dart @@ -0,0 +1,9 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:legacy_auth/src/core/data/repositories/sign_up_repository_impl.dart'; +import 'package:legacy_auth/src/core/domain/repositories/sign_up_repository.dart'; +import 'package:legacy_auth/src/core/providers/sign_up_remote_datasource_provider.dart'; + +final legacySignUpRepositoryProvider = Provider((ref) { + final remote = ref.read(legacySignUpRemoteDatasourceProvider); + return LegacySignUpRepositoryImpl(remote); +}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/utils/date_format_utils.dart b/modules/legacy/modules/legacy_auth/lib/src/core/utils/date_format_utils.dart new file mode 100644 index 00000000..4b50187b --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/utils/date_format_utils.dart @@ -0,0 +1,25 @@ +String formatDateDMY(DateTime date) { + final dd = date.day.toString().padLeft(2, '0'); + final mm = date.month.toString().padLeft(2, '0'); + final yyyy = date.year.toString(); + return '$dd/$mm/$yyyy'; +} + +DateTime? tryParseDMY(String value) { + final v = value.trim(); + if (v.isEmpty) return null; + + final parts = v.split('/'); + if (parts.length != 3) return null; + + final d = int.tryParse(parts[0]); + final m = int.tryParse(parts[1]); + final y = int.tryParse(parts[2]); + + if (d == null || m == null || y == null) return null; + + final date = DateTime(y, m, d); + if (date.year != y || date.month != m || date.day != d) return null; + + return date; +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/utils/dio_error_mapper.dart b/modules/legacy/modules/legacy_auth/lib/src/core/utils/dio_error_mapper.dart new file mode 100644 index 00000000..333d34d4 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/utils/dio_error_mapper.dart @@ -0,0 +1,57 @@ +import 'dart:convert'; + +import 'package:dio/dio.dart'; + +Future safeCall( + Future Function() call, + String fallbackMsg, +) async { + try { + return await call(); + } on DioException catch (error) { + throw mapDioError(error, defaultMessage: fallbackMsg); + } +} + +Exception mapDioError(DioException error, {required String defaultMessage}) { + final apiMsg = _extractApiMessage(error.response?.data); + final msg = apiMsg ?? error.message ?? defaultMessage; + return Exception(msg); +} + +String? _extractApiMessage(Object? data) { + if (data == null) return null; + + if (data is Map) { + final errorObj = data['error']; + if (errorObj is Map && errorObj['message'] is String) { + return (errorObj['message'] as String).trim(); + } + if (data['message'] is String) { + return (data['message'] as String).trim(); + } + return null; + } + + if (data is String) { + final raw = data.trim(); + if (raw.isEmpty) return null; + + try { + final decoded = jsonDecode(raw); + return _extractApiMessage(decoded); + } catch (_) { + return raw; + } + } + + return null; +} + +String formatErrorMessage(Object error) { + final raw = error.toString(); + if (raw.startsWith('Exception: ')) { + return raw.substring('Exception: '.length); + } + return raw; +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/core/utils/text_format_utils.dart b/modules/legacy/modules/legacy_auth/lib/src/core/utils/text_format_utils.dart new file mode 100644 index 00000000..1e724e63 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/core/utils/text_format_utils.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +String toCapitalized(String text) => text.splitMapJoin( + RegExp(r'\S+'), + onMatch: (m) { + final word = m[0]!; + return word[0].toUpperCase() + word.substring(1).toLowerCase(); + }, + onNonMatch: (s) => s, + ); + +void toCapitalizedController(TextEditingController controller) { + final text = controller.text; + final capitalized = toCapitalized(text); + if (text == capitalized) return; + + final offset = controller.selection.baseOffset.clamp(0, capitalized.length); + controller.value = TextEditingValue( + text: capitalized, + selection: TextSelection.collapsed(offset: offset), + ); +} + +void toUpperCaseController(TextEditingController controller) { + final text = controller.text; + final upper = text.toUpperCase(); + if (text == upper) return; + + final offset = controller.selection.baseOffset.clamp(0, upper.length); + controller.value = TextEditingValue( + text: upper, + selection: TextSelection.collapsed(offset: offset), + ); +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case.dart deleted file mode 100644 index 3a7afbbf..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart'; - -abstract class LegacyCreateChildProfileUseCase { - Future createChildProfile({ - required String id, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String genrer, - required String relationType, - required String address, - required String cardPublicKey, - required String deviceActivationCode, - required String scaProof, - }); -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case_impl.dart deleted file mode 100644 index 24a2f7c9..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/create_child_profile_use_case_impl.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart'; -import 'package:legacy_auth/src/features/device_setup/domain/entities/child_profile_entity.dart'; - -class LegacyCreateChildProfileUseCaseImpl implements LegacyCreateChildProfileUseCase { - LegacyCreateChildProfileUseCaseImpl(this._repository); - - final LegacyAuthRepository _repository; - - @override - Future createChildProfile({ - required String id, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String genrer, - required String relationType, - required String address, - required String cardPublicKey, - required String deviceActivationCode, - required String scaProof, - }) { - return _repository.createChildProfile( - id: id, - parentId: parentId, - firstName: firstName, - lastName: lastName, - bornAt: bornAt, - genrer: genrer, - relationType: relationType, - address: address, - cardPublicKey: cardPublicKey, - deviceActivationCode: deviceActivationCode, - scaProof: scaProof, - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.dart deleted file mode 100644 index 1c51ff87..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'child_profile_entity.freezed.dart'; - -@freezed -abstract class LegacyChildProfileEntity with _$LegacyChildProfileEntity { - const factory LegacyChildProfileEntity({ - required bool isCreated, - required LegacyChildProfileItemEntity item, - }) = _LegacyChildProfileEntity; -} - -@freezed -abstract class LegacyChildProfileItemEntity with _$LegacyChildProfileItemEntity { - const factory LegacyChildProfileItemEntity({ - required String id, - required String deviceIdentificator, - required String parentId, - required String firstName, - required String lastName, - required int bornAt, - required String address, - required int createdAt, - int? updatedAt, - String? profileImageId, - }) = _LegacyChildProfileItemEntity; -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.freezed.dart deleted file mode 100644 index cad2b37f..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/domain/entities/child_profile_entity.freezed.dart +++ /dev/null @@ -1,576 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND -// coverage:ignore-file -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'child_profile_entity.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -// dart format off -T _$identity(T value) => value; -/// @nodoc -mixin _$LegacyChildProfileEntity { - - bool get isCreated; LegacyChildProfileItemEntity get item; -/// Create a copy of LegacyChildProfileEntity -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$LegacyChildProfileEntityCopyWith get copyWith => _$LegacyChildProfileEntityCopyWithImpl(this as LegacyChildProfileEntity, _$identity); - - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item)); -} - - -@override -int get hashCode => Object.hash(runtimeType,isCreated,item); - -@override -String toString() { - return 'LegacyChildProfileEntity(isCreated: $isCreated, item: $item)'; -} - - -} - -/// @nodoc -abstract mixin class $LegacyChildProfileEntityCopyWith<$Res> { - factory $LegacyChildProfileEntityCopyWith(LegacyChildProfileEntity value, $Res Function(LegacyChildProfileEntity) _then) = _$LegacyChildProfileEntityCopyWithImpl; -@useResult -$Res call({ - bool isCreated, LegacyChildProfileItemEntity item -}); - - -$LegacyChildProfileItemEntityCopyWith<$Res> get item; - -} -/// @nodoc -class _$LegacyChildProfileEntityCopyWithImpl<$Res> - implements $LegacyChildProfileEntityCopyWith<$Res> { - _$LegacyChildProfileEntityCopyWithImpl(this._self, this._then); - - final LegacyChildProfileEntity _self; - final $Res Function(LegacyChildProfileEntity) _then; - -/// Create a copy of LegacyChildProfileEntity -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? isCreated = null,Object? item = null,}) { - return _then(_self.copyWith( -isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable -as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable -as LegacyChildProfileItemEntity, - )); -} -/// Create a copy of LegacyChildProfileEntity -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$LegacyChildProfileItemEntityCopyWith<$Res> get item { - - return $LegacyChildProfileItemEntityCopyWith<$Res>(_self.item, (value) { - return _then(_self.copyWith(item: value)); - }); -} -} - - -/// Adds pattern-matching-related methods to [LegacyChildProfileEntity]. -extension LegacyChildProfileEntityPatterns on LegacyChildProfileEntity { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _LegacyChildProfileEntity value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _LegacyChildProfileEntity() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _LegacyChildProfileEntity value) $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileEntity(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LegacyChildProfileEntity value)? $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileEntity() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( bool isCreated, LegacyChildProfileItemEntity item)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _LegacyChildProfileEntity() when $default != null: -return $default(_that.isCreated,_that.item);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( bool isCreated, LegacyChildProfileItemEntity item) $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileEntity(): -return $default(_that.isCreated,_that.item);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool isCreated, LegacyChildProfileItemEntity item)? $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileEntity() when $default != null: -return $default(_that.isCreated,_that.item);case _: - return null; - -} -} - -} - -/// @nodoc - - -class _LegacyChildProfileEntity implements LegacyChildProfileEntity { - const _LegacyChildProfileEntity({required this.isCreated, required this.item}); - - -@override final bool isCreated; -@override final LegacyChildProfileItemEntity item; - -/// Create a copy of LegacyChildProfileEntity -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$LegacyChildProfileEntityCopyWith<_LegacyChildProfileEntity> get copyWith => __$LegacyChildProfileEntityCopyWithImpl<_LegacyChildProfileEntity>(this, _$identity); - - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileEntity&&(identical(other.isCreated, isCreated) || other.isCreated == isCreated)&&(identical(other.item, item) || other.item == item)); -} - - -@override -int get hashCode => Object.hash(runtimeType,isCreated,item); - -@override -String toString() { - return 'LegacyChildProfileEntity(isCreated: $isCreated, item: $item)'; -} - - -} - -/// @nodoc -abstract mixin class _$LegacyChildProfileEntityCopyWith<$Res> implements $LegacyChildProfileEntityCopyWith<$Res> { - factory _$LegacyChildProfileEntityCopyWith(_LegacyChildProfileEntity value, $Res Function(_LegacyChildProfileEntity) _then) = __$LegacyChildProfileEntityCopyWithImpl; -@override @useResult -$Res call({ - bool isCreated, LegacyChildProfileItemEntity item -}); - - -@override $LegacyChildProfileItemEntityCopyWith<$Res> get item; - -} -/// @nodoc -class __$LegacyChildProfileEntityCopyWithImpl<$Res> - implements _$LegacyChildProfileEntityCopyWith<$Res> { - __$LegacyChildProfileEntityCopyWithImpl(this._self, this._then); - - final _LegacyChildProfileEntity _self; - final $Res Function(_LegacyChildProfileEntity) _then; - -/// Create a copy of LegacyChildProfileEntity -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? isCreated = null,Object? item = null,}) { - return _then(_LegacyChildProfileEntity( -isCreated: null == isCreated ? _self.isCreated : isCreated // ignore: cast_nullable_to_non_nullable -as bool,item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable -as LegacyChildProfileItemEntity, - )); -} - -/// Create a copy of LegacyChildProfileEntity -/// with the given fields replaced by the non-null parameter values. -@override -@pragma('vm:prefer-inline') -$LegacyChildProfileItemEntityCopyWith<$Res> get item { - - return $LegacyChildProfileItemEntityCopyWith<$Res>(_self.item, (value) { - return _then(_self.copyWith(item: value)); - }); -} -} - -/// @nodoc -mixin _$LegacyChildProfileItemEntity { - - String get id; String get deviceIdentificator; String get parentId; String get firstName; String get lastName; int get bornAt; String get address; int get createdAt; int? get updatedAt; String? get profileImageId; -/// Create a copy of LegacyChildProfileItemEntity -/// with the given fields replaced by the non-null parameter values. -@JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -$LegacyChildProfileItemEntityCopyWith get copyWith => _$LegacyChildProfileItemEntityCopyWithImpl(this as LegacyChildProfileItemEntity, _$identity); - - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyChildProfileItemEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId)); -} - - -@override -int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId); - -@override -String toString() { - return 'LegacyChildProfileItemEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)'; -} - - -} - -/// @nodoc -abstract mixin class $LegacyChildProfileItemEntityCopyWith<$Res> { - factory $LegacyChildProfileItemEntityCopyWith(LegacyChildProfileItemEntity value, $Res Function(LegacyChildProfileItemEntity) _then) = _$LegacyChildProfileItemEntityCopyWithImpl; -@useResult -$Res call({ - String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId -}); - - - - -} -/// @nodoc -class _$LegacyChildProfileItemEntityCopyWithImpl<$Res> - implements $LegacyChildProfileItemEntityCopyWith<$Res> { - _$LegacyChildProfileItemEntityCopyWithImpl(this._self, this._then); - - final LegacyChildProfileItemEntity _self; - final $Res Function(LegacyChildProfileItemEntity) _then; - -/// Create a copy of LegacyChildProfileItemEntity -/// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) { - return _then(_self.copyWith( -id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable -as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable -as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable -as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable -as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable -as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable -as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable -as String?, - )); -} - -} - - -/// Adds pattern-matching-related methods to [LegacyChildProfileItemEntity]. -extension LegacyChildProfileItemEntityPatterns on LegacyChildProfileItemEntity { -/// A variant of `map` that fallback to returning `orElse`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeMap(TResult Function( _LegacyChildProfileItemEntity value)? $default,{required TResult orElse(),}){ -final _that = this; -switch (_that) { -case _LegacyChildProfileItemEntity() when $default != null: -return $default(_that);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// Callbacks receives the raw object, upcasted. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case final Subclass2 value: -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult map(TResult Function( _LegacyChildProfileItemEntity value) $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileItemEntity(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `map` that fallback to returning `null`. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case final Subclass value: -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? mapOrNull(TResult? Function( _LegacyChildProfileItemEntity value)? $default,){ -final _that = this; -switch (_that) { -case _LegacyChildProfileItemEntity() when $default != null: -return $default(_that);case _: - return null; - -} -} -/// A variant of `when` that fallback to an `orElse` callback. -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return orElse(); -/// } -/// ``` - -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,{required TResult orElse(),}) {final _that = this; -switch (_that) { -case _LegacyChildProfileItemEntity() when $default != null: -return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _: - return orElse(); - -} -} -/// A `switch`-like method, using callbacks. -/// -/// As opposed to `map`, this offers destructuring. -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case Subclass2(:final field2): -/// return ...; -/// } -/// ``` - -@optionalTypeArgs TResult when(TResult Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId) $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileItemEntity(): -return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _: - throw StateError('Unexpected subclass'); - -} -} -/// A variant of `when` that fallback to returning `null` -/// -/// It is equivalent to doing: -/// ```dart -/// switch (sealedClass) { -/// case Subclass(:final field): -/// return ...; -/// case _: -/// return null; -/// } -/// ``` - -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId)? $default,) {final _that = this; -switch (_that) { -case _LegacyChildProfileItemEntity() when $default != null: -return $default(_that.id,_that.deviceIdentificator,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.createdAt,_that.updatedAt,_that.profileImageId);case _: - return null; - -} -} - -} - -/// @nodoc - - -class _LegacyChildProfileItemEntity implements LegacyChildProfileItemEntity { - const _LegacyChildProfileItemEntity({required this.id, required this.deviceIdentificator, required this.parentId, required this.firstName, required this.lastName, required this.bornAt, required this.address, required this.createdAt, this.updatedAt, this.profileImageId}); - - -@override final String id; -@override final String deviceIdentificator; -@override final String parentId; -@override final String firstName; -@override final String lastName; -@override final int bornAt; -@override final String address; -@override final int createdAt; -@override final int? updatedAt; -@override final String? profileImageId; - -/// Create a copy of LegacyChildProfileItemEntity -/// with the given fields replaced by the non-null parameter values. -@override @JsonKey(includeFromJson: false, includeToJson: false) -@pragma('vm:prefer-inline') -_$LegacyChildProfileItemEntityCopyWith<_LegacyChildProfileItemEntity> get copyWith => __$LegacyChildProfileItemEntityCopyWithImpl<_LegacyChildProfileItemEntity>(this, _$identity); - - - -@override -bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyChildProfileItemEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.profileImageId, profileImageId) || other.profileImageId == profileImageId)); -} - - -@override -int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,parentId,firstName,lastName,bornAt,address,createdAt,updatedAt,profileImageId); - -@override -String toString() { - return 'LegacyChildProfileItemEntity(id: $id, deviceIdentificator: $deviceIdentificator, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, createdAt: $createdAt, updatedAt: $updatedAt, profileImageId: $profileImageId)'; -} - - -} - -/// @nodoc -abstract mixin class _$LegacyChildProfileItemEntityCopyWith<$Res> implements $LegacyChildProfileItemEntityCopyWith<$Res> { - factory _$LegacyChildProfileItemEntityCopyWith(_LegacyChildProfileItemEntity value, $Res Function(_LegacyChildProfileItemEntity) _then) = __$LegacyChildProfileItemEntityCopyWithImpl; -@override @useResult -$Res call({ - String id, String deviceIdentificator, String parentId, String firstName, String lastName, int bornAt, String address, int createdAt, int? updatedAt, String? profileImageId -}); - - - - -} -/// @nodoc -class __$LegacyChildProfileItemEntityCopyWithImpl<$Res> - implements _$LegacyChildProfileItemEntityCopyWith<$Res> { - __$LegacyChildProfileItemEntityCopyWithImpl(this._self, this._then); - - final _LegacyChildProfileItemEntity _self; - final $Res Function(_LegacyChildProfileItemEntity) _then; - -/// Create a copy of LegacyChildProfileItemEntity -/// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = null,Object? address = null,Object? createdAt = null,Object? updatedAt = freezed,Object? profileImageId = freezed,}) { - return _then(_LegacyChildProfileItemEntity( -id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable -as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable -as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable -as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable -as String,bornAt: null == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable -as int,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable -as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as int,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as int?,profileImageId: freezed == profileImageId ? _self.profileImageId : profileImageId // ignore: cast_nullable_to_non_nullable -as String?, - )); -} - - -} - -// dart format on diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/add_kid_step_mapper.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/add_kid_step_mapper.dart deleted file mode 100644 index 9703832b..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/add_kid_step_mapper.dart +++ /dev/null @@ -1,19 +0,0 @@ -import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_main_step.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart'; - -extension LegacyAddKidStepMapper on LegacyAddKidStep { - LegacyAddKidMainStep get mainStep { - switch (this) { - case LegacyAddKidStep.linkInfo: - case LegacyAddKidStep.scanStrap: - case LegacyAddKidStep.scanWatch: - return LegacyAddKidMainStep.linkDevice; - case LegacyAddKidStep.profile: - return LegacyAddKidMainStep.profile; - case LegacyAddKidStep.allowance: - return LegacyAddKidMainStep.allowance; - case LegacyAddKidStep.intro: - return LegacyAddKidMainStep.linkDevice; - } - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/contact_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/contact_screen.dart deleted file mode 100644 index 77233326..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/contact_screen.dart +++ /dev/null @@ -1,74 +0,0 @@ -import 'package:design_system/design_system.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -class LegacyContactScreen extends ConsumerWidget { - const LegacyContactScreen({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final theme = ref.watch(themePortProvider); - - return Scaffold( - backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary), - body: Container( - margin: EdgeInsets.all(30), - child: Center( - child: Column( - spacing: 10, - children: [ - Text( - "Contáctanos", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 30), - ), - Text( - "Trasládanos tus dudas e intentaremos responderte lo antes posible", - ), - DropdownMenu( - initialSelection: "es", - label: Text("País"), - dropdownMenuEntries: [ - DropdownMenuEntry(value: "es", label: "España"), - DropdownMenuEntry(value: "fr", label: "Francia"), - DropdownMenuEntry(value: "pt", label: "Portugal"), - ], - ), - DropdownMenu( - initialSelection: "online", - label: Text("Canal de compra"), - dropdownMenuEntries: [ - DropdownMenuEntry(value: "online", label: "SF online shop"), - ], - ), - Expanded( - child: CustomTextField( - label: "Nombre", - hint: "Nombre y apellidos", - ), - ), - Expanded( - child: CustomTextField( - label: "Correo electrónico", - hint: "Correo electrónico", - ), - ), - Expanded( - child: CustomTextField( - lines: 3, - label: "Asunto del mensaje", - hint: "Escribe tu mensaje", - ), - ), - Expanded( - child: FilledButton( - onPressed: () => Navigator.pop(context), - child: Text("Enviar"), - ), - ), - ], - ), - ), - ), - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart index 0bfdb938..975797dd 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/device_setup_screen.dart @@ -1,6 +1,4 @@ -import 'package:legacy_auth/src/features/device_setup/presentation/add_kid_step_mapper.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_main_step.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/step_body.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/success_screen.dart'; @@ -10,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:navigation/app_routes.dart'; import 'package:navigation/navigation_contract.dart'; -import 'package:payments/payments.dart'; import 'package:sf_localizations/sf_localizations.dart'; class LegacyDeviceSetupScreen extends ConsumerWidget { @@ -23,17 +20,28 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { final state = ref.watch(legacyDeviceSetupViewModelProvider); final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier); final theme = ref.watch(themePortProvider); - final mainStep = state.step.mainStep; final isIntro = state.step == LegacyAddKidStep.intro; - final isAllowance = state.step == LegacyAddKidStep.allowance; final canPopRoute = state.step == LegacyAddKidStep.intro; + ref.listen( + legacyDeviceSetupViewModelProvider.select((s) => s.errorMessage), + (previous, next) { + if (next.isNotEmpty) { + showTopSnackbar( + context, + message: context.translate(next), + type: MessageType.error, + ); + } + }, + ); + return PopScope( canPop: canPopRoute, onPopInvokedWithResult: (didPop, result) { - if (didPop || isAllowance) return; + if (didPop) return; vm.back(); }, child: Scaffold( @@ -45,7 +53,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { padding: const EdgeInsets.only(top: 12, left: 8, right: 8), child: Row( children: [ - if (isIntro || isAllowance) + if (isIntro) const SizedBox(width: 48) else IconButton( @@ -60,17 +68,12 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { child: isIntro ? const SizedBox.shrink() : StepIndicator( - total: LegacyAddKidMainStep.values.length, - current: mainStep.index + 1, + total: LegacyAddKidStep.mainStepCount, + current: state.step.mainStepIndex + 1, color: theme.getColorFor(ThemeCode.buttonPrimary), ), ), - IconButton( - onPressed: () => - navigationContract.goTo(AppRoutes.dashboardHome), - icon: const Icon(Icons.close), - color: theme.getColorFor(ThemeCode.textPrimary), - ), + const SizedBox(width: 48), ], ), ), @@ -87,7 +90,7 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { onPrimary: () async { if (state.step == LegacyAddKidStep.profile) { if (!vm.validateProfile()) return; - final ok = await vm.createChildProfile(); + final ok = await vm.createDevice(); if (!context.mounted) return; if (ok) { Navigator.of(context).push( @@ -96,18 +99,8 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { } return; } - if (state.step == LegacyAddKidStep.allowance) { - _pushHiPayScreen(context, ref); - return; - } vm.next(); }, - secondaryText: isAllowance - ? context.translate(I18n.deviceSetup_skipAndConfigureLater) - : null, - onSecondary: isAllowance - ? () => navigationContract.pushTo(AppRoutes.dashboardHome) - : null, theme: theme, ), ], @@ -117,38 +110,10 @@ class LegacyDeviceSetupScreen extends ConsumerWidget { ); } - Future _pushHiPayScreen(BuildContext context, WidgetRef ref) async { - final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier); - final result = await Navigator.of(context).push( - MaterialPageRoute( - builder: (_) => - HiPayWebViewScreen(navigationContract: navigationContract), - ), - ); - if (!context.mounted) return; - if (result == HiPayResult.success) { - vm.setError(''); - showTopSnackbar( - context, - message: context.translate(I18n.deviceSetup_cardRegistered), - type: MessageType.success, - ); - navigationContract.pushTo(AppRoutes.dashboardHome); - } else { - showTopSnackbar( - context, - message: context.translate(I18n.deviceSetup_paymentCancelled), - type: MessageType.error, - ); - } - } - String primaryButtonText(LegacyAddKidStep step) { switch (step) { case LegacyAddKidStep.intro: return I18n.deviceSetup_start; - case LegacyAddKidStep.allowance: - return I18n.deviceSetup_addCreditCard; default: return I18n.continueKey; } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_main_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_main_step.dart deleted file mode 100644 index 63c144eb..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_main_step.dart +++ /dev/null @@ -1 +0,0 @@ -enum LegacyAddKidMainStep { linkDevice, profile, allowance } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_step.dart index 403bfce0..394e2769 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_step.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/add_kid_step.dart @@ -1 +1,20 @@ -enum LegacyAddKidStep { intro, linkInfo, scanStrap, scanWatch, profile, allowance } +enum LegacyAddKidStep { + intro, + linkInfo, + scanWatch, + profile; + + /// Maps detailed steps to the 2 main indicator steps. + int get mainStepIndex { + switch (this) { + case LegacyAddKidStep.intro: + case LegacyAddKidStep.linkInfo: + case LegacyAddKidStep.scanWatch: + return 0; + case LegacyAddKidStep.profile: + return 1; + } + } + + static const int mainStepCount = 2; +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/scan_link_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/scan_link_step.dart deleted file mode 100644 index 93b8e724..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/enums/scan_link_step.dart +++ /dev/null @@ -1 +0,0 @@ -enum LegacyScanLinkStep { strap, watch } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/providers/create_child_profile_use_case_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/providers/create_child_profile_use_case_provider.dart deleted file mode 100644 index a18db250..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/providers/create_child_profile_use_case_provider.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart'; -import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart'; -import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final legacyCreateChildProfileUseCaseProvider = - Provider.autoDispose((ref) { - final authRepository = ref.read(legacyAuthRepositoryProvider); - return LegacyCreateChildProfileUseCaseImpl(authRepository); - }); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart index 0b4faa0e..45a5d1f4 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_model.dart @@ -1,13 +1,12 @@ -import 'package:legacy_auth/src/features/device_setup/domain/create_child_profile_use_case.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/providers/create_child_profile_use_case_provider.dart'; +import 'package:legacy_auth/src/core/domain/repositories/device_setup_repository.dart'; +import 'package:legacy_auth/src/core/providers/device_setup_repository_provider.dart'; +import 'package:legacy_auth/src/core/utils/date_format_utils.dart'; +import 'package:legacy_auth/src/core/utils/text_format_utils.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_state.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:sf_localizations/sf_localizations.dart'; -import 'package:sf_shared/sf_shared.dart'; -import 'package:uuid/uuid.dart'; final legacyDeviceSetupViewModelProvider = NotifierProvider( @@ -15,20 +14,18 @@ final legacyDeviceSetupViewModelProvider = ); class LegacyDeviceSetupViewModel extends Notifier { - late final LegacyCreateChildProfileUseCase _createChildProfileUseCase; - late final GetUserInfoUseCase _getUserInfoUseCase; + late final LegacyDeviceSetupRepository _deviceSetupRepository; - late final TextEditingController bornAtController; late final TextEditingController firstNameController; late final TextEditingController lastNameController; - late final TextEditingController addressController; - late final TextEditingController strapCodeController; + late final TextEditingController bornAtController; + late final TextEditingController weightController; + late final TextEditingController heightController; late final TextEditingController watchCodeController; - late final TextEditingController allowanceAmountController; @override LegacyDeviceSetupViewState build() { - final initial = LegacyDeviceSetupViewState(id: const Uuid().v4()); + final initial = const LegacyDeviceSetupViewState(); _initControllers(initial); _addListeners(); @@ -38,30 +35,25 @@ class LegacyDeviceSetupViewModel extends Notifier { } void _initControllers(LegacyDeviceSetupViewState s) { - _createChildProfileUseCase = ref.read(legacyCreateChildProfileUseCaseProvider); - _getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider); + _deviceSetupRepository = ref.read(legacyDeviceSetupRepositoryProvider); firstNameController = TextEditingController(text: s.firstName); lastNameController = TextEditingController(text: s.lastName); bornAtController = TextEditingController( - text: s.bornAt == null ? '' : _formatDate(s.bornAt!), + text: s.bornAt == null ? '' : formatDateDMY(s.bornAt!), ); - - addressController = TextEditingController(text: s.address); - strapCodeController = TextEditingController(text: s.strapCode); + weightController = TextEditingController(text: s.weight); + heightController = TextEditingController(text: s.height); watchCodeController = TextEditingController(text: s.watchCode); - allowanceAmountController = TextEditingController(text: s.allowanceAmount); } void _addListeners() { firstNameController.addListener(_onFirstNameChanged); lastNameController.addListener(_onLastNameChanged); bornAtController.addListener(_onBornAtTextChanged); - addressController.addListener(_onAddressChanged); - - strapCodeController.addListener(_onStrapCodeChanged); + weightController.addListener(_onWeightChanged); + heightController.addListener(_onHeightChanged); watchCodeController.addListener(_onWatchCodeChanged); - allowanceAmountController.addListener(_onAllowanceAmountChanged); } void next() { @@ -70,19 +62,12 @@ class LegacyDeviceSetupViewModel extends Notifier { state = state.copyWith(step: LegacyAddKidStep.linkInfo); return; case LegacyAddKidStep.linkInfo: - state = state.copyWith(step: LegacyAddKidStep.scanStrap); - return; - case LegacyAddKidStep.scanStrap: - final hasStrap = state.strapQr.isNotEmpty || state.strapCode.isNotEmpty; - if (!hasStrap) { - state = state.copyWith(errorMessage: I18n.errorScanStrapRequired); - return; - } - state = state.copyWith(step: LegacyAddKidStep.scanWatch, errorMessage: ''); + state = state.copyWith(step: LegacyAddKidStep.scanWatch); return; case LegacyAddKidStep.scanWatch: final hasWatch = state.watchQr.isNotEmpty || state.watchCode.isNotEmpty; if (!hasWatch) { + state = state.copyWith(errorMessage: ''); state = state.copyWith(errorMessage: I18n.errorScanWatchRequired); return; } @@ -90,8 +75,6 @@ class LegacyDeviceSetupViewModel extends Notifier { return; case LegacyAddKidStep.profile: return; - case LegacyAddKidStep.allowance: - return; } } @@ -99,89 +82,52 @@ class LegacyDeviceSetupViewModel extends Notifier { switch (state.step) { case LegacyAddKidStep.intro: return; - case LegacyAddKidStep.linkInfo: state = state.copyWith(step: LegacyAddKidStep.intro, errorMessage: ''); return; - case LegacyAddKidStep.scanStrap: - state = state.copyWith(step: LegacyAddKidStep.linkInfo); - return; case LegacyAddKidStep.scanWatch: - state = state.copyWith(step: LegacyAddKidStep.scanStrap); + state = state.copyWith(step: LegacyAddKidStep.linkInfo); return; case LegacyAddKidStep.profile: state = state.copyWith(step: LegacyAddKidStep.scanWatch); return; - case LegacyAddKidStep.allowance: - state = state.copyWith(step: LegacyAddKidStep.profile); - return; } } - void onQrScanned({required LegacyScanLinkStep step, required String qr}) { - switch (step) { - case LegacyScanLinkStep.strap: - state = state.copyWith(strapQr: qr, step: LegacyAddKidStep.scanWatch); - break; - - case LegacyScanLinkStep.watch: - state = state.copyWith(watchQr: qr, step: LegacyAddKidStep.profile); - break; - } - } - - Future pickBornAt(BuildContext context) async { - FocusManager.instance.primaryFocus?.unfocus(); - - final now = DateTime.now(); - final initial = state.bornAt ?? DateTime(now.year - 18, now.month, now.day); - - final safeInitial = initial.isAfter(now) ? now : initial; - - final picked = await showDatePicker( - context: context, - initialDate: safeInitial, - firstDate: DateTime(1900, 1, 1), - lastDate: now, - ); - - if (!ref.mounted) return; - if (picked == null) return; - - setBornAt(picked); + void onWatchQrScanned(String qr) { + state = state.copyWith(watchQr: qr, step: LegacyAddKidStep.profile); } void setBornAt(DateTime date) { - bornAtController.text = _formatDate(date); + bornAtController.text = formatDateDMY(date); state = state.copyWith(bornAt: date); } - Future createChildProfile() async { - await getUserInfo(); - final firstName = state.firstName.trim(); - final lastName = state.lastName.trim(); + Future createDevice() async { + final name = + '${state.firstName.trim()} ${state.lastName.trim()}'.trim().toUpperCase(); final birth = state.bornAt!; final bornAt = DateTime.utc(birth.year, birth.month, birth.day) .millisecondsSinceEpoch; - final address = state.address.trim(); + final weight = int.parse(state.weight.trim()); + final heightCm = double.parse(state.height.trim()); + final stepLength = (heightCm * 0.40).round(); final genrer = state.genrer.trim(); final relationType = state.relationType.trim(); + final activationKey = + state.watchCode.isNotEmpty ? state.watchCode : state.watchQr; state = state.copyWith(isLoading: true); try { - await _createChildProfileUseCase.createChildProfile( - id: state.id, - parentId: state.parentId, - firstName: firstName, - lastName: lastName, - bornAt: bornAt, + await _deviceSetupRepository.createDevice( + name: name, genrer: genrer, + weight: weight, + stepLength: stepLength, + bornAt: bornAt, relationType: relationType, - address: address, - cardPublicKey: state.strapCode, - deviceActivationCode: state.watchCode, - scaProof: '', + activationKey: activationKey, ); if (!ref.mounted) return false; @@ -199,58 +145,35 @@ class LegacyDeviceSetupViewModel extends Notifier { } } - Future getUserInfo() async { - state = state.copyWith(isLoading: true, errorMessage: ''); - - try { - final user = await _getUserInfoUseCase.getUserInfo(); - - if (ref.mounted) { - state = state.copyWith(isLoading: false); - } - - debugPrint('[getUserInfo] userId => ${user.id}'); - state = state.copyWith(parentId: user.id); - - return user; - } catch (e) { - if (ref.mounted) { - state = state.copyWith(isLoading: false, errorMessage: e.toString()); - } - return null; - } - } - bool validateProfile() { final isInvalid = state.firstName.trim().isEmpty || state.lastName.trim().isEmpty || state.bornAt == null || - state.address.trim().isEmpty || state.genrer.trim().isEmpty || - state.relationType.trim().isEmpty; + state.relationType.trim().isEmpty || + state.weight.trim().isEmpty || + int.tryParse(state.weight.trim()) == null || + state.height.trim().isEmpty || + double.tryParse(state.height.trim()) == null; if (isInvalid) { + state = state.copyWith(errorMessage: ''); state = state.copyWith(errorMessage: I18n.errorAllFieldsRequired); return false; } return true; } - String _formatDate(DateTime date) { - final dd = date.day.toString().padLeft(2, '0'); - final mm = date.month.toString().padLeft(2, '0'); - final yyyy = date.year.toString(); - return '$dd/$mm/$yyyy'; - } - void _onFirstNameChanged() { + toCapitalizedController(firstNameController); final text = firstNameController.text; if (text == state.firstName) return; state = state.copyWith(firstName: text, errorMessage: ''); } void _onLastNameChanged() { + toCapitalizedController(lastNameController); final text = lastNameController.text; if (text == state.lastName) return; state = state.copyWith(lastName: text, errorMessage: ''); @@ -258,7 +181,7 @@ class LegacyDeviceSetupViewModel extends Notifier { void _onBornAtTextChanged() { final text = bornAtController.text; - final parsed = _tryParseDate(text); + final parsed = tryParseDMY(text); if (text.trim().isEmpty) { if (state.bornAt != null) { @@ -272,16 +195,16 @@ class LegacyDeviceSetupViewModel extends Notifier { } } - void _onAddressChanged() { - final text = addressController.text; - if (text == state.address) return; - state = state.copyWith(address: text, errorMessage: ''); + void _onWeightChanged() { + final text = weightController.text; + if (text == state.weight) return; + state = state.copyWith(weight: text, errorMessage: ''); } - void _onStrapCodeChanged() { - final text = strapCodeController.text; - if (text == state.strapCode) return; - state = state.copyWith(strapCode: text, errorMessage: ''); + void _onHeightChanged() { + final text = heightController.text; + if (text == state.height) return; + state = state.copyWith(height: text, errorMessage: ''); } void _onWatchCodeChanged() { @@ -290,20 +213,10 @@ class LegacyDeviceSetupViewModel extends Notifier { state = state.copyWith(watchCode: text, errorMessage: ''); } - void _onAllowanceAmountChanged() { - final text = allowanceAmountController.text; - if (text == state.allowanceAmount) return; - state = state.copyWith(allowanceAmount: text, errorMessage: ''); - } - void setError(String message) { state = state.copyWith(errorMessage: message); } - void goToAllowance() { - state = state.copyWith(step: LegacyAddKidStep.allowance, errorMessage: ''); - } - void onGenrerChanged(String? value) { final v = value ?? ''; if (v == state.genrer) return; @@ -316,40 +229,23 @@ class LegacyDeviceSetupViewModel extends Notifier { state = state.copyWith(relationType: v, errorMessage: ''); } - DateTime? _tryParseDate(String value) { - final v = value.trim(); - if (v.isEmpty) return null; - - final parts = v.split('/'); - if (parts.length != 3) return null; - - final d = int.tryParse(parts[0]); - final m = int.tryParse(parts[1]); - final y = int.tryParse(parts[2]); - - if (d == null || m == null || y == null) return null; - - final date = DateTime(y, m, d); - if (date.year != y || date.month != m || date.day != d) return null; - - return date; - } - void resetForNewKid() { firstNameController.clear(); lastNameController.clear(); bornAtController.clear(); - addressController.clear(); - strapCodeController.clear(); + weightController.clear(); + heightController.clear(); watchCodeController.clear(); - allowanceAmountController.clear(); - state = LegacyDeviceSetupViewState(id: const Uuid().v4()); + state = const LegacyDeviceSetupViewState(); } void disposeControllers() { - // firstNameController.dispose(); - // lastNameController.dispose(); + firstNameController.dispose(); + lastNameController.dispose(); bornAtController.dispose(); + weightController.dispose(); + heightController.dispose(); + watchCodeController.dispose(); } } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart index cb915884..4f34465c 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.dart @@ -7,24 +7,19 @@ part 'device_setup_view_state.freezed.dart'; abstract class LegacyDeviceSetupViewState with _$LegacyDeviceSetupViewState { const factory LegacyDeviceSetupViewState({ @Default(LegacyAddKidStep.intro) LegacyAddKidStep step, - @Default('') String id, - @Default('') String parentId, @Default('') String firstName, @Default('') String lastName, DateTime? bornAt, - @Default('') String address, @Default('') String genrer, @Default('') String relationType, + @Default('') String weight, + @Default('') String height, - @Default('') String strapQr, - @Default('') String strapCode, @Default('') String watchQr, @Default('') String watchCode, @Default(false) bool isLoading, @Default('') String errorMessage, @Default(false) bool isSuccess, - - @Default('') String allowanceAmount, }) = _AddKidFlowState; } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart index b6f5de2a..93886a6d 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/state/device_setup_view_state.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$LegacyDeviceSetupViewState { - LegacyAddKidStep get step; String get id; String get parentId; String get firstName; String get lastName; DateTime? get bornAt; String get address; String get genrer; String get relationType; String get strapQr; String get strapCode; String get watchQr; String get watchCode; bool get isLoading; String get errorMessage; bool get isSuccess; String get allowanceAmount; + LegacyAddKidStep get step; String get firstName; String get lastName; DateTime? get bornAt; String get genrer; String get relationType; String get weight; String get height; String get watchQr; String get watchCode; bool get isLoading; String get errorMessage; bool get isSuccess; /// Create a copy of LegacyDeviceSetupViewState /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -25,16 +25,16 @@ $LegacyDeviceSetupViewStateCopyWith get copyWith => @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceSetupViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.id, id) || other.id == id)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.strapQr, strapQr) || other.strapQr == strapQr)&&(identical(other.strapCode, strapCode) || other.strapCode == strapCode)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)&&(identical(other.allowanceAmount, allowanceAmount) || other.allowanceAmount == allowanceAmount)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyDeviceSetupViewState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)); } @override -int get hashCode => Object.hash(runtimeType,step,id,parentId,firstName,lastName,bornAt,address,genrer,relationType,strapQr,strapCode,watchQr,watchCode,isLoading,errorMessage,isSuccess,allowanceAmount); +int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,isLoading,errorMessage,isSuccess); @override String toString() { - return 'LegacyDeviceSetupViewState(step: $step, id: $id, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, genrer: $genrer, relationType: $relationType, strapQr: $strapQr, strapCode: $strapCode, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess, allowanceAmount: $allowanceAmount)'; + return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)'; } @@ -45,7 +45,7 @@ abstract mixin class $LegacyDeviceSetupViewStateCopyWith<$Res> { factory $LegacyDeviceSetupViewStateCopyWith(LegacyDeviceSetupViewState value, $Res Function(LegacyDeviceSetupViewState) _then) = _$LegacyDeviceSetupViewStateCopyWithImpl; @useResult $Res call({ - LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount + LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess }); @@ -62,26 +62,22 @@ class _$LegacyDeviceSetupViewStateCopyWithImpl<$Res> /// Create a copy of LegacyDeviceSetupViewState /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? id = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? address = null,Object? genrer = null,Object? relationType = null,Object? strapQr = null,Object? strapCode = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,Object? allowanceAmount = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) { return _then(_self.copyWith( step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable -as LegacyAddKidStep,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable -as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as LegacyAddKidStep,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String,bornAt: freezed == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable -as DateTime?,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable -as String,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable +as DateTime?,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable -as String,strapQr: null == strapQr ? _self.strapQr : strapQr // ignore: cast_nullable_to_non_nullable -as String,strapCode: null == strapCode ? _self.strapCode : strapCode // ignore: cast_nullable_to_non_nullable +as String,weight: null == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable +as String,height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable as String,watchQr: null == watchQr ? _self.watchQr : watchQr // ignore: cast_nullable_to_non_nullable as String,watchCode: null == watchCode ? _self.watchCode : watchCode // ignore: cast_nullable_to_non_nullable as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as String,isSuccess: null == isSuccess ? _self.isSuccess : isSuccess // ignore: cast_nullable_to_non_nullable -as bool,allowanceAmount: null == allowanceAmount ? _self.allowanceAmount : allowanceAmount // ignore: cast_nullable_to_non_nullable -as String, +as bool, )); } @@ -166,10 +162,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _AddKidFlowState() when $default != null: -return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);case _: +return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: return orElse(); } @@ -187,10 +183,10 @@ return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastNam /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess) $default,) {final _that = this; switch (_that) { case _AddKidFlowState(): -return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);case _: +return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: throw StateError('Unexpected subclass'); } @@ -207,10 +203,10 @@ return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastNam /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess)? $default,) {final _that = this; switch (_that) { case _AddKidFlowState() when $default != null: -return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastName,_that.bornAt,_that.address,_that.genrer,_that.relationType,_that.strapQr,_that.strapCode,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess,_that.allowanceAmount);case _: +return $default(_that.step,_that.firstName,_that.lastName,_that.bornAt,_that.genrer,_that.relationType,_that.weight,_that.height,_that.watchQr,_that.watchCode,_that.isLoading,_that.errorMessage,_that.isSuccess);case _: return null; } @@ -222,26 +218,22 @@ return $default(_that.step,_that.id,_that.parentId,_that.firstName,_that.lastNam class _AddKidFlowState implements LegacyDeviceSetupViewState { - const _AddKidFlowState({this.step = LegacyAddKidStep.intro, this.id = '', this.parentId = '', this.firstName = '', this.lastName = '', this.bornAt, this.address = '', this.genrer = '', this.relationType = '', this.strapQr = '', this.strapCode = '', this.watchQr = '', this.watchCode = '', this.isLoading = false, this.errorMessage = '', this.isSuccess = false, this.allowanceAmount = ''}); + const _AddKidFlowState({this.step = LegacyAddKidStep.intro, this.firstName = '', this.lastName = '', this.bornAt, this.genrer = '', this.relationType = '', this.weight = '', this.height = '', this.watchQr = '', this.watchCode = '', this.isLoading = false, this.errorMessage = '', this.isSuccess = false}); @override@JsonKey() final LegacyAddKidStep step; -@override@JsonKey() final String id; -@override@JsonKey() final String parentId; @override@JsonKey() final String firstName; @override@JsonKey() final String lastName; @override final DateTime? bornAt; -@override@JsonKey() final String address; @override@JsonKey() final String genrer; @override@JsonKey() final String relationType; -@override@JsonKey() final String strapQr; -@override@JsonKey() final String strapCode; +@override@JsonKey() final String weight; +@override@JsonKey() final String height; @override@JsonKey() final String watchQr; @override@JsonKey() final String watchCode; @override@JsonKey() final bool isLoading; @override@JsonKey() final String errorMessage; @override@JsonKey() final bool isSuccess; -@override@JsonKey() final String allowanceAmount; /// Create a copy of LegacyDeviceSetupViewState /// with the given fields replaced by the non-null parameter values. @@ -253,16 +245,16 @@ _$AddKidFlowStateCopyWith<_AddKidFlowState> get copyWith => __$AddKidFlowStateCo @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddKidFlowState&&(identical(other.step, step) || other.step == step)&&(identical(other.id, id) || other.id == id)&&(identical(other.parentId, parentId) || other.parentId == parentId)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.address, address) || other.address == address)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.strapQr, strapQr) || other.strapQr == strapQr)&&(identical(other.strapCode, strapCode) || other.strapCode == strapCode)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)&&(identical(other.allowanceAmount, allowanceAmount) || other.allowanceAmount == allowanceAmount)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AddKidFlowState&&(identical(other.step, step) || other.step == step)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.bornAt, bornAt) || other.bornAt == bornAt)&&(identical(other.genrer, genrer) || other.genrer == genrer)&&(identical(other.relationType, relationType) || other.relationType == relationType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.height, height) || other.height == height)&&(identical(other.watchQr, watchQr) || other.watchQr == watchQr)&&(identical(other.watchCode, watchCode) || other.watchCode == watchCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.isSuccess, isSuccess) || other.isSuccess == isSuccess)); } @override -int get hashCode => Object.hash(runtimeType,step,id,parentId,firstName,lastName,bornAt,address,genrer,relationType,strapQr,strapCode,watchQr,watchCode,isLoading,errorMessage,isSuccess,allowanceAmount); +int get hashCode => Object.hash(runtimeType,step,firstName,lastName,bornAt,genrer,relationType,weight,height,watchQr,watchCode,isLoading,errorMessage,isSuccess); @override String toString() { - return 'LegacyDeviceSetupViewState(step: $step, id: $id, parentId: $parentId, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, address: $address, genrer: $genrer, relationType: $relationType, strapQr: $strapQr, strapCode: $strapCode, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess, allowanceAmount: $allowanceAmount)'; + return 'LegacyDeviceSetupViewState(step: $step, firstName: $firstName, lastName: $lastName, bornAt: $bornAt, genrer: $genrer, relationType: $relationType, weight: $weight, height: $height, watchQr: $watchQr, watchCode: $watchCode, isLoading: $isLoading, errorMessage: $errorMessage, isSuccess: $isSuccess)'; } @@ -273,7 +265,7 @@ abstract mixin class _$AddKidFlowStateCopyWith<$Res> implements $LegacyDeviceSet factory _$AddKidFlowStateCopyWith(_AddKidFlowState value, $Res Function(_AddKidFlowState) _then) = __$AddKidFlowStateCopyWithImpl; @override @useResult $Res call({ - LegacyAddKidStep step, String id, String parentId, String firstName, String lastName, DateTime? bornAt, String address, String genrer, String relationType, String strapQr, String strapCode, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess, String allowanceAmount + LegacyAddKidStep step, String firstName, String lastName, DateTime? bornAt, String genrer, String relationType, String weight, String height, String watchQr, String watchCode, bool isLoading, String errorMessage, bool isSuccess }); @@ -290,26 +282,22 @@ class __$AddKidFlowStateCopyWithImpl<$Res> /// Create a copy of LegacyDeviceSetupViewState /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? id = null,Object? parentId = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? address = null,Object? genrer = null,Object? relationType = null,Object? strapQr = null,Object? strapCode = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,Object? allowanceAmount = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? step = null,Object? firstName = null,Object? lastName = null,Object? bornAt = freezed,Object? genrer = null,Object? relationType = null,Object? weight = null,Object? height = null,Object? watchQr = null,Object? watchCode = null,Object? isLoading = null,Object? errorMessage = null,Object? isSuccess = null,}) { return _then(_AddKidFlowState( step: null == step ? _self.step : step // ignore: cast_nullable_to_non_nullable -as LegacyAddKidStep,id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable -as String,parentId: null == parentId ? _self.parentId : parentId // ignore: cast_nullable_to_non_nullable -as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as LegacyAddKidStep,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String,bornAt: freezed == bornAt ? _self.bornAt : bornAt // ignore: cast_nullable_to_non_nullable -as DateTime?,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable -as String,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable +as DateTime?,genrer: null == genrer ? _self.genrer : genrer // ignore: cast_nullable_to_non_nullable as String,relationType: null == relationType ? _self.relationType : relationType // ignore: cast_nullable_to_non_nullable -as String,strapQr: null == strapQr ? _self.strapQr : strapQr // ignore: cast_nullable_to_non_nullable -as String,strapCode: null == strapCode ? _self.strapCode : strapCode // ignore: cast_nullable_to_non_nullable +as String,weight: null == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable +as String,height: null == height ? _self.height : height // ignore: cast_nullable_to_non_nullable as String,watchQr: null == watchQr ? _self.watchQr : watchQr // ignore: cast_nullable_to_non_nullable as String,watchCode: null == watchCode ? _self.watchCode : watchCode // ignore: cast_nullable_to_non_nullable as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as String,isSuccess: null == isSuccess ? _self.isSuccess : isSuccess // ignore: cast_nullable_to_non_nullable -as bool,allowanceAmount: null == allowanceAmount ? _self.allowanceAmount : allowanceAmount // ignore: cast_nullable_to_non_nullable -as String, +as bool, )); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/step_body.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/step_body.dart index 902e8bf8..6ca8fcec 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/step_body.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/step_body.dart @@ -1,11 +1,9 @@ import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_state.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/enums/add_kid_step.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/steps/intro_step.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/steps/link_info_step.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/steps/allowance_step.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/steps/profile_step.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/steps/scan_strap_and_watch_step.dart'; +import 'package:legacy_auth/src/features/device_setup/presentation/steps/scan_watch_step.dart'; import 'package:flutter/material.dart'; class LegacyStepBody extends StatelessWidget { @@ -19,14 +17,10 @@ class LegacyStepBody extends StatelessWidget { return LegacyIntroStepScreen(); case LegacyAddKidStep.linkInfo: return LegacyLinkInfoStepScreen(); - case LegacyAddKidStep.scanStrap: - return LegacyScanStrapAndWatchStepScreen(step: LegacyScanLinkStep.strap); case LegacyAddKidStep.scanWatch: - return LegacyScanStrapAndWatchStepScreen(step: LegacyScanLinkStep.watch); + return LegacyScanWatchStepScreen(); case LegacyAddKidStep.profile: return LegacyProfileStepScreen(); - case LegacyAddKidStep.allowance: - return LegacyAllowanceStepScreen(); } } } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/allowance_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/allowance_step.dart deleted file mode 100644 index fd889692..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/allowance_step.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:sf_localizations/sf_localizations.dart'; - -class LegacyAllowanceStepScreen extends ConsumerWidget { - const LegacyAllowanceStepScreen({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - return SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 24), - child: Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox(height: 30), - Text( - context.translate(I18n.deviceSetup_addCreditCard_title), - style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold), - textAlign: TextAlign.center, - ), - const SizedBox(height: 20), - Text( - context.translate(I18n.deviceSetup_addCreditCard_subtitle), - style: const TextStyle(fontSize: 18), - textAlign: TextAlign.center, - ), - const SizedBox(height: 24), - Text( - context.translate(I18n.deviceSetup_addCreditCard_info), - style: const TextStyle(fontSize: 14), - textAlign: TextAlign.center, - ), - ], - ), - ), - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/intro_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/intro_step.dart index 980825ad..77c928fa 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/intro_step.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/intro_step.dart @@ -12,7 +12,7 @@ class LegacyIntroStepScreen extends ConsumerWidget { final theme = ref.watch(themePortProvider); return Column( - mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( @@ -30,50 +30,9 @@ class LegacyIntroStepScreen extends ConsumerWidget { steps: [ context.translate(I18n.deviceSetup_intro_step_1), context.translate(I18n.deviceSetup_intro_step_2), - context.translate(I18n.deviceSetup_intro_step_3), ], color: theme.getColorFor(ThemeCode.buttonPrimary), ), - SizedBox(height: 40), - - Text( - context.translate(I18n.deviceSetup_intro_ready_title), - textAlign: TextAlign.center, - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), - ), - SizedBox(height: 40), - - Text( - context.translate(I18n.deviceSetup_intro_remember_prefix), - style: TextStyle(fontSize: 16), - ), - Text( - context.translate(I18n.deviceSetup_intro_plan_name), - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - SizedBox(height: 20), - - Padding( - padding: const EdgeInsets.symmetric(horizontal: 50.0), - child: RichText( - textAlign: TextAlign.center, - text: TextSpan( - text: context.translate(I18n.deviceSetup_intro_web_prefix), - style: TextStyle(fontSize: 16, color: Colors.black), - children: [ - TextSpan( - text: context.translate(I18n.deviceSetup_intro_web_link), - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - color: Colors.black, - decoration: TextDecoration.underline, - ), - ), - ], - ), - ), - ), ], ); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/link_info_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/link_info_step.dart index 9f97e385..88e529b7 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/link_info_step.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/link_info_step.dart @@ -17,7 +17,7 @@ class LegacyLinkInfoStepScreen extends ConsumerWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 65), child: Text( - context.translate(I18n.deviceSetup_linkInfo_title), + context.translate(I18n.legacy_deviceSetup_linkInfo_title), style: const TextStyle( fontSize: 28, fontWeight: FontWeight.bold, @@ -39,27 +39,23 @@ class LegacyLinkInfoStepScreen extends ConsumerWidget { children: [ LegacyLinkInfoItem( number: 1, - boldWord: context.translate( - I18n.deviceSetup_linkInfo_item1_boldWord, - ), + boldWord: '', titlePrefix: context.translate( - I18n.deviceSetup_linkInfo_item1_prefix, + I18n.legacy_deviceSetup_linkInfo_item1_title, ), subtitle: context.translate( - I18n.deviceSetup_linkInfo_item1_subtitle, + I18n.legacy_deviceSetup_linkInfo_item1_subtitle, ), ), SizedBox(height: 20), LegacyLinkInfoItem( number: 2, - boldWord: context.translate( - I18n.deviceSetup_linkInfo_item2_boldWord, - ), + boldWord: '', titlePrefix: context.translate( - I18n.deviceSetup_linkInfo_item2_prefix, + I18n.legacy_deviceSetup_linkInfo_item2_title, ), subtitle: context.translate( - I18n.deviceSetup_linkInfo_item2_subtitle, + I18n.legacy_deviceSetup_linkInfo_item2_subtitle, ), ), ], diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart index 63208c3d..8fcf6c70 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/profile_step.dart @@ -4,21 +4,42 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:sf_localizations/sf_localizations.dart'; +Future _pickBornAt( + BuildContext context, + DateTime? currentBornAt, + void Function(DateTime) onPicked, +) async { + FocusManager.instance.primaryFocus?.unfocus(); + + final now = DateTime.now(); + final initial = currentBornAt ?? DateTime(now.year - 18, now.month, now.day); + final safeInitial = initial.isAfter(now) ? now : initial; + + final picked = await showDatePicker( + context: context, + initialDate: safeInitial, + firstDate: DateTime(1900, 1, 1), + lastDate: now, + ); + + if (picked != null) onPicked(picked); +} + class LegacyProfileStepScreen extends ConsumerWidget { const LegacyProfileStepScreen({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { - const Map genrer = { - 'F': 'Femenino', - 'M': 'Masculino', - 'O': 'Otro', + final genrerItems = { + 'F': context.translate(I18n.genderFemale), + 'M': context.translate(I18n.genderMale), + 'O': context.translate(I18n.genderOther), }; - const Map relationship = { - 'FATHER': 'Padre', - 'MOTHER': 'Madre', - 'OTHER': 'Otro', + final relationshipItems = { + 'FATHER': context.translate(I18n.relationshipFather), + 'MOTHER': context.translate(I18n.relationshipMother), + 'OTHER': context.translate(I18n.relationshipOther), }; final state = ref.watch(legacyDeviceSetupViewModelProvider); @@ -31,14 +52,17 @@ class LegacyProfileStepScreen extends ConsumerWidget { children: [ const SizedBox(height: 30), Text( - context.translate(I18n.deviceSetup_intro_step_1), + context.translate(I18n.deviceSetup_intro_step_2), style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold), ), const SizedBox(height: 30), - Text( - context.translate(I18n.deviceSetup_accountData_info), - style: const TextStyle(fontSize: 18), - textAlign: TextAlign.center, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 24), + child: Text( + context.translate(I18n.legacy_deviceSetup_accountData_info), + style: const TextStyle(fontSize: 18), + textAlign: TextAlign.center, + ), ), const SizedBox(height: 20), Text( @@ -65,7 +89,7 @@ class LegacyProfileStepScreen extends ConsumerWidget { const SizedBox(height: 8), GestureDetector( - onTap: () => vm.pickBornAt(context), + onTap: () => _pickBornAt(context, state.bornAt, vm.setBornAt), child: AbsorbPointer( child: CustomTextField( label: context.translate(I18n.birthDateLabel), @@ -80,31 +104,43 @@ class LegacyProfileStepScreen extends ConsumerWidget { const SizedBox(height: 8), CustomDropdown( - items: genrer.values.map(Text.new).toList(growable: false), - values: genrer.keys.toList(growable: false), + items: genrerItems.values.map(Text.new).toList(growable: false), + values: genrerItems.keys.toList(growable: false), value: state.genrer.isEmpty ? null : state.genrer, - hint: 'Género', + label: context.translate(I18n.genderLabel), + hint: context.translate(I18n.genderHint), onChanged: (v) => vm.onGenrerChanged(v as String?), ), const SizedBox(height: 8), CustomDropdown( - items: relationship.values + items: relationshipItems.values .map(Text.new) .toList(growable: false), - values: relationship.keys.toList(growable: false), + values: relationshipItems.keys.toList(growable: false), value: state.relationType.isEmpty ? null : state.relationType, - hint: 'Relación', + label: context.translate(I18n.relationshipLabel), + hint: context.translate(I18n.relationshipHint), onChanged: (v) => vm.onRelationTypeChanged(v as String?), ), const SizedBox(height: 8), CustomTextField( - label: 'Dirección', - hint: 'Dirección', - controller: vm.addressController, + label: context.translate(I18n.deviceSetup_weightLabel), + hint: context.translate(I18n.deviceSetup_weightHint), + controller: vm.weightController, + keyboardType: TextInputType.number, + ), + + const SizedBox(height: 8), + + CustomTextField( + label: context.translate(I18n.deviceSetup_heightLabel), + hint: context.translate(I18n.deviceSetup_heightHint), + controller: vm.heightController, + keyboardType: TextInputType.number, ), const SizedBox(height: 8), diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_strap_and_watch_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_strap_and_watch_step.dart deleted file mode 100644 index 9f6b7d40..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_strap_and_watch_step.dart +++ /dev/null @@ -1,210 +0,0 @@ -import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/qr_scanner_screen.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/widgets/scan_link_steps_indicator.dart'; -import 'package:design_system/design_system.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:sf_localizations/sf_localizations.dart'; - -class LegacyScanStrapAndWatchStepScreen extends ConsumerWidget { - const LegacyScanStrapAndWatchStepScreen({super.key, required this.step}); - - final LegacyScanLinkStep step; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final theme = ref.watch(themePortProvider); - final activeColor = theme.getColorFor(ThemeCode.buttonPrimary); - final inactiveCircleColor = theme.getColorFor( - ThemeCode.backgroundSecondary, - ); - final inactiveLineColor = Colors.grey.shade200; - final textPrimary = theme.getColorFor(ThemeCode.textPrimary); - - final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier); - final state = ref.watch(legacyDeviceSetupViewModelProvider); - - return SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox(height: 30), - - Padding( - padding: const EdgeInsets.symmetric(horizontal: 65), - child: Text( - context.translate(I18n.deviceSetup_linkInfo_title), - style: const TextStyle( - fontSize: 28, - fontWeight: FontWeight.bold, - height: 1.2, - ), - textAlign: TextAlign.center, - ), - ), - - const SizedBox(height: 18), - - Padding( - padding: const EdgeInsets.symmetric(horizontal: 100), - child: LegacyScanLinkStepsIndicator( - step: step, - activeColor: activeColor, - inactiveCircleColor: inactiveCircleColor, - inactiveLineColor: inactiveLineColor, - textPrimary: textPrimary, - ), - ), - - const SizedBox(height: 12), - - Padding( - padding: const EdgeInsets.symmetric(horizontal: 35), - child: Row( - children: [ - Expanded( - child: Align( - alignment: Alignment.centerLeft, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: context.translate( - I18n.deviceSetup_linkInfo_item1_prefix, - ), - ), - TextSpan( - text: context.translate( - I18n.deviceSetup_linkInfo_item1_boldWord, - ), - style: TextStyle(fontWeight: FontWeight.w800), - ), - ], - ), - style: const TextStyle(fontSize: 18), - ), - ), - ), - Expanded( - child: Align( - alignment: Alignment.centerRight, - child: Text.rich( - TextSpan( - children: [ - TextSpan( - text: context.translate( - I18n.deviceSetup_linkInfo_item2_prefix, - ), - ), - TextSpan( - text: context.translate( - I18n.deviceSetup_linkInfo_item2_boldWord, - ), - style: TextStyle(fontWeight: FontWeight.w800), - ), - ], - ), - style: const TextStyle(fontSize: 18), - ), - ), - ), - ], - ), - ), - - const SizedBox(height: 28), - - InkWell( - borderRadius: BorderRadius.circular(16), - onTap: () async { - final result = await Navigator.of(context).push( - MaterialPageRoute(builder: (_) => const LegacyQrScannerScreen()), - ); - if (result == null || result.isEmpty) return; - vm.onQrScanned(step: step, qr: result); - }, - child: Container( - width: 170, - height: 170, - decoration: BoxDecoration( - border: Border.all(color: Colors.grey.shade500, width: 1), - borderRadius: BorderRadius.circular(16), - ), - child: Center( - child: SvgPicture.asset( - "assets/shared/images/qr.svg", - width: 90, - height: 90, - fit: BoxFit.contain, - ), - ), - ), - ), - - const SizedBox(height: 22), - - // if (step == LegacyScanLinkStep.watch) ...[ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - context.translate(I18n.deviceSetup_watchCode_orInsert), - style: const TextStyle(fontSize: 16), - ), - const SizedBox(height: 12), - Row( - children: [ - Expanded( - child: CustomTextField( - hint: "XXXXXXXXXX", - controller: LegacyScanLinkStep.strap == step - ? vm.strapCodeController - : vm.watchCodeController, - // controller: vm.codeController, - ), - ), - const SizedBox(width: 12), - // Expanded( - // child: PrimaryButton( - // onPressed: () {}, - // text: context.translate( - // I18n.deviceSetup_watchCode_continueWithCode, - // ), - // size: 14, - // color: theme.getColorFor(ThemeCode.buttonSecondary), - // ), - // ), - ], - ), - ], - ), - ), - - // ], - const SizedBox(height: 10), - - Column( - children: [ - Text( - context.translate(I18n.deviceSetup_linkTroubleshoot_title), - textAlign: TextAlign.center, - style: TextStyle(fontSize: 18), - ), - CustomTextButton( - onPressed: () {}, - text: context.translate(I18n.deviceSetup_contactUs), - weight: FontWeight.w800, - size: 18, - ), - ], - ), - ], - ), - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_watch_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_watch_step.dart new file mode 100644 index 00000000..41b034cd --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/scan_watch_step.dart @@ -0,0 +1,113 @@ +import 'package:legacy_auth/src/features/device_setup/presentation/qr_scanner_screen.dart'; +import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:sf_localizations/sf_localizations.dart'; + +class LegacyScanWatchStepScreen extends ConsumerWidget { + const LegacyScanWatchStepScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier); + + return SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 30), + + Padding( + padding: const EdgeInsets.symmetric(horizontal: 65), + child: Text( + context.translate(I18n.legacy_deviceSetup_scanWatch_title), + style: const TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + height: 1.2, + ), + textAlign: TextAlign.center, + ), + ), + + const SizedBox(height: 28), + + InkWell( + borderRadius: BorderRadius.circular(16), + onTap: () async { + final result = await Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const LegacyQrScannerScreen()), + ); + if (result == null || result.isEmpty) return; + vm.onWatchQrScanned(result); + }, + child: Container( + width: 170, + height: 170, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey.shade500, width: 1), + borderRadius: BorderRadius.circular(16), + ), + child: Center( + child: SvgPicture.asset( + "assets/shared/images/qr.svg", + width: 90, + height: 90, + fit: BoxFit.contain, + ), + ), + ), + ), + + const SizedBox(height: 22), + + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + context.translate(I18n.deviceSetup_watchCode_orInsert), + style: const TextStyle(fontSize: 16), + ), + const SizedBox(height: 12), + Row( + children: [ + Expanded( + child: CustomTextField( + hint: "XXXXXXXXXX", + controller: vm.watchCodeController, + ), + ), + const SizedBox(width: 12), + ], + ), + ], + ), + ), + + const SizedBox(height: 10), + + Column( + children: [ + Text( + context.translate(I18n.legacy_deviceSetup_linkTroubleshoot_title), + textAlign: TextAlign.center, + style: TextStyle(fontSize: 18), + ), + CustomTextButton( + onPressed: () {}, + text: context.translate(I18n.deviceSetup_contactUs), + weight: FontWeight.w800, + size: 18, + ), + ], + ), + ], + ), + ); + } +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/success_step.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/success_step.dart deleted file mode 100644 index 318d7a83..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/steps/success_step.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart'; -import 'package:design_system/design_system.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:sf_localizations/sf_localizations.dart'; - -class LegacySuccessStepScreen extends ConsumerWidget { - const LegacySuccessStepScreen({super.key}); - - @override - Widget build(BuildContext context, WidgetRef ref) { - final theme = ref.watch(themePortProvider); - final state = ref.watch(legacyDeviceSetupViewModelProvider); - final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier); - - return Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - Icons.check, - color: theme.getColorFor(ThemeCode.buttonPrimary), - size: 50, - ), - const SizedBox(height: 20), - Text( - context.translate(I18n.accountCreatedTitle), - style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold), - ), - const SizedBox(height: 30), - Text( - context.translate(I18n.accountCreatedForLabel), - style: TextStyle(fontSize: 18), - textAlign: TextAlign.center, - ), - Text( - '${state.firstName} ${state.lastName}', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500), - textAlign: TextAlign.center, - ), - SizedBox(height: 40), - - Text( - 'Reloj: ${state.watchCode}', - textAlign: TextAlign.center, - style: TextStyle(fontSize: 16), - ), - Text( - 'ID de la tarjeta: ${state.strapCode} ', - textAlign: TextAlign.center, - style: TextStyle(fontSize: 16), - ), - SizedBox(height: 40), - - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Text( - context.translate(I18n.deviceSetup_firstAllowance_title), - style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), - textAlign: TextAlign.center, - ), - ), - ], - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart index 329a8448..7ece3b99 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/success_screen.dart @@ -1,5 +1,4 @@ import 'package:legacy_auth/src/features/device_setup/presentation/state/device_setup_view_model.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/steps/success_step.dart'; import 'package:legacy_auth/src/features/device_setup/presentation/widgets/flow_footer.dart'; import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; @@ -12,6 +11,7 @@ class LegacySuccessScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final vm = ref.read(legacyDeviceSetupViewModelProvider.notifier); + final state = ref.watch(legacyDeviceSetupViewModelProvider); final theme = ref.watch(themePortProvider); return Scaffold( @@ -20,13 +20,44 @@ class LegacySuccessScreen extends ConsumerWidget { child: Column( children: [ const SizedBox(height: 20), - Expanded(child: LegacySuccessStepScreen()), - LegacyFlowFooter( - primaryText: context.translate( - I18n.deviceSetup_giveFirstAllowance, + Expanded( + child: Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + Icons.check, + color: theme.getColorFor(ThemeCode.buttonPrimary), + size: 50, + ), + const SizedBox(height: 20), + Text( + context.translate(I18n.accountCreatedTitle), + style: const TextStyle( + fontSize: 30, + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 30), + Text( + context.translate(I18n.accountCreatedForLabel), + style: const TextStyle(fontSize: 18), + textAlign: TextAlign.center, + ), + Text( + '${state.firstName} ${state.lastName}', + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, + ), + textAlign: TextAlign.center, + ), + ], ), + ), + LegacyFlowFooter( + primaryText: context.translate(I18n.continueKey), onPrimary: () { - vm.goToAllowance(); Navigator.of(context).pop(); }, secondaryText: context.translate(I18n.deviceSetup_addAnotherKid), diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/flow_footer.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/flow_footer.dart index e0ac9282..6b977ef1 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/flow_footer.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/flow_footer.dart @@ -9,7 +9,6 @@ class LegacyFlowFooter extends StatelessWidget { required this.theme, this.secondaryText, this.onSecondary, - this.error, }); final String primaryText; @@ -19,8 +18,6 @@ class LegacyFlowFooter extends StatelessWidget { final String? secondaryText; final VoidCallback? onSecondary; - final String? error; - @override Widget build(BuildContext context) { return Container( @@ -30,18 +27,10 @@ class LegacyFlowFooter extends StatelessWidget { borderRadius: const BorderRadius.vertical(top: Radius.circular(16)), ), child: Padding( - padding: const EdgeInsets.fromLTRB(16, 0, 16, 10), + padding: const EdgeInsets.fromLTRB(16, 16, 16, 16), child: Column( mainAxisSize: MainAxisSize.min, children: [ - if (error != null) ...[ - Text( - error!, - style: const TextStyle(color: Colors.red, fontSize: 13), - textAlign: TextAlign.center, - ), - const SizedBox(height: 8), - ], PrimaryButton( text: primaryText, onPressed: onPrimary, diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/link_info_item.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/link_info_item.dart index cadc7efd..b0ee8a44 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/link_info_item.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/link_info_item.dart @@ -17,6 +17,8 @@ class LegacyLinkInfoItem extends StatelessWidget { @override Widget build(BuildContext context) { + final textColor = Theme.of(context).colorScheme.onSurfaceVariant; + return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -32,18 +34,18 @@ class LegacyLinkInfoItem extends StatelessWidget { children: [ TextSpan( text: titlePrefix, - style: const TextStyle( + style: TextStyle( fontSize: 24, fontWeight: FontWeight.w500, - color: Color(0xFF4B4B4B), + color: textColor, ), ), TextSpan( text: boldWord, - style: const TextStyle( + style: TextStyle( fontSize: 24, fontWeight: FontWeight.w800, - color: Color(0xFF4B4B4B), + color: textColor, ), ), ], diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/number_circle.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/number_circle.dart index 92dcaa5d..0fd5e8e3 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/number_circle.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/number_circle.dart @@ -1,9 +1,16 @@ import 'package:flutter/material.dart'; class LegacyNumberCircle extends StatelessWidget { - const LegacyNumberCircle({super.key, required this.number}); + const LegacyNumberCircle({ + super.key, + required this.number, + this.backgroundColor, + this.textColor, + }); final int number; + final Color? backgroundColor; + final Color? textColor; @override Widget build(BuildContext context) { @@ -11,16 +18,16 @@ class LegacyNumberCircle extends StatelessWidget { width: 48, height: 48, alignment: Alignment.center, - decoration: const BoxDecoration( - color: Color(0xFFF2F2F2), + decoration: BoxDecoration( + color: backgroundColor ?? Theme.of(context).colorScheme.surfaceContainerHighest, shape: BoxShape.circle, ), child: Text( number.toString(), - style: const TextStyle( + style: TextStyle( fontSize: 24, fontWeight: FontWeight.w700, - color: Color(0xFF5A5A5A), + color: textColor ?? Theme.of(context).colorScheme.onSurfaceVariant, ), ), ); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/numbered_steps.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/numbered_steps.dart index 8f6babe0..6a378c66 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/numbered_steps.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/numbered_steps.dart @@ -16,7 +16,6 @@ class LegacyNumberedSteps extends StatelessWidget { final TextStyle? textStyle; - @override @override Widget build(BuildContext context) { final Color resolvedColor = @@ -44,10 +43,22 @@ class LegacyNumberedSteps extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - _LegacyStepCircle( - number: index + 1, - size: 32, - color: resolvedColor, + Container( + width: 32, + height: 32, + alignment: Alignment.center, + decoration: BoxDecoration( + color: resolvedColor, + shape: BoxShape.circle, + ), + child: Text( + '${index + 1}', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.w700, + fontSize: 32 * 0.55, + ), + ), ), if (!isLast) Container( @@ -72,33 +83,3 @@ class LegacyNumberedSteps extends StatelessWidget { ); } } - -class _LegacyStepCircle extends StatelessWidget { - const _LegacyStepCircle({ - required this.number, - required this.size, - required this.color, - }); - - final int number; - final double size; - final Color color; - - @override - Widget build(BuildContext context) { - return Container( - width: size, - height: size, - alignment: Alignment.center, - decoration: BoxDecoration(color: color, shape: BoxShape.circle), - child: Text( - '$number', - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.w700, - fontSize: size * 0.55, - ), - ), - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/scan_link_steps_indicator.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/scan_link_steps_indicator.dart deleted file mode 100644 index 60f06a03..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/scan_link_steps_indicator.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:legacy_auth/src/features/device_setup/presentation/enums/scan_link_step.dart'; -import 'package:legacy_auth/src/features/device_setup/presentation/widgets/step_circle.dart'; -import 'package:flutter/material.dart'; - -class LegacyScanLinkStepsIndicator extends StatelessWidget { - const LegacyScanLinkStepsIndicator({ - super.key, - required this.step, - required this.activeColor, - required this.inactiveCircleColor, - required this.inactiveLineColor, - required this.textPrimary, - }); - - final LegacyScanLinkStep step; - final Color activeColor; - final Color inactiveCircleColor; - final Color inactiveLineColor; - final Color textPrimary; - - bool get isWatch => step == LegacyScanLinkStep.watch; - - @override - Widget build(BuildContext context) { - const circleSize = 48.0; - const lineHeight = 4.0; - - return Row( - children: [ - LegacyStepCircle( - label: "1", - size: circleSize, - background: activeColor, - textColor: Colors.white, - ), - Expanded( - child: ClipRRect( - borderRadius: BorderRadius.circular(99), - child: SizedBox( - height: lineHeight, - child: Row( - children: [ - Expanded(child: Container(color: activeColor)), - if (!isWatch) - Expanded(child: Container(color: inactiveLineColor)), - ], - ), - ), - ), - ), - LegacyStepCircle( - label: "2", - size: circleSize, - background: isWatch ? activeColor : inactiveCircleColor, - textColor: isWatch ? Colors.white : textPrimary, - ), - ], - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/step_circle.dart b/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/step_circle.dart deleted file mode 100644 index 42083866..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/device_setup/presentation/widgets/step_circle.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:flutter/material.dart'; - -class LegacyStepCircle extends StatelessWidget { - const LegacyStepCircle({ - super.key, - required this.label, - required this.size, - required this.background, - required this.textColor, - }); - - final String label; - final double size; - final Color background; - final Color textColor; - - @override - Widget build(BuildContext context) { - return Container( - width: size, - height: size, - alignment: Alignment.center, - decoration: BoxDecoration(color: background, shape: BoxShape.circle), - child: Text( - label, - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.w800, - color: textColor, - ), - ), - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case.dart deleted file mode 100644 index d1510301..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart'; - -abstract class LegacyLoginUseCase { - Future login({ - required String email, - required String password, - }); -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case_impl.dart deleted file mode 100644 index 84b5f05d..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/login_use_case_impl.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/login/domain/entities/login_response_entity.dart'; -import 'package:legacy_auth/src/features/login/domain/login_use_case.dart'; - -class LegacyLoginUseCaseImpl implements LegacyLoginUseCase { - LegacyLoginUseCaseImpl(this._repository); - - final LegacyAuthRepository _repository; - - @override - Future login({ - required String email, - required String password, - }) { - return _repository.login(email: email, password: password); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case.dart deleted file mode 100644 index 0c3c0265..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case.dart +++ /dev/null @@ -1,6 +0,0 @@ -abstract class LegacyTwoFARequestCodeUseCase { - Future twoFARequestCode({ - required String token, - required String methodType, - }); -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case_impl.dart deleted file mode 100644 index a06ca034..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_request_code_use_case_impl.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case.dart'; - -class LegacyTwoFARequestCodeUseCaseImpl implements LegacyTwoFARequestCodeUseCase { - LegacyTwoFARequestCodeUseCaseImpl(this._repository); - - final LegacyAuthRepository _repository; - - @override - Future twoFARequestCode({ - required String token, - required String methodType, - }) { - return _repository.twoFARequestCode(token: token, methodType: methodType); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case.dart deleted file mode 100644 index bf34f66f..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case.dart +++ /dev/null @@ -1,7 +0,0 @@ -abstract class LegacyTwoFASendCodeUseCase { - Future twoFASendCode({ - required String token, - required String code, - required String methodType, - }); -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case_impl.dart deleted file mode 100644 index 49d10aaf..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/domain/two_fa_send_code_use_case_impl.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case.dart'; - -class LegacyTwoFASendCodeUseCaseImpl implements LegacyTwoFASendCodeUseCase { - LegacyTwoFASendCodeUseCaseImpl(this._repository); - - final LegacyAuthRepository _repository; - - @override - Future twoFASendCode({ - required String token, - required String code, - required String methodType, - }) { - return _repository.twoFASendCode( - token: token, - methodType: methodType, - code: code, - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/login_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/login_screen.dart index 03a9510c..860ecc41 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/login_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/login_screen.dart @@ -25,6 +25,7 @@ class LegacyLoginScreen extends ConsumerWidget { error: s.errorMessage, twoFA: s.twoFARequested, verified: s.twoFAVerified, + hasDevices: s.hasDevices, ), ), (previous, next) { @@ -44,7 +45,11 @@ class LegacyLoginScreen extends ConsumerWidget { message: context.translate(I18n.loginSuccess), type: MessageType.success, ); - navigationContract.goTo(AppRoutes.controlPanel); + if (next.hasDevices) { + navigationContract.goTo(AppRoutes.controlPanel); + } else { + navigationContract.goTo(AppRoutes.legacyDeviceSetup); + } } }, ); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/mixins/login_form_validation.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/mixins/login_form_validation.dart new file mode 100644 index 00000000..e8469cb0 --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/mixins/login_form_validation.dart @@ -0,0 +1,29 @@ +import 'package:sf_localizations/sf_localizations.dart'; + +mixin LoginFormValidation { + static final RegExp _emailRegex = RegExp( + r'^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$', + caseSensitive: false, + ); + + String validateEmail(String value) { + final email = value.trim(); + if (email.isEmpty) return I18n.errorEmailRequired; + if (!_emailRegex.hasMatch(email)) return I18n.errorEmailInvalid; + return ''; + } + + String validatePassword(String value) { + final password = value.trim(); + if (password.isEmpty) return I18n.errorPasswordRequired; + if (password.length < 6) return I18n.errorPasswordMinLength; + return ''; + } + + String validateCode(String value) { + final code = value.trim(); + if (code.isEmpty) return I18n.errorTwoFactorCodeRequired; + if (code.length != 6) return I18n.errorTwoFactorCodeInvalidLength; + return ''; + } +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/login_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/login_provider.dart deleted file mode 100644 index b5e37261..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/login_provider.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart'; -import 'package:legacy_auth/src/features/login/domain/login_use_case.dart'; -import 'package:legacy_auth/src/features/login/domain/login_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final legacyLoginUseCaseProvider = Provider.autoDispose((ref) { - final authRepository = ref.read(legacyAuthRepositoryProvider); - return LegacyLoginUseCaseImpl(authRepository); -}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_request_code_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_request_code_provider.dart deleted file mode 100644 index fad9c918..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_request_code_provider.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final legacyTwoFARequestCodeUseCaseProvider = - Provider.autoDispose((ref) { - final authRepository = ref.read(legacyAuthRepositoryProvider); - return LegacyTwoFARequestCodeUseCaseImpl(authRepository); - }); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_send_code_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_send_code_provider.dart deleted file mode 100644 index eb3a6ccb..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/providers/two_fa_send_code_provider.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final legacyTwoFASendCodeUseCaseProvider = Provider.autoDispose( - (ref) { - final authRepository = ref.read(legacyAuthRepositoryProvider); - return LegacyTwoFASendCodeUseCaseImpl(authRepository); - }, -); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_model.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_model.dart index 55252875..1a468a3e 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_model.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_model.dart @@ -1,15 +1,12 @@ import 'dart:async'; -import 'package:legacy_auth/src/features/login/domain/login_use_case.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_request_code_use_case.dart'; -import 'package:legacy_auth/src/features/login/domain/two_fa_send_code_use_case.dart'; -import 'package:legacy_auth/src/features/login/presentation/providers/login_provider.dart'; -import 'package:legacy_auth/src/features/login/presentation/providers/two_fa_request_code_provider.dart'; -import 'package:legacy_auth/src/features/login/presentation/providers/two_fa_send_code_provider.dart'; +import 'package:legacy_auth/src/core/domain/repositories/login_repository.dart'; +import 'package:legacy_auth/src/core/providers/login_repository_provider.dart'; +import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart'; +import 'package:legacy_auth/src/features/login/presentation/mixins/login_form_validation.dart'; import 'package:legacy_auth/src/features/login/presentation/state/login_view_state.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:sf_localizations/sf_localizations.dart'; import 'package:sf_shared/sf_shared.dart'; final legacyLoginViewModelProvider = @@ -17,10 +14,9 @@ final legacyLoginViewModelProvider = LegacyLoginViewModel.new, ); -class LegacyLoginViewModel extends Notifier { - late final LegacyLoginUseCase _loginUseCase; - late final LegacyTwoFARequestCodeUseCase _twoFARequestCodeUseCase; - late final LegacyTwoFASendCodeUseCase _twoFASendCodeUseCase; +class LegacyLoginViewModel extends Notifier + with LoginFormValidation { + late final LegacyLoginRepository _repository; late final GetUserInfoUseCase _getUserInfoUseCase; late final TextEditingController emailController; @@ -30,16 +26,9 @@ class LegacyLoginViewModel extends Notifier { static const int resendCooldownSeconds = 30; - static final RegExp _emailRegex = RegExp( - r'^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$', - caseSensitive: false, - ); - @override LegacyLoginViewState build() { - _loginUseCase = ref.read(legacyLoginUseCaseProvider); - _twoFARequestCodeUseCase = ref.read(legacyTwoFARequestCodeUseCaseProvider); - _twoFASendCodeUseCase = ref.read(legacyTwoFASendCodeUseCaseProvider); + _repository = ref.read(legacyLoginRepositoryProvider); _getUserInfoUseCase = ref.read(getUserInfoUseCaseProvider); emailController = TextEditingController(); @@ -59,7 +48,7 @@ class LegacyLoginViewModel extends Notifier { state = state.copyWith( email: value, errorMessage: '', - emailError: state.showErrors ? _validateEmail(value) : state.emailError, + emailError: state.showErrors ? validateEmail(value) : state.emailError, ); } @@ -70,7 +59,7 @@ class LegacyLoginViewModel extends Notifier { password: value, errorMessage: '', passwordError: - state.showErrors ? _validatePassword(value) : state.passwordError, + state.showErrors ? validatePassword(value) : state.passwordError, ); } @@ -86,23 +75,9 @@ class LegacyLoginViewModel extends Notifier { state = state.copyWith(passwordVisible: !state.passwordVisible); } - String _validateEmail(String value) { - final email = value.trim(); - if (email.isEmpty) return I18n.errorEmailRequired; - if (!_emailRegex.hasMatch(email)) return I18n.errorEmailInvalid; - return ''; - } - - String _validatePassword(String value) { - final password = value.trim(); - if (password.isEmpty) return I18n.errorPasswordRequired; - if (password.length < 6) return I18n.errorPasswordMinLength; - return ''; - } - bool _validateForm() { - final emailError = _validateEmail(state.email); - final passwordError = _validatePassword(state.password); + final emailError = validateEmail(state.email); + final passwordError = validatePassword(state.password); state = state.copyWith( showErrors: true, @@ -127,7 +102,7 @@ class LegacyLoginViewModel extends Notifier { ); try { - final response = await _loginUseCase.login( + final response = await _repository.login( email: email, password: password, ); @@ -144,7 +119,7 @@ class LegacyLoginViewModel extends Notifier { state = state.copyWith( isLoading: false, - errorMessage: _formatErrorMessage(e), + errorMessage: formatErrorMessage(e), ); return; } @@ -160,24 +135,17 @@ class LegacyLoginViewModel extends Notifier { state = state.copyWith(code: code, codeError: ''); } - String _validateCode(String value) { - final code = value.trim(); - if (code.isEmpty) return I18n.errorTwoFactorCodeRequired; - if (code.length != 6) return I18n.errorTwoFactorCodeInvalidLength; - return ''; - } - Future _requestTwoFACode({bool updateLoading = false}) async { if (state.availableMethods.isEmpty) { state = state.copyWith( - errorMessage: I18n.errorTwoFactorNoMethods, + errorMessage: 'No 2FA methods available', isLoading: updateLoading ? false : state.isLoading, ); return; } try { - await _twoFARequestCodeUseCase.twoFARequestCode( + await _repository.twoFARequestCode( token: state.token, methodType: state.availableMethods.first.methodType, ); @@ -193,7 +161,7 @@ class LegacyLoginViewModel extends Notifier { if (!ref.mounted) return; state = state.copyWith( - errorMessage: _formatErrorMessage(e), + errorMessage: formatErrorMessage(e), isLoading: updateLoading ? false : state.isLoading, ); } @@ -217,7 +185,7 @@ class LegacyLoginViewModel extends Notifier { } Future submitTwoFACode() async { - final codeError = _validateCode(state.code); + final codeError = validateCode(state.code); if (codeError.isNotEmpty) { state = state.copyWith(showErrors: true, codeError: codeError); return; @@ -233,7 +201,7 @@ class LegacyLoginViewModel extends Notifier { state = state.copyWith(isLoading: true, errorMessage: '', codeError: ''); try { - await _twoFASendCodeUseCase.twoFASendCode( + await _repository.twoFASendCode( token: state.token, code: state.code.trim(), methodType: method.methodType, @@ -245,13 +213,21 @@ class LegacyLoginViewModel extends Notifier { if (!ref.mounted) return; - state = state.copyWith(isLoading: false, twoFAVerified: true); + final hasDevices = await _repository.hasDevices(); + + if (!ref.mounted) return; + + state = state.copyWith( + isLoading: false, + twoFAVerified: true, + hasDevices: hasDevices, + ); } catch (e) { if (!ref.mounted) return; state = state.copyWith( isLoading: false, - errorMessage: _formatErrorMessage(e), + errorMessage: formatErrorMessage(e), ); } } @@ -260,12 +236,4 @@ class LegacyLoginViewModel extends Notifier { state = state.copyWith(code: '', isLoading: true); await _requestTwoFACode(updateLoading: true); } - - static String _formatErrorMessage(Object error) { - final raw = error.toString(); - if (raw.startsWith('Exception: ')) { - return raw.substring('Exception: '.length); - } - return raw; - } } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.dart index dcac7e76..07230e3c 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.dart @@ -22,5 +22,6 @@ abstract class LegacyLoginViewState with _$LegacyLoginViewState { @Default('') String codeError, @Default(0) int resendCooldown, @Default(false) bool twoFAVerified, + @Default(false) bool hasDevices, }) = _LegacyLoginViewState; } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.freezed.dart index 2f63909a..a748a5df 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.freezed.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/login/presentation/state/login_view_state.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$LegacyLoginViewState { - String get email; String get password; bool get passwordVisible; String get emailError; String get passwordError; String get errorMessage; bool get showErrors; bool get isLoading; List get availableMethods; String get token; bool get twoFARequested; String get code; String get codeError; int get resendCooldown; bool get twoFAVerified; + String get email; String get password; bool get passwordVisible; String get emailError; String get passwordError; String get errorMessage; bool get showErrors; bool get isLoading; List get availableMethods; String get token; bool get twoFARequested; String get code; String get codeError; int get resendCooldown; bool get twoFAVerified; bool get hasDevices; /// Create a copy of LegacyLoginViewState /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -25,16 +25,16 @@ $LegacyLoginViewStateCopyWith get copyWith => _$LegacyLogi @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyLoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods)&&(identical(other.token, token) || other.token == token)&&(identical(other.twoFARequested, twoFARequested) || other.twoFARequested == twoFARequested)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError)&&(identical(other.resendCooldown, resendCooldown) || other.resendCooldown == resendCooldown)&&(identical(other.twoFAVerified, twoFAVerified) || other.twoFAVerified == twoFAVerified)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyLoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other.availableMethods, availableMethods)&&(identical(other.token, token) || other.token == token)&&(identical(other.twoFARequested, twoFARequested) || other.twoFARequested == twoFARequested)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError)&&(identical(other.resendCooldown, resendCooldown) || other.resendCooldown == resendCooldown)&&(identical(other.twoFAVerified, twoFAVerified) || other.twoFAVerified == twoFAVerified)&&(identical(other.hasDevices, hasDevices) || other.hasDevices == hasDevices)); } @override -int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,const DeepCollectionEquality().hash(availableMethods),token,twoFARequested,code,codeError,resendCooldown,twoFAVerified); +int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,const DeepCollectionEquality().hash(availableMethods),token,twoFARequested,code,codeError,resendCooldown,twoFAVerified,hasDevices); @override String toString() { - return 'LegacyLoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, availableMethods: $availableMethods, token: $token, twoFARequested: $twoFARequested, code: $code, codeError: $codeError, resendCooldown: $resendCooldown, twoFAVerified: $twoFAVerified)'; + return 'LegacyLoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, availableMethods: $availableMethods, token: $token, twoFARequested: $twoFARequested, code: $code, codeError: $codeError, resendCooldown: $resendCooldown, twoFAVerified: $twoFAVerified, hasDevices: $hasDevices)'; } @@ -45,7 +45,7 @@ abstract mixin class $LegacyLoginViewStateCopyWith<$Res> { factory $LegacyLoginViewStateCopyWith(LegacyLoginViewState value, $Res Function(LegacyLoginViewState) _then) = _$LegacyLoginViewStateCopyWithImpl; @useResult $Res call({ - String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified + String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified, bool hasDevices }); @@ -62,7 +62,7 @@ class _$LegacyLoginViewStateCopyWithImpl<$Res> /// Create a copy of LegacyLoginViewState /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? availableMethods = null,Object? token = null,Object? twoFARequested = null,Object? code = null,Object? codeError = null,Object? resendCooldown = null,Object? twoFAVerified = null,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? availableMethods = null,Object? token = null,Object? twoFARequested = null,Object? code = null,Object? codeError = null,Object? resendCooldown = null,Object? twoFAVerified = null,Object? hasDevices = null,}) { return _then(_self.copyWith( email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable @@ -79,6 +79,7 @@ as bool,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_n as String,codeError: null == codeError ? _self.codeError : codeError // ignore: cast_nullable_to_non_nullable as String,resendCooldown: null == resendCooldown ? _self.resendCooldown : resendCooldown // ignore: cast_nullable_to_non_nullable as int,twoFAVerified: null == twoFAVerified ? _self.twoFAVerified : twoFAVerified // ignore: cast_nullable_to_non_nullable +as bool,hasDevices: null == hasDevices ? _self.hasDevices : hasDevices // ignore: cast_nullable_to_non_nullable as bool, )); } @@ -164,10 +165,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified, bool hasDevices)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _LegacyLoginViewState() when $default != null: -return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified);case _: +return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified,_that.hasDevices);case _: return orElse(); } @@ -185,10 +186,10 @@ return $default(_that.email,_that.password,_that.passwordVisible,_that.emailErro /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified, bool hasDevices) $default,) {final _that = this; switch (_that) { case _LegacyLoginViewState(): -return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified);case _: +return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified,_that.hasDevices);case _: throw StateError('Unexpected subclass'); } @@ -205,10 +206,10 @@ return $default(_that.email,_that.password,_that.passwordVisible,_that.emailErro /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified, bool hasDevices)? $default,) {final _that = this; switch (_that) { case _LegacyLoginViewState() when $default != null: -return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified);case _: +return $default(_that.email,_that.password,_that.passwordVisible,_that.emailError,_that.passwordError,_that.errorMessage,_that.showErrors,_that.isLoading,_that.availableMethods,_that.token,_that.twoFARequested,_that.code,_that.codeError,_that.resendCooldown,_that.twoFAVerified,_that.hasDevices);case _: return null; } @@ -220,7 +221,7 @@ return $default(_that.email,_that.password,_that.passwordVisible,_that.emailErro class _LegacyLoginViewState implements LegacyLoginViewState { - const _LegacyLoginViewState({this.email = '', this.password = '', this.passwordVisible = false, this.emailError = '', this.passwordError = '', this.errorMessage = '', this.showErrors = false, this.isLoading = false, final List availableMethods = const [], this.token = '', this.twoFARequested = false, this.code = '', this.codeError = '', this.resendCooldown = 0, this.twoFAVerified = false}): _availableMethods = availableMethods; + const _LegacyLoginViewState({this.email = '', this.password = '', this.passwordVisible = false, this.emailError = '', this.passwordError = '', this.errorMessage = '', this.showErrors = false, this.isLoading = false, final List availableMethods = const [], this.token = '', this.twoFARequested = false, this.code = '', this.codeError = '', this.resendCooldown = 0, this.twoFAVerified = false, this.hasDevices = false}): _availableMethods = availableMethods; @override@JsonKey() final String email; @@ -244,6 +245,7 @@ class _LegacyLoginViewState implements LegacyLoginViewState { @override@JsonKey() final String codeError; @override@JsonKey() final int resendCooldown; @override@JsonKey() final bool twoFAVerified; +@override@JsonKey() final bool hasDevices; /// Create a copy of LegacyLoginViewState /// with the given fields replaced by the non-null parameter values. @@ -255,16 +257,16 @@ _$LegacyLoginViewStateCopyWith<_LegacyLoginViewState> get copyWith => __$LegacyL @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyLoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods)&&(identical(other.token, token) || other.token == token)&&(identical(other.twoFARequested, twoFARequested) || other.twoFARequested == twoFARequested)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError)&&(identical(other.resendCooldown, resendCooldown) || other.resendCooldown == resendCooldown)&&(identical(other.twoFAVerified, twoFAVerified) || other.twoFAVerified == twoFAVerified)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyLoginViewState&&(identical(other.email, email) || other.email == email)&&(identical(other.password, password) || other.password == password)&&(identical(other.passwordVisible, passwordVisible) || other.passwordVisible == passwordVisible)&&(identical(other.emailError, emailError) || other.emailError == emailError)&&(identical(other.passwordError, passwordError) || other.passwordError == passwordError)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.showErrors, showErrors) || other.showErrors == showErrors)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other._availableMethods, _availableMethods)&&(identical(other.token, token) || other.token == token)&&(identical(other.twoFARequested, twoFARequested) || other.twoFARequested == twoFARequested)&&(identical(other.code, code) || other.code == code)&&(identical(other.codeError, codeError) || other.codeError == codeError)&&(identical(other.resendCooldown, resendCooldown) || other.resendCooldown == resendCooldown)&&(identical(other.twoFAVerified, twoFAVerified) || other.twoFAVerified == twoFAVerified)&&(identical(other.hasDevices, hasDevices) || other.hasDevices == hasDevices)); } @override -int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,const DeepCollectionEquality().hash(_availableMethods),token,twoFARequested,code,codeError,resendCooldown,twoFAVerified); +int get hashCode => Object.hash(runtimeType,email,password,passwordVisible,emailError,passwordError,errorMessage,showErrors,isLoading,const DeepCollectionEquality().hash(_availableMethods),token,twoFARequested,code,codeError,resendCooldown,twoFAVerified,hasDevices); @override String toString() { - return 'LegacyLoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, availableMethods: $availableMethods, token: $token, twoFARequested: $twoFARequested, code: $code, codeError: $codeError, resendCooldown: $resendCooldown, twoFAVerified: $twoFAVerified)'; + return 'LegacyLoginViewState(email: $email, password: $password, passwordVisible: $passwordVisible, emailError: $emailError, passwordError: $passwordError, errorMessage: $errorMessage, showErrors: $showErrors, isLoading: $isLoading, availableMethods: $availableMethods, token: $token, twoFARequested: $twoFARequested, code: $code, codeError: $codeError, resendCooldown: $resendCooldown, twoFAVerified: $twoFAVerified, hasDevices: $hasDevices)'; } @@ -275,7 +277,7 @@ abstract mixin class _$LegacyLoginViewStateCopyWith<$Res> implements $LegacyLogi factory _$LegacyLoginViewStateCopyWith(_LegacyLoginViewState value, $Res Function(_LegacyLoginViewState) _then) = __$LegacyLoginViewStateCopyWithImpl; @override @useResult $Res call({ - String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified + String email, String password, bool passwordVisible, String emailError, String passwordError, String errorMessage, bool showErrors, bool isLoading, List availableMethods, String token, bool twoFARequested, String code, String codeError, int resendCooldown, bool twoFAVerified, bool hasDevices }); @@ -292,7 +294,7 @@ class __$LegacyLoginViewStateCopyWithImpl<$Res> /// Create a copy of LegacyLoginViewState /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? availableMethods = null,Object? token = null,Object? twoFARequested = null,Object? code = null,Object? codeError = null,Object? resendCooldown = null,Object? twoFAVerified = null,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? email = null,Object? password = null,Object? passwordVisible = null,Object? emailError = null,Object? passwordError = null,Object? errorMessage = null,Object? showErrors = null,Object? isLoading = null,Object? availableMethods = null,Object? token = null,Object? twoFARequested = null,Object? code = null,Object? codeError = null,Object? resendCooldown = null,Object? twoFAVerified = null,Object? hasDevices = null,}) { return _then(_LegacyLoginViewState( email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable @@ -309,6 +311,7 @@ as bool,code: null == code ? _self.code : code // ignore: cast_nullable_to_non_n as String,codeError: null == codeError ? _self.codeError : codeError // ignore: cast_nullable_to_non_nullable as String,resendCooldown: null == resendCooldown ? _self.resendCooldown : resendCooldown // ignore: cast_nullable_to_non_nullable as int,twoFAVerified: null == twoFAVerified ? _self.twoFAVerified : twoFAVerified // ignore: cast_nullable_to_non_nullable +as bool,hasDevices: null == hasDevices ? _self.hasDevices : hasDevices // ignore: cast_nullable_to_non_nullable as bool, )); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart index c1549e5a..ff2d86b2 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_screen.dart @@ -28,11 +28,26 @@ class LegacyOnboardingScreen extends ConsumerWidget { final viewModel = ref.read(legacyOnBoardingViewModelProvider.notifier); final pageController = ref.watch(legacyOnboardingPageControllerProvider); + ref.listen( + legacyOnBoardingViewModelProvider.select((s) => s.isSessionValid), + (previous, isValid) { + if (isValid) { + navigationContract.goTo(AppRoutes.controlPanel); + } + }, + ); + + if (state.isCheckingSession) { + return const Scaffold( + body: Center(child: CircularProgressIndicator()), + ); + } + final isLast = state.cardIndex >= onboardingPages.length - 1; void goToNext() { if (isLast) { - navigationContract.goTo(AppRoutes.login); + navigationContract.goTo(AppRoutes.legacyLogin); } else { pageController.nextPage( duration: const Duration(milliseconds: 400), @@ -111,7 +126,7 @@ class LegacyOnboardingScreen extends ConsumerWidget { ? const SizedBox.shrink() : TextButton( onPressed: () => - navigationContract.goTo(AppRoutes.login), + navigationContract.goTo(AppRoutes.legacyLogin), child: Text( context.translate(I18n.skip), style: AppFonts.stolzlStyle( diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart index 619eba11..bb84a663 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_model.dart @@ -1,6 +1,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; - import 'package:legacy_auth/src/features/onboarding/presentation/onboarding_view_state.dart'; +import 'package:sf_shared/sf_shared.dart'; final legacyOnBoardingViewModelProvider = NotifierProvider.autoDispose( @@ -10,9 +10,21 @@ final legacyOnBoardingViewModelProvider = class LegacyOnBoardingViewModel extends Notifier { @override LegacyOnboardingViewState build() { + _checkSession(); return const LegacyOnboardingViewState(); } + Future _checkSession() async { + try { + await ref.read(getUserInfoUseCaseProvider).getUserInfo(); + if (!ref.mounted) return; + state = state.copyWith(isCheckingSession: false, isSessionValid: true); + } catch (_) { + if (!ref.mounted) return; + state = state.copyWith(isCheckingSession: false, isSessionValid: false); + } + } + void onPageChanged(int index) { state = state.copyWith(cardIndex: index); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart index ce2e4ba1..b493e91c 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.dart @@ -6,6 +6,8 @@ part 'onboarding_view_state.freezed.dart'; abstract class LegacyOnboardingViewState with _$LegacyOnboardingViewState { const factory LegacyOnboardingViewState({ @Default(0) int cardIndex, + @Default(true) bool isCheckingSession, + @Default(false) bool isSessionValid, String? error, }) = _LegacyOnboardingViewState; } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart index b04854ac..34b8e872 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/onboarding/presentation/onboarding_view_state.freezed.dart @@ -14,7 +14,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$LegacyOnboardingViewState { - int get cardIndex; String? get error; + int get cardIndex; bool get isCheckingSession; bool get isSessionValid; String? get error; /// Create a copy of LegacyOnboardingViewState /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -25,16 +25,16 @@ $LegacyOnboardingViewStateCopyWith get copyWith => _$ @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.error, error) || other.error == error)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.isCheckingSession, isCheckingSession) || other.isCheckingSession == isCheckingSession)&&(identical(other.isSessionValid, isSessionValid) || other.isSessionValid == isSessionValid)&&(identical(other.error, error) || other.error == error)); } @override -int get hashCode => Object.hash(runtimeType,cardIndex,error); +int get hashCode => Object.hash(runtimeType,cardIndex,isCheckingSession,isSessionValid,error); @override String toString() { - return 'LegacyOnboardingViewState(cardIndex: $cardIndex, error: $error)'; + return 'LegacyOnboardingViewState(cardIndex: $cardIndex, isCheckingSession: $isCheckingSession, isSessionValid: $isSessionValid, error: $error)'; } @@ -45,7 +45,7 @@ abstract mixin class $LegacyOnboardingViewStateCopyWith<$Res> { factory $LegacyOnboardingViewStateCopyWith(LegacyOnboardingViewState value, $Res Function(LegacyOnboardingViewState) _then) = _$LegacyOnboardingViewStateCopyWithImpl; @useResult $Res call({ - int cardIndex, String? error + int cardIndex, bool isCheckingSession, bool isSessionValid, String? error }); @@ -62,10 +62,12 @@ class _$LegacyOnboardingViewStateCopyWithImpl<$Res> /// Create a copy of LegacyOnboardingViewState /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? cardIndex = null,Object? error = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? cardIndex = null,Object? isCheckingSession = null,Object? isSessionValid = null,Object? error = freezed,}) { return _then(_self.copyWith( cardIndex: null == cardIndex ? _self.cardIndex : cardIndex // ignore: cast_nullable_to_non_nullable -as int,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as int,isCheckingSession: null == isCheckingSession ? _self.isCheckingSession : isCheckingSession // ignore: cast_nullable_to_non_nullable +as bool,isSessionValid: null == isSessionValid ? _self.isSessionValid : isSessionValid // ignore: cast_nullable_to_non_nullable +as bool,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable as String?, )); } @@ -151,10 +153,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( int cardIndex, String? error)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _LegacyOnboardingViewState() when $default != null: -return $default(_that.cardIndex,_that.error);case _: +return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _: return orElse(); } @@ -172,10 +174,10 @@ return $default(_that.cardIndex,_that.error);case _: /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( int cardIndex, String? error) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error) $default,) {final _that = this; switch (_that) { case _LegacyOnboardingViewState(): -return $default(_that.cardIndex,_that.error);case _: +return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _: throw StateError('Unexpected subclass'); } @@ -192,10 +194,10 @@ return $default(_that.cardIndex,_that.error);case _: /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( int cardIndex, String? error)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int cardIndex, bool isCheckingSession, bool isSessionValid, String? error)? $default,) {final _that = this; switch (_that) { case _LegacyOnboardingViewState() when $default != null: -return $default(_that.cardIndex,_that.error);case _: +return $default(_that.cardIndex,_that.isCheckingSession,_that.isSessionValid,_that.error);case _: return null; } @@ -207,10 +209,12 @@ return $default(_that.cardIndex,_that.error);case _: class _LegacyOnboardingViewState implements LegacyOnboardingViewState { - const _LegacyOnboardingViewState({this.cardIndex = 0, this.error}); + const _LegacyOnboardingViewState({this.cardIndex = 0, this.isCheckingSession = true, this.isSessionValid = false, this.error}); @override@JsonKey() final int cardIndex; +@override@JsonKey() final bool isCheckingSession; +@override@JsonKey() final bool isSessionValid; @override final String? error; /// Create a copy of LegacyOnboardingViewState @@ -223,16 +227,16 @@ _$LegacyOnboardingViewStateCopyWith<_LegacyOnboardingViewState> get copyWith => @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.error, error) || other.error == error)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LegacyOnboardingViewState&&(identical(other.cardIndex, cardIndex) || other.cardIndex == cardIndex)&&(identical(other.isCheckingSession, isCheckingSession) || other.isCheckingSession == isCheckingSession)&&(identical(other.isSessionValid, isSessionValid) || other.isSessionValid == isSessionValid)&&(identical(other.error, error) || other.error == error)); } @override -int get hashCode => Object.hash(runtimeType,cardIndex,error); +int get hashCode => Object.hash(runtimeType,cardIndex,isCheckingSession,isSessionValid,error); @override String toString() { - return 'LegacyOnboardingViewState(cardIndex: $cardIndex, error: $error)'; + return 'LegacyOnboardingViewState(cardIndex: $cardIndex, isCheckingSession: $isCheckingSession, isSessionValid: $isSessionValid, error: $error)'; } @@ -243,7 +247,7 @@ abstract mixin class _$LegacyOnboardingViewStateCopyWith<$Res> implements $Legac factory _$LegacyOnboardingViewStateCopyWith(_LegacyOnboardingViewState value, $Res Function(_LegacyOnboardingViewState) _then) = __$LegacyOnboardingViewStateCopyWithImpl; @override @useResult $Res call({ - int cardIndex, String? error + int cardIndex, bool isCheckingSession, bool isSessionValid, String? error }); @@ -260,10 +264,12 @@ class __$LegacyOnboardingViewStateCopyWithImpl<$Res> /// Create a copy of LegacyOnboardingViewState /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? cardIndex = null,Object? error = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? cardIndex = null,Object? isCheckingSession = null,Object? isSessionValid = null,Object? error = freezed,}) { return _then(_LegacyOnboardingViewState( cardIndex: null == cardIndex ? _self.cardIndex : cardIndex // ignore: cast_nullable_to_non_nullable -as int,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable +as int,isCheckingSession: null == isCheckingSession ? _self.isCheckingSession : isCheckingSession // ignore: cast_nullable_to_non_nullable +as bool,isSessionValid: null == isSessionValid ? _self.isSessionValid : isSessionValid // ignore: cast_nullable_to_non_nullable +as bool,error: freezed == error ? _self.error : error // ignore: cast_nullable_to_non_nullable as String?, )); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case.dart deleted file mode 100644 index 8adfee15..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:legacy_auth/src/features/sign_up/domain/entities/two_fa_secret_entity.dart'; - -abstract class GenerateTwoFALegacySignUpUseCase { - Future generateTwoFASignUp({required String token}); -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case_impl.dart deleted file mode 100644 index 6aa2151a..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/generate_two_fa_sign_up_use_case_impl.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:legacy_auth/src/core/data/models/two_fa_secret_response_model.dart'; -import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/two_fa_secret_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/generate_two_fa_sign_up_use_case.dart'; - -class GenerateTwoFALegacySignUpUseCaseImpl implements GenerateTwoFALegacySignUpUseCase { - GenerateTwoFALegacySignUpUseCaseImpl(this._repository); - - final LegacyAuthRepository _repository; - @override - Future generateTwoFASignUp({required String token}) { - return _repository - .generateTwoFASignUp(token: token) - .then((model) => model.toEntity()); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/sign_up_use_case_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/sign_up_use_case_impl.dart deleted file mode 100644 index c2a86c2c..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/sign_up_use_case_impl.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/sign_up_use_case.dart'; - -class LegacySignUpUseCaseImpl implements LegacySignUpUseCase { - LegacySignUpUseCaseImpl(this._repository); - - final LegacyAuthRepository _repository; - - @override - Future signUp({required LegacySignUpRequestEntity request}) { - return _repository.signUp(request: request); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case.dart deleted file mode 100644 index 55ed3f44..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case.dart +++ /dev/null @@ -1,6 +0,0 @@ -abstract class LegacyVerifyTwoFACodeSignUpUseCase { - Future verifyTwoFACodeSignUp({ - required String token, - required String code, - }); -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case_impl.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case_impl.dart deleted file mode 100644 index 9a131081..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case_impl.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:legacy_auth/src/core/domain/repositories/auth_repository.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case.dart'; - -class LegacyVerifyTwoFaCodeSignUpUseCaseImpl implements LegacyVerifyTwoFACodeSignUpUseCase { - LegacyVerifyTwoFaCodeSignUpUseCaseImpl(this._repository); - - final LegacyAuthRepository _repository; - @override - Future verifyTwoFACodeSignUp({ - required String token, - required String code, - }) { - return _repository.verifyTwoFACodeSignUp(token: token, code: code); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mappers/sign_up_view_state_mapper.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mappers/sign_up_view_state_mapper.dart deleted file mode 100644 index 6c5a1bad..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mappers/sign_up_view_state_mapper.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:legacy_auth/src/features/sign_up/domain/entities/address_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/presentation/mappers/address_view_state_mapper.dart'; -import 'package:legacy_auth/src/features/sign_up/presentation/state/sign_up_view_state.dart'; - -extension LegacySignUpViewStateMapper on LegacySignUpViewState { - bool get canSubmit => - document.trim().isNotEmpty && - documentType.trim().isNotEmpty && - relationType.trim().isNotEmpty && - firstName.trim().isNotEmpty && - lastName.trim().isNotEmpty && - email.trim().isNotEmpty && - phone.trim().isNotEmpty && - password.isNotEmpty && - bornAt != null && - placeOfBirth.trim().isNotEmpty && - birthCountry.trim().isNotEmpty && - address.isValid; - - LegacySignUpRequestEntity toRequestEntity() { - final birth = bornAt; - if (birth == null) { - throw Exception('bornAt is required'); - } - - return LegacySignUpRequestEntity( - document: document.trim(), - documentType: documentType.trim(), - relationType: relationType.trim(), - firstName: firstName.trim(), - lastName: lastName.trim(), - email: email.trim(), - phone: phone.trim(), - language: language.trim(), - password: password, - bornAt: birth.millisecondsSinceEpoch, - placeOfBirth: placeOfBirth.trim(), - birthCountry: birthCountry.trim(), - addresses: [address.toEntity()], - taxResidences: [address.toEntity()], - ); - } -} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mixins/sign_up_form_validation.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mixins/sign_up_form_validation.dart new file mode 100644 index 00000000..f18aed7f --- /dev/null +++ b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/mixins/sign_up_form_validation.dart @@ -0,0 +1,61 @@ +import 'package:legacy_auth/src/features/sign_up/presentation/mappers/address_view_state_mapper.dart'; +import 'package:legacy_auth/src/features/sign_up/presentation/state/address_view_state.dart'; +import 'package:sf_localizations/sf_localizations.dart'; + +mixin SignUpFormValidation { + static final RegExp _emailRegex = RegExp( + r'^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$', + caseSensitive: false, + ); + + static final RegExp _phoneRegex = RegExp(r'^\+?\d{6,15}$'); + + static final RegExp _nameRegex = RegExp(r"^[a-zA-ZÀ-ÿ\s\-']+$"); + + String emailErrorFor(String value) { + final email = value.trim(); + if (email.isEmpty) return I18n.errorEmailRequired; + if (email.contains('+')) return I18n.errorEmailPlusNotAllowed; + if (!_emailRegex.hasMatch(email)) return I18n.errorEmailInvalid; + return ''; + } + + static final RegExp _upperRegex = RegExp(r'[A-Z]'); + static final RegExp _digitRegex = RegExp(r'[0-9]'); + static final RegExp _specialRegex = RegExp(r'[!@#$%^&*(),.?":{}|<>\-_+=\[\]\\\/~`]'); + + String passwordErrorFor({ + required String password, + required String repeatPassword, + }) { + final p = password.trim(); + final rp = repeatPassword.trim(); + + if (p.isEmpty) return I18n.errorPasswordRequired; + if (p.length < 8) return I18n.errorMessagePasswordTooShort; + if (!_upperRegex.hasMatch(p)) return I18n.errorMessagePasswordNoCapitals; + if (!_digitRegex.hasMatch(p)) return I18n.errorMessagePasswordNoNumbers; + if (!_specialRegex.hasMatch(p)) return I18n.errorMessagePasswordNoSpecialChars; + if (rp.isEmpty) return I18n.repeatPassword; + if (p != rp) return I18n.errorMessageUnequalPasswords; + + return ''; + } + + bool hasMinLength(String password) => password.length >= 8; + bool hasUpperCase(String password) => _upperRegex.hasMatch(password); + bool hasNumber(String password) => _digitRegex.hasMatch(password); + bool hasSpecialChar(String password) => _specialRegex.hasMatch(password); + + String phoneErrorFor(String value) { + final phone = value.trim(); + if (phone.isEmpty) return I18n.errorMessagePhoneIsEmpty; + if (!_phoneRegex.hasMatch(phone)) return I18n.errorMessagePhoneIsEmpty; + return ''; + } + + bool isNameValid(String name) => + name.trim().isNotEmpty && _nameRegex.hasMatch(name.trim()); + + bool isAddressValid(LegacyAddressViewState address) => address.isValid; +} diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/generate_two_fa_sign_up_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/generate_two_fa_sign_up_provider.dart deleted file mode 100644 index 33472d94..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/generate_two_fa_sign_up_provider.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/generate_two_fa_sign_up_use_case.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/generate_two_fa_sign_up_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final generateTwoFALegacySignUpUseCaseProvider = - Provider.autoDispose((ref) { - final authRepository = ref.read(legacyAuthRepositoryProvider); - return GenerateTwoFALegacySignUpUseCaseImpl(authRepository); - }); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/sign_up_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/sign_up_provider.dart deleted file mode 100644 index 5afb1474..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/sign_up_provider.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/sign_up_use_case.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/sign_up_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final legacySignUpUseCaseProvider = Provider.autoDispose((ref) { - final authRepository = ref.read(legacyAuthRepositoryProvider); - return LegacySignUpUseCaseImpl(authRepository); -}); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/verify_two_fa_code_sign_up_provider.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/verify_two_fa_code_sign_up_provider.dart deleted file mode 100644 index 57345a6a..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/providers/verify_two_fa_code_sign_up_provider.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:legacy_auth/src/core/providers/auth_repository_provider.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/verify_two_fa_code_sign_up_use_case_impl.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -final legacyVerifyTwoFACodeSignUpUseCaseProvider = - Provider.autoDispose((ref) { - final authRepository = ref.read(legacyAuthRepositoryProvider); - return LegacyVerifyTwoFaCodeSignUpUseCaseImpl(authRepository); - }); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/secret_code_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/secret_code_screen.dart deleted file mode 100644 index 905e9883..00000000 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/secret_code_screen.dart +++ /dev/null @@ -1,281 +0,0 @@ -// import 'dart:convert'; - -// import 'package:legacy_auth/src/features/login/presentation/widgets/two_factor_bottom_sheet.dart'; -// import 'package:legacy_auth/src/features/sign_up/presentation/state/sign_up_view_model.dart'; -// import 'package:design_system/design_system.dart'; -// import 'package:flutter/material.dart'; -// import 'package:flutter/services.dart'; -// import 'package:flutter_riverpod/flutter_riverpod.dart'; -// import 'package:navigation/navigation.dart'; -// import 'package:sf_localizations/sf_localizations.dart'; - -// class SecretCodeScreen extends ConsumerWidget { -// final NavigationContract navigationContract; - -// const SecretCodeScreen({super.key, required this.navigationContract}); - -// Uint8List? _qrBytes(String? dataUri) { -// final value = (dataUri ?? '').trim(); -// if (value.isEmpty) return null; - -// final idx = value.indexOf('base64,'); -// final b64 = idx == -1 ? value : value.substring(idx + 7); - -// try { -// return base64Decode(b64); -// } catch (_) { -// return null; -// } -// } - -// Future _openTwoFactorSignUpBottomSheet( -// BuildContext context, -// WidgetRef ref, -// ) async { -// final token = ref.read(legacySignUpViewModelProvider).token; -// if (token.trim().isEmpty) return false; - -// return showModalBottomSheet( -// context: context, -// isScrollControlled: true, -// useSafeArea: true, -// isDismissible: false, -// enableDrag: false, -// backgroundColor: Colors.transparent, -// builder: (context) { -// return Consumer( -// builder: (context, ref, _) { -// final theme = ref.watch(themePortProvider); -// final vm = ref.read(legacySignUpViewModelProvider.notifier); - -// final otpErrorKey = ref.watch( -// legacySignUpViewModelProvider.select((s) => s.otpError), -// ); -// final isOtpLoading = ref.watch( -// legacySignUpViewModelProvider.select((s) => s.isOtpLoading), -// ); -// final otpCode = ref.watch( -// legacySignUpViewModelProvider.select((s) => s.otpCode), -// ); - -// final otpErrorText = otpErrorKey.isEmpty -// ? '' -// : context.translate(otpErrorKey); - -// Future onVerify() async { -// FocusManager.instance.primaryFocus?.unfocus(); - -// final ok = await vm.verifyTwoFACodeSignUp(token: token); -// if (!context.mounted) return; - -// if (ok) Navigator.of(context).pop(true); -// } - -// return LegacyTwoFactorBottomSheetView( -// theme: theme, -// title: context.translate(I18n.twoFactorTitle), -// subtitle: context.translate(I18n.twoFactorSubtitle), -// verifyText: context.translate(I18n.twoFactorVerify), -// closeText: context.translate(I18n.close), -// isOtpLoading: isOtpLoading, -// otpCode: otpCode, -// otpErrorText: otpErrorText, -// onChanged: vm.setOtpCode, -// onVerify: onVerify, -// onClose: () => Navigator.of(context).pop(false), -// ); -// }, -// ); -// }, -// ); -// } - -// @override -// Widget build(BuildContext context, WidgetRef ref) { -// final theme = ref.watch(themePortProvider); -// final vm = ref.read(legacySignUpViewModelProvider.notifier); -// final state = ref.watch(legacySignUpViewModelProvider); - -// final secret = state.twoFASecret?.item.secret.trim() ?? ''; -// final qrDataUri = state.twoFASecret?.item.qr; -// final qrBytes = _qrBytes(qrDataUri); - -// return Scaffold( -// backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary), -// body: SafeArea( -// child: SingleChildScrollView( -// padding: const EdgeInsets.fromLTRB(24, 8, 24, 24), -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Text( -// context.translate(I18n.secretCodeTitle), -// style: TextStyle( -// fontSize: 20, -// fontWeight: FontWeight.w700, -// color: theme.getColorFor(ThemeCode.textPrimary), -// ), -// ), -// const SizedBox(height: 20), - -// _StepBlock( -// theme: theme, -// number: '1.', -// title: context.translate(I18n.secretCodeStep1Title), -// body: context.translate(I18n.secretCodeStep1Body), -// ), -// const SizedBox(height: 14), - -// _StepBlock( -// theme: theme, -// number: '2.', -// title: context.translate(I18n.secretCodeStep2Title), -// body: context.translate(I18n.secretCodeStep2Body), -// ), -// const SizedBox(height: 12), - -// Center( -// child: Container( -// width: 150, -// height: 150, -// decoration: BoxDecoration( -// borderRadius: BorderRadius.circular(12), -// border: Border.all(width: 1, color: Colors.black), -// color: theme.getColorFor(ThemeCode.backgroundSecondary), -// ), -// child: qrBytes == null -// ? const Center(child: Icon(Icons.qr_code_2, size: 60)) -// : ClipRRect( -// borderRadius: BorderRadius.circular(12), -// child: Image.memory(qrBytes, fit: BoxFit.cover), -// ), -// ), -// ), -// const SizedBox(height: 12), - -// Center( -// child: Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 14, -// vertical: 10, -// ), -// decoration: BoxDecoration( -// borderRadius: BorderRadius.circular(10), -// color: theme.getColorFor(ThemeCode.backgroundSecondary), -// border: Border.all(width: 1, color: Colors.black), -// ), -// child: Row( -// mainAxisSize: MainAxisSize.min, -// children: [ -// Text( -// secret, -// style: TextStyle( -// fontWeight: FontWeight.w700, -// letterSpacing: 1.1, -// color: theme.getColorFor(ThemeCode.textPrimary), -// ), -// ), -// const SizedBox(width: 10), -// IconButton( -// visualDensity: VisualDensity.compact, -// padding: EdgeInsets.zero, -// constraints: const BoxConstraints(), -// icon: const Icon(Icons.copy, size: 18), -// onPressed: secret.isEmpty -// ? null -// : () async { -// await Clipboard.setData( -// ClipboardData(text: secret), -// ); -// if (!context.mounted) return; -// ScaffoldMessenger.of(context).showSnackBar( -// SnackBar( -// content: Text( -// context.translate( -// I18n.secretCodeKeyCopied, -// ), -// ), -// ), -// ); -// }, -// ), -// ], -// ), -// ), -// ), - -// const SizedBox(height: 18), -// _StepBlock( -// theme: theme, -// number: '3.', -// title: context.translate(I18n.secretCodeStep3Title), -// body: context.translate(I18n.secretCodeStep3Body), -// ), - -// const SizedBox(height: 26), -// PrimaryButton( -// onPressed: () async { -// final verified = await _openTwoFactorSignUpBottomSheet( -// context, -// ref, -// ); -// if (!context.mounted) return; - -// if (verified == true) { -// vm.showAccountCreated(); -// } -// }, -// text: context.translate(I18n.secretCodeConfigure), -// color: theme.getColorFor(ThemeCode.buttonPrimary), -// ), -// ], -// ), -// ), -// ), -// ); -// } -// } - -// class _StepBlock extends StatelessWidget { -// final ThemePort theme; -// final String number; -// final String title; -// final String body; - -// const _StepBlock({ -// required this.theme, -// required this.number, -// required this.title, -// required this.body, -// }); - -// @override -// Widget build(BuildContext context) { -// return RichText( -// text: TextSpan( -// style: TextStyle( -// height: 1.35, -// fontSize: 14, -// color: theme.getColorFor(ThemeCode.textPrimary), -// ), -// children: [ -// TextSpan( -// text: '$number ', -// style: const TextStyle(fontWeight: FontWeight.w700), -// ), -// TextSpan( -// text: '$title\n', -// style: const TextStyle(fontWeight: FontWeight.w700), -// ), -// TextSpan( -// text: body, -// style: TextStyle( -// fontWeight: FontWeight.w400, -// color: theme.getColorFor(ThemeCode.textSecondary), -// ), -// ), -// ], -// ), -// ); -// } -// } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/sign_up_password_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/sign_up_password_screen.dart index e6eb27c6..4120f92b 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/sign_up_password_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/screens/sign_up_password_screen.dart @@ -1,13 +1,17 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; +import 'package:sf_localizations/sf_localizations.dart'; class LegacySignUpPasswordScreen extends StatelessWidget { final bool isPasswordVisible; + final String password; final TextEditingController passwordTextFieldController; final TextEditingController repeatPasswordTextFieldController; + const LegacySignUpPasswordScreen({ super.key, required this.isPasswordVisible, + required this.password, required this.passwordTextFieldController, required this.repeatPasswordTextFieldController, }); @@ -16,19 +20,104 @@ class LegacySignUpPasswordScreen extends StatelessWidget { Widget build(BuildContext context) { return Column( spacing: 24, + crossAxisAlignment: CrossAxisAlignment.start, children: [ CustomTextField( showPassword: isPasswordVisible, - label: "Contraseña", - hint: "********", + label: context.translate(I18n.password), + hint: '********', controller: passwordTextFieldController, ), CustomTextField( showPassword: isPasswordVisible, - label: "Repetir contraseña", - hint: "*******", + label: context.translate(I18n.repeatPassword), + hint: '********', controller: repeatPasswordTextFieldController, ), + _PasswordCriteriaList(password: password), + ], + ); + } +} + +class _PasswordCriteriaList extends StatelessWidget { + final String password; + + const _PasswordCriteriaList({required this.password}); + + static final _upperRegex = RegExp(r'[A-Z]'); + static final _digitRegex = RegExp(r'[0-9]'); + static final _specialRegex = + RegExp(r'[!@#$%^&*(),.?":{}|<>\-_+=\[\]\\\/~`]'); + + @override + Widget build(BuildContext context) { + final hasInput = password.isNotEmpty; + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 6, + children: [ + _CriteriaRow( + label: context.translate(I18n.passwordLength), + met: password.length >= 8, + hasInput: hasInput, + ), + _CriteriaRow( + label: context.translate(I18n.passwordCapital), + met: _upperRegex.hasMatch(password), + hasInput: hasInput, + ), + _CriteriaRow( + label: context.translate(I18n.passwordNumber), + met: _digitRegex.hasMatch(password), + hasInput: hasInput, + ), + _CriteriaRow( + label: context.translate(I18n.passwordSpecial), + met: _specialRegex.hasMatch(password), + hasInput: hasInput, + ), + ], + ); + } +} + +class _CriteriaRow extends StatelessWidget { + final String label; + final bool met; + final bool hasInput; + + const _CriteriaRow({ + required this.label, + required this.met, + required this.hasInput, + }); + + @override + Widget build(BuildContext context) { + final Color color; + final IconData icon; + + if (!hasInput) { + color = Colors.grey; + icon = Icons.circle_outlined; + } else if (met) { + color = Colors.green; + icon = Icons.check_circle; + } else { + color = Colors.red.shade400; + icon = Icons.cancel; + } + + return Row( + spacing: 8, + children: [ + Icon(icon, size: 16, color: color), + Text( + label, + style: TextStyle(fontSize: 13, color: color), + ), ], ); } diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_screen.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_screen.dart index af07a843..8d3aac3c 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_screen.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_screen.dart @@ -67,6 +67,7 @@ class LegacySignupScreen extends ConsumerWidget { currentStep: index + 1, numSteps: steps.length, body: step.bodyBuilder(context, ref), + isLoading: state.isLoading, onBackPressed: state.currentIndex == 0 ? navigationContract.goBack : vm.back, diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_steps.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_steps.dart index 883a5bc1..f825b2fb 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_steps.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/sign_up_steps.dart @@ -171,6 +171,7 @@ List signUpSteps(BuildContext context) => [ return LegacySignUpPasswordScreen( isPasswordVisible: state.isShowPassword, + password: state.password, passwordTextFieldController: vm.passwordController, repeatPasswordTextFieldController: vm.repeatPasswordController, ); diff --git a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/state/sign_up_view_model.dart b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/state/sign_up_view_model.dart index 96705448..d0536d1f 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/state/sign_up_view_model.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/features/sign_up/presentation/state/sign_up_view_model.dart @@ -1,24 +1,27 @@ import 'dart:async'; +import 'package:legacy_auth/src/core/domain/repositories/sign_up_repository.dart'; +import 'package:legacy_auth/src/core/providers/sign_up_repository_provider.dart'; +import 'package:legacy_auth/src/core/utils/dio_error_mapper.dart'; +import 'package:legacy_auth/src/core/utils/text_format_utils.dart'; import 'package:legacy_auth/src/features/sign_up/domain/entities/address_entity.dart'; import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_request_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/entities/sign_up_response_entity.dart'; -import 'package:legacy_auth/src/features/sign_up/domain/sign_up_use_case.dart'; -import 'package:legacy_auth/src/features/sign_up/presentation/providers/sign_up_provider.dart'; +import 'package:legacy_auth/src/features/sign_up/presentation/mixins/sign_up_form_validation.dart'; import 'package:legacy_auth/src/features/sign_up/presentation/state/address_view_state.dart'; import 'package:legacy_auth/src/features/sign_up/presentation/state/sign_up_view_state.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:sf_localizations/sf_localizations.dart'; import 'package:sealed_countries/sealed_countries.dart'; +import 'package:sf_localizations/sf_localizations.dart'; final legacySignUpViewModelProvider = NotifierProvider.autoDispose( LegacySignUpViewModel.new, ); -class LegacySignUpViewModel extends Notifier { - late final LegacySignUpUseCase _signUpUseCase; +class LegacySignUpViewModel extends Notifier + with SignUpFormValidation { + late final LegacySignUpRepository _repository; late final TextEditingController firstNameController; late final TextEditingController lastNameController; @@ -44,24 +47,15 @@ class LegacySignUpViewModel extends Notifier { static const int _lastIndex = 2; - static final RegExp _emailRegex = RegExp( - r'^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$', - caseSensitive: false, - ); - - static final RegExp _phoneRegex = RegExp(r'^\+?\d{6,15}$'); - - static final RegExp _nameRegex = RegExp(r"^[a-zA-ZÀ-ÿ\s\-']+$"); - @override LegacySignUpViewState build() { - _signUpUseCase = ref.read(legacySignUpUseCaseProvider); + _repository = ref.read(legacySignUpRepositoryProvider); final initial = LegacySignUpViewState(); _initControllers(initial); _addListeners(); - ref.onDispose(disposeControllers); + ref.onDispose(_disposeControllers); return initial; } @@ -96,6 +90,31 @@ class LegacySignUpViewModel extends Notifier { repeatPasswordController = TextEditingController(text: s.repeatPassword); } + + + void _syncField( + String text, { + required String current, + required LegacySignUpViewState Function() update, + }) { + if (text == current) return; + state = update(); + } + + void _syncAddressField( + String text, { + required String current, + required LegacyAddressViewState Function() updateAddress, + }) { + if (text == current) return; + state = state.copyWith( + address: updateAddress(), + errorMessage: '', + ); + } + + + void _addListeners() { firstNameController.addListener(_onFirstNameChanged); lastNameController.addListener(_onLastNameChanged); @@ -120,6 +139,222 @@ class LegacySignUpViewModel extends Notifier { repeatPasswordController.addListener(_onRepeatPasswordChanged); } + void _onFirstNameChanged() { + toCapitalizedController(firstNameController); + _syncField( + firstNameController.text, + current: state.firstName, + update: () => state.copyWith( + firstName: firstNameController.text, + errorMessage: '', + ), + ); + } + + void _onLastNameChanged() { + toCapitalizedController(lastNameController); + _syncField( + lastNameController.text, + current: state.lastName, + update: () => state.copyWith( + lastName: lastNameController.text, + errorMessage: '', + ), + ); + } + + void _onDocumentNumberChanged() { + toUpperCaseController(documentNumberController); + _syncField( + documentNumberController.text, + current: state.document, + update: () => state.copyWith( + document: documentNumberController.text, + errorMessage: '', + ), + ); + } + + void _onDocumentTypeChanged() => _syncField( + documentTypeController.text, + current: state.documentType, + update: () => state.copyWith( + documentType: documentTypeController.text, + errorMessage: '', + ), + ); + + void _onRelationshipChanged() => _syncField( + relationshipController.text, + current: state.relationType, + update: () => state.copyWith( + relationType: relationshipController.text, + errorMessage: '', + ), + ); + + void _onPlaceOfBirthChanged() { + toCapitalizedController(placeOfBirthController); + _syncField( + placeOfBirthController.text, + current: state.placeOfBirth, + update: () => state.copyWith( + placeOfBirth: placeOfBirthController.text, + errorMessage: '', + ), + ); + } + + void _onBirthCountryChanged() => _syncField( + birthCountryController.text, + current: state.birthCountry, + update: () => state.copyWith( + birthCountry: birthCountryController.text, + errorMessage: '', + ), + ); + + void _onPhoneChanged() { + final text = phoneController.text; + if (text == state.phone) return; + + state = state.copyWith(phone: text); + + if (state.showErrors) { + state = state.copyWith(phoneError: phoneErrorFor(text)); + } + } + + void _onEmailChanged() { + final text = emailController.text; + if (text == state.email) return; + + state = state.copyWith(email: text, errorMessage: ''); + + if (state.showErrors) { + state = state.copyWith(emailError: emailErrorFor(text)); + } + } + + void _onPasswordChanged() { + final text = passwordController.text; + if (text == state.password) return; + + state = state.copyWith(password: text, errorMessage: ''); + + if (state.showErrors) { + state = state.copyWith( + passwordError: passwordErrorFor( + password: text, + repeatPassword: state.repeatPassword, + ), + ); + } + } + + void _onRepeatPasswordChanged() { + final text = repeatPasswordController.text; + if (text == state.repeatPassword) return; + + state = state.copyWith(repeatPassword: text, errorMessage: ''); + + if (state.showErrors) { + state = state.copyWith( + passwordError: passwordErrorFor( + password: state.password, + repeatPassword: text, + ), + ); + } + } + + void _onBornAtTextChanged() { + final text = bornAtController.text; + final parsed = _tryParseDate(text); + + if (text.trim().isEmpty) { + if (state.bornAt != null) { + state = state.copyWith(bornAt: null, errorMessage: ''); + } + return; + } + + if (parsed != null && parsed != state.bornAt) { + state = state.copyWith(bornAt: parsed, errorMessage: ''); + } + } + + void _onAddressStreetChanged() { + toCapitalizedController(addressStreetController); + _syncAddressField( + addressStreetController.text, + current: state.address.street, + updateAddress: () => + state.address.copyWith(street: addressStreetController.text), + ); + } + + void _onAddressCityChanged() { + toCapitalizedController(addressCityController); + _syncAddressField( + addressCityController.text, + current: state.address.city, + updateAddress: () => + state.address.copyWith(city: addressCityController.text), + ); + } + + void _onAddressProvinceChanged() { + toCapitalizedController(addressProvinceController); + _syncAddressField( + addressProvinceController.text, + current: state.address.province, + updateAddress: () => + state.address.copyWith(province: addressProvinceController.text), + ); + } + + void _onAddressStateChanged() { + toCapitalizedController(addressStateController); + _syncAddressField( + addressStateController.text, + current: state.address.state, + updateAddress: () => + state.address.copyWith(state: addressStateController.text), + ); + } + + void _onAddressCountryChanged() => _syncAddressField( + addressCountryController.text, + current: state.address.country, + updateAddress: () => + state.address.copyWith(country: addressCountryController.text), + ); + + void _onAddressPostCodeChanged() { + final text = addressPostCodeController.text.trim(); + final parsed = int.tryParse(text); + + if (text.isEmpty) { + if (state.address.postCode != null) { + state = state.copyWith( + address: state.address.copyWith(postCode: null), + errorMessage: '', + ); + } + return; + } + + if (parsed != null && parsed != state.address.postCode) { + state = state.copyWith( + address: state.address.copyWith(postCode: parsed), + errorMessage: '', + ); + } + } + + + void next() { if (state.isLoading) return; @@ -151,6 +386,8 @@ class LegacySignUpViewModel extends Notifier { ); } + + void updateDialCode(String dialCode) { state = state.copyWith(dialCode: dialCode); } @@ -165,7 +402,6 @@ class LegacySignUpViewModel extends Notifier { final now = DateTime.now(); final initial = state.bornAt ?? DateTime(now.year - 18, now.month, now.day); - final safeInitial = initial.isAfter(now) ? now : initial; final picked = await showDatePicker( @@ -175,12 +411,16 @@ class LegacySignUpViewModel extends Notifier { lastDate: now, ); - if (!ref.mounted) return; - if (picked == null) return; + if (!ref.mounted || picked == null) return; setBornAt(picked); } + void setBornAt(DateTime date) { + bornAtController.text = _formatDate(date); + state = state.copyWith(bornAt: date, errorMessage: ''); + } + void setDocumentType(String? value) { final v = value ?? ''; if (documentTypeController.text == v) return; @@ -209,199 +449,23 @@ class LegacySignUpViewModel extends Notifier { state = state.copyWith(isShowPassword: !state.isShowPassword); } - void _onFirstNameChanged() { - final text = firstNameController.text; - if (text == state.firstName) return; - state = state.copyWith(firstName: text, errorMessage: ''); - } - void _onLastNameChanged() { - final text = lastNameController.text; - if (text == state.lastName) return; - state = state.copyWith(lastName: text, errorMessage: ''); - } - - void _onDocumentNumberChanged() { - final text = documentNumberController.text; - if (text == state.document) return; - state = state.copyWith(document: text, errorMessage: ''); - } - - void _onDocumentTypeChanged() { - final text = documentTypeController.text; - if (text == state.documentType) return; - state = state.copyWith(documentType: text, errorMessage: ''); - } - - void _onRelationshipChanged() { - final text = relationshipController.text; - if (text == state.relationType) return; - state = state.copyWith(relationType: text, errorMessage: ''); - } - - void _onPhoneChanged() { - final text = phoneController.text; - if (text == state.phone) return; - - state = state.copyWith(phone: text); - - if (state.showErrors) { - state = state.copyWith(phoneError: _phoneErrorFor(text)); - } - } - - void _onEmailChanged() { - final text = emailController.text; - if (text == state.email) return; - - state = state.copyWith(email: text, errorMessage: ''); - - if (state.showErrors) { - state = state.copyWith(emailError: _emailErrorFor(text)); - } - } - - void _onPasswordChanged() { - final text = passwordController.text; - if (text == state.password) return; - - state = state.copyWith(password: text, errorMessage: ''); - - if (state.showErrors) { - state = state.copyWith( - passwordError: _passwordErrorFor( - password: state.password, - repeatPassword: state.repeatPassword, - ), - ); - } - } - - void _onRepeatPasswordChanged() { - final text = repeatPasswordController.text; - if (text == state.repeatPassword) return; - - state = state.copyWith(repeatPassword: text, errorMessage: ''); - - if (state.showErrors) { - state = state.copyWith( - passwordError: _passwordErrorFor( - password: state.password, - repeatPassword: state.repeatPassword, - ), - ); - } - } - - void _onBornAtTextChanged() { - final text = bornAtController.text; - final parsed = _tryParseDate(text); - - if (text.trim().isEmpty) { - if (state.bornAt != null) { - state = state.copyWith(bornAt: null, errorMessage: ''); - } - return; - } - - if (parsed != null && parsed != state.bornAt) { - state = state.copyWith(bornAt: parsed, errorMessage: ''); - } - } - - void _onPlaceOfBirthChanged() { - final text = placeOfBirthController.text; - if (text == state.placeOfBirth) return; - state = state.copyWith(placeOfBirth: text, errorMessage: ''); - } - - void _onBirthCountryChanged() { - final text = birthCountryController.text; - if (text == state.birthCountry) return; - state = state.copyWith(birthCountry: text, errorMessage: ''); - } - - void _onAddressStreetChanged() { - final text = addressStreetController.text; - if (text == state.address.street) return; - state = state.copyWith( - address: state.address.copyWith(street: text), - errorMessage: '', - ); - } - - void _onAddressCityChanged() { - final text = addressCityController.text; - if (text == state.address.city) return; - state = state.copyWith( - address: state.address.copyWith(city: text), - errorMessage: '', - ); - } - - void _onAddressProvinceChanged() { - final text = addressProvinceController.text; - if (text == state.address.province) return; - state = state.copyWith( - address: state.address.copyWith(province: text), - errorMessage: '', - ); - } - - void _onAddressStateChanged() { - final text = addressStateController.text; - if (text == state.address.state) return; - state = state.copyWith( - address: state.address.copyWith(state: text), - errorMessage: '', - ); - } - - void _onAddressCountryChanged() { - final text = addressCountryController.text; - if (text == state.address.country) return; - state = state.copyWith( - address: state.address.copyWith(country: text), - errorMessage: '', - ); - } - - void _onAddressPostCodeChanged() { - final text = addressPostCodeController.text.trim(); - final parsed = int.tryParse(text); - - if (text.isEmpty) { - if (state.address.postCode != null) { - state = state.copyWith( - address: state.address.copyWith(postCode: null), - errorMessage: '', - ); - } - return; - } - - if (parsed != null && parsed != state.address.postCode) { - state = state.copyWith( - address: state.address.copyWith(postCode: parsed), - errorMessage: '', - ); - } - } bool _validateStep0() { - final emailError = _emailErrorFor(state.email); - final phoneError = _phoneErrorFor(state.phone); + final emailErr = emailErrorFor(state.email); + final phoneErr = phoneErrorFor(state.phone); state = state.copyWith( showErrors: true, - emailError: emailError, - phoneError: phoneError, + emailError: emailErr, + phoneError: phoneErr, errorMessage: '', ); + if (state.firstName.trim().isEmpty) { state = state.copyWith(errorMessage: I18n.errorFirstNameRequired); return false; } - if (!_nameRegex.hasMatch(state.firstName.trim())) { + if (!isNameValid(state.firstName)) { state = state.copyWith(errorMessage: I18n.errorNameInvalidChars); return false; } @@ -409,7 +473,7 @@ class LegacySignUpViewModel extends Notifier { state = state.copyWith(errorMessage: I18n.errorLastNameRequired); return false; } - if (!_nameRegex.hasMatch(state.lastName.trim())) { + if (!isNameValid(state.lastName)) { state = state.copyWith(errorMessage: I18n.errorNameInvalidChars); return false; } @@ -421,12 +485,12 @@ class LegacySignUpViewModel extends Notifier { state = state.copyWith(errorMessage: I18n.errorDocumentNumberRequired); return false; } - if (phoneError.isNotEmpty) { - state = state.copyWith(errorMessage: phoneError); + if (phoneErr.isNotEmpty) { + state = state.copyWith(errorMessage: phoneErr); return false; } - if (emailError.isNotEmpty) { - state = state.copyWith(errorMessage: emailError); + if (emailErr.isNotEmpty) { + state = state.copyWith(errorMessage: emailErr); return false; } if (!state.acceptTerms) { @@ -437,11 +501,8 @@ class LegacySignUpViewModel extends Notifier { } bool _validateStep1() { - if (!state.showErrors) { - state = state.copyWith(showErrors: true, errorMessage: ''); - } else { - state = state.copyWith(errorMessage: ''); - } + state = state.copyWith(showErrors: true, errorMessage: ''); + if (state.bornAt == null) { state = state.copyWith(errorMessage: I18n.errorBirthDateRequired); return false; @@ -450,101 +511,77 @@ class LegacySignUpViewModel extends Notifier { state = state.copyWith(errorMessage: I18n.errorRelationshipRequired); return false; } - if (state.placeOfBirth.trim().isEmpty) { state = state.copyWith(errorMessage: I18n.errorPlaceOfBirthRequired); return false; } - if (state.birthCountry.trim().isEmpty) { state = state.copyWith(errorMessage: I18n.errorBirthCountryRequired); return false; } - - if (!_isAddressValid(state.address)) { + if (!isAddressValid(state.address)) { state = state.copyWith(errorMessage: I18n.errorAddressRequired); return false; } - return true; } bool _validateStep2() { - final passwordError = _passwordErrorFor( + final passwordErr = passwordErrorFor( password: state.password, repeatPassword: state.repeatPassword, ); state = state.copyWith( showErrors: true, - passwordError: passwordError, + passwordError: passwordErr, + errorMessage: passwordErr, + ); + + return passwordErr.isEmpty; + } + + bool _validateForm() => + _validateStep0() && _validateStep1() && _validateStep2(); + + + + Future signUp() async { + if (state.isLoading) return false; + if (!_validateForm()) return false; + + state = state.copyWith( + isLoading: true, errorMessage: '', + showAccountCreated: false, ); - if (passwordError.isNotEmpty) return false; + try { + final request = _toRequest(); + final response = await _repository.signUp(request: request); - return true; - } + if (!ref.mounted) return false; - bool _validateForm() { - return _validateStep0() && _validateStep1() && _validateStep2(); - } + state = state.copyWith( + isLoading: false, + isCreated: response.isCreated, + errorMessage: '', + showAccountCreated: true, + ); + return true; + } catch (e) { + if (!ref.mounted) return false; - bool _isValidEmail(String email) => _emailRegex.hasMatch(email); + final msg = formatErrorMessage(e); + final errorMsg = + msg == 'BadRequest' ? I18n.errorEmailAlreadyRegistered : msg; - String _emailErrorFor(String value) { - final email = value.trim(); - if (email.isEmpty) return I18n.errorEmailRequired; - if (email.contains('+')) return I18n.errorEmailPlusNotAllowed; - if (!_isValidEmail(email)) return I18n.errorEmailInvalid; - return ''; - } - - String _passwordErrorFor({ - required String password, - required String repeatPassword, - }) { - final p = password.trim(); - final rp = repeatPassword.trim(); - - if (p.isEmpty) return I18n.errorPasswordRequired; - if (p.length < 6) return I18n.errorPasswordMinLength; - - if (rp.isEmpty) return 'Repite la contraseña'; - if (p != rp) return 'Las contraseñas no coinciden'; - - return ''; - } - - String _phoneErrorFor(String value) { - final phone = value.trim(); - if (phone.isEmpty) return 'El teléfono es obligatorio'; - if (!_phoneRegex.hasMatch(phone)) { - return 'El teléfono no tiene un formato válido'; + state = state.copyWith( + isLoading: false, + errorMessage: errorMsg, + ); + return false; } - return ''; - } - - bool _isAddressValid(LegacyAddressViewState a) { - return a.street.trim().isNotEmpty && - a.city.trim().isNotEmpty && - a.province.trim().isNotEmpty && - a.state.trim().isNotEmpty && - a.country.trim().isNotEmpty && - a.postCode != null; - } - - LegacyAddressEntity _toLegacyAddressEntity(LegacyAddressViewState a) { - final country = WorldCountry.fromCodeShort(a.countryCode.toUpperCase()); - - return LegacyAddressEntity( - street: a.street.trim(), - city: a.city.trim(), - province: a.province.trim(), - state: a.state.trim(), - country: country.name.common, - postCode: a.postCode ?? 0, - ); } LegacySignUpRequestEntity _toRequest() { @@ -555,8 +592,8 @@ class LegacySignUpViewModel extends Notifier { documentType: state.documentType.trim(), document: state.document.trim(), relationType: state.relationType.trim(), - firstName: state.firstName.trim(), - lastName: state.lastName.trim(), + firstName: state.firstName.trim().toUpperCase(), + lastName: state.lastName.trim().toUpperCase(), email: state.email.trim(), phone: state.dialCode.trim() + state.phone.trim(), language: state.language.trim().isEmpty ? 'es' : state.language.trim(), @@ -566,60 +603,25 @@ class LegacySignUpViewModel extends Notifier { bornAt.month, bornAt.day, ).millisecondsSinceEpoch, - placeOfBirth: state.placeOfBirth.trim(), + placeOfBirth: state.placeOfBirth.trim().toUpperCase(), birthCountry: state.birthCountryCode.trim(), addresses: [_toLegacyAddressEntity(state.address)], - taxResidences: [_toLegacyAddressEntity(state.address)], + taxResidences: [ + _toLegacyAddressEntity(state.address), + ], ); } - Future signUp() async { - if (state.isLoading) return false; - if (!_validateForm()) return false; + LegacyAddressEntity _toLegacyAddressEntity(LegacyAddressViewState a) { + final country = WorldCountry.fromCodeShort(a.countryCode.toUpperCase()); - _startLoadingForSignUp(); - - try { - final request = _toRequest(); - - final response = await _signUp(request); - if (!ref.mounted) return false; - - _finishWithSuccess(isCreated: response.isCreated); - return true; - } catch (e) { - if (!ref.mounted) return false; - _finishWithError(message: e.toString()); - return false; - } - } - - void _startLoadingForSignUp() { - state = state.copyWith( - isLoading: true, - errorMessage: '', - showAccountCreated: false, - ); - } - - Future _signUp(LegacySignUpRequestEntity request) { - return _signUpUseCase.signUp(request: request); - } - - void _finishWithSuccess({required bool isCreated}) { - state = state.copyWith( - isLoading: false, - isCreated: isCreated, - errorMessage: '', - showAccountCreated: true, - ); - } - - void _finishWithError({bool? isCreated, required String message}) { - state = state.copyWith( - isLoading: false, - isCreated: isCreated ?? state.isCreated, - errorMessage: message, + return LegacyAddressEntity( + street: a.street.trim().toUpperCase(), + city: a.city.trim().toUpperCase(), + province: a.province.trim().toUpperCase(), + state: a.state.trim().toUpperCase(), + country: country.name.common.toUpperCase(), + postCode: a.postCode ?? 0, ); } @@ -649,12 +651,7 @@ class LegacySignUpViewModel extends Notifier { return '$dd/$mm/$yyyy'; } - void setBornAt(DateTime date) { - bornAtController.text = _formatDate(date); - state = state.copyWith(bornAt: date, errorMessage: ''); - } - - void disposeControllers() { + void _disposeControllers() { firstNameController.removeListener(_onFirstNameChanged); lastNameController.removeListener(_onLastNameChanged); documentNumberController.removeListener(_onDocumentNumberChanged); diff --git a/modules/legacy/modules/legacy_auth/lib/src/widgets/layouts/sign_up_layout.dart b/modules/legacy/modules/legacy_auth/lib/src/widgets/layouts/sign_up_layout.dart index 41523c10..69809f91 100644 --- a/modules/legacy/modules/legacy_auth/lib/src/widgets/layouts/sign_up_layout.dart +++ b/modules/legacy/modules/legacy_auth/lib/src/widgets/layouts/sign_up_layout.dart @@ -13,6 +13,7 @@ class LegacySignUpLayout extends StatelessWidget { final VoidCallback onBackPressed; final VoidCallback onNextPressed; + final bool isLoading; const LegacySignUpLayout({ super.key, @@ -25,10 +26,24 @@ class LegacySignUpLayout extends StatelessWidget { required this.body, required this.onBackPressed, required this.onNextPressed, + this.isLoading = false, }); @override Widget build(BuildContext context) { + return Stack( + children: [ + _buildScaffold(context), + if (isLoading) + const ColoredBox( + color: Colors.black26, + child: Center(child: AppLoadingIndicator()), + ), + ], + ); + } + + Widget _buildScaffold(BuildContext context) { return Scaffold( backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary), body: SafeArea( diff --git a/modules/legacy/modules/legacy_auth/pubspec.yaml b/modules/legacy/modules/legacy_auth/pubspec.yaml index 50105912..85827a74 100644 --- a/modules/legacy/modules/legacy_auth/pubspec.yaml +++ b/modules/legacy/modules/legacy_auth/pubspec.yaml @@ -27,8 +27,6 @@ dependencies: path: ../../../../packages/utils sf_shared: path: ../../../../packages/sf_shared - payments: - path: ../../../../packages/payments fonts: path: ../../../../packages/fonts #dependencies go here diff --git a/modules/legacy/modules/location/lib/location.dart b/modules/legacy/modules/location/lib/location.dart new file mode 100644 index 00000000..c7e3f3de --- /dev/null +++ b/modules/legacy/modules/location/lib/location.dart @@ -0,0 +1 @@ +export 'src/features/location/location_builder.dart'; diff --git a/modules/legacy/modules/location/lib/src/features/location/location_builder.dart b/modules/legacy/modules/location/lib/src/features/location/location_builder.dart new file mode 100644 index 00000000..09e7bdb6 --- /dev/null +++ b/modules/legacy/modules/location/lib/src/features/location/location_builder.dart @@ -0,0 +1,14 @@ +import 'package:location/src/features/location/presentation/location_screen.dart'; +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; + +class LocationBuilder { + const LocationBuilder(); + + Page buildPage(BuildContext context, GoRouterState state) { + return MaterialPage( + key: state.pageKey, + child: const LocationScreen(), + ); + } +} diff --git a/modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart b/modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart new file mode 100644 index 00000000..9268529b --- /dev/null +++ b/modules/legacy/modules/location/lib/src/features/location/presentation/location_screen.dart @@ -0,0 +1,54 @@ +import 'package:control_panel/control_panel.dart'; +import 'package:design_system/design_system.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:sf_localizations/sf_localizations.dart'; +import 'package:utils/utils.dart'; + +class LocationScreen extends ConsumerWidget { + const LocationScreen({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final theme = ref.watch(themePortProvider); + final state = ref.watch(controlPanelViewModelProvider); + + if (state.isLoading) { + return Scaffold( + backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary), + body: const Center(child: CircularProgressIndicator()), + ); + } + + return Scaffold( + backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary), + body: SafeArea( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 14, + vertical: SizeUtils.getByScreen(small: 12, big: 14), + ), + child: Text( + context.translate(I18n.watchesOnMap), + style: TextStyle( + fontSize: SizeUtils.getByScreen(small: 20, big: 19), + fontWeight: FontWeight.bold, + color: theme.getColorFor(ThemeCode.legacyPrimary), + ), + ), + ), + Expanded( + child: DeviceMap( + selectedPosition: state.selectedPosition, + selectedDevice: state.selectedDevice, + ), + ), + ], + ), + ), + ); + } +} diff --git a/modules/legacy/modules/location/melos_location.iml b/modules/legacy/modules/location/melos_location.iml new file mode 100644 index 00000000..9fc8ce79 --- /dev/null +++ b/modules/legacy/modules/location/melos_location.iml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/legacy/modules/location/pubspec.lock b/modules/legacy/modules/location/pubspec.lock new file mode 100644 index 00000000..11cf6875 --- /dev/null +++ b/modules/legacy/modules/location/pubspec.lock @@ -0,0 +1,1407 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: da0d9209ca76bde579f2da330aeb9df62b6319c834fa7baae052021b0462401f + url: "https://pub.dev" + source: hosted + version: "85.0.0" + activity: + dependency: "direct overridden" + description: + path: "../../../activity" + relative: true + source: path + version: "0.0.1" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "974859dc0ff5f37bc4313244b3218c791810d03ab3470a579580279ba971a48d" + url: "https://pub.dev" + source: hosted + version: "7.7.1" + archive: + dependency: transitive + description: + name: archive + sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff + url: "https://pub.dev" + source: hosted + version: "4.0.9" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + auth: + dependency: "direct overridden" + description: + path: "../../../auth" + relative: true + source: path + version: "0.0.1" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + build: + dependency: transitive + description: + name: build + sha256: ce76b1d48875e3233fde17717c23d1f60a91cc631597e49a400c89b475395b1d + url: "https://pub.dev" + source: hosted + version: "3.1.0" + build_config: + dependency: transitive + description: + name: build_config + sha256: "4f64382b97504dc2fcdf487d5aae33418e08b4703fc21249e4db6d804a4d0187" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: bf05f6e12cfea92d3c09308d7bcdab1906cd8a179b023269eed00c071004b957 + url: "https://pub.dev" + source: hosted + version: "4.1.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: d1d57f7807debd7349b4726a19fd32ec8bc177c71ad0febf91a20f84cd2d4b46 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + build_runner: + dependency: transitive + description: + name: build_runner + sha256: b24597fceb695969d47025c958f3837f9f0122e237c6a22cb082a5ac66c3ca30 + url: "https://pub.dev" + source: hosted + version: "2.7.1" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "066dda7f73d8eb48ba630a55acb50c4a84a2e6b453b1cb4567f581729e794f7b" + url: "https://pub.dev" + source: hosted + version: "9.3.1" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: "6ae8a6435a8c6520c7077b107e77f1fb4ba7009633259a4d49a8afd8e7efc5e9" + url: "https://pub.dev" + source: hosted + version: "8.12.4" + characters: + dependency: transitive + description: + name: characters + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f" + url: "https://pub.dev" + source: hosted + version: "2.0.4" + cli_config: + dependency: transitive + description: + name: cli_config + sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec + url: "https://pub.dev" + source: hosted + version: "0.2.0" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "6a6cab2ba4680d6423f34a9b972a4c9a94ebe1b62ecec4e1a1f2cba91fd1319d" + url: "https://pub.dev" + source: hosted + version: "4.11.1" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + confetti: + dependency: transitive + description: + name: confetti + sha256: "979aafde2428c53947892c95eb244466c109c129b7eee9011f0a66caaca52267" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + control_panel: + dependency: "direct main" + description: + path: "../control_panel" + relative: true + source: path + version: "1.0.0+1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + cookie_jar: + dependency: transitive + description: + name: cookie_jar + sha256: "963da02c1ef64cb5ac20de948c9e5940aa351f1e34a12b1d327c83d85b7e8fff" + url: "https://pub.dev" + source: hosted + version: "4.0.9" + country_code_picker: + dependency: transitive + description: + name: country_code_picker + sha256: f0411f4833b6f98e8b7215f4fa3813bcc88e50f13925f70a170dbd36e3e447f5 + url: "https://pub.dev" + source: hosted + version: "3.4.1" + coverage: + dependency: transitive + description: + name: coverage + sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d" + url: "https://pub.dev" + source: hosted + version: "1.15.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: transitive + description: + name: cupertino_icons + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + url: "https://pub.dev" + source: hosted + version: "1.0.8" + dart_earcut: + dependency: transitive + description: + name: dart_earcut + sha256: e485001bfc05dcbc437d7bfb666316182e3522d4c3f9668048e004d0eb2ce43b + url: "https://pub.dev" + source: hosted + version: "1.2.0" + dart_polylabel2: + dependency: transitive + description: + name: dart_polylabel2 + sha256: "7eeab15ce72894e4bdba6a8765712231fc81be0bd95247de4ad9966abc57adc6" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + dashboard_shell: + dependency: "direct overridden" + description: + path: "../../../dashboard_shell" + relative: true + source: path + version: "0.0.1" + design_system: + dependency: "direct main" + description: + path: "../../../../packages/design_system" + relative: true + source: path + version: "0.0.1" + diacritic: + dependency: transitive + description: + name: diacritic + sha256: "12981945ec38931748836cd76f2b38773118d0baef3c68404bdfde9566147876" + url: "https://pub.dev" + source: hosted + version: "0.1.6" + dio: + dependency: transitive + description: + name: dio + sha256: aff32c08f92787a557dd5c0145ac91536481831a01b4648136373cddb0e64f8c + url: "https://pub.dev" + source: hosted + version: "5.9.2" + dio_cookie_manager: + dependency: transitive + description: + name: dio_cookie_manager + sha256: "0db1a7b997a0455e488ac35744c68eed3f2a4280d3ab531835a65641b0a08744" + url: "https://pub.dev" + source: hosted + version: "3.4.0" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "2f9e64323a7c3c7ef69567d5c800424a11f8337b8b228bad02524c9fb3c1f340" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + equatable: + dependency: transitive + description: + name: equatable + sha256: "3e0141505477fd8ad55d6eb4e7776d3fe8430be8e497ccb1521370c3f21a3e2b" + url: "https://pub.dev" + source: hosted + version: "2.0.8" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + fl_chart: + dependency: transitive + description: + name: fl_chart + sha256: "7ca9a40f4eb85949190e54087be8b4d6ac09dc4c54238d782a34cf1f7c011de9" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_map: + dependency: transitive + description: + name: flutter_map + sha256: "391e7dc95cc3f5190748210a69d4cfeb5d8f84dcdfa9c3235d0a9d7742ccb3f8" + url: "https://pub.dev" + source: hosted + version: "8.2.2" + flutter_riverpod: + dependency: "direct main" + description: + name: flutter_riverpod + sha256: e2026c72738a925a60db30258ff1f29974e40716749f3c9850aabf34ffc1a14c + url: "https://pub.dev" + source: hosted + version: "3.2.1" + flutter_svg: + dependency: transitive + description: + name: flutter_svg + sha256: "1ded017b39c8e15c8948ea855070a5ff8ff8b3d5e83f3446e02d6bb12add7ad9" + url: "https://pub.dev" + source: hosted + version: "2.2.4" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_treezor_entrust_sdk_bridge: + dependency: "direct overridden" + description: + path: "../../../../packages/flutter_treezor_entrust_sdk_bridge" + relative: true + source: path + version: "1.0.2" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + fonts: + dependency: "direct overridden" + description: + path: "../../../../packages/fonts" + relative: true + source: path + version: "0.0.1" + freezed: + dependency: transitive + description: + name: freezed + sha256: "13065f10e135263a4f5a4391b79a8efc5fb8106f8dd555a9e49b750b45393d77" + url: "https://pub.dev" + source: hosted + version: "3.2.3" + freezed_annotation: + dependency: transitive + description: + name: freezed_annotation + sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + get_it: + dependency: transitive + description: + name: get_it + sha256: "568d62f0e68666fb5d95519743b3c24a34c7f19d834b0658c46e26d778461f66" + url: "https://pub.dev" + source: hosted + version: "9.2.1" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: "7974313e217a7771557add6ff2238acb63f635317c35fa590d348fb238f00896" + url: "https://pub.dev" + source: hosted + version: "17.1.0" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + home: + dependency: "direct overridden" + description: + path: "../../../home" + relative: true + source: path + version: "0.0.1" + http: + dependency: transitive + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + intl: + dependency: transitive + description: + name: intl + sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5" + url: "https://pub.dev" + source: hosted + version: "0.20.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + json_serializable: + dependency: transitive + description: + name: json_serializable + sha256: c5b2ee75210a0f263c6c7b9eeea80553dbae96ea1bf57f02484e806a3ffdffa3 + url: "https://pub.dev" + source: hosted + version: "6.11.2" + l10n_countries: + dependency: transitive + description: + name: l10n_countries + sha256: dfeb4d4925f71d61d2c495a0f0e1430fe66ce664cf87533dd10dc445cab0ff02 + url: "https://pub.dev" + source: hosted + version: "1.3.1" + l10n_currencies: + dependency: transitive + description: + name: l10n_currencies + sha256: "7a64e1e2ae7e8aae00cca3d079f7bef333f255bff98976ddf765121e2e5eb87e" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + l10n_languages: + dependency: transitive + description: + name: l10n_languages + sha256: "808f25db80df1697f9e8f05cdc9f2dad11a21ea6473f14f7bb65bef7082b27d3" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + latlong2: + dependency: transitive + description: + name: latlong2 + sha256: "98227922caf49e6056f91b6c56945ea1c7b166f28ffcd5fb8e72fc0b453cc8fe" + url: "https://pub.dev" + source: hosted + version: "0.9.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + legacy_dashboard_shell: + dependency: "direct overridden" + description: + path: "../legacy_dashboard_shell" + relative: true + source: path + version: "0.0.1" + legacy_shared: + dependency: "direct overridden" + description: + path: "../../packages/legacy_shared" + relative: true + source: path + version: "0.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.dev" + source: hosted + version: "5.1.1" + lists: + dependency: transitive + description: + name: lists + sha256: "4ca5c19ae4350de036a7e996cdd1ee39c93ac0a2b840f4915459b7d0a7d4ab27" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + logger: + dependency: transitive + description: + name: logger + sha256: a7967e31b703831a893bbc3c3dd11db08126fe5f369b5c648a36f821979f5be3 + url: "https://pub.dev" + source: hosted + version: "2.6.2" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + lottie: + dependency: transitive + description: + name: lottie + sha256: "8ae0be46dbd9e19641791dc12ee480d34e1fd3f84c749adc05f3ad9342b71b95" + url: "https://pub.dev" + source: hosted + version: "3.3.2" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" + meta: + dependency: transitive + description: + name: meta + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + url: "https://pub.dev" + source: hosted + version: "1.16.0" + mgrs_dart: + dependency: transitive + description: + name: mgrs_dart + sha256: fb89ae62f05fa0bb90f70c31fc870bcbcfd516c843fb554452ab3396f78586f7 + url: "https://pub.dev" + source: hosted + version: "2.0.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + mobile_scanner: + dependency: transitive + description: + name: mobile_scanner + sha256: c92c26bf2231695b6d3477c8dcf435f51e28f87b1745966b1fe4c47a286171ce + url: "https://pub.dev" + source: hosted + version: "7.2.0" + navigation: + dependency: "direct overridden" + description: + path: "../../../../packages/navigation" + relative: true + source: path + version: "0.0.1" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + notifications: + dependency: "direct overridden" + description: + path: "../../../notifications" + relative: true + source: path + version: "0.0.1" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_parsing: + dependency: transitive + description: + name: path_parsing + sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + path_provider: + dependency: transitive + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e + url: "https://pub.dev" + source: hosted + version: "2.2.22" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4" + url: "https://pub.dev" + source: hosted + version: "2.5.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + payments: + dependency: "direct overridden" + description: + path: "../../../../packages/payments" + relative: true + source: path + version: "0.0.1" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" + url: "https://pub.dev" + source: hosted + version: "7.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pool: + dependency: transitive + description: + name: pool + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + url: "https://pub.dev" + source: hosted + version: "1.5.2" + posix: + dependency: transitive + description: + name: posix + sha256: "185ef7606574f789b40f289c233efa52e96dead518aed988e040a10737febb07" + url: "https://pub.dev" + source: hosted + version: "6.5.0" + profile: + dependency: "direct overridden" + description: + path: "../../../profile" + relative: true + source: path + version: "0.0.1" + proj4dart: + dependency: transitive + description: + name: proj4dart + sha256: c8a659ac9b6864aa47c171e78d41bbe6f5e1d7bd790a5814249e6b68bc44324e + url: "https://pub.dev" + source: hosted + version: "2.1.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + riverpod: + dependency: transitive + description: + name: riverpod + sha256: "8c22216be8ad3ef2b44af3a329693558c98eca7b8bd4ef495c92db0bba279f83" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + sca_treezor: + dependency: "direct overridden" + description: + path: "../../../../packages/sca_treezor" + relative: true + source: path + version: "0.0.1" + sealed_countries: + dependency: transitive + description: + name: sealed_countries + sha256: bfb57edd964ca553da380ef181f665307b2847db418144b5d896a03e1adb06cc + url: "https://pub.dev" + source: hosted + version: "2.8.0" + sealed_currencies: + dependency: transitive + description: + name: sealed_currencies + sha256: "5885c77381cca83348529afd25d2ae7c0da295e972a6310c1acd1a8ae0033734" + url: "https://pub.dev" + source: hosted + version: "2.5.0" + sealed_languages: + dependency: transitive + description: + name: sealed_languages + sha256: "488a2bc6ccf01bbc0182b8c3203af9cc1a85dc1c6aa3d39792539643d11d199c" + url: "https://pub.dev" + source: hosted + version: "2.5.0" + sf_infrastructure: + dependency: "direct overridden" + description: + path: "../../../../packages/sf_infrastructure" + relative: true + source: path + version: "0.0.1" + sf_localizations: + dependency: "direct main" + description: + path: "../../../../packages/sf_localizations" + relative: true + source: path + version: "0.0.1" + sf_shared: + dependency: "direct overridden" + description: + path: "../../../../packages/sf_shared" + relative: true + source: path + version: "0.0.1" + shared_preferences: + dependency: transitive + description: + name: shared_preferences + sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64" + url: "https://pub.dev" + source: hosted + version: "2.5.4" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: "8374d6200ab33ac99031a852eba4c8eb2170c4bf20778b3e2c9eccb45384fb41" + url: "https://pub.dev" + source: hosted + version: "2.4.21" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "800f12fb87434defa13432ab37e33051b43b290a174e15259563b043cda40c46" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723" + url: "https://pub.dev" + source: hosted + version: "1.3.8" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812" + url: "https://pub.dev" + source: hosted + version: "0.10.13" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.dev" + source: hosted + version: "1.10.2" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + state_notifier: + dependency: transitive + description: + name: state_notifier + sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb + url: "https://pub.dev" + source: hosted + version: "1.0.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test: + dependency: transitive + description: + name: test + sha256: "65e29d831719be0591f7b3b1a32a3cda258ec98c58c7b25f7b84241bc31215bb" + url: "https://pub.dev" + source: hosted + version: "1.26.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" + url: "https://pub.dev" + source: hosted + version: "0.7.6" + test_core: + dependency: transitive + description: + name: test_core + sha256: "80bf5a02b60af04b09e14f6fe68b921aad119493e26e490deaca5993fef1b05a" + url: "https://pub.dev" + source: hosted + version: "0.6.11" + timing: + dependency: transitive + description: + name: timing + sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + top_snackbar_flutter: + dependency: transitive + description: + name: top_snackbar_flutter + sha256: ad3f93062450e8c7db97b271d405c180536408cc2be4380a59da7022eb1d750c + url: "https://pub.dev" + source: hosted + version: "3.3.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + unicode: + dependency: transitive + description: + name: unicode + sha256: "0f69e46593d65245774d4f17125c6084d2c20b4e473a983f6e21b7d7762218f1" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: f63cbc48103236abf48e345e07a03ce5757ea86285ed313a6a032596ed9301e2 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8 + url: "https://pub.dev" + source: hosted + version: "6.3.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611" + url: "https://pub.dev" + source: hosted + version: "6.3.28" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: cfde38aa257dae62ffe79c87fab20165dfdf6988c1d31b58ebf59b9106062aad + url: "https://pub.dev" + source: hosted + version: "6.3.6" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a + url: "https://pub.dev" + source: hosted + version: "3.2.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18" + url: "https://pub.dev" + source: hosted + version: "3.2.5" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f" + url: "https://pub.dev" + source: hosted + version: "3.1.5" + utils: + dependency: "direct main" + description: + path: "../../../../packages/utils" + relative: true + source: path + version: "0.0.1" + uuid: + dependency: transitive + description: + name: uuid + sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489" + url: "https://pub.dev" + source: hosted + version: "4.5.3" + vector_graphics: + dependency: transitive + description: + name: vector_graphics + sha256: a4f059dc26fc8295b5921376600a194c4ec7d55e72f2fe4c7d2831e103d461e6 + url: "https://pub.dev" + source: hosted + version: "1.1.19" + vector_graphics_codec: + dependency: transitive + description: + name: vector_graphics_codec + sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146" + url: "https://pub.dev" + source: hosted + version: "1.1.13" + vector_graphics_compiler: + dependency: transitive + description: + name: vector_graphics_compiler + sha256: "5a88dd14c0954a5398af544651c7fb51b457a2a556949bfb25369b210ef73a74" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + watcher: + dependency: transitive + description: + name: watcher + sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + webview_flutter: + dependency: transitive + description: + name: webview_flutter + sha256: a3da219916aba44947d3a5478b1927876a09781174b5a2b67fa5be0555154bf9 + url: "https://pub.dev" + source: hosted + version: "4.13.1" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + sha256: "2a03df01df2fd30b075d1e7f24c28aee593f2e5d5ac4c3c4283c5eda63717b24" + url: "https://pub.dev" + source: hosted + version: "4.10.13" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: "63d26ee3aca7256a83ccb576a50272edd7cfc80573a4305caa98985feb493ee0" + url: "https://pub.dev" + source: hosted + version: "2.14.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + sha256: fc0af89d403e1c053f03d023d97550412fa79f35332e2939514c82e6fe633198 + url: "https://pub.dev" + source: hosted + version: "3.23.8" + wkt_parser: + dependency: transitive + description: + name: wkt_parser + sha256: "8a555fc60de3116c00aad67891bcab20f81a958e4219cc106e3c037aa3937f13" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025" + url: "https://pub.dev" + source: hosted + version: "6.6.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.9.2 <4.0.0" + flutter: ">=3.35.0" diff --git a/modules/legacy/modules/location/pubspec.yaml b/modules/legacy/modules/location/pubspec.yaml new file mode 100644 index 00000000..767f1703 --- /dev/null +++ b/modules/legacy/modules/location/pubspec.yaml @@ -0,0 +1,30 @@ +name: location +description: "Location map module for legacy dashboard" +publish_to: 'none' +version: 1.0.0+1 + +environment: + sdk: ^3.9.2 + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + control_panel: + path: ../control_panel + design_system: + path: ../../../../packages/design_system + sf_localizations: + path: ../../../../packages/sf_localizations + utils: + path: ../../../../packages/utils + flutter_riverpod: ^3.0.3 + go_router: ^17.0.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^5.0.0 + +flutter: + uses-material-design: true diff --git a/modules/legacy/modules/location/pubspec_overrides.yaml b/modules/legacy/modules/location/pubspec_overrides.yaml new file mode 100644 index 00000000..9798666b --- /dev/null +++ b/modules/legacy/modules/location/pubspec_overrides.yaml @@ -0,0 +1,40 @@ +# melos_managed_dependency_overrides: activity,auth,control_panel,dashboard_shell,design_system,flutter_treezor_entrust_sdk_bridge,fonts,home,legacy_dashboard_shell,legacy_shared,navigation,notifications,payments,profile,sca_treezor,sf_infrastructure,sf_localizations,sf_shared,utils +dependency_overrides: + activity: + path: ../../../activity + auth: + path: ../../../auth + control_panel: + path: ../control_panel + dashboard_shell: + path: ../../../dashboard_shell + design_system: + path: ../../../../packages/design_system + flutter_treezor_entrust_sdk_bridge: + path: ../../../../packages/flutter_treezor_entrust_sdk_bridge + fonts: + path: ../../../../packages/fonts + home: + path: ../../../home + legacy_dashboard_shell: + path: ../legacy_dashboard_shell + legacy_shared: + path: ../../packages/legacy_shared + navigation: + path: ../../../../packages/navigation + notifications: + path: ../../../notifications + payments: + path: ../../../../packages/payments + profile: + path: ../../../profile + sca_treezor: + path: ../../../../packages/sca_treezor + sf_infrastructure: + path: ../../../../packages/sf_infrastructure + sf_localizations: + path: ../../../../packages/sf_localizations + sf_shared: + path: ../../../../packages/sf_shared + utils: + path: ../../../../packages/utils diff --git a/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource.dart b/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource.dart index f760be5d..c8492eab 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource.dart @@ -1,5 +1,5 @@ import 'package:legacy_shared/src/data/models/entities/user_entity.dart'; abstract class LegacySharedRemoteDatasource { - Future getLoggedUser({required String token}); + Future getLoggedUser(); } diff --git a/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource_impl.dart b/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource_impl.dart index 112dcc87..5f3c0bd9 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource_impl.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/data/datasource/legacy_shared_remote_datasource_impl.dart @@ -1,5 +1,3 @@ -import 'dart:convert'; - import 'package:dio/dio.dart'; import 'package:legacy_shared/src/data/datasource/legacy_shared_remote_datasource.dart'; import 'package:legacy_shared/src/data/models/entities/user_entity.dart'; @@ -12,64 +10,20 @@ class LegacySharedRemoteDatasourceImpl implements LegacySharedRemoteDatasource { final QuestiaRepository _repository; @override - Future getLoggedUser({required String token}) async { + Future getLoggedUser() async { try { - /*final response = await _repository.get>( - '/users/api/auth/me', + final response = await _repository.get>( + '/auth/me', ); - final data = response.data!['item']; + final data = response.data; if (data == null || data.isEmpty) { throw Exception('Empty response from /auth/me'); } - final model = GetLoggedUserResponseModel.fromJson(data);*/ - final model = GetLoggedUserResponseModel(item: - GetLoggedUserItemResponseModel( - id: '1111', - firstName: 'Juan', - email: 'juan@test.com', - phone: '111111111')); + final model = GetLoggedUserResponseModel.fromJson(data); return model.toEntity(); - } on DioException catch (error) { - throw _mapDioError( - error, - defaultMessage: error.message ?? 'Error getting logged user', - ); + } on DioException { + rethrow; } } } - -Exception _mapDioError(DioException error, {required String defaultMessage}) { - final apiMsg = _extractApiMessage(error.response?.data); - final msg = apiMsg ?? error.message ?? defaultMessage; - return Exception(msg); -} - -String? _extractApiMessage(Object? data) { - if (data == null) return null; - - if (data is Map) { - final errorObj = data['error']; - if (errorObj is Map && errorObj['message'] is String) { - return (errorObj['message'] as String).trim(); - } - if (data['message'] is String) { - return (data['message'] as String).trim(); - } - return null; - } - - if (data is String) { - final raw = data.trim(); - if (raw.isEmpty) return null; - - try { - final decoded = jsonDecode(raw); - return _extractApiMessage(decoded); - } catch (_) { - return raw; - } - } - - return null; -} diff --git a/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.dart b/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.dart index 02bd7f91..18e70c3e 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.dart @@ -20,19 +20,18 @@ abstract class GetLoggedUserItemResponseModel with _$GetLoggedUserItemResponseMo required String id, String? delegationId, String? email, - String? createdAt, - String? updatedAt, + dynamic createdAt, + dynamic updatedAt, String? status, String? role, - String? lastLogin, - String? currentLogin, + dynamic lastLogin, + dynamic currentLogin, String? language, String? firstName, String? lastName, - String? hasApiKey, + dynamic hasApiKey, String? phone, - }) = - _GetLoggedUserItemResponseModel; + }) = _GetLoggedUserItemResponseModel; factory GetLoggedUserItemResponseModel.fromJson(Map json) => _$GetLoggedUserItemResponseModelFromJson(json); @@ -44,16 +43,16 @@ extension GetLoggedUserResponseModelMapper on GetLoggedUserResponseModel { id: item.id, delegationId: item.delegationId ?? '', email: item.email ?? '', - createdAt: item.createdAt ?? '', - updatedAt: item.updatedAt ?? '', + createdAt: item.createdAt?.toString() ?? '', + updatedAt: item.updatedAt?.toString() ?? '', status: item.status ?? '', role: item.role ?? '', - lastLogin: item.lastLogin ?? '', - currentLogin: item.currentLogin ?? '', + lastLogin: item.lastLogin?.toString() ?? '', + currentLogin: item.currentLogin?.toString() ?? '', language: item.language ?? '', firstName: item.firstName ?? '', lastName: item.lastName ?? '', - hasApiKey: item.hasApiKey ?? '', + hasApiKey: item.hasApiKey?.toString() ?? '', phone: item.phone ?? '' ); } diff --git a/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.freezed.dart b/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.freezed.dart index 15722cae..32686e5e 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.freezed.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.freezed.dart @@ -296,7 +296,7 @@ $GetLoggedUserItemResponseModelCopyWith<$Res> get item { /// @nodoc mixin _$GetLoggedUserItemResponseModel { - String get id; String? get delegationId; String? get email; String? get createdAt; String? get updatedAt; String? get status; String? get role; String? get lastLogin; String? get currentLogin; String? get language; String? get firstName; String? get lastName; String? get hasApiKey; String? get phone; + String get id; String? get delegationId; String? get email; dynamic get createdAt; dynamic get updatedAt; String? get status; String? get role; dynamic get lastLogin; dynamic get currentLogin; String? get language; String? get firstName; String? get lastName; dynamic get hasApiKey; String? get phone; /// Create a copy of GetLoggedUserItemResponseModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -309,12 +309,12 @@ $GetLoggedUserItemResponseModelCopyWith get copy @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLoggedUserItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is GetLoggedUserItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&const DeepCollectionEquality().equals(other.createdAt, createdAt)&&const DeepCollectionEquality().equals(other.updatedAt, updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&const DeepCollectionEquality().equals(other.lastLogin, lastLogin)&&const DeepCollectionEquality().equals(other.currentLogin, currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&const DeepCollectionEquality().equals(other.hasApiKey, hasApiKey)&&(identical(other.phone, phone) || other.phone == phone)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone); +int get hashCode => Object.hash(runtimeType,id,delegationId,email,const DeepCollectionEquality().hash(createdAt),const DeepCollectionEquality().hash(updatedAt),status,role,const DeepCollectionEquality().hash(lastLogin),const DeepCollectionEquality().hash(currentLogin),language,firstName,lastName,const DeepCollectionEquality().hash(hasApiKey),phone); @override String toString() { @@ -329,7 +329,7 @@ abstract mixin class $GetLoggedUserItemResponseModelCopyWith<$Res> { factory $GetLoggedUserItemResponseModelCopyWith(GetLoggedUserItemResponseModel value, $Res Function(GetLoggedUserItemResponseModel) _then) = _$GetLoggedUserItemResponseModelCopyWithImpl; @useResult $Res call({ - String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone + String id, String? delegationId, String? email, dynamic createdAt, dynamic updatedAt, String? status, String? role, dynamic lastLogin, dynamic currentLogin, String? language, String? firstName, String? lastName, dynamic hasApiKey, String? phone }); @@ -352,16 +352,16 @@ id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as dynamic,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as dynamic,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable -as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable -as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable +as dynamic,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable +as dynamic,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable -as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as dynamic,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable as String?, )); } @@ -447,7 +447,7 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String? delegationId, String? email, dynamic createdAt, dynamic updatedAt, String? status, String? role, dynamic lastLogin, dynamic currentLogin, String? language, String? firstName, String? lastName, dynamic hasApiKey, String? phone)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _GetLoggedUserItemResponseModel() when $default != null: return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _: @@ -468,7 +468,7 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String id, String? delegationId, String? email, dynamic createdAt, dynamic updatedAt, String? status, String? role, dynamic lastLogin, dynamic currentLogin, String? language, String? firstName, String? lastName, dynamic hasApiKey, String? phone) $default,) {final _that = this; switch (_that) { case _GetLoggedUserItemResponseModel(): return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _: @@ -488,7 +488,7 @@ return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.up /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String? delegationId, String? email, dynamic createdAt, dynamic updatedAt, String? status, String? role, dynamic lastLogin, dynamic currentLogin, String? language, String? firstName, String? lastName, dynamic hasApiKey, String? phone)? $default,) {final _that = this; switch (_that) { case _GetLoggedUserItemResponseModel() when $default != null: return $default(_that.id,_that.delegationId,_that.email,_that.createdAt,_that.updatedAt,_that.status,_that.role,_that.lastLogin,_that.currentLogin,_that.language,_that.firstName,_that.lastName,_that.hasApiKey,_that.phone);case _: @@ -509,16 +509,16 @@ class _GetLoggedUserItemResponseModel implements GetLoggedUserItemResponseModel @override final String id; @override final String? delegationId; @override final String? email; -@override final String? createdAt; -@override final String? updatedAt; +@override final dynamic createdAt; +@override final dynamic updatedAt; @override final String? status; @override final String? role; -@override final String? lastLogin; -@override final String? currentLogin; +@override final dynamic lastLogin; +@override final dynamic currentLogin; @override final String? language; @override final String? firstName; @override final String? lastName; -@override final String? hasApiKey; +@override final dynamic hasApiKey; @override final String? phone; /// Create a copy of GetLoggedUserItemResponseModel @@ -534,12 +534,12 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLoggedUserItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&(identical(other.lastLogin, lastLogin) || other.lastLogin == lastLogin)&&(identical(other.currentLogin, currentLogin) || other.currentLogin == currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.hasApiKey, hasApiKey) || other.hasApiKey == hasApiKey)&&(identical(other.phone, phone) || other.phone == phone)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetLoggedUserItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.delegationId, delegationId) || other.delegationId == delegationId)&&(identical(other.email, email) || other.email == email)&&const DeepCollectionEquality().equals(other.createdAt, createdAt)&&const DeepCollectionEquality().equals(other.updatedAt, updatedAt)&&(identical(other.status, status) || other.status == status)&&(identical(other.role, role) || other.role == role)&&const DeepCollectionEquality().equals(other.lastLogin, lastLogin)&&const DeepCollectionEquality().equals(other.currentLogin, currentLogin)&&(identical(other.language, language) || other.language == language)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&const DeepCollectionEquality().equals(other.hasApiKey, hasApiKey)&&(identical(other.phone, phone) || other.phone == phone)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,id,delegationId,email,createdAt,updatedAt,status,role,lastLogin,currentLogin,language,firstName,lastName,hasApiKey,phone); +int get hashCode => Object.hash(runtimeType,id,delegationId,email,const DeepCollectionEquality().hash(createdAt),const DeepCollectionEquality().hash(updatedAt),status,role,const DeepCollectionEquality().hash(lastLogin),const DeepCollectionEquality().hash(currentLogin),language,firstName,lastName,const DeepCollectionEquality().hash(hasApiKey),phone); @override String toString() { @@ -554,7 +554,7 @@ abstract mixin class _$GetLoggedUserItemResponseModelCopyWith<$Res> implements $ factory _$GetLoggedUserItemResponseModelCopyWith(_GetLoggedUserItemResponseModel value, $Res Function(_GetLoggedUserItemResponseModel) _then) = __$GetLoggedUserItemResponseModelCopyWithImpl; @override @useResult $Res call({ - String id, String? delegationId, String? email, String? createdAt, String? updatedAt, String? status, String? role, String? lastLogin, String? currentLogin, String? language, String? firstName, String? lastName, String? hasApiKey, String? phone + String id, String? delegationId, String? email, dynamic createdAt, dynamic updatedAt, String? status, String? role, dynamic lastLogin, dynamic currentLogin, String? language, String? firstName, String? lastName, dynamic hasApiKey, String? phone }); @@ -577,16 +577,16 @@ id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,delegationId: freezed == delegationId ? _self.delegationId : delegationId // ignore: cast_nullable_to_non_nullable as String?,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable -as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable -as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as dynamic,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as dynamic,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable as String?,role: freezed == role ? _self.role : role // ignore: cast_nullable_to_non_nullable as String?,lastLogin: freezed == lastLogin ? _self.lastLogin : lastLogin // ignore: cast_nullable_to_non_nullable -as String?,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable -as String?,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable +as dynamic,currentLogin: freezed == currentLogin ? _self.currentLogin : currentLogin // ignore: cast_nullable_to_non_nullable +as dynamic,language: freezed == language ? _self.language : language // ignore: cast_nullable_to_non_nullable as String?,firstName: freezed == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String?,lastName: freezed == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String?,hasApiKey: freezed == hasApiKey ? _self.hasApiKey : hasApiKey // ignore: cast_nullable_to_non_nullable -as String?,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as dynamic,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable as String?, )); } diff --git a/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.g.dart b/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.g.dart index 7ad418b7..31f6e581 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.g.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/data/models/get_logged_user_response_model.g.dart @@ -24,16 +24,16 @@ _GetLoggedUserItemResponseModel _$GetLoggedUserItemResponseModelFromJson( id: json['id'] as String, delegationId: json['delegationId'] as String?, email: json['email'] as String?, - createdAt: json['createdAt'] as String?, - updatedAt: json['updatedAt'] as String?, + createdAt: json['createdAt'], + updatedAt: json['updatedAt'], status: json['status'] as String?, role: json['role'] as String?, - lastLogin: json['lastLogin'] as String?, - currentLogin: json['currentLogin'] as String?, + lastLogin: json['lastLogin'], + currentLogin: json['currentLogin'], language: json['language'] as String?, firstName: json['firstName'] as String?, lastName: json['lastName'] as String?, - hasApiKey: json['hasApiKey'] as String?, + hasApiKey: json['hasApiKey'], phone: json['phone'] as String?, ); diff --git a/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository.dart b/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository.dart index 13854552..67b02278 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository.dart @@ -2,5 +2,5 @@ import 'package:legacy_shared/src/data/models/entities/user_entity.dart'; abstract class LegacySharedRepository { - Future getLoggedUser({required String token}); + Future getLoggedUser(); } diff --git a/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository_impl.dart b/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository_impl.dart index dac7b5df..ce03fa98 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository_impl.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/data/repositories/legacy_shared_repository_impl.dart @@ -9,7 +9,7 @@ class LegacySharedRepositoryImpl implements LegacySharedRepository { final LegacySharedRemoteDatasource _remote; @override - Future getLoggedUser({required String token}) { - return _remote.getLoggedUser(token: token); + Future getLoggedUser() { + return _remote.getLoggedUser(); } } diff --git a/modules/legacy/packages/legacy_shared/lib/src/providers/logged_user_provider.dart b/modules/legacy/packages/legacy_shared/lib/src/providers/logged_user_provider.dart index b39aa974..66bf5d8d 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/providers/logged_user_provider.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/providers/logged_user_provider.dart @@ -16,6 +16,6 @@ class LoggedUserNotifier extends AsyncNotifier { @override Future build() { _legacySharedRepository = ref.read(legacySharedRepositoryProvider); - return _legacySharedRepository.getLoggedUser(token: ''); + return _legacySharedRepository.getLoggedUser(); } } diff --git a/modules/legacy/packages/legacy_shared/lib/src/widgets/layouts/page_layout.dart b/modules/legacy/packages/legacy_shared/lib/src/widgets/layouts/page_layout.dart index 80117dbb..11e9c942 100644 --- a/modules/legacy/packages/legacy_shared/lib/src/widgets/layouts/page_layout.dart +++ b/modules/legacy/packages/legacy_shared/lib/src/widgets/layouts/page_layout.dart @@ -1,5 +1,7 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; +import 'package:get_it/get_it.dart'; +import 'package:navigation/navigation.dart'; import 'package:utils/utils.dart'; class LegacyPageLayout extends StatelessWidget{ @@ -38,7 +40,9 @@ class LegacyPageLayout extends StatelessWidget{ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - IconButton(onPressed: () {Navigator.pop(context);}, + IconButton(onPressed: () { + GetIt.I().goBack(); + }, icon: Icon(Icons.arrow_back, color: theme.getColorFor(ThemeCode.legacyPrimary), size: 32, diff --git a/modules/legacy/packages/legacy_shared/pubspec.lock b/modules/legacy/packages/legacy_shared/pubspec.lock index cacc42bb..48c8caca 100644 --- a/modules/legacy/packages/legacy_shared/pubspec.lock +++ b/modules/legacy/packages/legacy_shared/pubspec.lock @@ -263,7 +263,7 @@ packages: source: hosted version: "0.1.6" dio: - dependency: transitive + dependency: "direct main" description: name: dio sha256: aff32c08f92787a557dd5c0145ac91536481831a01b4648136373cddb0e64f8c @@ -667,7 +667,7 @@ packages: source: hosted version: "7.2.0" navigation: - dependency: "direct overridden" + dependency: "direct main" description: path: "../../../../packages/navigation" relative: true @@ -871,7 +871,7 @@ packages: source: hosted version: "2.5.0" sf_infrastructure: - dependency: "direct overridden" + dependency: "direct main" description: path: "../../../../packages/sf_infrastructure" relative: true diff --git a/modules/legacy/packages/legacy_shared/pubspec.yaml b/modules/legacy/packages/legacy_shared/pubspec.yaml index d41caa9e..bc393213 100644 --- a/modules/legacy/packages/legacy_shared/pubspec.yaml +++ b/modules/legacy/packages/legacy_shared/pubspec.yaml @@ -16,9 +16,14 @@ dependencies: #packages dependencies go here design_system: path: ../../../../packages/design_system + navigation: + path: ../../../../packages/navigation + sf_infrastructure: + path: ../../../../packages/sf_infrastructure utils: path: ../../../../packages/utils #dependencies go here + dio: ^5.9.0 get_it: ^9.0.5 flutter_riverpod: ^3.0.3 freezed_annotation: ^3.1.0 diff --git a/packages/design_system/lib/src/dropdowns/dropdown.dart b/packages/design_system/lib/src/dropdowns/dropdown.dart index 44182adc..97ee4749 100644 --- a/packages/design_system/lib/src/dropdowns/dropdown.dart +++ b/packages/design_system/lib/src/dropdowns/dropdown.dart @@ -14,6 +14,7 @@ class CustomDropdown extends StatelessWidget { final double width; final Color? color; final EdgeInsets? padding; + final bool showIcon; const CustomDropdown({ super.key, @@ -28,6 +29,7 @@ class CustomDropdown extends StatelessWidget { this.height = 70, this.color, this.padding, + this.showIcon = true, }); @override @@ -55,6 +57,7 @@ class CustomDropdown extends StatelessWidget { height: height, child: Center( child: DropdownButtonFormField( + icon: showIcon ? null : const SizedBox.shrink(), dropdownColor: Colors.white, decoration: InputDecoration( enabledBorder: border(borderColor), diff --git a/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml b/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml index aecb0213..62f97c42 100644 --- a/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml +++ b/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml @@ -7,6 +7,6 @@ 2.6.4 - 20260306000000 + 20260309000000 diff --git a/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.md5 b/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.md5 index 26c72f5c..07888a04 100644 --- a/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.md5 +++ b/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.md5 @@ -1 +1 @@ -9118b6cbe462c0b755ae39f29c647c7d \ No newline at end of file +efba28f7c4340264bc1e42e5d11102a8 \ No newline at end of file diff --git a/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.sha1 b/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.sha1 index 354e4b68..b515de4c 100644 --- a/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.sha1 +++ b/packages/flutter_treezor_entrust_sdk_bridge/android/build/com/entrust/antelop/antelop/maven-metadata.xml.sha1 @@ -1 +1 @@ -903dc88b372a947a02ddf473496fc4c33afe51c6 \ No newline at end of file +33fe0a028f582b89ab719f8dafc0490e05af4ff5 \ No newline at end of file diff --git a/packages/navigation/lib/app_routes.dart b/packages/navigation/lib/app_routes.dart index a3c6863f..1377da97 100644 --- a/packages/navigation/lib/app_routes.dart +++ b/packages/navigation/lib/app_routes.dart @@ -46,6 +46,7 @@ class AppRoutes { static const customerService = '$controlPanel/customer_service'; static const deviceManagement = '$legacyDashboard/device_management'; + static const legacyLocation = '$legacyDashboard/location'; static const contacts = '$deviceManagement/contacts'; static const remoteConnection = '$deviceManagement/remote_connection'; static const locateDevice = '$deviceManagement/locate_device'; diff --git a/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart b/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart index 64e5f2b4..3e174530 100644 --- a/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart +++ b/packages/sf_infrastructure/lib/src/network/treezor_token_interceptor.dart @@ -25,11 +25,12 @@ class TreezorTokenInterceptor extends Interceptor { _handling = true; _onUnauthorized(); Future.delayed(const Duration(seconds: 2), () => _handling = false); - } else if (err.response?.statusCode == 500) { - _handling = true; - _onTokenExpired(); - Future.delayed(const Duration(seconds: 2), () => _handling = false); } + // } else if (err.response?.statusCode == 500) { + // _handling = true; + // _onTokenExpired(); + // Future.delayed(const Duration(seconds: 2), () => _handling = false); + // } } handler.next(err); } diff --git a/packages/sf_localizations/assets/l10n/de.json b/packages/sf_localizations/assets/l10n/de.json index 9aa28763..fea9ccc0 100644 --- a/packages/sf_localizations/assets/l10n/de.json +++ b/packages/sf_localizations/assets/l10n/de.json @@ -138,8 +138,8 @@ "secretCodeConfigure": "Einrichten", "deviceSetup_intro_title": "Füge dein Kind hinzu", "deviceSetup_intro_subtitle": "Behalte die Ausgaben im Blick, während es verantwortungsvolle Finanzgewohnheiten lernt", - "deviceSetup_intro_step_1": "Erstelle sein Profil", - "deviceSetup_intro_step_2": "Verbinde seine Uhr und das Armband", + "deviceSetup_intro_step_1": "Verbinde seine Uhr", + "deviceSetup_intro_step_2": "Erstelle sein Profil", "deviceSetup_intro_step_3": "Lade sein Sparschwein auf", "deviceSetup_intro_ready_title": "Und fertig - alles ist bereit, damit es sein Geld hat!", "deviceSetup_intro_remember_prefix": "Denk daran, dass du einen", @@ -147,17 +147,25 @@ "deviceSetup_intro_web_prefix": "Wenn du ihn noch nicht hast, kannst du ihn über ", "deviceSetup_intro_web_link": "unsere Website bekommen", "deviceSetup_linkInfo_title": "Verbinde Armband und Uhr", + "legacy_deviceSetup_linkInfo_title": "Verbinde die Uhr und erstelle das Profil", "deviceSetup_linkInfo_item1_prefix": "Scanne das ", "deviceSetup_linkInfo_item1_boldWord": "Armband", "deviceSetup_linkInfo_item1_subtitle": "Dein Kind kann damit Zahlungen durchführen", "deviceSetup_linkInfo_item2_prefix": "Scanne die ", "deviceSetup_linkInfo_item2_boldWord": "Uhr", "deviceSetup_linkInfo_item2_subtitle": "Du kannst die getätigten Ausgaben sehen", + "legacy_deviceSetup_linkInfo_item1_title": "Scanne die Uhr", + "legacy_deviceSetup_linkInfo_item1_subtitle": "Verknüpfe deinen Aktivierungscode", + "legacy_deviceSetup_linkInfo_item2_title": "Erstelle das Profil", + "legacy_deviceSetup_linkInfo_item2_subtitle": "Fülle das Formular deines Kindes aus", "deviceSetup_watchCode_orInsert": "Oder gib den Code", "deviceSetup_watchCode_continueWithCode": "Mit Code fortfahren", "deviceSetup_linkTroubleshoot_title": "Wenn du das Armband oder die Uhr nicht verbinden kannst", + "legacy_deviceSetup_scanWatch_title": "Verbinde die Uhr", + "legacy_deviceSetup_linkTroubleshoot_title": "Wenn du die Uhr nicht verbinden kannst", "deviceSetup_contactUs": "Kontaktiere uns", "deviceSetup_accountData_info": "Wir benötigen diese Angaben, um das Konto zu erstellen und Taschengeld sowie Ausgaben zu verwalten", + "legacy_deviceSetup_accountData_info": "Wir benötigen diese Angaben, um das Konto zu erstellen", "deviceSetup_startWithOneKid_info": "Starte mit einem Kind, später kannst du weitere hinzufügen", "deviceSetup_firstAllowance_title": "Du kannst ihnen jetzt das erste Taschengeld geben, damit sie es auf ihrer Uhr nutzen können", "deviceSetup_addAnotherKid": "Ein weiteres Kind hinzufügen", @@ -215,6 +223,7 @@ "deviceSetupConfirm": "Bestätigen", "errorLoadingData": "Fehler beim Laden der Daten", + "errorEmailAlreadyRegistered": "Diese E-Mail ist bereits registriert", "retry": "Erneut versuchen", "walletTitle": "Wallet", @@ -468,5 +477,15 @@ "dashboardTabHome": "Startseite", "dashboardTabActivity": "Aktivität", "dashboardTabNotifications": "Benachrichtigungen", - "dashboardTabProfile": "Profil" + "dashboardTabProfile": "Profil", + "genderLabel": "Geschlecht", + "genderHint": "Geschlecht auswählen", + "genderFemale": "Weiblich", + "genderMale": "Männlich", + "genderOther": "Andere", + "relationshipOther": "Andere", + "deviceSetup_weightLabel": "Gewicht (kg)", + "deviceSetup_weightHint": "30", + "deviceSetup_heightLabel": "Größe (cm)", + "deviceSetup_heightHint": "120" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/en.json b/packages/sf_localizations/assets/l10n/en.json index 9356f274..9fb43baa 100755 --- a/packages/sf_localizations/assets/l10n/en.json +++ b/packages/sf_localizations/assets/l10n/en.json @@ -138,8 +138,8 @@ "secretCodeConfigure": "Set up", "deviceSetup_intro_title": "Add your child", "deviceSetup_intro_subtitle": "Track their spending while they learn responsible financial habits", - "deviceSetup_intro_step_1": "Create their profile", - "deviceSetup_intro_step_2": "Link their watch and band", + "deviceSetup_intro_step_1": "Link their watch", + "deviceSetup_intro_step_2": "Create their profile", "deviceSetup_intro_step_3": "Top up their piggy bank", "deviceSetup_intro_ready_title": "And you're all set so they can have their money!", "deviceSetup_intro_remember_prefix": "Remember you need to have a", @@ -147,17 +147,25 @@ "deviceSetup_intro_web_prefix": "If you don't have it yet, you can get it through ", "deviceSetup_intro_web_link": "our website", "deviceSetup_linkInfo_title": "Link their band and watch", + "legacy_deviceSetup_linkInfo_title": "Link their watch and create their profile", "deviceSetup_linkInfo_item1_prefix": "Scan the ", "deviceSetup_linkInfo_item1_boldWord": "band", "deviceSetup_linkInfo_item1_subtitle": "Your child will be able to make payments", "deviceSetup_linkInfo_item2_prefix": "Scan the ", "deviceSetup_linkInfo_item2_boldWord": "watch", "deviceSetup_linkInfo_item2_subtitle": "You'll be able to see the expenses made", + "legacy_deviceSetup_linkInfo_item1_title": "Scan the watch", + "legacy_deviceSetup_linkInfo_item1_subtitle": "Link your activation code", + "legacy_deviceSetup_linkInfo_item2_title": "Create their profile", + "legacy_deviceSetup_linkInfo_item2_subtitle": "Fill in your child's form", "deviceSetup_watchCode_orInsert": "Or enter code", "deviceSetup_watchCode_continueWithCode": "Continue with code", "deviceSetup_linkTroubleshoot_title": "If you can't link their band or watch", + "legacy_deviceSetup_scanWatch_title": "Link their watch", + "legacy_deviceSetup_linkTroubleshoot_title": "If you can't link their watch", "deviceSetup_contactUs": "Contact us", "deviceSetup_accountData_info": "We need this information to create their account and manage their allowances and spending", + "legacy_deviceSetup_accountData_info": "We need this information to create their account", "deviceSetup_startWithOneKid_info": "Start with one child; you can add more later", "deviceSetup_firstAllowance_title": "You can now give them their first allowance so they can start enjoying it on their watch", "deviceSetup_addAnotherKid": "Add another child", @@ -214,6 +222,7 @@ "deviceSetupCreatingProfile": "Creating profile...", "deviceSetupConfirm": "Confirm", "errorLoadingData": "Error loading data", + "errorEmailAlreadyRegistered": "This email is already registered", "retry": "Retry", "walletTitle": "Wallet", "walletTotal": "{amount}€ total", @@ -524,5 +533,15 @@ "call": "Call me", "takePicture": "Take a picture", "remoteCamera": "Remote Camera", - "remoteListening": "Remote Listening" + "remoteListening": "Remote Listening", + "genderLabel": "Gender", + "genderHint": "Select gender", + "genderFemale": "Female", + "genderMale": "Male", + "genderOther": "Other", + "relationshipOther": "Other", + "deviceSetup_weightLabel": "Weight (kg)", + "deviceSetup_weightHint": "30", + "deviceSetup_heightLabel": "Height (cm)", + "deviceSetup_heightHint": "120" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/es.json b/packages/sf_localizations/assets/l10n/es.json index 8204e4aa..bccacf24 100644 --- a/packages/sf_localizations/assets/l10n/es.json +++ b/packages/sf_localizations/assets/l10n/es.json @@ -138,8 +138,8 @@ "secretCodeConfigure": "Configurar", "deviceSetup_intro_title": "Añade a tu peque", "deviceSetup_intro_subtitle": "Controla su gasto a la vez que aprende hábitos financieros responsables", - "deviceSetup_intro_step_1": "Crea su perfil", - "deviceSetup_intro_step_2": "Vincula su reloj y su correa", + "deviceSetup_intro_step_1": "Vincula su reloj", + "deviceSetup_intro_step_2": "Crea su perfil", "deviceSetup_intro_step_3": "Carga su hucha", "deviceSetup_intro_ready_title": "¡Y todo listo para que tenga su dinero!", "deviceSetup_intro_remember_prefix": "Recuerda que necesitas tener un", @@ -147,17 +147,25 @@ "deviceSetup_intro_web_prefix": "Si aún no lo tienes, puedes conseguirlo a través de ", "deviceSetup_intro_web_link": "nuestra web", "deviceSetup_linkInfo_title": "Vincula su correa y su reloj", + "legacy_deviceSetup_linkInfo_title": "Vincula su reloj y crea su perfil", "deviceSetup_linkInfo_item1_prefix": "Escanea la ", "deviceSetup_linkInfo_item1_boldWord": "correa", "deviceSetup_linkInfo_item1_subtitle": "El peque podrá realizar pagos", "deviceSetup_linkInfo_item2_prefix": "Escanea el ", "deviceSetup_linkInfo_item2_boldWord": "reloj", "deviceSetup_linkInfo_item2_subtitle": "Visualizarás los gastos que se hagan", + "legacy_deviceSetup_linkInfo_item1_title": "Escanea el reloj", + "legacy_deviceSetup_linkInfo_item1_subtitle": "Vincula tu código de activación", + "legacy_deviceSetup_linkInfo_item2_title": "Crea su perfil", + "legacy_deviceSetup_linkInfo_item2_subtitle": "Llena el formulario de tu peque", "deviceSetup_watchCode_orInsert": "O inserta el código", "deviceSetup_watchCode_continueWithCode": "Continuar con código", "deviceSetup_linkTroubleshoot_title": "Si no consigues vincular su correa o reloj", + "legacy_deviceSetup_scanWatch_title": "Vincula su reloj", + "legacy_deviceSetup_linkTroubleshoot_title": "Si no consigues vincular su reloj", "deviceSetup_contactUs": "Contáctanos", "deviceSetup_accountData_info": "Necesitamos estos datos para crear su cuenta y gestionar sus pagas y gastos", + "legacy_deviceSetup_accountData_info": "Necesitamos estos datos para crear su cuenta", "deviceSetup_startWithOneKid_info": "Comienza con un peque; luego podrás agregar más", "deviceSetup_firstAllowance_title": "Ya puedes darle su primera paga para que empiece a disfrutarla en su reloj", "deviceSetup_addAnotherKid": "Añadir otro peque", @@ -214,6 +222,7 @@ "deviceSetupCreatingProfile": "Creando perfil...", "deviceSetupConfirm": "Confirmar", "errorLoadingData": "Error al cargar datos", + "errorEmailAlreadyRegistered": "El email ya está registrado", "retry": "Reintentar", "walletTitle": "Wallet", "walletTotal": "{amount}€ total", @@ -520,5 +529,15 @@ "call": "Llámame", "takePicture": "Tomar fotografía", "remoteCamera": "Foto remota", - "remoteListening": "Escucha remota" + "remoteListening": "Escucha remota", + "genderLabel": "Género", + "genderHint": "Selecciona el género", + "genderFemale": "Femenino", + "genderMale": "Masculino", + "genderOther": "Otro", + "relationshipOther": "Otro", + "deviceSetup_weightLabel": "Peso (kg)", + "deviceSetup_weightHint": "30", + "deviceSetup_heightLabel": "Altura (cm)", + "deviceSetup_heightHint": "120" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/fr.json b/packages/sf_localizations/assets/l10n/fr.json index 1504ea77..b66986a5 100644 --- a/packages/sf_localizations/assets/l10n/fr.json +++ b/packages/sf_localizations/assets/l10n/fr.json @@ -138,8 +138,8 @@ "secretCodeConfigure": "Configurer", "deviceSetup_intro_title": "Ajoutez votre enfant", "deviceSetup_intro_subtitle": "Suivez ses dépenses tout en l'aidant à adopter des habitudes financières responsables", - "deviceSetup_intro_step_1": "Créez son profil", - "deviceSetup_intro_step_2": "Associez sa montre et son bracelet", + "deviceSetup_intro_step_1": "Associez sa montre", + "deviceSetup_intro_step_2": "Créez son profil", "deviceSetup_intro_step_3": "Alimentez sa cagnotte", "deviceSetup_intro_ready_title": "Et voilà, tout est prêt pour qu'il/elle ait son argent !", "deviceSetup_intro_remember_prefix": "N'oubliez pas que vous devez avoir un", @@ -147,17 +147,25 @@ "deviceSetup_intro_web_prefix": "Si vous ne l'avez pas encore, vous pouvez l'obtenir via ", "deviceSetup_intro_web_link": "notre site web", "deviceSetup_linkInfo_title": "Associez son bracelet et sa montre", + "legacy_deviceSetup_linkInfo_title": "Associez sa montre et créez son profil", "deviceSetup_linkInfo_item1_prefix": "Scanne le ", "deviceSetup_linkInfo_item1_boldWord": "bracelet", "deviceSetup_linkInfo_item1_subtitle": "Votre enfant pourra effectuer des paiements", "deviceSetup_linkInfo_item2_prefix": "Scanne la ", "deviceSetup_linkInfo_item2_boldWord": "montre", "deviceSetup_linkInfo_item2_subtitle": "Vous verrez les dépenses effectuées", + "legacy_deviceSetup_linkInfo_item1_title": "Scannez la montre", + "legacy_deviceSetup_linkInfo_item1_subtitle": "Associez votre code d'activation", + "legacy_deviceSetup_linkInfo_item2_title": "Créez son profil", + "legacy_deviceSetup_linkInfo_item2_subtitle": "Remplissez le formulaire de votre enfant", "deviceSetup_watchCode_orInsert": "Ou saisissez le code", "deviceSetup_watchCode_continueWithCode": "Continuer avec un code", "deviceSetup_linkTroubleshoot_title": "Si vous n'arrivez pas à associer son bracelet ou sa montre", + "legacy_deviceSetup_scanWatch_title": "Associez sa montre", + "legacy_deviceSetup_linkTroubleshoot_title": "Si vous n'arrivez pas à associer sa montre", "deviceSetup_contactUs": "Contactez-nous", "deviceSetup_accountData_info": "Nous avons besoin de ces informations pour créer son compte et gérer ses allocations et dépenses", + "legacy_deviceSetup_accountData_info": "Nous avons besoin de ces informations pour créer son compte", "deviceSetup_startWithOneKid_info": "Commencez avec un enfant, vous pourrez en ajouter d'autres ensuite", "deviceSetup_firstAllowance_title": "Vous pouvez maintenant lui donner sa première allocation pour qu'il/elle commence à en profiter sur sa montre", "deviceSetup_addAnotherKid": "Ajouter un autre enfant", @@ -215,6 +223,7 @@ "deviceSetupConfirm": "Confirmer", "errorLoadingData": "Erreur lors du chargement des données", + "errorEmailAlreadyRegistered": "Cet email est déjà enregistré", "retry": "Réessayer", "walletTitle": "Portefeuille", @@ -468,5 +477,15 @@ "dashboardTabHome": "Accueil", "dashboardTabActivity": "Activité", "dashboardTabNotifications": "Notifications", - "dashboardTabProfile": "Profil" + "dashboardTabProfile": "Profil", + "genderLabel": "Genre", + "genderHint": "Sélectionnez le genre", + "genderFemale": "Féminin", + "genderMale": "Masculin", + "genderOther": "Autre", + "relationshipOther": "Autre", + "deviceSetup_weightLabel": "Poids (kg)", + "deviceSetup_weightHint": "30", + "deviceSetup_heightLabel": "Taille (cm)", + "deviceSetup_heightHint": "120" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/it.json b/packages/sf_localizations/assets/l10n/it.json index 1cf4b0d5..ee82a8df 100644 --- a/packages/sf_localizations/assets/l10n/it.json +++ b/packages/sf_localizations/assets/l10n/it.json @@ -138,8 +138,8 @@ "secretCodeConfigure": "Configura", "deviceSetup_intro_title": "Aggiungi il tuo bambino", "deviceSetup_intro_subtitle": "Controlla le sue spese mentre impara abitudini finanziarie responsabili", - "deviceSetup_intro_step_1": "Crea il suo profilo", - "deviceSetup_intro_step_2": "Collega il suo orologio e il cinturino", + "deviceSetup_intro_step_1": "Collega il suo orologio", + "deviceSetup_intro_step_2": "Crea il suo profilo", "deviceSetup_intro_step_3": "Ricarica il suo salvadanaio", "deviceSetup_intro_ready_title": "E tutto è pronto perché abbia i suoi soldi!", "deviceSetup_intro_remember_prefix": "Ricorda che devi avere un", @@ -147,17 +147,25 @@ "deviceSetup_intro_web_prefix": "Se non ce l'hai ancora, puoi ottenerlo tramite ", "deviceSetup_intro_web_link": "il nostro sito web", "deviceSetup_linkInfo_title": "Collega il cinturino e l'orologio", + "legacy_deviceSetup_linkInfo_title": "Collega l'orologio e crea il profilo", "deviceSetup_linkInfo_item1_prefix": "Scansiona il ", "deviceSetup_linkInfo_item1_boldWord": "cinturino", "deviceSetup_linkInfo_item1_subtitle": "Il bambino potrà effettuare pagamenti", "deviceSetup_linkInfo_item2_prefix": "Scansiona l'", "deviceSetup_linkInfo_item2_boldWord": "orologio", "deviceSetup_linkInfo_item2_subtitle": "Potrai visualizzare le spese effettuate", + "legacy_deviceSetup_linkInfo_item1_title": "Scansiona l'orologio", + "legacy_deviceSetup_linkInfo_item1_subtitle": "Collega il tuo codice di attivazione", + "legacy_deviceSetup_linkInfo_item2_title": "Crea il profilo", + "legacy_deviceSetup_linkInfo_item2_subtitle": "Compila il modulo del tuo bambino", "deviceSetup_watchCode_orInsert": "Oppure inserisci il codice", "deviceSetup_watchCode_continueWithCode": "Continua con il codice", "deviceSetup_linkTroubleshoot_title": "Se non riesci a collegare il cinturino o l'orologio", + "legacy_deviceSetup_scanWatch_title": "Collega l'orologio", + "legacy_deviceSetup_linkTroubleshoot_title": "Se non riesci a collegare l'orologio", "deviceSetup_contactUs": "Contactez-nous", "deviceSetup_accountData_info": "Abbiamo bisogno di questi dati per creare il suo conto e gestire paghette e spese", + "legacy_deviceSetup_accountData_info": "Abbiamo bisogno di questi dati per creare il suo conto", "deviceSetup_startWithOneKid_info": "Inizia con un bambino, poi potrai aggiungerne altri", "deviceSetup_firstAllowance_title": "Ora puoi dargli la sua prima paghetta così potrà iniziare a usarla sul suo orologio", "deviceSetup_addAnotherKid": "Aggiungi un altro bambino", @@ -215,6 +223,7 @@ "deviceSetupConfirm": "Conferma", "errorLoadingData": "Errore durante il caricamento dei dati", + "errorEmailAlreadyRegistered": "Questa email è già registrata", "retry": "Riprova", "walletTitle": "Portafoglio", @@ -468,5 +477,15 @@ "dashboardTabHome": "Home", "dashboardTabActivity": "Attività", "dashboardTabNotifications": "Notifiche", - "dashboardTabProfile": "Profilo" + "dashboardTabProfile": "Profilo", + "genderLabel": "Genere", + "genderHint": "Seleziona il genere", + "genderFemale": "Femminile", + "genderMale": "Maschile", + "genderOther": "Altro", + "relationshipOther": "Altro", + "deviceSetup_weightLabel": "Peso (kg)", + "deviceSetup_weightHint": "30", + "deviceSetup_heightLabel": "Altezza (cm)", + "deviceSetup_heightHint": "120" } \ No newline at end of file diff --git a/packages/sf_localizations/assets/l10n/pt.json b/packages/sf_localizations/assets/l10n/pt.json index 70c15bf5..2554978c 100644 --- a/packages/sf_localizations/assets/l10n/pt.json +++ b/packages/sf_localizations/assets/l10n/pt.json @@ -138,8 +138,8 @@ "secretCodeConfigure": "Configurar", "deviceSetup_intro_title": "Adicione o seu filho", "deviceSetup_intro_subtitle": "Acompanhe os gastos enquanto ele aprende hábitos financeiros responsáveis", - "deviceSetup_intro_step_1": "Crie o perfil dele", - "deviceSetup_intro_step_2": "Vincule o relógio e a pulseira", + "deviceSetup_intro_step_1": "Vincule o relógio", + "deviceSetup_intro_step_2": "Crie o perfil dele", "deviceSetup_intro_step_3": "Carregue o cofrinho dele", "deviceSetup_intro_ready_title": "E pronto, tudo preparado para ele ter o dinheiro dele!", "deviceSetup_intro_remember_prefix": "Lembre-se de que precisa de um", @@ -147,17 +147,25 @@ "deviceSetup_intro_web_prefix": "Se ainda não tem, pode conseguir através do ", "deviceSetup_intro_web_link": "nosso site", "deviceSetup_linkInfo_title": "Vincula a pulseira e o relógio", + "legacy_deviceSetup_linkInfo_title": "Vincule o relógio e crie o perfil", "deviceSetup_linkInfo_item1_prefix": "Digitaliza a ", "deviceSetup_linkInfo_item1_boldWord": "pulseira", "deviceSetup_linkInfo_item1_subtitle": "A criança poderá realizar pagamentos", "deviceSetup_linkInfo_item2_prefix": "Digitaliza o ", "deviceSetup_linkInfo_item2_boldWord": "relógio", "deviceSetup_linkInfo_item2_subtitle": "Poderás visualizar os gastos efetuados", + "legacy_deviceSetup_linkInfo_item1_title": "Digitalize o relógio", + "legacy_deviceSetup_linkInfo_item1_subtitle": "Vincule o seu código de ativação", + "legacy_deviceSetup_linkInfo_item2_title": "Crie o perfil", + "legacy_deviceSetup_linkInfo_item2_subtitle": "Preencha o formulário do seu filho", "deviceSetup_watchCode_orInsert": "Ou introduz o código", "deviceSetup_watchCode_continueWithCode": "Continuar com código", "deviceSetup_linkTroubleshoot_title": "Se não conseguires vincular a pulseira ou o relógio", + "legacy_deviceSetup_scanWatch_title": "Vincule o relógio", + "legacy_deviceSetup_linkTroubleshoot_title": "Se não conseguires vincular o relógio", "deviceSetup_contactUs": "Contacta-nos", "deviceSetup_accountData_info": "Precisamos destes dados para criar a conta e gerir as mesadas e os gastos", + "legacy_deviceSetup_accountData_info": "Precisamos destes dados para criar a conta", "deviceSetup_startWithOneKid_info": "Começa com uma criança; depois podes adicionar mais", "deviceSetup_firstAllowance_title": "Agora já podes dar-lhe a primeira mesada para que comece a aproveitá-la no relógio", "deviceSetup_addAnotherKid": "Adicionar outra criança", @@ -215,6 +223,7 @@ "deviceSetupConfirm": "Confirmar", "errorLoadingData": "Erro ao carregar dados", + "errorEmailAlreadyRegistered": "Este email já está registado", "retry": "Tentar novamente", "walletTitle": "Carteira", @@ -468,5 +477,15 @@ "dashboardTabHome": "Início", "dashboardTabActivity": "Atividade", "dashboardTabNotifications": "Notificações", - "dashboardTabProfile": "Perfil" + "dashboardTabProfile": "Perfil", + "genderLabel": "Género", + "genderHint": "Selecione o género", + "genderFemale": "Feminino", + "genderMale": "Masculino", + "genderOther": "Outro", + "relationshipOther": "Outro", + "deviceSetup_weightLabel": "Peso (kg)", + "deviceSetup_weightHint": "30", + "deviceSetup_heightLabel": "Altura (cm)", + "deviceSetup_heightHint": "120" } \ No newline at end of file diff --git a/packages/sf_localizations/lib/src/generated/i18n.dart b/packages/sf_localizations/lib/src/generated/i18n.dart index fbf1b614..21516df0 100755 --- a/packages/sf_localizations/lib/src/generated/i18n.dart +++ b/packages/sf_localizations/lib/src/generated/i18n.dart @@ -181,6 +181,22 @@ class I18n { 'deviceSetup_intro_web_prefix'; static const String deviceSetup_intro_web_link = 'deviceSetup_intro_web_link'; static const String deviceSetup_linkInfo_title = 'deviceSetup_linkInfo_title'; + static const String legacy_deviceSetup_linkInfo_title = + 'legacy_deviceSetup_linkInfo_title'; + static const String legacy_deviceSetup_linkInfo_item1_title = + 'legacy_deviceSetup_linkInfo_item1_title'; + static const String legacy_deviceSetup_linkInfo_item1_subtitle = + 'legacy_deviceSetup_linkInfo_item1_subtitle'; + static const String legacy_deviceSetup_linkInfo_item2_title = + 'legacy_deviceSetup_linkInfo_item2_title'; + static const String legacy_deviceSetup_linkInfo_item2_subtitle = + 'legacy_deviceSetup_linkInfo_item2_subtitle'; + static const String legacy_deviceSetup_scanWatch_title = + 'legacy_deviceSetup_scanWatch_title'; + static const String legacy_deviceSetup_linkTroubleshoot_title = + 'legacy_deviceSetup_linkTroubleshoot_title'; + static const String legacy_deviceSetup_accountData_info = + 'legacy_deviceSetup_accountData_info'; static const String deviceSetup_linkInfo_item1_prefix = 'deviceSetup_linkInfo_item1_prefix'; static const String deviceSetup_linkInfo_item1_boldWord = @@ -260,6 +276,7 @@ class I18n { static const String deviceSetupCreatingProfile = 'deviceSetupCreatingProfile'; static const String deviceSetupConfirm = 'deviceSetupConfirm'; static const String errorLoadingData = 'errorLoadingData'; + static const String errorEmailAlreadyRegistered = 'errorEmailAlreadyRegistered'; static const String retry = 'retry'; static const String walletTitle = 'walletTitle'; static const String walletTotal = 'walletTotal'; @@ -633,4 +650,14 @@ class I18n { static const String takePicture = 'takePicture'; static const String remoteCamera = 'remoteCamera'; static const String remoteListening = 'remoteListening'; + static const String genderLabel = 'genderLabel'; + static const String genderHint = 'genderHint'; + static const String genderFemale = 'genderFemale'; + static const String genderMale = 'genderMale'; + static const String genderOther = 'genderOther'; + static const String relationshipOther = 'relationshipOther'; + static const String deviceSetup_weightLabel = 'deviceSetup_weightLabel'; + static const String deviceSetup_weightHint = 'deviceSetup_weightHint'; + static const String deviceSetup_heightLabel = 'deviceSetup_heightLabel'; + static const String deviceSetup_heightHint = 'deviceSetup_heightHint'; }