From a4ee7331ab21ea4f56b0ff6cfb642ef9785bc4ce Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Tue, 3 Dec 2024 15:58:50 -0300 Subject: [PATCH] WIP --- lib/backend/api_requests/api_calls.dart | 218 +++--- .../firebase_messaging_service.dart | 2 +- .../notifications/notification_service.dart | 8 +- ..._arrow_linked_locals_component_widget.dart | 16 +- .../schedule_visit_detail_model.dart | 6 +- ...p_arrow_linked_locals_component_model.dart | 8 +- ...cation_modal_template_component_model.dart | 6 +- .../change_pass_widget.dart | 2 +- ...item_details_template_component_model.dart | 6 +- .../provisional_schedule_template_model.dart | 10 +- ...siter_vistor_template_component_model.dart | 6 +- .../sign_up_template_component_widget.dart | 2 +- .../view_visit_detail_model.dart | 6 +- ...search_modal_template_component_model.dart | 6 +- .../home/presentation/blocs/home_bloc.dart | 10 +- .../home/presentation/pages/home_page.dart | 8 +- .../pages/about_property_screen.dart | 8 +- lib/flutter_flow/nav/nav.dart | 8 +- lib/main.dart | 10 +- .../acess_history_page_model.dart | 6 +- .../fast_pass_page/fast_pass_page_widget.dart | 10 +- .../liberation_history_model.dart | 6 +- .../message_history_page_model.dart | 6 +- .../package_order_page.dart | 2 +- .../pets_history_screen.dart | 8 +- lib/pages/pets_page/pets_page_model.dart | 8 +- .../preferences_settings_model.dart | 34 +- .../qr_code_page/qr_code_page_model.dart | 4 +- .../qr_code_page/qr_code_page_widget.dart | 2 +- .../reception_page/reception_page_model.dart | 2 +- .../reception_page/reception_page_widget.dart | 4 +- .../reservation_page_widget.dart | 10 +- .../residents_on_the_property_model.dart | 4 +- .../schedule_complete_visit_page_model.dart | 6 +- .../visit_history_page_widget.dart | 14 +- lib/pages/visits_on_the_property/model.dart | 4 +- .../welcome_page/welcome_page_widget.dart | 6 +- .../molecules/drawer/drawer_widget.dart | 8 +- .../locals_remote_data_source.dart | 160 +--- .../repositories/locals_repository_impl.dart | 17 +- .../respositories/locals_repository.dart | 7 +- .../components/molecules/locals/index.dart | 1 + .../blocs/local_profile_bloc.dart | 8 +- .../local_profile/local_profile_widget.dart | 8 +- .../molecules/locals/utils/index.dart | 1 + .../molecules/locals/utils/local_util.dart | 130 ++++ .../menu/data/data_sources/index.dart | 1 + .../data_sources/menu_local_data_source.dart | 98 +++ .../menu/data/repositories/index.dart | 1 + .../repositories/menu_repository_impl.dart | 45 ++ .../molecules/menu/domain/entities/index.dart | 2 - .../menu/domain/entities/menu_entry.dart | 20 - .../menu/domain/entities/menu_item.dart | 6 +- .../menu/domain/entities/menu_view.dart | 0 .../domain/respositories/menu_repository.dart | 6 + .../presentation/blocs/menu_view_bloc.dart | 119 +-- .../molecules/menu/presentation/index.dart | 1 + .../menu/presentation/mappers/index.dart | 1 + .../menu/presentation/mappers/menu_entry.dart | 219 ++++++ .../menu/presentation/widgets/index.dart | 4 +- .../widgets/menu_entry/drawer_menu_entry.dart | 228 ------ .../widgets/menu_entry/home_menu_entry.dart | 217 ------ .../widgets/menu_entry/index.dart | 4 - .../menu_entry/menu_entry_factory.dart | 38 - .../menu_entry/property_menu_entry.dart | 69 -- ...nu_view_factory.dart => menu_factory.dart} | 13 +- .../widgets/menu_factory/index.dart | 1 - .../widgets/menu_factory/menu_factory.dart | 25 - .../presentation/widgets/menu_item/index.dart | 1 - .../widgets/menu_item/menu_item_button.dart | 6 +- .../widgets/menu_item/menu_item_card.dart | 6 +- .../widgets/menu_item/menu_item_factory.dart | 24 - .../presentation/widgets/menu_view/index.dart | 1 - .../widgets/menu_view/menu_list_view.dart | 2 - .../menu_view/menu_staggered_view.dart | 3 +- .../license_local_data_source.dart | 4 +- .../license_remote_data_source.dart | 10 +- .../repositories/license_repository_impl.dart | 15 +- .../modules/domain/entities/license.dart | 710 +----------------- .../respositories/license_repository.dart | 7 +- .../helpers/database/database_helper.dart | 2 +- .../helpers/storage/storage_helper.dart | 8 +- .../authentication_service.dart | 26 +- lib/shared/utils/path_util.dart | 17 + lib/shared/utils/share_util.dart | 4 +- 85 files changed, 895 insertions(+), 1891 deletions(-) create mode 100644 lib/shared/components/molecules/locals/utils/index.dart create mode 100644 lib/shared/components/molecules/locals/utils/local_util.dart create mode 100644 lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart create mode 100644 lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart delete mode 100644 lib/shared/components/molecules/menu/domain/entities/menu_entry.dart delete mode 100644 lib/shared/components/molecules/menu/domain/entities/menu_view.dart create mode 100644 lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart create mode 100644 lib/shared/components/molecules/menu/presentation/mappers/index.dart create mode 100644 lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_entry/drawer_menu_entry.dart delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_entry/home_menu_entry.dart delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_entry/index.dart delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_entry/menu_entry_factory.dart delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_entry/property_menu_entry.dart rename lib/shared/components/molecules/menu/presentation/widgets/{menu_view/menu_view_factory.dart => menu_factory.dart} (87%) delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_factory/index.dart delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_factory/menu_factory.dart delete mode 100644 lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_factory.dart create mode 100644 lib/shared/utils/path_util.dart diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index 269dcf4c..ca2f5d9c 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -65,9 +65,9 @@ class PhpGroup { class GetOpenedVisits { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getOpenedVisits'; const String pageSize = '10'; return await ApiManager.instance.makeApiCall( @@ -97,9 +97,9 @@ class GetOpenedVisits { class GetResidentsByProperty { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; - final String cliID = await StorageHelper().g(KeychainStorageKey.clientUUID.value) ?? ''; + final String devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; + final String userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; + final String cliID = await StorageHelper().get(KeychainStorageKey.clientUUID.value) ?? ''; const String atividade = 'getResidentsByProperty'; const String pageSize = '10'; return await ApiManager.instance.makeApiCall( @@ -128,9 +128,9 @@ class GetResidentsByProperty { class GetVehiclesByProperty { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getVehiclesByProperty'; const String pageSize = '10'; return await ApiManager.instance.makeApiCall( @@ -191,9 +191,9 @@ class TestCall { class GetLicense { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'getLicense', @@ -222,8 +222,8 @@ class GetLicense { class UnregisterDevice { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'unregisterDevice', @@ -250,9 +250,9 @@ class UnregisterDevice { class DeletePet { Future call({final int? petID = 0}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'excluirPet'; return await ApiManager.instance.makeApiCall( @@ -295,9 +295,9 @@ class UpdatePet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'atualizarPet'; return await ApiManager.instance.makeApiCall( @@ -341,9 +341,9 @@ class GetPets { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'consultaPets'; return await ApiManager.instance.makeApiCall( @@ -375,9 +375,9 @@ class GetPetPhoto { Future call({final int? petId}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'consultaFotoPet'; return await ApiManager.instance.makeApiCall( @@ -418,9 +418,9 @@ class RegisterPet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'cadastrarPet'; return await ApiManager.instance.makeApiCall( @@ -463,9 +463,9 @@ class BuscaEnconcomendas { final String? adresseeType, final String? status, }) async { - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getEncomendas'; final String baseUrl = PhpGroup.getBaseUrl(); @@ -507,9 +507,9 @@ class CancelaVisita { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'cancelaVisita'; return await ApiManager.instance.makeApiCall( @@ -541,8 +541,8 @@ class CancelaVisita { class DeleteAccount { Future call() async { - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; final String baseUrl = PhpGroup.getBaseUrl(); return await ApiManager.instance.makeApiCall( @@ -573,9 +573,9 @@ class ChangePanic { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -609,9 +609,9 @@ class ChangePass { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -645,9 +645,9 @@ class RespondeVinculo { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'respondeVinculo', @@ -679,9 +679,9 @@ class ChangeNotifica { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -713,10 +713,10 @@ class UpdateIDE { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - final String newIde = (await StorageHelper().g(KeychainStorageKey.userDevUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String newIde = (await StorageHelper().get(KeychainStorageKey.userDevUUID.value)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -748,9 +748,9 @@ class UpdToken { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String token = (await StorageHelper().g(SecureStorageKey.token.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String token = (await StorageHelper().get(SecureStorageKey.token.value)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'updToken', @@ -777,11 +777,11 @@ class UpdToken { class LoginCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String email = (await StorageHelper().g(SecureStorageKey.email.value)) ?? ''; - final String password = (await StorageHelper().g(SecureStorageKey.password.value)) ?? ''; - final String type = (await StorageHelper().g(SecureStorageKey.deviceType.value)) ?? ''; - final String description = (await StorageHelper().g(SecureStorageKey.deviceDescription.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String email = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; + final String password = (await StorageHelper().get(SecureStorageKey.password.value)) ?? ''; + final String type = (await StorageHelper().get(SecureStorageKey.deviceType.value)) ?? ''; + final String description = (await StorageHelper().get(SecureStorageKey.deviceDescription.value)) ?? ''; late final String token; try { token = await FirebaseMessagingService.getToken(); @@ -864,9 +864,9 @@ class ChangePasswordCall { required final String psswd, }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'changePassword', @@ -925,8 +925,8 @@ class GetLocalsCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; + final String devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; + final String userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'getLocals', @@ -965,9 +965,9 @@ class PostScheduleVisitorCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'putVisitante'; return await ApiManager.instance.makeApiCall( @@ -1020,9 +1020,9 @@ class PostScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'putVisita'; return await ApiManager.instance.makeApiCall( @@ -1074,9 +1074,9 @@ class GetScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getVisitas'; return await ApiManager.instance.makeApiCall( @@ -1348,9 +1348,9 @@ class GetDadosCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getDados'; return await ApiManager.instance.makeApiCall( @@ -1581,9 +1581,9 @@ class GetVisitorByDocCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getVisitante'; return await ApiManager.instance.makeApiCall( @@ -1635,9 +1635,9 @@ class GetFotoVisitanteCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getFotoVisitante'; return await ApiManager.instance.makeApiCall( @@ -1674,9 +1674,9 @@ class PostProvVisitSchedulingCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'putAgendamentoProv'; return await ApiManager.instance.makeApiCall( @@ -1723,9 +1723,9 @@ class GetVisitsCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getVisitas'; return await ApiManager.instance.makeApiCall( @@ -1986,9 +1986,9 @@ class DeleteVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'cancelaVisita'; return await ApiManager.instance.makeApiCall( @@ -2029,10 +2029,10 @@ class GetPessoasLocalCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String ownerUUID = (await StorageHelper().get(KeychainStorageKey.ownerUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'getPessoasLocal', @@ -2095,9 +2095,9 @@ class RespondeSolicitacaoCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'respondeSolicitacao'; return await ApiManager.instance.makeApiCall( @@ -2145,9 +2145,9 @@ class GetAccessCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getAcessos'; return await ApiManager.instance.makeApiCall( @@ -2394,9 +2394,9 @@ class GetLiberationsCall { final StreamController controller = StreamController(); Future.microtask(() async { - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getSolicitacoes'; try { @@ -2586,9 +2586,9 @@ class GetMessagesCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getMensagens'; return await ApiManager.instance.makeApiCall( diff --git a/lib/backend/notifications/firebase_messaging_service.dart b/lib/backend/notifications/firebase_messaging_service.dart index 390a2036..3b768ad2 100644 --- a/lib/backend/notifications/firebase_messaging_service.dart +++ b/lib/backend/notifications/firebase_messaging_service.dart @@ -43,7 +43,7 @@ class FirebaseMessagingService { final String? deviceToken = await _firebaseMessaging.getToken(); if (deviceToken != null) { - await StorageHelper().s(SecureStorageKey.token.value, deviceToken); + await StorageHelper().set(SecureStorageKey.token.value, deviceToken); final ApiCallResponse? response; response = await PhpGroup.updToken.call(); diff --git a/lib/backend/notifications/notification_service.dart b/lib/backend/notifications/notification_service.dart index db0a7c0f..c771a378 100644 --- a/lib/backend/notifications/notification_service.dart +++ b/lib/backend/notifications/notification_service.dart @@ -15,7 +15,7 @@ import 'package:hub/shared/utils/dialog_util.dart'; Future onMessageReceived(Map payload, String? extra, String? handleClick) async { final localId = jsonDecode(payload['local']!)['CLI_ID']; - final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; answersRequest( {required BuildContext context, @@ -239,7 +239,7 @@ Future onMessageReceived(Map payload, String? extra, Stri break; case 'enroll_cond': - await StorageHelper().s(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); StorageHelper().context!.go('/homePage'); break; default: @@ -271,11 +271,11 @@ class NotificationService { await AwesomeNotifications().isNotificationAllowed().then((isAllowed) async { final bool requestOSnotification = - (await StorageHelper().g(KeychainStorageKey.requestOSNotification.value)) == 'true'; + (await StorageHelper().get(KeychainStorageKey.requestOSNotification.value)) == 'true'; if (requestOSnotification == false) { if (isAllowed == false) { - await StorageHelper().s(KeychainStorageKey.requestOSNotification.value, true); + await StorageHelper().set(KeychainStorageKey.requestOSNotification.value, true); await AwesomeNotifications().requestPermissionToSendNotifications(); } } diff --git a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart index 8d5da9a3..8d781daa 100644 --- a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart @@ -105,9 +105,9 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State _fetchResponseLink(String status, String cliID) async { try { - await StorageHelper().s(KeychainStorageKey.clientUUID.value, cliID); + await StorageHelper().set(KeychainStorageKey.clientUUID.value, cliID); var response = await PhpGroup.resopndeVinculo.call(tarefa: status); if (response.jsonBody['error'] == false) { @@ -147,7 +147,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State initDB() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override diff --git a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart index 746a34fe..87665faa 100644 --- a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart +++ b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart @@ -16,10 +16,10 @@ class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel initDB() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; } @override diff --git a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart index 114242ef..fa663658 100644 --- a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart +++ b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart @@ -32,9 +32,9 @@ class AccessNotificationModalTemplateComponentModel } Future initDB() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override diff --git a/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart b/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart index 0e52975f..e361442d 100644 --- a/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart +++ b/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart @@ -49,7 +49,7 @@ class _PassKeyTemplateWidgetState extends State { } Future _initialize() async { - _accessPass = await StorageHelper().g(SecureStorageKey.accessPass.value) ?? ''; + _accessPass = await StorageHelper().get(SecureStorageKey.accessPass.value) ?? ''; } @override diff --git a/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart b/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart index b7d768b8..4a9c55bb 100644 --- a/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart +++ b/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart @@ -27,9 +27,9 @@ class LiberationHistoryItemDetailsTemplateComponentModel void initState(BuildContext context) {} Future initDatabase() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; ; } diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart index 4f8bd82e..8ec62766 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart @@ -137,12 +137,12 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel init() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; ; - cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; - ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; + cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + ownerUUID = (await StorageHelper().get(KeychainStorageKey.ownerUUID.value)) ?? ''; setState?.call(); } } diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart index f7ff104f..d1f63dc2 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart @@ -129,9 +129,9 @@ class RegisiterVistorTemplateComponentModel extends FlutterFlowModel initializeDatabase() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; ; } diff --git a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart index ca51110b..07614dfe 100644 --- a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart +++ b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart @@ -91,7 +91,7 @@ class _SignUpTemplateComponentWidgetState extends State _initialize() async { - _deviceType = (await StorageHelper().g(SecureStorageKey.deviceType.value)) ?? ''; + _deviceType = (await StorageHelper().get(SecureStorageKey.deviceType.value)) ?? ''; } @override diff --git a/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart b/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart index 58ea89e5..3fde3bf2 100644 --- a/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart +++ b/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart @@ -37,9 +37,9 @@ class ViewVisitDetailModel extends FlutterFlowModel { } Future initializeDatabase() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; ; } diff --git a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart index ab8f9fc4..e71a2c86 100644 --- a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart +++ b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart @@ -35,9 +35,9 @@ class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel initDatabase() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; ; } diff --git a/lib/features/home/presentation/blocs/home_bloc.dart b/lib/features/home/presentation/blocs/home_bloc.dart index b92d32b3..bf6e580e 100644 --- a/lib/features/home/presentation/blocs/home_bloc.dart +++ b/lib/features/home/presentation/blocs/home_bloc.dart @@ -7,11 +7,11 @@ import 'index.dart'; class HomeBloc extends Bloc { HomeBloc() : super(HomeState()) { on((event, emit) async { - final devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - final userName = (await StorageHelper().g(KeychainStorageKey.userName.value)) ?? ''; - final userEmail = (await StorageHelper().g(SecureStorageKey.email.value)) ?? ''; + final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final userName = (await StorageHelper().get(KeychainStorageKey.userName.value)) ?? ''; + final userEmail = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; emit(state.copyWith( devUUID: devUUID, diff --git a/lib/features/home/presentation/pages/home_page.dart b/lib/features/home/presentation/pages/home_page.dart index 79db0532..f63c044e 100644 --- a/lib/features/home/presentation/pages/home_page.dart +++ b/lib/features/home/presentation/pages/home_page.dart @@ -128,10 +128,10 @@ class _HomePageWidgetState extends State { color: FlutterFlowTheme.of(context).primaryBackground, child: Padding( padding: const EdgeInsets.only(bottom: 40), - child: MenuFactory( - menuEntry: MenuEntries.home, - menuItem: EnumMenuItem.button, - menuView: MenuView.list_grid, + child: Menufactory( + entry: MenuEntry.getEntriesByType(MenuEntryType.Home), + item: EnumMenuItem.button, + view: MenuView.list_grid, ), ), ); diff --git a/lib/features/property/presentation/pages/about_property_screen.dart b/lib/features/property/presentation/pages/about_property_screen.dart index de4bc014..dea748d2 100644 --- a/lib/features/property/presentation/pages/about_property_screen.dart +++ b/lib/features/property/presentation/pages/about_property_screen.dart @@ -77,10 +77,10 @@ class _AboutPropertyPageState extends State with SingleTicker return SingleChildScrollView( child: Container( color: FlutterFlowTheme.of(context).primaryBackground, - child: MenuFactory( - menuEntry: MenuEntries.AboutProperty, - menuItem: EnumMenuItem.button, - menuView: MenuView.list_grid, + child: Menufactory( + entry: MenuEntry.getEntriesByType(MenuEntryType.Drawer), + item: EnumMenuItem.button, + view: MenuView.list_grid, ), ), ); diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index 1efd1362..11bb57dd 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -85,10 +85,10 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { builder: (context, _) { return FutureBuilder( future: () async { - final bool isLogged = await StorageHelper().g(SecureStorageKey.isLogged.value) == 'true'; - final bool haveLocal = await StorageHelper().g(SecureStorageKey.haveLocal.value) == 'true'; - final bool haveUserUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value))?.isNotEmpty ?? false; - final bool haveDevUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value))?.isNotEmpty ?? false; + final bool isLogged = await StorageHelper().get(SecureStorageKey.isLogged.value) == 'true'; + final bool haveLocal = await StorageHelper().get(SecureStorageKey.haveLocal.value) == 'true'; + final bool haveUserUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value))?.isNotEmpty ?? false; + final bool haveDevUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value))?.isNotEmpty ?? false; if (isLogged && haveDevUUID && haveUserUUID) { return haveLocal ? const HomePageWidget() : const ReceptionPageWidget(); diff --git a/lib/main.dart b/lib/main.dart index 1053f9bd..409d2a04 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -30,7 +30,7 @@ void main() async { Future _foregroundHandlerMessage(RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - await StorageHelper().s(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); StorageHelper().context?.go('/homePage'); } @@ -41,7 +41,7 @@ Future _foregroundHandlerMessage(RemoteMessage message) async { Future _backgroundHandlerMessage(RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - await StorageHelper().s(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); StorageHelper().context?.go('/homePage'); } } @@ -133,7 +133,7 @@ class _AppState extends State with WidgetsBindingObserver { FirebaseMessaging.onMessage.listen(_foregroundHandlerMessage); FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - await StorageHelper().s(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); log('onMessageOpenedApp'); } else { onMessageReceived(message.data, message.notification!.body, message.data['click_action']); @@ -142,7 +142,7 @@ class _AppState extends State with WidgetsBindingObserver { FirebaseMessaging.instance.getInitialMessage().then((message) async { if (message != null) { if (message.data['click_action'] == 'enroll_cond') { - await StorageHelper().s(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); log('getInitialMessage'); } } @@ -187,7 +187,7 @@ class _AppState extends State with WidgetsBindingObserver { @override void didChangeAppLifecycleState(AppLifecycleState state) async { if (state == AppLifecycleState.detached) { - await LocalsRepositoryImpl().processLocals(context); + await LocalsRepositoryImpl().update(context); await FirebaseMessagingService().updateDeviceToken(); } } diff --git a/lib/pages/acess_history_page/acess_history_page_model.dart b/lib/pages/acess_history_page/acess_history_page_model.dart index 98a33bf6..429ae806 100644 --- a/lib/pages/acess_history_page/acess_history_page_model.dart +++ b/lib/pages/acess_history_page/acess_history_page_model.dart @@ -33,9 +33,9 @@ class AcessHistoryPageModel extends FlutterFlowModel { } Future initDatabase() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override diff --git a/lib/pages/fast_pass_page/fast_pass_page_widget.dart b/lib/pages/fast_pass_page/fast_pass_page_widget.dart index 8df206f9..31bb70eb 100644 --- a/lib/pages/fast_pass_page/fast_pass_page_widget.dart +++ b/lib/pages/fast_pass_page/fast_pass_page_widget.dart @@ -25,11 +25,11 @@ class _FastPassPageWidgetState extends State { late InAppWebViewController _controllerIOS; Future> initVariables() async { - final email = (await StorageHelper().g(SecureStorageKey.email.value)) ?? ''; - final name = (await StorageHelper().g(KeychainStorageKey.userName.value)) ?? ''; - final devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final email = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; + final name = (await StorageHelper().get(KeychainStorageKey.userName.value)) ?? ''; + final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const createdAt = '0000-00-00 00:00:00'; final url = 'https://hub.freaccess.com.br/hub/fast-pass/$cliUUID'; final freUserData = diff --git a/lib/pages/liberation_history/liberation_history_model.dart b/lib/pages/liberation_history/liberation_history_model.dart index 7c64039a..8c016069 100644 --- a/lib/pages/liberation_history/liberation_history_model.dart +++ b/lib/pages/liberation_history/liberation_history_model.dart @@ -36,9 +36,9 @@ class LiberationHistoryModel extends FlutterFlowModel { } Future init() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } Future answersRequest( diff --git a/lib/pages/message_history_page/message_history_page_model.dart b/lib/pages/message_history_page/message_history_page_model.dart index 7db66d8a..1a2cd70d 100644 --- a/lib/pages/message_history_page/message_history_page_model.dart +++ b/lib/pages/message_history_page/message_history_page_model.dart @@ -39,9 +39,9 @@ class MessageHistoryPageModel extends FlutterFlowModel } Future init() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override diff --git a/lib/pages/package_order_page/package_order_page.dart b/lib/pages/package_order_page/package_order_page.dart index c3d352f4..0df4e591 100644 --- a/lib/pages/package_order_page/package_order_page.dart +++ b/lib/pages/package_order_page/package_order_page.dart @@ -64,7 +64,7 @@ class _PackageOrderPage extends State { } Future initDatabase() async { - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override diff --git a/lib/pages/pets_on_the_property_page/pets_history_screen.dart b/lib/pages/pets_on_the_property_page/pets_history_screen.dart index 1229f3c6..5c29a948 100644 --- a/lib/pages/pets_on_the_property_page/pets_history_screen.dart +++ b/lib/pages/pets_on_the_property_page/pets_history_screen.dart @@ -291,10 +291,10 @@ class _PetsHistoryScreenState extends State with TickerProvid } ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - final cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; await showDialog( useSafeArea: true, context: context, diff --git a/lib/pages/pets_page/pets_page_model.dart b/lib/pages/pets_page/pets_page_model.dart index 21f74d62..aeb213a9 100644 --- a/lib/pages/pets_page/pets_page_model.dart +++ b/lib/pages/pets_page/pets_page_model.dart @@ -147,10 +147,10 @@ class PetsPageModel extends FlutterFlowModel { textControllerObservation = TextEditingController(); WidgetsBinding.instance.addPostFrameCallback((_) async { - devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; - userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; - cliUUID = await StorageHelper().g(KeychainStorageKey.clientUUID.value) ?? ''; - petAmountRegister = await StorageHelper().g(KeychainStorageKey.petAmount.value) ?? ''; + devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; + userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; + cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value) ?? ''; + petAmountRegister = await StorageHelper().get(KeychainStorageKey.petAmount.value) ?? ''; }); } diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 734a8f92..2f8adda5 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -23,11 +23,11 @@ class PreferencesPageModel with ChangeNotifier { late bool isPanic = false; Future _initialize() async { - isFingerprint = await StorageHelper().g(KeychainStorageKey.fingerprint.value) == 'true'; - isPerson = await StorageHelper().g(KeychainStorageKey.person.value) == 'true'; - isNotify = await StorageHelper().g(KeychainStorageKey.notify.value) == 'true'; - isAccess = await StorageHelper().g(KeychainStorageKey.access.value) == 'true'; - isPanic = await StorageHelper().g(KeychainStorageKey.panic.value) == 'true'; + isFingerprint = await StorageHelper().get(KeychainStorageKey.fingerprint.value) == 'true'; + isPerson = await StorageHelper().get(KeychainStorageKey.person.value) == 'true'; + isNotify = await StorageHelper().get(KeychainStorageKey.notify.value) == 'true'; + isAccess = await StorageHelper().get(KeychainStorageKey.access.value) == 'true'; + isPanic = await StorageHelper().get(KeychainStorageKey.panic.value) == 'true'; notifyListeners(); } @@ -36,7 +36,7 @@ class PreferencesPageModel with ChangeNotifier { } Future enablePerson(BuildContext context) async { - final String userDevUUID = (await StorageHelper().g(KeychainStorageKey.userDevUUID.value)) ?? ''; + final String userDevUUID = (await StorageHelper().get(KeychainStorageKey.userDevUUID.value)) ?? ''; notifyListeners(); Share.share( FFLocalizations.of(context).getVariableText( @@ -63,7 +63,7 @@ class PreferencesPageModel with ChangeNotifier { .call(notifica: value) .then((value) async { if (value.jsonBody['error'] == false) { - await StorageHelper().s(KeychainStorageKey.notify.value, isNotify ? 'false' : 'true'); + await StorageHelper().set(KeychainStorageKey.notify.value, isNotify ? 'false' : 'true'); content = FFLocalizations.of(context).getVariableText( enText: 'Notification changed successfully', ptText: 'Notificação alterada com sucesso', @@ -85,7 +85,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isNotify = await StorageHelper().g(KeychainStorageKey.notify.value) == 'true') + .then((_) async => isNotify = await StorageHelper().get(KeychainStorageKey.notify.value) == 'true') .whenComplete(() => notifyListeners()); context.pop(); } @@ -134,13 +134,13 @@ class PreferencesPageModel with ChangeNotifier { Future toggleAccess(BuildContext context) async { onChange(String key) async { - await StorageHelper().s(SecureStorageKey.accessPass.value, key); + await StorageHelper().set(SecureStorageKey.accessPass.value, key); await PhpGroup.changePass .call(newSenha: key) .then((value) async { final String content; if (jsonDecode(value.jsonBody['error'].toString()) == false) { - await StorageHelper().s(KeychainStorageKey.access.value, isAccess ? 'false' : 'true'); + await StorageHelper().set(KeychainStorageKey.access.value, isAccess ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Access pass changed successfully', @@ -162,7 +162,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isAccess = await StorageHelper().g(KeychainStorageKey.access.value) == 'true') + .then((_) async => isAccess = await StorageHelper().get(KeychainStorageKey.access.value) == 'true') .whenComplete(() => notifyListeners()); } @@ -171,13 +171,13 @@ class PreferencesPageModel with ChangeNotifier { Future togglePanic(BuildContext context) async { onChange(String key) async { - await StorageHelper().s(SecureStorageKey.panicPass.value, key); + await StorageHelper().set(SecureStorageKey.panicPass.value, key); await PhpGroup.changePanic .call(newSenhaPanico: key) .then((value) async { final String content; if (jsonDecode(value.jsonBody['error'].toString()) == false) { - await StorageHelper().s(KeychainStorageKey.panic.value, isPanic ? 'false' : 'true'); + await StorageHelper().set(KeychainStorageKey.panic.value, isPanic ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Panic password changed successfully', @@ -199,7 +199,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isPanic = await StorageHelper().g(KeychainStorageKey.panic.value) == 'true') + .then((_) async => isPanic = await StorageHelper().get(KeychainStorageKey.panic.value) == 'true') .whenComplete(() => notifyListeners()); } @@ -214,11 +214,11 @@ class PreferencesPageModel with ChangeNotifier { onChange(String? key) async { isFingerprint = !isFingerprint; - await StorageHelper().s(SecureStorageKey.fingerprintPass.value, key ?? ''); - await StorageHelper().s(KeychainStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false'); + await StorageHelper().set(SecureStorageKey.fingerprintPass.value, key ?? ''); + await StorageHelper().set(KeychainStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false'); notifyListeners(); SnackBarUtil.showSnackBar(context, content); - isFingerprint = await StorageHelper().g(KeychainStorageKey.fingerprint.value) == 'true'; + isFingerprint = await StorageHelper().get(KeychainStorageKey.fingerprint.value) == 'true'; } isFingerprint ? onChange(null) : _showPassKey(context, onChange); diff --git a/lib/pages/qr_code_page/qr_code_page_model.dart b/lib/pages/qr_code_page/qr_code_page_model.dart index 002192ad..41df6e77 100644 --- a/lib/pages/qr_code_page/qr_code_page_model.dart +++ b/lib/pages/qr_code_page/qr_code_page_model.dart @@ -29,8 +29,8 @@ class QrCodePageModel extends FlutterFlowModel { } Future initVariable() async { - isFingerprint = await StorageHelper().g(KeychainStorageKey.fingerprint.value) == 'true'; - userDevUUID = await StorageHelper().g(KeychainStorageKey.userDevUUID.value) ?? ''; + isFingerprint = await StorageHelper().get(KeychainStorageKey.fingerprint.value) == 'true'; + userDevUUID = await StorageHelper().get(KeychainStorageKey.userDevUUID.value) ?? ''; safeSetState?.call(); } diff --git a/lib/pages/qr_code_page/qr_code_page_widget.dart b/lib/pages/qr_code_page/qr_code_page_widget.dart index b2005f96..6aad1599 100644 --- a/lib/pages/qr_code_page/qr_code_page_widget.dart +++ b/lib/pages/qr_code_page/qr_code_page_widget.dart @@ -353,7 +353,7 @@ class _QrCodePageWidgetState extends State with TickerProvider await BiometricHelper.checkBiometrics() .then((value) async => await BiometricHelper.authenticateBiometric().then((value) async { if (value == false) throw Exception('Biometric authentication failed'); - final key = await StorageHelper().g(SecureStorageKey.fingerprintPass.value); + final key = await StorageHelper().get(SecureStorageKey.fingerprintPass.value); if (key == null || key.isEmpty) throw Exception('No key found'); safeSetState(() { if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { diff --git a/lib/pages/reception_page/reception_page_model.dart b/lib/pages/reception_page/reception_page_model.dart index e0afe000..239f675a 100644 --- a/lib/pages/reception_page/reception_page_model.dart +++ b/lib/pages/reception_page/reception_page_model.dart @@ -6,7 +6,7 @@ import 'package:share_plus/share_plus.dart'; class ReceptionPageModel with ChangeNotifier { Future getIdenfifier(BuildContext context) async { - final String userDevUUID = (await StorageHelper().g(KeychainStorageKey.userDevUUID.value)) ?? ''; + final String userDevUUID = (await StorageHelper().get(KeychainStorageKey.userDevUUID.value)) ?? ''; notifyListeners(); Share.share( diff --git a/lib/pages/reception_page/reception_page_widget.dart b/lib/pages/reception_page/reception_page_widget.dart index 3891122c..a29e194b 100644 --- a/lib/pages/reception_page/reception_page_widget.dart +++ b/lib/pages/reception_page/reception_page_widget.dart @@ -33,7 +33,7 @@ class _ReceptionPageWidgetState extends State with WidgetsB }(); FirebaseMessagingService().updateDeviceToken(); - LocalsRepositoryImpl().checkLocals(context); + LocalsRepositoryImpl().validateLocal(context); } @override @@ -46,7 +46,7 @@ class _ReceptionPageWidgetState extends State with WidgetsB void didChangeAppLifecycleState(AppLifecycleState state) { if (state == AppLifecycleState.resumed) { setState(() { - LocalsRepositoryImpl().checkLocals(context); + LocalsRepositoryImpl().validateLocal(context); }); } } diff --git a/lib/pages/reservation_page/reservation_page_widget.dart b/lib/pages/reservation_page/reservation_page_widget.dart index 37b0fe1a..4d9091ac 100644 --- a/lib/pages/reservation_page/reservation_page_widget.dart +++ b/lib/pages/reservation_page/reservation_page_widget.dart @@ -22,11 +22,11 @@ class _ReservationPageWidgetState extends State { late WebViewController _controllerAll; Future> initVariables() async { - final email = (await StorageHelper().g(SecureStorageKey.email.value)) ?? ''; - final name = (await StorageHelper().g(KeychainStorageKey.userName.value)) ?? ''; - final devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final clientId = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final email = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; + final name = (await StorageHelper().get(KeychainStorageKey.userName.value)) ?? ''; + final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final clientId = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; const createdAt = '0000-00-00 00:00:00'; final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId'; final freUserData = diff --git a/lib/pages/residents_on_the_property/residents_on_the_property_model.dart b/lib/pages/residents_on_the_property/residents_on_the_property_model.dart index e5f1f84c..4883ceb3 100644 --- a/lib/pages/residents_on_the_property/residents_on_the_property_model.dart +++ b/lib/pages/residents_on_the_property/residents_on_the_property_model.dart @@ -18,8 +18,8 @@ class ResidentsOnThePropertyModel extends FlutterFlowModel } Future _initVariables() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override diff --git a/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart b/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart index c20c8927..e706f92f 100644 --- a/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart @@ -35,9 +35,9 @@ class _VisitHistoryWidgetState extends State with TickerProv List _visitWrap = []; Future _initVariables() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override @@ -245,10 +245,10 @@ class _VisitHistoryWidgetState extends State with TickerProv }, ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - final cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; await showDialog( useSafeArea: true, diff --git a/lib/pages/visits_on_the_property/model.dart b/lib/pages/visits_on_the_property/model.dart index c880c726..9870b4bb 100644 --- a/lib/pages/visits_on_the_property/model.dart +++ b/lib/pages/visits_on_the_property/model.dart @@ -30,8 +30,8 @@ class VisitsModel extends FlutterFlowModel { void dispose() {} Future initAsync() async { - devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; onRefresh?.call(); } diff --git a/lib/pages/welcome_page/welcome_page_widget.dart b/lib/pages/welcome_page/welcome_page_widget.dart index a2a0e7bd..53ac8018 100644 --- a/lib/pages/welcome_page/welcome_page_widget.dart +++ b/lib/pages/welcome_page/welcome_page_widget.dart @@ -32,13 +32,13 @@ class _WelcomePageWidgetState extends State { // On page load action. SchedulerBinding.instance.addPostFrameCallback((_) async { if (isAndroid == true) { - await StorageHelper().s(SecureStorageKey.deviceType.value, 'Android'); + await StorageHelper().set(SecureStorageKey.deviceType.value, 'Android'); setState(() {}); } else if (isiOS == true) { - await StorageHelper().s(SecureStorageKey.deviceType.value, 'iOS'); + await StorageHelper().set(SecureStorageKey.deviceType.value, 'iOS'); setState(() {}); } else { - await StorageHelper().s(SecureStorageKey.deviceType.value, 'Web'); + await StorageHelper().set(SecureStorageKey.deviceType.value, 'Web'); setState(() {}); } }); diff --git a/lib/shared/components/molecules/drawer/drawer_widget.dart b/lib/shared/components/molecules/drawer/drawer_widget.dart index c913dcb5..253540d1 100644 --- a/lib/shared/components/molecules/drawer/drawer_widget.dart +++ b/lib/shared/components/molecules/drawer/drawer_widget.dart @@ -189,10 +189,10 @@ class CustomDrawer extends StatelessWidget { } Widget _buildDrawerBody(BuildContext context) { - return MenuFactory( - menuEntry: MenuEntries.drawer, - menuItem: EnumMenuItem.tile, - menuView: MenuView.list, + return Menufactory( + entry: MenuEntry.getEntriesByType(MenuEntryType.Property), + item: EnumMenuItem.tile, + view: MenuView.list, ); } } diff --git a/lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart b/lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart index 05ecdc28..c2321d4d 100644 --- a/lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart +++ b/lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart @@ -8,13 +8,13 @@ import 'package:hub/components/organism_components/bottom_arrow_linked_locals_co import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; import 'package:hub/shared/components/molecules/modules/index.dart'; import 'package:hub/shared/helpers/storage/base_storage.dart'; import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/services/authentication/authentication_service.dart'; import 'package:hub/shared/utils/dialog_util.dart'; -import 'package:hub/shared/utils/log_util.dart'; import 'package:hub/shared/utils/snackbar_util.dart'; abstract class LocalsRemoteDataSource { @@ -22,7 +22,7 @@ abstract class LocalsRemoteDataSource { Future processLocals(BuildContext context) async => false; Future processData(BuildContext context) async => false; Future selectLocal(BuildContext context, ApiCallResponse? response) async => false; - Future unlinkLocal(BuildContext context) async {} + Future detachLocal(BuildContext context) async {} } class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { @@ -38,7 +38,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { final bool? isError = response.jsonBody['error']; if (isError == true) { - _handleError(context, response.jsonBody['error_msg']); + LocalUtil.handleError(context, response.jsonBody['error_msg']); return; } if (response.jsonBody == null) { @@ -56,11 +56,11 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { final bool isEnable = !isEmpty && isActive; if (isEnable) { - await StorageHelper().s(SecureStorageKey.haveLocal.value, true); - await StorageHelper().s(SecureStorageKey.isLogged.value, true); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.isLogged.value, true); await WidgetsBinding.instance.endOfFrame; - await StorageHelper().s(KeychainStorageKey.clientUUID.value, ''); - await StorageHelper().s(KeychainStorageKey.ownerUUID.value, ''); + await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(KeychainStorageKey.ownerUUID.value, ''); StorageHelper().context?.go('/homePage'); } } catch (e, s) { @@ -78,7 +78,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { if (isError == true) { final String errorMsg = response.jsonBody['error_msg']; - _handleError(context, errorMsg); + LocalUtil.handleError(context, errorMsg); return false; } if (response.jsonBody == null) { @@ -91,27 +91,27 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { } final List locals = response.jsonBody['locais'].toList() ?? []; - _logLocalsStatus(locals); + LocalUtil.logLocalsStatus(locals); - final bool isActive = _isActive(locals); - final bool isInactived = await _isInactived(locals); - final bool isPending = _isPending(locals); + final bool isActive = LocalUtil.isActive(locals); + final bool isInactived = await LocalUtil.isInactived(locals); + final bool isPending = LocalUtil.isPending(locals); final bool isUnique = locals.length == 1; final bool isBlocked = locals.where((local) => local['CLU_STATUS'] == 'B').isNotEmpty; final bool isEnabled = isUnique && isActive; final bool isDisabled = isUnique && isBlocked; - final bool isUnselected = await _isUnselected(); - final bool isSelected = await _isSelected(isInactived); + final bool isUnselected = await LocalUtil.isUnselected(); + final bool isSelected = await LocalUtil.isSelected(isInactived); final bool isUnavailable = isPending && isUnselected && isUnique; - final bool isAvailable = await _isAvailable(); + final bool isAvailable = await LocalUtil.isAvailable(); if (isDisabled) { AuthenticationService.signOut(context); return true; } else if (isUnavailable) { - return await _handleUnavailable(context, locals); + return await LocalUtil.handleUnavailable(context, locals); } else if (isEnabled) { - return await _handleEnabled(context, locals[0]); + return await LocalUtil.handleEnabled(context, locals[0]); } else if (isUnselected) { log('() => isUnselected'); return await selectLocal(context, response); @@ -166,12 +166,8 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); return false; } else { - final bool isNewVersion = await _updateStorageUtil(response.jsonBody); - await LicenseRepositoryImpl().setupLicense(isNewVersion); - if (isNewVersion) { - return await LicenseRepositoryImpl().fetchLicense(isNewVersion); - } - return false; + final bool isNewVersion = await LocalUtil.updateStorageUtil(response.jsonBody); + return await LicenseRepositoryImpl().updateLicense(isNewVersion); } } catch (e, s) { log('() => error processData: $e', stackTrace: s); @@ -205,7 +201,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { } @override - Future unlinkLocal(BuildContext context) async { + Future detachLocal(BuildContext context) async { String content; try { content = FFLocalizations.of(context).getVariableText( @@ -215,8 +211,8 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { if (value.jsonBody['error'] == false) { - await StorageHelper().s(KeychainStorageKey.clientName.value, ''); - await StorageHelper().s(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(KeychainStorageKey.clientName.value, ''); + await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); context.pop(); context.go( '/homePage', @@ -249,117 +245,5 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { } } - void _handleError(BuildContext context, String errorMsg) async { - final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; - final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty; - final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); - log('() => isLinked: $errorMsg'); - if (!isAuthenticated) { - errorMsg = FFLocalizations.of(context).getVariableText( - ptText: 'Erro ao obter credenciais de autenticação', - enText: 'Error getting authentication credentials', - ); - await DialogUtil.error(context, errorMsg); - return; - // await DialogUtil.error(context, errorMsg).whenComplete(() async => await AuthenticationService.signOut(context)); - } - if (!isDevLinked) { - errorMsg = FFLocalizations.of(context).getVariableText( - ptText: 'Não foi possível vincular o dispositivo, tente novamente.', - enText: 'Unable to link device, try again', - ); - await DialogUtil.warning(context, errorMsg); - return; - } - await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, null)); - } - Future _handleUnavailable(BuildContext context, List locals) async { - log('() => isUnavailable'); - try { - await StorageHelper().s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']); - await StorageHelper().s(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']); - await StorageHelper().s(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']); - var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); - if (response.jsonBody['error'] == true) { - await StorageHelper().s(KeychainStorageKey.clientUUID.value, ''); - await StorageHelper().s(KeychainStorageKey.ownerUUID.value, ''); - await StorageHelper().s(KeychainStorageKey.clientName.value, ''); - return false; - } - if (response.jsonBody['error'] == false) return await processData(context).then((value) => value); - } catch (e, s) { - await DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vínculo', e, s); - return false; - } - return false; - } - - Future _handleEnabled(BuildContext context, dynamic local) async { - log('() => isEnabled'); - await StorageHelper().s(KeychainStorageKey.clientUUID.value, local['CLI_ID']); - await StorageHelper().s(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']); - await StorageHelper().s(KeychainStorageKey.clientName.value, local['CLI_NOME']); - await StorageHelper().s(KeychainStorageKey.userName.value, local['USU_NOME']); - return await processData(context); - } - - void _logLocalsStatus(List locals) { - for (var local in locals) { - final String status = local['CLU_STATUS']; - log('() => CLU_STATUS: $status'); - } - } - - Future _updateStorageUtil(Map jsonBody) async { - try { - await StorageHelper().s(KeychainStorageKey.whatsapp.value, jsonBody['whatsapp'] ?? false); - await StorageHelper().s(KeychainStorageKey.provisional.value, jsonBody['provisional'] ?? false); - await StorageHelper().s(KeychainStorageKey.pets.value, jsonBody['pet'] ?? false); - await StorageHelper().s(KeychainStorageKey.petAmount.value, - jsonBody['petAmountRegister']?.toString().isEmpty ?? true ? '0' : jsonBody['petAmountRegister'].toString()); - await StorageHelper().s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'] ?? ''); - - final bool isNewVersion = jsonBody['newVersion'] ?? false; - await StorageHelper().s(KeychainStorageKey.isNewVersion.value, isNewVersion); - return isNewVersion; - } catch (e, s) { - log('Error in _updateStorageUtil: $e', stackTrace: s); - return false; - } - } - - bool _isActive(List locals) { - return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty; - } - - Future _isInactived(List locals) async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; - } - - bool _isPending(List locals) { - return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty; - } - - Future _isUnselected() async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; - String ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; - return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty; - } - - Future _isSelected(bool isInactived) async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; - return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived; - } - - Future _isAvailable() async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; - return cliUUID.isNotEmpty && cliName.isNotEmpty; - } } diff --git a/lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart b/lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart index cd711443..39916fc1 100644 --- a/lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart +++ b/lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart @@ -1,35 +1,24 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/shared/components/molecules/locals/index.dart'; class LocalsRepositoryImpl implements LocalsRepository { final LocalsRemoteDataSource remoteDataSource = LocalsRemoteDataSourceImpl(); @override - Future checkLocals(BuildContext context) async { + Future validateLocal(BuildContext context) async { return await remoteDataSource.checkLocals(context); } @override - Future processData(BuildContext context) async { - return await remoteDataSource.processData(context); - } - - @override - Future processLocals(BuildContext context) async { + Future update(BuildContext context) async { final bool response = await remoteDataSource.processLocals(context); context.read().add(LocalProfileEvent()); return response; } - @override - Future selectLocal(BuildContext context, ApiCallResponse? response) async { - return await remoteDataSource.selectLocal(context, response); - } - @override Future unlinkLocal(BuildContext context) { - return remoteDataSource.unlinkLocal(context); + return remoteDataSource.detachLocal(context); } } diff --git a/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart b/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart index 39577166..1862d79c 100644 --- a/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart +++ b/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart @@ -1,10 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; abstract class LocalsRepository { - Future checkLocals(BuildContext context) async {} - Future processLocals(BuildContext context) async => false; - Future processData(BuildContext context) async => false; - Future selectLocal(BuildContext context, ApiCallResponse? response) async => false; + Future validateLocal(BuildContext context) async {} + Future update(BuildContext context) async => false; Future unlinkLocal(BuildContext context) async {} } diff --git a/lib/shared/components/molecules/locals/index.dart b/lib/shared/components/molecules/locals/index.dart index aa560630..c6e39062 100644 --- a/lib/shared/components/molecules/locals/index.dart +++ b/lib/shared/components/molecules/locals/index.dart @@ -1,3 +1,4 @@ export 'data/index.dart'; export 'domain/index.dart'; export 'presentation/index.dart'; +export 'utils/index.dart'; \ No newline at end of file diff --git a/lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart b/lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart index cd838442..b91360f2 100644 --- a/lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart +++ b/lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart @@ -24,8 +24,8 @@ class LocalProfileState { class LocalProfileBloc extends Bloc { LocalProfileBloc() : super(LocalProfileState()) { on((event, emit) async { - final cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; - final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; emit(state.copyWith(cliName: cliName, cliUUID: cliUUID)); }); } @@ -42,8 +42,8 @@ class LocalProfileComponentModel extends FlutterFlowModel getData() async { - cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; - cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; setStateCallback?.call(); } diff --git a/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart b/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart index d742425e..189cb702 100644 --- a/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart +++ b/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart @@ -22,8 +22,8 @@ class _LocalProfileComponentWidgetState extends State isLinked: $errorMsg'); + if (!isAuthenticated) { + errorMsg = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao obter credenciais de autenticação', + enText: 'Error getting authentication credentials', + ); + await DialogUtil.error(context, errorMsg); + return; + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await AuthenticationService.signOut(context)); + } + if (!isDevLinked) { + errorMsg = FFLocalizations.of(context).getVariableText( + ptText: 'Não foi possível vincular o dispositivo, tente novamente.', + enText: 'Unable to link device, try again', + ); + await DialogUtil.warning(context, errorMsg); + return; + } + await DialogUtil.error(context, errorMsg).whenComplete(() async => await LocalsRemoteDataSourceImpl().selectLocal(context, null)); + } + + static Future handleUnavailable(BuildContext context, List locals) async { + log('() => isUnavailable'); + try { + await StorageHelper().set(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']); + await StorageHelper().set(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']); + await StorageHelper().set(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']); + var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); + if (response.jsonBody['error'] == true) { + await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(KeychainStorageKey.ownerUUID.value, ''); + await StorageHelper().set(KeychainStorageKey.clientName.value, ''); + return false; + } + if (response.jsonBody['error'] == false) return await LocalsRemoteDataSourceImpl().processData(context).then((value) => value); + } catch (e, s) { + await DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vínculo', e, s); + return false; + } + return false; + } + + static Future handleEnabled(BuildContext context, dynamic local) async { + log('() => isEnabled'); + await StorageHelper().set(KeychainStorageKey.clientUUID.value, local['CLI_ID']); + await StorageHelper().set(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']); + await StorageHelper().set(KeychainStorageKey.clientName.value, local['CLI_NOME']); + await StorageHelper().set(KeychainStorageKey.userName.value, local['USU_NOME']); + return await LocalsRemoteDataSourceImpl().processData(context); + } + + static void logLocalsStatus(List locals) { + for (var local in locals) { + final String status = local['CLU_STATUS']; + log('() => CLU_STATUS: $status'); + } + } + + static Future updateStorageUtil(Map jsonBody) async { + try { + await StorageHelper().set(KeychainStorageKey.whatsapp.value, jsonBody['whatsapp'] ?? false); + await StorageHelper().set(KeychainStorageKey.provisional.value, jsonBody['provisional'] ?? false); + await StorageHelper().set(KeychainStorageKey.pets.value, jsonBody['pet'] ?? false); + await StorageHelper().set(KeychainStorageKey.petAmount.value, + jsonBody['petAmountRegister']?.toString().isEmpty ?? true ? '0' : jsonBody['petAmountRegister'].toString()); + await StorageHelper().set(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'] ?? ''); + + final bool isNewVersion = jsonBody['newVersion'] ?? false; + await StorageHelper().set(KeychainStorageKey.isNewVersion.value, isNewVersion); + return isNewVersion; + } catch (e, s) { + log('Error in _updateStorageUtil: $e', stackTrace: s); + return false; + } + } + + static bool isActive(List locals) { + return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty; + } + + static Future isInactived(List locals) async { + String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; + } + + static bool isPending(List locals) { + return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty; + } + + static Future isUnselected() async { + String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + String ownerUUID = (await StorageHelper().get(KeychainStorageKey.ownerUUID.value)) ?? ''; + return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty; + } + + static Future isSelected(bool isInactived) async { + String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived; + } + + static Future isAvailable() async { + String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + return cliUUID.isNotEmpty && cliName.isNotEmpty; + } + +} \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/data/data_sources/index.dart b/lib/shared/components/molecules/menu/data/data_sources/index.dart index e69de29b..8b421899 100644 --- a/lib/shared/components/molecules/menu/data/data_sources/index.dart +++ b/lib/shared/components/molecules/menu/data/data_sources/index.dart @@ -0,0 +1 @@ +export 'menu_local_data_source.dart'; diff --git a/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart b/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart new file mode 100644 index 00000000..ebccda7b --- /dev/null +++ b/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart @@ -0,0 +1,98 @@ + + +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/shared/extensions/dialog_extensions.dart'; +import 'package:hub/shared/services/authentication/authentication_service.dart'; +import 'package:hub/shared/utils/path_util.dart'; + +abstract class MenuLocalDataSource { + Future addMenuEntry(EnumMenuItem item, List entries, IconData icon, String text, Function() action); + Future processDisplayDefault(EnumMenuItem item, MenuEntry opt, List entries); + Future processDisplay(EnumMenuItem item, String display, MenuEntry opt, List entries); + Future processStartDate(String startDate, MenuEntry opt); + Future processExpirationDate(String expirationDate, MenuEntry opt); +} + +class MenuLocalDataSourceImpl implements MenuLocalDataSource { + static final MenuLocalDataSourceImpl _instance = MenuLocalDataSourceImpl._internal(); + factory MenuLocalDataSourceImpl() => _instance; + MenuLocalDataSourceImpl._internal(); + + @override + Future addMenuEntry(EnumMenuItem item, List entries, IconData icon, String text, Function() action) async { + final menuItem = item == EnumMenuItem.button + ? ButtonMenuItem(icon: icon, action: action, title: text) + : item == EnumMenuItem.card || item == EnumMenuItem.tile + ? CardMenuItem(icon: icon, action: action, title: text) + : null; + if (menuItem != null) { + entries.add(menuItem); + } + return null; + } + + @override + Future processDisplayDefault(EnumMenuItem item, MenuEntry opt, List entries) async { + if (opt.value == 'FRE-HUB-LOGOUT') { + await addMenuEntry(item, entries, opt.icon, opt.name, () async { + await AuthenticationService.signOut(navigatorKey.currentContext!); + }); + return true; + + } + else return false; + } + + @override + Future processDisplay(EnumMenuItem item, String display, MenuEntry opt, List entries) async { + try { + switch (display) { + case 'VISIVEL': + await addMenuEntry(item, entries, opt.icon, opt.name, () async { + await PathUtil.nav(opt.route); + }); + break; + case 'DESABILITADO': + await addMenuEntry(item, entries, opt.icon, opt.name, () async { + await DialogUnavailable.unavailableFeature(navigatorKey.currentContext!); + }); + break; + case 'INVISIVEL': + break; + } + } catch (e) { + log('Error processing display for module ${opt.value}: $e'); + } + } + + @override + Future processStartDate(String startDate, MenuEntry opt) async { + try { + if (startDate.isEmpty) return true; + final start = DateTime.tryParse(startDate); + return start != null && DateTime.now().isAfter(start); + } catch (e) { + log('Error processing start date for module ${opt.value}: $e'); + } + return false; + } + + @override + Future processExpirationDate(String expirationDate, MenuEntry opt) async { + try { + if (expirationDate.isEmpty) return false; + final expiration = DateTime.tryParse(expirationDate); + return expiration != null && DateTime.now().isAfter(expiration); + } catch (e) { + log('Error processing expiration date for module ${opt.value}: $e'); + } + return false; + } + + + +} \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/data/repositories/index.dart b/lib/shared/components/molecules/menu/data/repositories/index.dart index e69de29b..f3a81afb 100644 --- a/lib/shared/components/molecules/menu/data/repositories/index.dart +++ b/lib/shared/components/molecules/menu/data/repositories/index.dart @@ -0,0 +1 @@ +export 'menu_repository_impl.dart'; diff --git a/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart b/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart new file mode 100644 index 00000000..fdf1d434 --- /dev/null +++ b/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart @@ -0,0 +1,45 @@ + + +import 'dart:developer'; + +import 'package:hub/flutter_flow/custom_functions.dart'; +import 'package:hub/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart'; +import 'package:hub/shared/components/molecules/menu/domain/respositories/menu_repository.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/shared/components/molecules/modules/index.dart'; + + +class MenuRepositoryImpl implements MenuRepository { + final MenuLocalDataSource menuDataSource = MenuLocalDataSourceImpl(); + + + @override + Future> generateMenuEntries(List menuOptions, EnumMenuItem item) async { + List entries = []; + try { + for (var opt in menuOptions) { + final bool isDefault = await menuDataSource.processDisplayDefault(item, opt, entries); + if (isDefault) continue; + final licenseValue = await LicenseRepositoryImpl().getLicense(opt.value); + if (licenseValue != null) { + final licenseMap = await stringToMap(licenseValue); + final display = licenseMap['display'] ?? 'INVISIVEL'; + final startDate = licenseMap['startDate'] ?? ''; + final expirationDate = licenseMap['expirationDate'] ?? ''; + final isStarted = await menuDataSource.processStartDate(startDate, opt); + final isExpired = await menuDataSource.processExpirationDate(expirationDate, opt); + if (isStarted && !isExpired) { + await menuDataSource.processDisplay(item, display, opt, entries); + } + } + } + } catch (e, s) { + log('Error generating menu entries: $e', stackTrace: s); + } + return entries; + } + + + + +} \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/domain/entities/index.dart b/lib/shared/components/molecules/menu/domain/entities/index.dart index ab4ce12a..329a4c9c 100644 --- a/lib/shared/components/molecules/menu/domain/entities/index.dart +++ b/lib/shared/components/molecules/menu/domain/entities/index.dart @@ -1,3 +1 @@ -export 'menu_entry.dart'; export 'menu_item.dart'; -export 'menu_view.dart'; diff --git a/lib/shared/components/molecules/menu/domain/entities/menu_entry.dart b/lib/shared/components/molecules/menu/domain/entities/menu_entry.dart deleted file mode 100644 index 6a7bb9e7..00000000 --- a/lib/shared/components/molecules/menu/domain/entities/menu_entry.dart +++ /dev/null @@ -1,20 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/modules/domain/entities/base_module.dart'; - - -class MenuEntry implements BaseModule { - @override - IconData get icon => throw UnimplementedError(); - - @override - String get name => throw UnimplementedError(); - - @override - String get route => throw UnimplementedError(); - - @override - String get value => throw UnimplementedError(); -} - - diff --git a/lib/shared/components/molecules/menu/domain/entities/menu_item.dart b/lib/shared/components/molecules/menu/domain/entities/menu_item.dart index 479ce679..31b36da6 100644 --- a/lib/shared/components/molecules/menu/domain/entities/menu_item.dart +++ b/lib/shared/components/molecules/menu/domain/entities/menu_item.dart @@ -9,11 +9,11 @@ enum EnumMenuItem { MenuItem getInstance(final Function() action, final String title, final IconData icon) { switch (this) { case EnumMenuItem.button: - return MenuButtonWidget(action: action, title: title, icon: icon); + return ButtonMenuItem(action: action, title: title, icon: icon); case EnumMenuItem.card: - return MenuCardItem(action: action, title: title, icon: icon); + return CardMenuItem(action: action, title: title, icon: icon); case EnumMenuItem.tile: - return MenuCardItem(action: action, title: title, icon: icon); + return CardMenuItem(action: action, title: title, icon: icon); } } } diff --git a/lib/shared/components/molecules/menu/domain/entities/menu_view.dart b/lib/shared/components/molecules/menu/domain/entities/menu_view.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart b/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart new file mode 100644 index 00000000..1abf171d --- /dev/null +++ b/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart @@ -0,0 +1,6 @@ +import 'package:hub/shared/components/molecules/menu/domain/entities/menu_item.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; + +abstract class MenuRepository { + Future> generateMenuEntries(List menuOptions, EnumMenuItem item); +} \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/presentation/blocs/menu_view_bloc.dart b/lib/shared/components/molecules/menu/presentation/blocs/menu_view_bloc.dart index fab4e6f0..fa22cbfc 100644 --- a/lib/shared/components/molecules/menu/presentation/blocs/menu_view_bloc.dart +++ b/lib/shared/components/molecules/menu/presentation/blocs/menu_view_bloc.dart @@ -1,17 +1,11 @@ import 'dart:async'; -import 'dart:convert'; -import 'dart:developer'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; -import 'package:hub/flutter_flow/custom_functions.dart'; -import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'package:hub/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart'; import 'package:hub/shared/components/molecules/menu/index.dart'; import 'package:hub/shared/components/molecules/modules/index.dart'; -import 'package:hub/shared/extensions/dialog_extensions.dart'; -import 'package:hub/shared/services/authentication/authentication_service.dart'; + class MenuViewEvent {} @@ -32,15 +26,14 @@ class MenuViewState { class MenuViewBloc extends Bloc { final MenuView style; final EnumMenuItem item; - final bool expandable; final List menuOptions; late StreamSubscription _completer; - MenuViewBloc({required this.style, required this.item, required this.expandable, required this.menuOptions}) : super(MenuViewState()) { + MenuViewBloc({required this.style, required this.item, required this.menuOptions}) : super(MenuViewState()) { on((event, emit) async { await LicenseRemoteDataSourceImpl().waitForSaveCompletion(); - final entries = await generateMenuEntries(); + final entries = await MenuRepositoryImpl().generateMenuEntries(menuOptions, item); emit(state.copyWith(menuEntries: entries)); }); @@ -54,104 +47,6 @@ class MenuViewBloc extends Bloc { _completer.cancel(); return super.close(); } + - Future addMenuEntry(List entries, IconData icon, String text, Function() action) async { - entries.add( - item == EnumMenuItem.button - ? MenuButtonWidget(icon: icon, action: action, title: text) - : item == EnumMenuItem.card - ? MenuCardItem(icon: icon, action: action, title: text) - : item == EnumMenuItem.tile - ? MenuCardItem(icon: icon, action: action, title: text) - : null, - ); - return null; - } - - Future> generateMenuEntries() async { - List entries = []; - try { - for (var opt in menuOptions) { - String? licenseValue = await LicenseRepositoryImpl().g(opt.value); - if (licenseValue != null) { - Map licenseMap = await stringToMap(licenseValue); - final String display = licenseMap['display'] ?? 'INVISIVEL'; - final String startDate = licenseMap['startDate'] ?? ''; - final String expirationDate = licenseMap['expirationDate'] ?? ''; - final bool isStarted = await processStartDate(startDate, opt); - final bool isExpired = await processExpirationDate(expirationDate, opt); - if (isStarted && !isExpired) { - await processDisplay(display, opt, entries); - } - } - } - } catch (e, s) { - log('Error generating menu entries: $e', stackTrace: s); - - } - return entries; - } - - Future processDisplay(String display, MenuEntry opt, List entries) async { - try { - switch (display) { - case 'VISIVEL': - if(opt.value == 'FRE-HUB-LOGOUT') - await addMenuEntry(entries, opt.icon, opt.name, () async { - await AuthenticationService.signOut(navigatorKey.currentContext!); - }); - else - await addMenuEntry(entries, opt.icon, opt.name, () async { - await nav(opt.route); - }); - break; - case 'DESABILITADO': - await addMenuEntry(entries, opt.icon, opt.name, () async { - await DialogUnavailable.unavailableFeature(navigatorKey.currentContext!); - }); - break; - case 'INVISIVEL': - default: - break; - } - } catch (e) { - log('Error processing display for module ${opt.value}: $e'); - } - } - - Future processStartDate(String startDate, MenuEntry opt) async { - try { - if (startDate.isEmpty) return true; - final DateTime? start = DateTime.tryParse(startDate); - if (start != null) { - return DateTime.now().isAfter(start); - } - } catch (e) { - log('Error processing start date for module ${opt.value}: $e'); - } - return false; - } - - Future processExpirationDate(String expirationDate, MenuEntry opt) async { - try { - if (expirationDate.isEmpty) return false; - final DateTime? expiration = DateTime.tryParse(expirationDate); - if (expiration != null) { - return DateTime.now().isAfter(expiration); - } - } catch (e) { - log('Error processing expiration date for module ${opt.value}: $e'); - } - return false; - } - - Future nav(String link) async { - navigatorKey.currentContext!.push(link, extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }); - } } diff --git a/lib/shared/components/molecules/menu/presentation/index.dart b/lib/shared/components/molecules/menu/presentation/index.dart index 688818c6..2bb09756 100644 --- a/lib/shared/components/molecules/menu/presentation/index.dart +++ b/lib/shared/components/molecules/menu/presentation/index.dart @@ -1,2 +1,3 @@ export 'blocs/index.dart'; export 'widgets/index.dart'; +export 'mappers/index.dart'; \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/presentation/mappers/index.dart b/lib/shared/components/molecules/menu/presentation/mappers/index.dart new file mode 100644 index 00000000..8b9365b1 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/mappers/index.dart @@ -0,0 +1 @@ +export 'menu_entry.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart b/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart new file mode 100644 index 00000000..39b8e3c7 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart @@ -0,0 +1,219 @@ +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/components/molecules/modules/domain/entities/base_module.dart'; + +enum MenuEntryType { Home, Drawer, Property } + +class MenuEntry implements BaseModule { + final String value; + final IconData icon; + final String name; + final String route; + final List types; + + const MenuEntry({ + required this.value, + required this.icon, + required this.name, + required this.route, + required this.types, + }); + + static List entries = [ + MenuEntry( + value: 'FRE-HUB-MESSAGES', + icon: Icons.chat_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Consultar Mensagens', + enText: 'Messages History', + ), + route: '/messageHistoryPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-LIBERATIONS', + icon: Icons.how_to_reg_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Consultar Liberações', + enText: 'Liberations History', + ), + route: '/liberationHistory', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-RESERVATIONS', + icon: Icons.event_available, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Reservas', + enText: 'Reservations', + ), + route: '/reservation', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-ACCESS', + icon: Icons.transfer_within_a_station_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Consultar Acessos', + enText: 'Access History', + ), + route: '/acessHistoryPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-PETS', + icon: Icons.pets, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Pets', + enText: 'Pets', + ), + route: '/petsPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-PEOPLE', + icon: Icons.groups, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Pessoas na Propriedade', + enText: 'People on the Property', + ), + route: '/peopleOnThePropertyPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-ORDERS', + icon: Icons.inventory_2_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Minhas Encomendas', + enText: 'My Orders', + ), + route: '/packageOrder', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-COMPLETE-SCHEDULE', + icon: Icons.event, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Agenda Completa', + enText: 'Complete Schedule', + ), + route: '/scheduleCompleteVisitPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-AGE-PROV-PRESTADOR', + icon: Icons.engineering_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Agendar Prestadores', + enText: 'Schedule Providers', + ), + route: '/provisionalSchedule', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-AGE-PROV-DELIVERY', + icon: Icons.sports_motorsports_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Agendar Delivery', + enText: 'Schedule Delivery', + ), + route: '/deliverySchedule', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-FASTPASS', + icon: Icons.attach_email_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Fast Pass', + enText: 'Fast Pass', + ), + route: '/fastPassPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-QRCODE', + icon: Icons.qr_code, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'QRCode de Acesso', + enText: 'Access QRCode', + ), + route: '/qrCodePage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-VISITORS', + icon: Icons.person_add_alt_1_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Cadastrar Visitantes', + enText: 'Register Visitors', + ), + route: '/registerVisitorPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-PROPERTY', + icon: Icons.home, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Sobre a Propriedade', + enText: 'About the Property', + ), + route: '/aboutProperty', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-SETTINGS', + icon: Icons.settings, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Configurações', + enText: 'Settings', + ), + route: '/preferencesSettings', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-LOGOUT', + icon: Icons.exit_to_app, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Sair', + enText: 'Logout', + ), + route: '/WelcomePage', + types: [MenuEntryType.Drawer], + ), + MenuEntry( + value: 'FRE-HUB-RESIDENTS', + icon: Icons.groups, + name: 'Residents', + route: '/residentsOnThePropertyPage', + types: [MenuEntryType.Property], + ), + MenuEntry( + value: 'FRE-HUB-VEHICLES', + icon: Icons.directions_car, + name: 'Vehicles', + route: '/vehiclesOnThePropertyPage', + types: [MenuEntryType.Property], + ), + MenuEntry( + value: 'FRE-HUB-OPENED-VISITS', + icon: Icons.perm_contact_calendar, + name: 'Opened Visits', + route: '/openedVisitsPage', + types: [MenuEntryType.Property], + ), + MenuEntry( + value: 'FRE-HUB-PETS-HISTORY', + icon: Icons.pets, + name: 'Pets History', + route: '/petsOnThePropertyPage', + types: [MenuEntryType.Property], + ), + ]; + + static List getEntriesByType(MenuEntryType type) { + return entries.where((entry) => entry.types.contains(type)).toList(); + } +} + + diff --git a/lib/shared/components/molecules/menu/presentation/widgets/index.dart b/lib/shared/components/molecules/menu/presentation/widgets/index.dart index 3101060a..800e0aa8 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/index.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/index.dart @@ -1,4 +1,4 @@ export 'menu_item/index.dart'; export 'menu_view/index.dart'; -export 'menu_factory/index.dart'; -export 'menu_entry/index.dart'; + +export 'menu_factory.dart'; \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/drawer_menu_entry.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/drawer_menu_entry.dart deleted file mode 100644 index 5b86aae6..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/drawer_menu_entry.dart +++ /dev/null @@ -1,228 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/flutter_flow/internationalization.dart'; -import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - -enum DrawerMenuEntries implements MenuEntry { - providerSchedule, - deliverySchedule, - fastPass, - completeSchedule, - orders, - reservations, - visitors, - qrCode, - pets, - access, - liberations, - messages, - aboutProperty, - peopleOnTheProperty, - settings, - logout; - - @override - String get value { - switch (this) { - case DrawerMenuEntries.messages: - return 'FRE-HUB-MESSAGES'; - case DrawerMenuEntries.liberations: - return 'FRE-HUB-LIBERATIONS'; - case DrawerMenuEntries.reservations: - return 'FRE-HUB-RESERVATIONS'; - case DrawerMenuEntries.access: - return 'FRE-HUB-ACCESS'; - case DrawerMenuEntries.pets: - return 'FRE-HUB-PETS'; - case DrawerMenuEntries.orders: - return 'FRE-HUB-ORDERS'; - case DrawerMenuEntries.completeSchedule: - return 'FRE-HUB-COMPLETE-SCHEDULE'; - case DrawerMenuEntries.providerSchedule: - return 'FRE-HUB-AGE-PROV-PRESTADOR'; - case DrawerMenuEntries.deliverySchedule: - return 'FRE-HUB-AGE-PROV-DELIVERY'; - case DrawerMenuEntries.aboutProperty: - return 'FRE-HUB-PROPERTY'; - case DrawerMenuEntries.fastPass: - return 'FRE-HUB-FASTPASS'; - case DrawerMenuEntries.visitors: - return 'FRE-HUB-VISITORS'; - case DrawerMenuEntries.qrCode: - return 'FRE-HUB-QRCODE'; - case DrawerMenuEntries.peopleOnTheProperty: - return 'FRE-HUB-PEOPLE'; - case DrawerMenuEntries.settings: - return 'FRE-HUB-SETTINGS'; - case DrawerMenuEntries.logout: - return 'FRE-HUB-LOGOUT'; - default: - return ''; - } - } - - @override - String get name { - switch (this) { - case DrawerMenuEntries.messages: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Consultar Mensagens', - enText: 'Messages History', - ); - case DrawerMenuEntries.liberations: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Consultar Liberações', - enText: 'Liberations History', - ); - case DrawerMenuEntries.reservations: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Reservas', - enText: 'Reservations', - ); - case DrawerMenuEntries.access: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Consultar Acessos', - enText: 'Access History', - ); - case DrawerMenuEntries.pets: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Pets', - enText: 'Pets', - ); - case DrawerMenuEntries.peopleOnTheProperty: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Pessoas na Propriedade', - enText: 'People on the Property', - ); - case DrawerMenuEntries.orders: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Minhas Encomendas', - enText: 'My Orders', - ); - case DrawerMenuEntries.completeSchedule: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Agenda Completa', - enText: 'Complete Schedule', - ); - case DrawerMenuEntries.providerSchedule: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Agendar Prestadores', - enText: 'Schedule Providers', - ); - case DrawerMenuEntries.deliverySchedule: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Agendar Delivery', - enText: 'Schedule Delivery', - ); - case DrawerMenuEntries.fastPass: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Fast Pass', - enText: 'Fast Pass', - ); - case DrawerMenuEntries.qrCode: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'QRCode de Acesso', - enText: 'Access QRCode', - ); - case DrawerMenuEntries.visitors: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Cadastrar Visitantes', - enText: 'Register Visitors', - ); - case DrawerMenuEntries.aboutProperty: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Sobre a Propriedade', - enText: 'About the Property', - ); - case DrawerMenuEntries.settings: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Configurações', - enText: 'Settings', - ); - case DrawerMenuEntries.logout: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Sair', - enText: 'Logout', - ); - } - } - - @override - IconData get icon { - switch (this) { - case DrawerMenuEntries.messages: - return Icons.chat_outlined; - case DrawerMenuEntries.liberations: - return Icons.how_to_reg_outlined; - case DrawerMenuEntries.reservations: - return Icons.event_available; - case DrawerMenuEntries.access: - return Icons.transfer_within_a_station_outlined; - case DrawerMenuEntries.pets: - return Icons.pets; - case DrawerMenuEntries.peopleOnTheProperty: - return Icons.groups; - case DrawerMenuEntries.orders: - return Icons.inventory_2_outlined; - case DrawerMenuEntries.completeSchedule: - return Icons.event; - case DrawerMenuEntries.providerSchedule: - return Icons.engineering_outlined; - case DrawerMenuEntries.deliverySchedule: - return Icons.sports_motorsports_outlined; - case DrawerMenuEntries.fastPass: - return Icons.attach_email_outlined; - case DrawerMenuEntries.qrCode: - return Icons.qr_code; - case DrawerMenuEntries.visitors: - return Icons.person_add_alt_1_outlined; - case DrawerMenuEntries.aboutProperty: - return Icons.home; - case DrawerMenuEntries.settings: - return Icons.settings; - case DrawerMenuEntries.logout: - return Icons.exit_to_app; - } - } - - @override - String get route { - switch (this) { - case DrawerMenuEntries.messages: - return '/messageHistoryPage'; - case DrawerMenuEntries.liberations: - return '/liberationHistory'; - case DrawerMenuEntries.reservations: - return '/reservation'; - case DrawerMenuEntries.access: - return '/acessHistoryPage'; - case DrawerMenuEntries.pets: - return '/petsPage'; - case DrawerMenuEntries.peopleOnTheProperty: - return '/peopleOnThePropertyPage'; - case DrawerMenuEntries.orders: - return '/packageOrder'; - case DrawerMenuEntries.completeSchedule: - return '/scheduleCompleteVisitPage'; - case DrawerMenuEntries.providerSchedule: - return '/provisionalSchedule'; - case DrawerMenuEntries.aboutProperty: - return '/aboutProperty'; - case DrawerMenuEntries.deliverySchedule: - return '/deliverySchedule'; - case DrawerMenuEntries.fastPass: - return '/fastPassPage'; - case DrawerMenuEntries.qrCode: - return '/qrCodePage'; - case DrawerMenuEntries.visitors: - return '/registerVisitorPage'; - case DrawerMenuEntries.settings: - return '/preferencesSettings'; - case DrawerMenuEntries.logout: - return '/WelcomePage'; - default: - return ''; - } - } - -} diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/home_menu_entry.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/home_menu_entry.dart deleted file mode 100644 index 3915c3d9..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/home_menu_entry.dart +++ /dev/null @@ -1,217 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/flutter_flow/internationalization.dart'; -import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - -enum HomeMenuEntries implements MenuEntry { - providerSchedule, - deliverySchedule, - fastPass, - completeSchedule, - orders, - reservations, - visitors, - qrCode, - pets, - access, - liberations, - messages, - aboutProperty, - peopleOnTheProperty, - settings; - - @override - String get value { - switch (this) { - case HomeMenuEntries.messages: - return 'FRE-HUB-MESSAGES'; - case HomeMenuEntries.liberations: - return 'FRE-HUB-LIBERATIONS'; - case HomeMenuEntries.reservations: - return 'FRE-HUB-RESERVATIONS'; - case HomeMenuEntries.access: - return 'FRE-HUB-ACCESS'; - case HomeMenuEntries.pets: - return 'FRE-HUB-PETS'; - case HomeMenuEntries.orders: - return 'FRE-HUB-ORDERS'; - case HomeMenuEntries.completeSchedule: - return 'FRE-HUB-COMPLETE-SCHEDULE'; - case HomeMenuEntries.providerSchedule: - return 'FRE-HUB-AGE-PROV-PRESTADOR'; - case HomeMenuEntries.deliverySchedule: - return 'FRE-HUB-AGE-PROV-DELIVERY'; - case HomeMenuEntries.aboutProperty: - return 'FRE-HUB-PROPERTY'; - case HomeMenuEntries.fastPass: - return 'FRE-HUB-FASTPASS'; - case HomeMenuEntries.visitors: - return 'FRE-HUB-VISITORS'; - case HomeMenuEntries.qrCode: - return 'FRE-HUB-QRCODE'; - case HomeMenuEntries.peopleOnTheProperty: - return 'FRE-HUB-PEOPLE'; - case HomeMenuEntries.settings: - return 'FRE-HUB-SETTINGS'; - default: - return ''; - } - } - - @override - String get name { - switch (this) { - case HomeMenuEntries.messages: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Consultar Mensagens', - enText: 'Messages History', - ); - case HomeMenuEntries.liberations: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Consultar Liberações', - enText: 'Liberations History', - ); - case HomeMenuEntries.reservations: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Reservas', - enText: 'Reservations', - ); - case HomeMenuEntries.access: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Consultar Acessos', - enText: 'Access History', - ); - case HomeMenuEntries.pets: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Pets', - enText: 'Pets', - ); - case HomeMenuEntries.peopleOnTheProperty: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Pessoas na Propriedade', - enText: 'People on the Property', - ); - case HomeMenuEntries.orders: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Minhas Encomendas', - enText: 'My Orders', - ); - case HomeMenuEntries.completeSchedule: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Agenda Completa', - enText: 'Complete Schedule', - ); - case HomeMenuEntries.providerSchedule: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Agendar Prestadores', - enText: 'Schedule Providers', - ); - case HomeMenuEntries.deliverySchedule: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Agendar Delivery', - enText: 'Schedule Delivery', - ); - case HomeMenuEntries.fastPass: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Fast Pass', - enText: 'Fast Pass', - ); - case HomeMenuEntries.qrCode: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'QRCode de Acesso', - enText: 'Access QRCode', - ); - case HomeMenuEntries.visitors: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Cadastrar Visitantes', - enText: 'Register Visitors', - ); - case HomeMenuEntries.aboutProperty: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Sobre a Propriedade', - enText: 'About the Property', - ); - case HomeMenuEntries.settings: - return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Configurações', - enText: 'Settings', - ); - } - } - - @override - IconData get icon { - switch (this) { - case HomeMenuEntries.messages: - return Icons.chat_outlined; - case HomeMenuEntries.liberations: - return Icons.how_to_reg_outlined; - case HomeMenuEntries.reservations: - return Icons.event_available; - case HomeMenuEntries.access: - return Icons.transfer_within_a_station_outlined; - case HomeMenuEntries.pets: - return Icons.pets; - case HomeMenuEntries.peopleOnTheProperty: - return Icons.groups; - case HomeMenuEntries.orders: - return Icons.inventory_2_outlined; - case HomeMenuEntries.completeSchedule: - return Icons.event; - case HomeMenuEntries.providerSchedule: - return Icons.engineering_outlined; - case HomeMenuEntries.deliverySchedule: - return Icons.sports_motorsports_outlined; - case HomeMenuEntries.fastPass: - return Icons.attach_email_outlined; - case HomeMenuEntries.qrCode: - return Icons.qr_code; - case HomeMenuEntries.visitors: - return Icons.person_add_alt_1_outlined; - case HomeMenuEntries.aboutProperty: - return Icons.home; - case HomeMenuEntries.settings: - return Icons.settings; - } - } - - @override - String get route { - switch (this) { - case HomeMenuEntries.messages: - return '/messageHistoryPage'; - case HomeMenuEntries.liberations: - return '/liberationHistory'; - case HomeMenuEntries.reservations: - return '/reservation'; - case HomeMenuEntries.access: - return '/acessHistoryPage'; - case HomeMenuEntries.pets: - return '/petsPage'; - case HomeMenuEntries.peopleOnTheProperty: - return '/peopleOnThePropertyPage'; - case HomeMenuEntries.orders: - return '/packageOrder'; - case HomeMenuEntries.completeSchedule: - return '/scheduleCompleteVisitPage'; - case HomeMenuEntries.providerSchedule: - return '/provisionalSchedule'; - case HomeMenuEntries.aboutProperty: - return '/aboutProperty'; - case HomeMenuEntries.deliverySchedule: - return '/deliverySchedule'; - case HomeMenuEntries.fastPass: - return '/fastPassPage'; - case HomeMenuEntries.qrCode: - return '/qrCodePage'; - case HomeMenuEntries.visitors: - return '/registerVisitorPage'; - case HomeMenuEntries.settings: - return '/preferencesSettings'; - default: - return ''; - } - } - - -} diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/index.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/index.dart deleted file mode 100644 index 9b5d30cf..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/index.dart +++ /dev/null @@ -1,4 +0,0 @@ -export 'drawer_menu_entry.dart'; -export 'home_menu_entry.dart'; -export 'property_menu_entry.dart'; -export 'menu_entry_factory.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/menu_entry_factory.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/menu_entry_factory.dart deleted file mode 100644 index 88d11129..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/menu_entry_factory.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - -enum MenuEntries { - home, - drawer, - AboutProperty; - - List get getValues { - switch (this) { - case MenuEntries.home: - return HomeMenuEntries.values.toList(); - case MenuEntries.drawer: - return DrawerMenuEntries.values.toList(); - case MenuEntries.AboutProperty: - return AboutPropertyMenuEntries.values.toList(); - } - } -} - -class MenuEntryFactory { - static List createMenuEntry(MenuEntry type) { - switch (type) { - case HomeMenuEntries _: - return HomeMenuEntries.values.toList(); - case DrawerMenuEntries _: - return DrawerMenuEntries.values.toList(); - case AboutPropertyMenuEntries _: - return AboutPropertyMenuEntries.values.toList(); - default: - throw ArgumentError('Invalid menu entry type'); - } - } - - List buildMenuEntry(MenuEntry type) { - return createMenuEntry(type); - } -} diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/property_menu_entry.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/property_menu_entry.dart deleted file mode 100644 index 5830a53d..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_entry/property_menu_entry.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - -enum AboutPropertyMenuEntries implements MenuEntry { - residents, - vehicles, - openedVisits, - petsHistory; - - @override - String get value { - switch (this) { - case AboutPropertyMenuEntries.openedVisits: - return 'FRE-HUB-OPENED-VISITS'; - case AboutPropertyMenuEntries.vehicles: - return 'FRE-HUB-VEHICLES'; - case AboutPropertyMenuEntries.residents: - return 'FRE-HUB-RESIDENTS'; - case AboutPropertyMenuEntries.petsHistory: - return 'FRE-HUB-PETS-HISTORY'; - default: - return ''; - } - } - - @override - IconData get icon { - switch (this) { - case AboutPropertyMenuEntries.residents: - return Icons.groups; - case AboutPropertyMenuEntries.vehicles: - return Icons.directions_car; - case AboutPropertyMenuEntries.openedVisits: - return Icons.perm_contact_calendar; - case AboutPropertyMenuEntries.petsHistory: - return Icons.pets; - } - } - - @override - String get name { - switch (this) { - case AboutPropertyMenuEntries.residents: - return 'Residents'; - case AboutPropertyMenuEntries.vehicles: - return 'Vehicles'; - case AboutPropertyMenuEntries.openedVisits: - return 'Opened Visits'; - case AboutPropertyMenuEntries.petsHistory: - return 'Pets History'; - } - } - - @override - String get route { - switch (this) { - case AboutPropertyMenuEntries.residents: - return '/residentsOnThePropertyPage'; - case AboutPropertyMenuEntries.vehicles: - return '/vehiclesOnThePropertyPage'; - case AboutPropertyMenuEntries.openedVisits: - return '/openedVisitsPage'; - case AboutPropertyMenuEntries.petsHistory: - return '/petsOnThePropertyPage'; - } - } - - -} diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_view_factory.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart similarity index 87% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_view_factory.dart rename to lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart index 23eb2f8c..927fda08 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_view_factory.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart @@ -7,17 +7,15 @@ import 'package:hub/shared/components/molecules/modules/index.dart'; import 'package:hub/shared/components/molecules/menu/index.dart'; import 'package:hub/shared/utils/loading_util.dart'; -class MenuViewFactory extends StatelessWidget { +class Menufactory extends StatelessWidget { final MenuView view; final EnumMenuItem item; - final bool expandable; - final MenuEntries entry; + final List entry; - const MenuViewFactory({ + const Menufactory({ super.key, required this.view, required this.item, - required this.expandable, required this.entry, }); @@ -49,15 +47,13 @@ class MenuViewFactory extends StatelessWidget { create: (context) => MenuViewBloc( style: view, item: item, - menuOptions: entry.getValues, - expandable: expandable, + menuOptions: entry, )..add(MenuViewEvent()), child: BlocBuilder( builder: (context, state) { if (view == MenuView.list_grid) { return MenuStaggeredView( options: state.menuEntries, - expandable: expandable, item: item, changeMenuStyle: () async {}, isGrid: state.isGrid, @@ -65,7 +61,6 @@ class MenuViewFactory extends StatelessWidget { } else if (view == MenuView.list) { return MenuListView( options: state.menuEntries, - expandable: expandable, item: item, changeMenuStyle: () async {}, ); diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory/index.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory/index.dart deleted file mode 100644 index aa113121..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory/index.dart +++ /dev/null @@ -1 +0,0 @@ -export 'menu_factory.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory/menu_factory.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory/menu_factory.dart deleted file mode 100644 index d5fd0458..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory/menu_factory.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - -class MenuFactory extends StatelessWidget { - final MenuView menuView; - final MenuEntries menuEntry; - final EnumMenuItem menuItem; - - const MenuFactory({ - super.key, - required this.menuView, - required this.menuEntry, - required this.menuItem, - }); - - @override - Widget build(BuildContext context) { - return MenuViewFactory( - view: menuView, - item: menuItem, - expandable: false, - entry: menuEntry, - ); - } -} diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/index.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/index.dart index 375b35a2..6380393e 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/index.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/index.dart @@ -1,3 +1,2 @@ export 'menu_item_button.dart'; export 'menu_item_card.dart'; -export 'menu_item_factory.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart index d95720e6..f5204eca 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart @@ -4,8 +4,8 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/shared/components/molecules/menu/index.dart'; -class MenuButtonWidget extends MenuItem { - const MenuButtonWidget({ +class ButtonMenuItem extends MenuItem { + const ButtonMenuItem({ super.key, required this.action, required this.title, @@ -23,7 +23,7 @@ class MenuButtonWidget extends MenuItem { _MenuButtonWidgetState createState() => _MenuButtonWidgetState(); } -class _MenuButtonWidgetState extends State { +class _MenuButtonWidgetState extends State { bool _isProcessing = false; @override diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart index b8031eac..074d5a22 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart @@ -4,8 +4,8 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/shared/components/molecules/menu/index.dart'; -class MenuCardItem extends MenuItem { - const MenuCardItem({ +class CardMenuItem extends MenuItem { + const CardMenuItem({ super.key, required this.action, required this.title, @@ -23,7 +23,7 @@ class MenuCardItem extends MenuItem { _MenuCardItemState createState() => _MenuCardItemState(); } -class _MenuCardItemState extends State { +class _MenuCardItemState extends State { bool _isProcessing = false; @override diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_factory.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_factory.dart deleted file mode 100644 index dfebce2b..00000000 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_factory.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - -class MenuItemFactory { - static MenuItem createMenuItem( - EnumMenuItem type, { - Key? key, - required Function() action, - required String title, - required IconData icon, - }) { - return MenuItem.create(type, key: key, action: action, title: title, icon: icon); - } - - MenuItem buildMenuItem( - EnumMenuItem type, { - Key? key, - required Function() action, - required String title, - required IconData icon, - }) { - return createMenuItem(type, key: key, action: action, title: title, icon: icon); - } -} diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/index.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/index.dart index 43bd7226..fae17fc0 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/index.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/index.dart @@ -1,3 +1,2 @@ export 'menu_list_view.dart'; export 'menu_staggered_view.dart'; -export 'menu_view_factory.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart index c8c836db..277fd2c3 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart @@ -19,12 +19,10 @@ class MenuListView extends StatefulWidget { const MenuListView({ super.key, required this.changeMenuStyle, - required this.expandable, required this.item, required this.options, }); - final bool expandable; final EnumMenuItem item; final List options; final Future Function()? changeMenuStyle; diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_staggered_view.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_staggered_view.dart index 1d279b70..fbaf5056 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_staggered_view.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_staggered_view.dart @@ -13,9 +13,8 @@ class MenuStaggeredViewModel extends FlutterFlowModel { } class MenuStaggeredView extends StatefulWidget { - const MenuStaggeredView({super.key, required this.changeMenuStyle, required this.expandable, required this.item, required this.options, required this.isGrid}); + const MenuStaggeredView({super.key, required this.changeMenuStyle, required this.item, required this.options, required this.isGrid}); - final bool expandable; final EnumMenuItem item; final bool isGrid; final List options; diff --git a/lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart b/lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart index 13000803..06cc2e68 100644 --- a/lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart +++ b/lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart @@ -7,7 +7,7 @@ import 'package:sqflite/sqflite.dart'; abstract class LicenseLocalDataSource { Future init(); - Future setByKey(final List key, final String display); + Future setDisplayByKey(final List key, final String display); Future isNewVersion(); Future g(String key); Future s(String key, T value); @@ -25,7 +25,7 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource { await DatabaseStorage.instance.init(); } - Future setByKey(final List key, final String display) async { + Future setDisplayByKey(final List key, final String display) async { if (key.isEmpty) return; for (var element in key) { if (element != null) { diff --git a/lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart b/lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart index 18ca868c..8755b436 100644 --- a/lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart +++ b/lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart @@ -55,13 +55,13 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource { .map((module) => module.key) .toList(); - await LicenseLocalDataSourceImpl().setByKey(inactiveModuleKey, 'INVISIVEL'); - await LicenseLocalDataSourceImpl().setByKey(activeModuleKey, 'VISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(inactiveModuleKey, 'INVISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(activeModuleKey, 'VISIVEL'); if (isNewVersion == true) { - await LicenseLocalDataSourceImpl().setByKey(disabledModuleKey, 'VISIVEL'); - await LicenseLocalDataSourceImpl().setByKey(['FRE-HUB-PROPERTY'], 'VISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(disabledModuleKey, 'VISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(['FRE-HUB-PROPERTY'], 'VISIVEL'); } else { - await LicenseLocalDataSourceImpl().setByKey(disabledModuleKey, 'DESABILITADO'); + await LicenseLocalDataSourceImpl().setDisplayByKey(disabledModuleKey, 'DESABILITADO'); } LicenseRepositoryImpl.license.add(true); diff --git a/lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart b/lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart index dcd97a3e..8cb1c549 100644 --- a/lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart +++ b/lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart @@ -17,23 +17,24 @@ class LicenseRepositoryImpl implements LicenseRepository { static final license = BehaviorSubject(); static get stream => license.stream; - Future fetchLicense(bool isNewVersion) async { - return await remoteDataSource.fetchLicenses(isNewVersion); - } + Future updateLicense(bool isNewVersion) async { + await remoteDataSource.setupLicense(database, isNewVersion); + if (isNewVersion) { + return await remoteDataSource.fetchLicenses(isNewVersion); + } + return false; - Future setupLicense(bool isNewVersion) async { - return await remoteDataSource.setupLicense(database, isNewVersion); } Future cleanLicense() async { return await remoteDataSource.cleanLicense(); } - Future g(String key) async { + Future getLicense(String key) async { return await localDataSource.g(key); } - Future s(String key, T value) async { + Future setLicense(String key, T value) async { return await localDataSource.s(key, value); } } diff --git a/lib/shared/components/molecules/modules/domain/entities/license.dart b/lib/shared/components/molecules/modules/domain/entities/license.dart index 49306773..1c3d6410 100644 --- a/lib/shared/components/molecules/modules/domain/entities/license.dart +++ b/lib/shared/components/molecules/modules/domain/entities/license.dart @@ -1,81 +1,41 @@ import 'package:hub/shared/extensions/string_extensions.dart'; -import 'package:hub/shared/helpers/database/database_helper.dart'; import 'package:hub/shared/helpers/storage/base_storage.dart'; import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'module.dart'; enum LicenseKeys { - messages, - liberations, - reservations, - access, - openedVisits, - vehicles, - residents, - pets, - orders, - completeSchedule, - providerSchedule, - deliverySchedule, - property, - fastPass, - visitors, - qrCode, - people, - petsHistory, - settings, - logout, + + messages('FRE-HUB-MESSAGES'), + liberations('FRE-HUB-LIBERATIONS'), + reservations('FRE-HUB-RESERVATIONS'), + access('FRE-HUB-ACCESS'), + openedVisits('FRE-HUB-OPENED-VISITS'), + vehicles('FRE-HUB-VEHICLES'), + residents('FRE-HUB-RESIDENTS'), + pets('FRE-HUB-PETS'), + orders('FRE-HUB-ORDERS'), + completeSchedule('FRE-HUB-COMPLETE-SCHEDULE'), + providerSchedule('FRE-HUB-AGE-PROV-PRESTADOR'), + deliverySchedule('FRE-HUB-AGE-PROV-DELIVERY'), + property('FRE-HUB-PROPERTY'), + fastPass('FRE-HUB-FASTPASS'), + visitors('FRE-HUB-VISITORS'), + qrCode('FRE-HUB-QRCODE'), + people('FRE-HUB-PEOPLE'), + petsHistory('FRE-HUB-PETS-HISTORY'), + settings('FRE-HUB-SETTINGS'), + logout('FRE-HUB-LOGOUT'); + + + final String value; + const LicenseKeys(this.value); } -extension LicenseKeysExtension on LicenseKeys { - String get value { - switch (this) { - case LicenseKeys.messages: - return 'FRE-HUB-MESSAGES'; - case LicenseKeys.liberations: - return 'FRE-HUB-LIBERATIONS'; - case LicenseKeys.reservations: - return 'FRE-HUB-RESERVATIONS'; - case LicenseKeys.access: - return 'FRE-HUB-ACCESS'; - case LicenseKeys.openedVisits: - return 'FRE-HUB-OPENED-VISITS'; - case LicenseKeys.vehicles: - return 'FRE-HUB-VEHICLES'; - case LicenseKeys.residents: - return 'FRE-HUB-RESIDENTS'; - case LicenseKeys.pets: - return 'FRE-HUB-PETS'; - case LicenseKeys.orders: - return 'FRE-HUB-ORDERS'; - case LicenseKeys.completeSchedule: - return 'FRE-HUB-COMPLETE-SCHEDULE'; - case LicenseKeys.providerSchedule: - return 'FRE-HUB-AGE-PROV-PRESTADOR'; - case LicenseKeys.deliverySchedule: - return 'FRE-HUB-AGE-PROV-DELIVERY'; - case LicenseKeys.property: - return 'FRE-HUB-PROPERTY'; - case LicenseKeys.fastPass: - return 'FRE-HUB-FASTPASS'; - case LicenseKeys.visitors: - return 'FRE-HUB-VISITORS'; - case LicenseKeys.qrCode: - return 'FRE-HUB-QRCODE'; - case LicenseKeys.people: - return 'FRE-HUB-PEOPLE'; - case LicenseKeys.petsHistory: - return 'FRE-HUB-PETS-HISTORY'; - case LicenseKeys.settings: - return 'FRE-HUB-SETTINGS'; - case LicenseKeys.logout: - return 'FRE-HUB-LOGOUT'; - } - } -} + + class License { final List modules; @@ -84,28 +44,6 @@ class License { this.modules, ); - // static List mods = [ - // 'FRE-HUB-MESSAGES', - // 'FRE-HUB-LIBERATIONS', - // 'FRE-HUB-RESERVATIONS', - // 'FRE-HUB-ACCESS', - // 'FRE-HUB-OPENED-VISITS', - // 'FRE-HUB-VEHICLES', - // 'FRE-HUB-RESIDENTS', - // 'FRE-HUB-PETS', - // 'FRE-HUB-ORDERS', - // 'FRE-HUB-COMPLETE-SCHEDULE', - // 'FRE-HUB-AGE-PROV-PRESTADOR', - // 'FRE-HUB-AGE-PROV-DELIVERY', - // 'FRE-HUB-PROPERTY', - // 'FRE-HUB-FASTPASS', - // 'FRE-HUB-VISITORS', - // 'FRE-HUB-QRCODE', - // 'FRE-HUB-PEOPLE', - // 'FRE-HUB-PETS-HISTORY' - // 'FRE-HUB-SETTINGS', - // 'FRE-HUB-LOGOUT', - // ]; static Future _proceessOldVersion(LicenseKeys key) async { switch(key) { @@ -125,22 +63,25 @@ class License { } static Future _precessWpp() async { - final bool whatsapp = await StorageHelper().g(KeychainStorageKey.whatsapp.value).then((v) => v.toBoolean()); + final bool whatsapp = await StorageHelper().get(KeychainStorageKey.whatsapp.value).then((v) => v.toBoolean()); if (whatsapp) return ModuleStatus.active.key; else return ModuleStatus.inactive.key; } static Future _processProvisional() async { - final bool provisional = await StorageHelper().g(KeychainStorageKey.provisional.value).then((v) => v.toBoolean()); + final bool provisional = await StorageHelper().get(KeychainStorageKey.provisional.value).then((v) => v.toBoolean()); if (provisional) return ModuleStatus.active.key; else return ModuleStatus.inactive.key; } static Future _processPets() async { - final bool pets = await StorageHelper().g(KeychainStorageKey.pets.value).then((v) => v.toBoolean()); + final bool pets = await StorageHelper().get(KeychainStorageKey.pets.value).then((v) => v.toBoolean()); if (pets) return ModuleStatus.active.key; else return ModuleStatus.inactive.key; } + static getKeyByModule(String s) { + + } static Future getLicense(bool isNewVersion) async { @@ -290,588 +231,3 @@ class License { } } -// import 'package:equatable/equatable.dart'; -// import 'module.dart'; - -// import 'package:flutter/material.dart'; -// import 'package:hub/flutter_flow/internationalization.dart'; -// import 'package:hub/flutter_flow/nav/nav.dart'; -// import 'package:hub/shared/components/molecules/modules/index.dart'; - -// enum ModuleStatus { active, inactive, disabled } - -// extension ModuleStatusExtension on ModuleStatus { -// String get value { -// switch (this) { -// case ModuleStatus.active: -// return 'VISIVEL'; -// case ModuleStatus.inactive: -// return 'INVISIVEL'; -// case ModuleStatus.disabled: -// return 'DESABILITADO'; -// } -// } -// } - -// class ModuleExt { -// final String value; -// final String name; -// final IconData icon; -// final String route; -// final (ModuleStatus inOldVersion, ModuleStatus inNewVersion) status; - -// const ModuleExt({ -// required this.value, -// required this.name, -// required this.icon, -// required this.route, -// required this.status, -// }); - -// static List get license => [ -// ModuleExt( -// value: 'FRE-HUB-MESSAGES', -// name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Consultar Mensagens', -// enText: 'Messages History', -// ), -// icon: Icons.chat_outlined, -// route: '/messageHistoryPage', -// status: (ModuleStatus.active, ModuleStatus.disabled), -// ), -// ]; -// } - -// enum EModule implements BaseModule { -// providerSchedule, -// deliverySchedule, -// fastPass, -// completeSchedule, -// orders, -// reservations, -// visitors, -// vehicles, -// residents, -// openedVisits, -// qrCode, -// pets, -// access, -// liberations, -// messages, -// aboutProperty, -// petsHistory, -// peopleOnTheProperty, -// settings, -// logout; - -// @override -// String get value { -// switch (this) { -// case Module.messages: -// return 'FRE-HUB-MESSAGES'; -// case Module.liberations: -// return 'FRE-HUB-LIBERATIONS'; -// case Module.reservations: -// return 'FRE-HUB-RESERVATIONS'; -// case Module.access: -// return 'FRE-HUB-ACCESS'; -// case Module.openedVisits: -// return 'FRE-HUB-OPENED-VISITS'; -// case Module.vehicles: -// return 'FRE-HUB-VEHICLES'; -// case Module.residents: -// return 'FRE-HUB-RESIDENTS'; -// case Module.pets: -// return 'FRE-HUB-PETS'; -// case Module.orders: -// return 'FRE-HUB-ORDERS'; -// case Module.completeSchedule: -// return 'FRE-HUB-COMPLETE-SCHEDULE'; -// case Module.providerSchedule: -// return 'FRE-HUB-AGE-PROV-PRESTADOR'; -// case Module.deliverySchedule: -// return 'FRE-HUB-AGE-PROV-DELIVERY'; -// case Module.aboutProperty: -// return 'FRE-HUB-PROPERTY'; -// case Module.fastPass: -// return 'FRE-HUB-FASTPASS'; -// case Module.visitors: -// return 'FRE-HUB-VISITORS'; -// case Module.qrCode: -// return 'FRE-HUB-QRCODE'; -// case Module.peopleOnTheProperty: -// return 'FRE-HUB-PEOPLE'; -// case Module.petsHistory: -// return 'FRE-HUB-PETS-HISTORY'; -// default: -// return ''; -// } -// } - -// @override -// String get name { -// switch (this) { -// case Module.messages: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Consultar Mensagens', -// enText: 'Messages History', -// ); -// case Module.liberations: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Consultar Liberações', -// enText: 'Liberations History', -// ); -// case Module.reservations: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Reservas', -// enText: 'Reservations', -// ); -// case Module.access: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Consultar Acessos', -// enText: 'Access History', -// ); -// case Module.openedVisits: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Visitas em Aberto', -// enText: 'Opened Visits', -// ); -// case Module.vehicles: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Veículos', -// enText: 'Vehicles', -// ); -// case Module.residents: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Moradores', -// enText: 'Residents', -// ); -// case Module.pets: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Pets', -// enText: 'Pets', -// ); -// case Module.petsHistory: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Pets', -// enText: 'Pets', -// ); -// case Module.peopleOnTheProperty: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Pessoas na Propriedade', -// enText: 'People on the Property', -// ); -// case Module.orders: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Minhas Encomendas', -// enText: 'My Orders', -// ); -// case Module.completeSchedule: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Agenda Completa', -// enText: 'Complete Schedule', -// ); -// case Module.providerSchedule: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Agendar Prestadores', -// enText: 'Schedule Providers', -// ); -// case Module.deliverySchedule: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Agendar Delivery', -// enText: 'Schedule Delivery', -// ); -// case Module.fastPass: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Fast Pass', -// enText: 'Fast Pass', -// ); -// case Module.qrCode: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'QRCode de Acesso', -// enText: 'Access QRCode', -// ); -// case Module.visitors: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Cadastrar Visitantes', -// enText: 'Register Visitors', -// ); -// case Module.aboutProperty: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Sobre a Propriedade', -// enText: 'About the Property', -// ); -// case Module.settings: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Configurações', -// enText: 'Settings', -// ); -// case Module.logout: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Sair', -// enText: 'Logout', -// ); -// } -// } - -// @override -// IconData get icon { -// switch (this) { -// case Module.messages: -// return Icons.chat_outlined; -// case Module.liberations: -// return Icons.how_to_reg_outlined; -// case Module.reservations: -// return Icons.event_available; -// case Module.access: -// return Icons.transfer_within_a_station_outlined; -// case Module.openedVisits: -// return Icons.perm_contact_calendar; -// case Module.vehicles: -// return Icons.directions_car; -// case Module.residents: -// return Icons.groups; -// case Module.pets: -// return Icons.pets; -// case Module.petsHistory: -// return Icons.pets; -// case Module.peopleOnTheProperty: -// return Icons.groups; -// case Module.orders: -// return Icons.inventory_2_outlined; -// case Module.completeSchedule: -// return Icons.event; -// case Module.providerSchedule: -// return Icons.engineering_outlined; -// case Module.deliverySchedule: -// return Icons.sports_motorsports_outlined; -// case Module.fastPass: -// return Icons.attach_email_outlined; -// case Module.qrCode: -// return Icons.qr_code; -// case Module.visitors: -// return Icons.person_add_alt_1_outlined; -// case Module.aboutProperty: -// return Icons.home; -// case Module.settings: -// return Icons.settings; -// case Module.logout: -// return Icons.logout; -// } -// } - -// @override -// String get route { -// switch (this) { -// case Module.messages: -// return '/messageHistoryPage'; -// case Module.liberations: -// return '/liberationHistory'; -// case Module.reservations: -// return '/reservation'; -// case Module.access: -// return '/acessHistoryPage'; -// case Module.openedVisits: -// return '/visitsOnThePropertyPage'; -// case Module.vehicles: -// return '/vehiclesOnThePropertyPage'; -// case Module.residents: -// return '/residentsOnThePropertyPage'; -// case Module.pets: -// return '/petsPage'; -// case Module.petsHistory: -// return '/petsHistoryPage'; -// case Module.peopleOnTheProperty: -// return '/peopleOnThePropertyPage'; -// case Module.orders: -// return '/packageOrder'; -// case Module.completeSchedule: -// return '/scheduleCompleteVisitPage'; -// case Module.providerSchedule: -// return '/provisionalSchedule'; -// case Module.aboutProperty: -// return '/aboutProperty'; -// case Module.deliverySchedule: -// return '/deliverySchedule'; -// case Module.fastPass: -// return '/fastPassPage'; -// case Module.qrCode: -// return '/qrCodePage'; -// case Module.visitors: -// return '/registerVisitorPage'; -// case Module.settings: -// return '/preferencesSettings'; -// case Module.logout: -// return '/WelcomePage'; -// default: -// return ''; -// } -// } -// } - -// enum ELicense implements BaseModule { -// providerSchedule, -// deliverySchedule, -// fastPass, -// completeSchedule, -// orders, -// reservations, -// visitors, -// vehicles, -// residents, -// openedVisits, -// qrCode, -// pets, -// access, -// liberations, -// messages, -// aboutProperty, -// petsHistory, -// peopleOnTheProperty, -// settings, -// logout; - -// @override -// String get value { -// switch (this) { -// case License.messages: -// return 'FRE-HUB-MESSAGES'; -// case License.liberations: -// return 'FRE-HUB-LIBERATIONS'; -// case License.reservations: -// return 'FRE-HUB-RESERVATIONS'; -// case License.access: -// return 'FRE-HUB-ACCESS'; -// case License.openedVisits: -// return 'FRE-HUB-OPENED-VISITS'; -// case License.vehicles: -// return 'FRE-HUB-VEHICLES'; -// case License.residents: -// return 'FRE-HUB-RESIDENTS'; -// case License.pets: -// return 'FRE-HUB-PETS'; -// case License.orders: -// return 'FRE-HUB-ORDERS'; -// case License.completeSchedule: -// return 'FRE-HUB-COMPLETE-SCHEDULE'; -// case License.providerSchedule: -// return 'FRE-HUB-AGE-PROV-PRESTADOR'; -// case License.deliverySchedule: -// return 'FRE-HUB-AGE-PROV-DELIVERY'; -// case License.aboutProperty: -// return 'FRE-HUB-PROPERTY'; -// case License.fastPass: -// return 'FRE-HUB-FASTPASS'; -// case License.visitors: -// return 'FRE-HUB-VISITORS'; -// case License.qrCode: -// return 'FRE-HUB-QRCODE'; -// case License.peopleOnTheProperty: -// return 'FRE-HUB-PEOPLE'; -// case License.petsHistory: -// return 'FRE-HUB-PETS-HISTORY'; -// default: -// return ''; -// } -// } - -// @override -// String get name { -// switch (this) { -// case License.messages: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Consultar Mensagens', -// enText: 'Messages History', -// ); -// case License.liberations: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Consultar Liberações', -// enText: 'Liberations History', -// ); -// case License.reservations: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Reservas', -// enText: 'Reservations', -// ); -// case License.access: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Consultar Acessos', -// enText: 'Access History', -// ); -// case License.openedVisits: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Visitas em Aberto', -// enText: 'Opened Visits', -// ); -// case License.vehicles: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Veículos', -// enText: 'Vehicles', -// ); -// case License.residents: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Moradores', -// enText: 'Residents', -// ); -// case License.pets: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Pets', -// enText: 'Pets', -// ); -// case License.petsHistory: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Pets', -// enText: 'Pets', -// ); -// case License.peopleOnTheProperty: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Pessoas na Propriedade', -// enText: 'People on the Property', -// ); -// case License.orders: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Minhas Encomendas', -// enText: 'My Orders', -// ); -// case License.completeSchedule: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Agenda Completa', -// enText: 'Complete Schedule', -// ); -// case License.providerSchedule: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Agendar Prestadores', -// enText: 'Schedule Providers', -// ); -// case License.deliverySchedule: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Agendar Delivery', -// enText: 'Schedule Delivery', -// ); -// case License.fastPass: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Fast Pass', -// enText: 'Fast Pass', -// ); -// case License.qrCode: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'QRCode de Acesso', -// enText: 'Access QRCode', -// ); -// case License.visitors: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Cadastrar Visitantes', -// enText: 'Register Visitors', -// ); -// case License.aboutProperty: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Sobre a Propriedade', -// enText: 'About the Property', -// ); -// case License.settings: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Configurações', -// enText: 'Settings', -// ); -// case License.logout: -// return FFLocalizations.of(navigatorKey.currentContext!).getVariableText( -// ptText: 'Sair', -// enText: 'Logout', -// ); -// } -// } - -// @override -// IconData get icon { -// switch (this) { -// case License.messages: -// return Icons.chat_outlined; -// case License.liberations: -// return Icons.how_to_reg_outlined; -// case License.reservations: -// return Icons.event_available; -// case License.access: -// return Icons.transfer_within_a_station_outlined; -// case License.openedVisits: -// return Icons.perm_contact_calendar; -// case License.vehicles: -// return Icons.directions_car; -// case License.residents: -// return Icons.groups; -// case License.pets: -// return Icons.pets; -// case License.petsHistory: -// return Icons.pets; -// case License.peopleOnTheProperty: -// return Icons.groups; -// case License.orders: -// return Icons.inventory_2_outlined; -// case License.completeSchedule: -// return Icons.event; -// case License.providerSchedule: -// return Icons.engineering_outlined; -// case License.deliverySchedule: -// return Icons.sports_motorsports_outlined; -// case License.fastPass: -// return Icons.attach_email_outlined; -// case License.qrCode: -// return Icons.qr_code; -// case License.visitors: -// return Icons.person_add_alt_1_outlined; -// case License.aboutProperty: -// return Icons.home; -// case License.settings: -// return Icons.settings; -// case License.logout: -// return Icons.logout; -// } -// } - -// @override -// String get route { -// switch (this) { -// case License.messages: -// return '/messageHistoryPage'; -// case License.liberations: -// return '/liberationHistory'; -// case License.reservations: -// return '/reservation'; -// case License.access: -// return '/acessHistoryPage'; -// case License.openedVisits: -// return '/visitsOnThePropertyPage'; -// case License.vehicles: -// return '/vehiclesOnThePropertyPage'; -// case License.residents: -// return '/residentsOnThePropertyPage'; -// case License.pets: -// return '/petsPage'; -// case License.petsHistory: -// return '/petsHistoryPage'; -// case License.peopleOnTheProperty: -// return '/peopleOnThePropertyPage'; -// case License.orders: -// return '/packageOrder'; -// case License.completeSchedule: -// return '/scheduleCompleteVisitPage'; -// case License.providerSchedule: -// return '/provisionalSchedule'; -// case License.aboutProperty: -// return '/aboutProperty'; -// case License.deliverySchedule: -// return '/deliverySchedule'; -// case License.fastPass: -// return '/fastPassPage'; -// case License.qrCode: -// return '/qrCodePage'; -// case License.visitors: -// return '/registerVisitorPage'; -// case License.settings: -// return '/preferencesSettings'; -// case License.logout: -// return '/WelcomePage'; -// default: -// return ''; -// } -// } -// } diff --git a/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart b/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart index 877ed320..1d1691d2 100644 --- a/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart +++ b/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart @@ -1,8 +1,7 @@ abstract class LicenseRepository { - Future fetchLicense(bool isNewVersion); - Future setupLicense(bool isNewVersion); + Future updateLicense(bool isNewVersion); Future cleanLicense(); - Future g(String key); - Future s(String key, T value); + Future getLicense(String key); + Future setLicense(String key, T value); } diff --git a/lib/shared/helpers/database/database_helper.dart b/lib/shared/helpers/database/database_helper.dart index 38415aa9..e3093ad5 100644 --- a/lib/shared/helpers/database/database_helper.dart +++ b/lib/shared/helpers/database/database_helper.dart @@ -32,7 +32,7 @@ class DatabaseStorage { onUpgrade: _onUpgrade, onDowngrade: _onDowngrade, ); - await LicenseRepositoryImpl().setupLicense(false); + await LicenseRepositoryImpl().updateLicense(false); isInitialized = true; } diff --git a/lib/shared/helpers/storage/storage_helper.dart b/lib/shared/helpers/storage/storage_helper.dart index cb5a3e1b..9600a652 100644 --- a/lib/shared/helpers/storage/storage_helper.dart +++ b/lib/shared/helpers/storage/storage_helper.dart @@ -51,19 +51,19 @@ class StorageHelper { } } - Future g(String key) async { + Future get(String key) async { return await getInstanceByKey(key).get(key); } - Future s(String key, T value) async { + Future set(String key, T value) async { return await getInstanceByKey(key).set(key, value); } - Future d(String key) async { + Future del(String key) async { return await getInstanceByKey(key).delete(key); } - Future c(Storage storage) async { + Future clean(Storage storage) async { return await getInstance(storage).clearAll(); } } diff --git a/lib/shared/services/authentication/authentication_service.dart b/lib/shared/services/authentication/authentication_service.dart index 48463b0e..2053ede1 100644 --- a/lib/shared/services/authentication/authentication_service.dart +++ b/lib/shared/services/authentication/authentication_service.dart @@ -25,14 +25,14 @@ class AuthenticationService { List locals = response.jsonBody['locais'] ?? []; if (locals.isEmpty) { - await StorageHelper().s(SecureStorageKey.haveLocal.value, false); + await StorageHelper().set(SecureStorageKey.haveLocal.value, false); context.go('/receptionPage'); } else { - await StorageHelper().s(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); context.go('/homePage'); } - await StorageHelper().s(SecureStorageKey.isLogged.value, true); + await StorageHelper().set(SecureStorageKey.isLogged.value, true); } static Future signIn( @@ -45,7 +45,7 @@ class AuthenticationService { final ApiCallResponse? response; final LoginCall callback = PhpGroup.loginCall; String deviceDescription = randomString(10, 10, true, false, false); - await StorageHelper().s(SecureStorageKey.deviceDescription.value, deviceDescription); + await StorageHelper().set(SecureStorageKey.deviceDescription.value, deviceDescription); final String? devUUID; final String userUUID; @@ -60,9 +60,9 @@ class AuthenticationService { devUUID = await DeviceUtil.getDevUUID(); if ((email != '') && (passwd != '')) { - await StorageHelper().s(SecureStorageKey.email.value, email); - await StorageHelper().s(SecureStorageKey.password.value, passwd); - await StorageHelper().s(KeychainStorageKey.devUUID.value, devUUID!); + await StorageHelper().set(SecureStorageKey.email.value, email); + await StorageHelper().set(SecureStorageKey.password.value, passwd); + await StorageHelper().set(KeychainStorageKey.devUUID.value, devUUID!); response = await callback.call(); if (response.jsonBody['error'] == false) { @@ -71,10 +71,10 @@ class AuthenticationService { userDevUUID = response.jsonBody['user']['dev_id']; userName = response.jsonBody['user']['name']; - await StorageHelper().s(KeychainStorageKey.userUUID.value, userUUID); - await StorageHelper().s(KeychainStorageKey.userDevUUID.value, userDevUUID); - await StorageHelper().s(KeychainStorageKey.status.value, status); - await StorageHelper().s(KeychainStorageKey.userName.value, userName); + await StorageHelper().set(KeychainStorageKey.userUUID.value, userUUID); + await StorageHelper().set(KeychainStorageKey.userDevUUID.value, userDevUUID); + await StorageHelper().set(KeychainStorageKey.status.value, status); + await StorageHelper().set(KeychainStorageKey.userName.value, userName); await login(context); } else { @@ -138,8 +138,8 @@ class AuthenticationService { alignment: Alignment.bottomCenter, ), }; - await StorageHelper().c(Storage.secureStorage); - await StorageHelper().c(Storage.databaseStorage); + await StorageHelper().clean(Storage.secureStorage); + await StorageHelper().clean(Storage.databaseStorage); context.go('/welcomePage', extra: extra); } diff --git a/lib/shared/utils/path_util.dart b/lib/shared/utils/path_util.dart new file mode 100644 index 00000000..4692235a --- /dev/null +++ b/lib/shared/utils/path_util.dart @@ -0,0 +1,17 @@ + +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; + +class PathUtil { + + static Future nav(String link) async { + navigatorKey.currentContext!.push(link, extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: false, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }); + } +} \ No newline at end of file diff --git a/lib/shared/utils/share_util.dart b/lib/shared/utils/share_util.dart index 511e143a..e04e11bf 100644 --- a/lib/shared/utils/share_util.dart +++ b/lib/shared/utils/share_util.dart @@ -4,8 +4,8 @@ import 'package:share_plus/share_plus.dart'; class ShareUtil { static Future showShare(payload) async { - final cliName = await StorageHelper().g(KeychainStorageKey.clientName.value); - final cliUUID = await StorageHelper().g(KeychainStorageKey.clientUUID.value); + final cliName = await StorageHelper().get(KeychainStorageKey.clientName.value); + final cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value); for (var i = 0; i < payload['convites'].length; i++) { await Share.share('''