diff --git a/analysis_options.yaml b/analysis_options.yaml index 4934b3e6..53fc4048 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -32,6 +32,7 @@ analyzer: errors: curly_braces_in_flow_control_structures: ignore use_build_context_synchronously: ignore + invalid_annotation_target: ignore exclude: - lib/custom_code/** - lib/flutter_flow/custom_functions.dart diff --git a/devtools_options.yaml b/devtools_options.yaml index fa0b357c..2bc8e05f 100644 --- a/devtools_options.yaml +++ b/devtools_options.yaml @@ -1,3 +1,4 @@ description: This file stores settings for Dart & Flutter DevTools. documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states extensions: + - provider: true \ No newline at end of file diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index 65e74d1a..1b9a9a9f 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -4,8 +4,8 @@ import 'dart:developer'; import 'package:flutter/foundation.dart'; import 'package:hub/backend/notifications/firebase_messaging_service.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/log_util.dart'; import 'package:hub/shared/utils/validator_util.dart'; @@ -58,17 +58,55 @@ class PhpGroup { static GetVehiclesByProperty getVehiclesByProperty = GetVehiclesByProperty(); static GetResidentsByProperty getResidentsByProperty = GetResidentsByProperty(); static GetOpenedVisits getOpenedVisits = GetOpenedVisits(); + static GetLicense getLicense = GetLicense(); + static GetProvSchedules getProvSchedules = GetProvSchedules(); +} + +class GetProvSchedules { + 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)) ?? ''; + // const String atividade = 'getProvSchedules'; + // const String pageSize = '10'; + final String baseUrl = 'http://localhost:3000'; + return await ApiManager.instance.makeApiCall( + callName: 'getProvSchedules', + apiUrl: '$baseUrl/getAgendamentoProv.php', + callType: ApiCallType.POST, + headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + params: { + "proId": "8", + "status": "AT", + "page": page, + "pageSize": "10" + // 'devUUID': devUUID, + // 'userUUID': userUUID, + // 'cliID': cliID, + // 'atividade': atividade, + // 'page': page, + // 'pageSize': pageSize, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + alwaysAllowBody: false, + ); + } } class GetOpenedVisits { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getOpenedVisits', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -95,12 +133,12 @@ class GetOpenedVisits { class GetResidentsByProperty { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getResidentsByProperty', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -126,12 +164,12 @@ class GetResidentsByProperty { class GetVehiclesByProperty { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getVehiclesByProperty', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -152,15 +190,49 @@ class GetVehiclesByProperty { alwaysAllowBody: false, ); } + + static GetLicense getLicense = GetLicense(); +} + + +class GetLicense { + Future call() async { + final String baseUrl = PhpGroup.getBaseUrl(); + 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', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliID, + 'atividade': 'getLicenca', + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); + } } class UnregisterDevice { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - return ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'unregisterDevice', apiUrl: '$baseUrl/unregisterDevice.php', callType: ApiCallType.POST, @@ -185,12 +257,12 @@ class UnregisterDevice { class DeletePet { Future call({final int? petID = 0}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'deletePet', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -230,12 +302,12 @@ class UpdatePet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'updatePet', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -276,12 +348,12 @@ class GetPets { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getPets', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -310,12 +382,12 @@ class GetPetPhoto { Future call({final int? petId}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getPetPhoto', apiUrl: '$baseUrl/getImage.php', callType: ApiCallType.POST, @@ -353,12 +425,12 @@ class RegisterPet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'registerPet', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -398,14 +470,14 @@ class BuscaEnconcomendas { final String? adresseeType, final String? status, }) async { - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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(); - return ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getEncomendas', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -442,12 +514,12 @@ class CancelaVisita { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'cancelaVisita', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -476,11 +548,11 @@ class CancelaVisita { class DeleteAccount { Future call() async { - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; final String baseUrl = PhpGroup.getBaseUrl(); - return ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'deleteAccount', apiUrl: '$baseUrl/deleteAccount.php', callType: ApiCallType.POST, @@ -508,12 +580,12 @@ class ChangePanic { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'changePass', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -544,12 +616,12 @@ class ChangePass { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'changePass', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -580,11 +652,11 @@ class RespondeVinculo { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'respondeVinculo', apiUrl: '$baseUrl/responderVinculo.php', callType: ApiCallType.POST, @@ -614,12 +686,12 @@ class ChangeNotifica { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'changeNotifica', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -648,13 +720,13 @@ class UpdateIDE { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - final String newIde = (await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'changeNotifica', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -683,11 +755,11 @@ class UpdToken { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String token = (await StorageHelper().get(SecureStorageKey.token.value, Storage.SecureStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'updToken', apiUrl: '$baseUrl/updtoken.php', callType: ApiCallType.POST, @@ -712,12 +784,11 @@ class UpdToken { class LoginCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String email = (await StorageHelper().get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? ''; - final String password = (await StorageHelper().get(SecureStorageKey.password.value, Storage.SecureStorage)) ?? ''; - final String type = (await StorageHelper().get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? ''; - final String description = - (await StorageHelper().get(SecureStorageKey.deviceDescription.value, Storage.SecureStorage)) ?? ''; + 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(); @@ -728,7 +799,7 @@ class LoginCall { LogUtil.requestAPIFailed('login.php', email, "Login", e, s); } - return ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'login', apiUrl: '$baseUrl/login.php', callType: ApiCallType.POST, @@ -766,7 +837,7 @@ class RegisterCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - return ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'register', apiUrl: '$baseUrl/registro.php', callType: ApiCallType.POST, @@ -800,11 +871,11 @@ class ChangePasswordCall { required final String psswd, }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'changePassword', apiUrl: '$baseUrl/alterarSenha.php', callType: ApiCallType.POST, @@ -836,7 +907,7 @@ class ForgotPasswordCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - return ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'forgotPassword', apiUrl: '$baseUrl/iforgot.php', callType: ApiCallType.POST, @@ -861,10 +932,10 @@ class GetLocalsCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? ''; - final String userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? ''; + final String devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; + final String userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; - return ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getLocals', apiUrl: '$baseUrl/getLocais.php', callType: ApiCallType.POST, @@ -901,12 +972,12 @@ class PostScheduleVisitorCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'postScheduleVisitor', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -956,12 +1027,12 @@ class PostScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'postScheduleVisit', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -1010,12 +1081,12 @@ class GetScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getScheduleVisit', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -1284,12 +1355,12 @@ class GetDadosCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getDados', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -1309,7 +1380,7 @@ class GetDadosCall { cache: false, isStreamingApi: false, alwaysAllowBody: false, - ); + ).timeout(const Duration(seconds: 30)); } bool? errorBolean(dynamic response) => castToType(getJsonField( @@ -1517,12 +1588,12 @@ class GetVisitorByDocCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getVisitorByDoc', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -1571,12 +1642,12 @@ class GetFotoVisitanteCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getFotoVisitante', apiUrl: '$baseUrl/getImage.php', callType: ApiCallType.GET, @@ -1610,12 +1681,12 @@ class PostProvVisitSchedulingCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'postProvVisitScheduling', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -1659,12 +1730,12 @@ class GetVisitsCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getVisits', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -1922,12 +1993,12 @@ class DeleteVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'deleteVisit', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -1965,12 +2036,12 @@ class GetPessoasLocalCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String ownerUUID = (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getPessoasLocal', apiUrl: '$baseUrl/getPessoasLocal.php', callType: ApiCallType.POST, @@ -2031,12 +2102,12 @@ class RespondeSolicitacaoCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'respondeSolicitacao', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -2081,12 +2152,12 @@ class GetAccessCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getAccess', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, @@ -2330,10 +2401,9 @@ class GetLiberationsCall { final StreamController controller = StreamController(); Future.microtask(() async { - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = - (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 { @@ -2523,12 +2593,12 @@ class GetMessagesCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 ApiManager.instance.makeApiCall( + return await ApiManager.instance.makeApiCall( callName: 'getMessages', apiUrl: '$baseUrl/processRequest.php', callType: ApiCallType.POST, diff --git a/lib/backend/notifications/firebase_messaging_service.dart b/lib/backend/notifications/firebase_messaging_service.dart index 1fa9864e..3b768ad2 100644 --- a/lib/backend/notifications/firebase_messaging_service.dart +++ b/lib/backend/notifications/firebase_messaging_service.dart @@ -2,8 +2,8 @@ import 'dart:developer'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/log_util.dart'; import 'notification_service.dart'; @@ -43,7 +43,7 @@ class FirebaseMessagingService { final String? deviceToken = await _firebaseMessaging.getToken(); if (deviceToken != null) { - await StorageHelper().set(SecureStorageKey.token.value, deviceToken, Storage.SecureStorage); + 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 b15eb326..c771a378 100644 --- a/lib/backend/notifications/notification_service.dart +++ b/lib/backend/notifications/notification_service.dart @@ -8,14 +8,14 @@ import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; 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().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + 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().get(SQLiteStorageKey.requestOSNotification.value, Storage.SQLiteStorage)) == 'true'; + (await StorageHelper().get(KeychainStorageKey.requestOSNotification.value)) == 'true'; if (requestOSnotification == false) { if (isAllowed == false) { - await StorageHelper().set(SQLiteStorageKey.requestOSNotification.value, 'true', Storage.SQLiteStorage); + await StorageHelper().set(KeychainStorageKey.requestOSNotification.value, true); await AwesomeNotifications().requestPermissionToSendNotifications(); } } diff --git a/lib/backend/schema/enums/enums.dart b/lib/backend/schema/enums/enums.dart index 3013905b..8f7ed174 100644 --- a/lib/backend/schema/enums/enums.dart +++ b/lib/backend/schema/enums/enums.dart @@ -5,18 +5,6 @@ enum AppHeaderComponent { home, } -enum MenuView { - list_grid, - list, - grid, -} - -enum MenuItem { - button, - card, - tile, -} - extension FFEnumExtensions on T { String serialize() => name; } diff --git a/lib/components/molecular_components/menu_item/menu_item.dart b/lib/components/molecular_components/menu_item/menu_item.dart deleted file mode 100644 index fe97affd..00000000 --- a/lib/components/molecular_components/menu_item/menu_item.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:flutter/material.dart'; - -enum MenuOption { - CompleteSchedule, - DeliverySchedule, - WorkersOnTheProperty, - FastPassSchedule, - QRCodeAccessInProperty, - AccessOnTheProperty, - LiberationsOnTheProperty, - MessagesOnTheProperty, - ReservationsOnTheLocal, - PackagesOnTheProperty, - VehiclesOnTheProperty, - PetsOnTheProperty, - PetsRegister, - VisitorsRegister, - VisitsOnTheProperty, - ResidentsOnTheProperty, - SettingsOnTheApp, - AboutProperty, - LogoutOnTheApp, -} - -abstract class MenuEntry extends StatefulWidget { - const MenuEntry({ - super.key, - required this.action, - required this.title, - required this.icon, - required this.safeSetState, - }); - - final Function() action; - final String title; - final IconData icon; - final VoidCallback safeSetState; -} diff --git a/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart b/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart index 79eefd3c..ec888c47 100644 --- a/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart +++ b/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart @@ -25,4 +25,4 @@ class OrderFilterModalModel extends FlutterFlowModel { textFieldFocusNode?.dispose(); textController?.dispose(); } -} +} \ No newline at end of file diff --git a/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart b/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart index 46f268bf..1835eb3c 100644 --- a/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart +++ b/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart @@ -4,7 +4,6 @@ import 'package:hub/components/molecular_components/order_filter_modal/order_fil import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; // ignore: unused_import import 'package:hub/shared/utils/limited_text_size.dart'; @@ -29,22 +28,22 @@ class _OrderFilterModalWidgetState extends State { late Map selected; final List> adresseeTypeOptions = [ { - 'title': FFLocalizations.of(StorageHelper().context!).getVariableText(enText: 'Resident', ptText: 'Morador'), + 'title': FFLocalizations.of(navigatorKey.currentContext!).getVariableText(enText: 'Resident', ptText: 'Morador'), 'value': 'MOR' }, { - 'title': FFLocalizations.of(StorageHelper().context!).getVariableText(enText: 'Property', ptText: 'Propriedade'), + 'title': FFLocalizations.of(navigatorKey.currentContext!).getVariableText(enText: 'Property', ptText: 'Propriedade'), 'value': 'PRO' }, ]; final List> statusOptions = [ { - 'title': FFLocalizations.of(StorageHelper().context!) + 'title': FFLocalizations.of(navigatorKey.currentContext!) .getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'), 'value': 'notPickedUp' }, { - 'title': FFLocalizations.of(StorageHelper().context!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'), + 'title': FFLocalizations.of(navigatorKey.currentContext!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'), 'value': 'pickedUp' }, ]; @@ -232,4 +231,4 @@ class _OrderFilterModalWidgetState extends State { ), ); } -} +} \ No newline at end of file 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 e5ebe5e3..58be572b 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 @@ -3,8 +3,8 @@ import 'package:hub/components/organism_components/bottom_arrow_linked_locals_co import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; @@ -105,9 +105,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State _fetchResponseLink(String status, String cliID) async { try { - await StorageHelper().set(SQLiteStorageKey.clientUUID.value, cliID, Storage.SQLiteStorage); + await StorageHelper().set(KeychainStorageKey.clientUUID.value, cliID); var response = await PhpGroup.resopndeVinculo.call(tarefa: status); if (response.jsonBody['error'] == false) { @@ -147,7 +148,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State { - String cliName = ''; - String cliUUID = ''; - VoidCallback? setStateCallback; - - @override - void initState(BuildContext context) { - getData(); - } - - Future getData() async { - cliName = await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage) ?? ''; - cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage) ?? ''; - setStateCallback?.call(); - } - - @override - void dispose() {} -} diff --git a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart deleted file mode 100644 index 5cf40e17..00000000 --- a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart +++ /dev/null @@ -1,167 +0,0 @@ -import 'dart:developer'; - -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; - -import '/flutter_flow/custom_functions.dart' as functions; -import '/flutter_flow/flutter_flow_theme.dart'; -import '/flutter_flow/flutter_flow_util.dart'; -import '../../../shared/services/localization/localization_service.dart'; -import 'local_profile_component_model.dart'; - -export 'local_profile_component_model.dart'; - -class LocalProfileComponentWidget extends StatefulWidget { - const LocalProfileComponentWidget({super.key}); - - @override - State createState() => _LocalProfileComponentWidgetState(); -} - -class _LocalProfileComponentWidgetState extends State { - late LocalProfileComponentModel _model; - - @override - void setState(VoidCallback callback) { - super.setState(callback); - callback(); - } - - @override - void initState() { - super.initState(); - _model = createModel(context, () => LocalProfileComponentModel()); - _model.setOnUpdate(onUpdate: () => safeSetState(() {})); - _model.setStateCallback = () => safeSetState(() {}); - - WidgetsBinding.instance.addPostFrameCallback((_) async { - bool initialized = false; - bool isDevLinked = _model.cliUUID.isNotEmpty; - if (!isDevLinked && !initialized) { - initialized = true; - await LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null); - } - }); - } - - @override - void dispose() { - _model.maybeDispose(); - - super.dispose(); - } - - void onUpdate() async { - log('() => onUpdate()'); - await _model.getData(); - safeSetState(() {}); - } - - @override - Widget build(BuildContext context) { - final textScaler = MediaQuery.textScalerOf(context); - final double baseFontSize = 14.0; - final double scaledFontSize = baseFontSize * textScaler.scale(1); - final double limitedFontSize = scaledFontSize > 20 ? 12 : scaledFontSize; - - return Container( - decoration: const BoxDecoration(), - child: Align( - alignment: const AlignmentDirectional(0.0, -1.0), - child: Material( - color: Colors.transparent, - elevation: 0.0, - child: Container( - width: double.infinity, - height: 119.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primary, - border: Border.all( - color: FlutterFlowTheme.of(context).primary, - ), - ), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Align( - alignment: const AlignmentDirectional(-1.0, 0.0), - child: Padding( - padding: const EdgeInsets.all(2.0), - child: InkWell( - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onTap: () async { - await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); - await LocalizationService.processLocals(context).whenComplete(() => onUpdate()); - }, - child: ClipRRect( - borderRadius: BorderRadius.circular(200.0), - child: CachedNetworkImage( - imageBuilder: (context, imageProvider) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, - fit: BoxFit.cover, - ), - ), - ), - imageUrl: valueOrDefault( - 'https://freaccess.com.br/freaccess/Images/Clients/${_model.cliUUID}.png', - 'assets/images/home.png'), - width: 80.0, - height: 80.0, - fit: BoxFit.cover, - alignment: const Alignment(0.0, 0.0), - placeholder: (context, url) => Image.asset('assets/images/home.png'), - errorListener: (_) => Image.asset('assets/images/home.png'), - errorWidget: (_, __, ___) => Image.asset('assets/images/home.png'), - ), - )), - ), - ), - Expanded( - child: Tooltip( - message: valueOrDefault( - functions.convertToUppercase(_model.cliName), - FFLocalizations.of(context).getVariableText( - ptText: 'SEM LOCAL VINCULADO', - enText: 'NO LINKED LOCAL', - ), - ), - child: Text( - valueOrDefault( - functions.convertToUppercase(_model.cliName), - FFLocalizations.of(context).getVariableText( - ptText: 'SEM LOCAL VINCULADO', - enText: 'NO LINKED LOCAL', - ), - ), - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).info, - fontSize: limitedFontSize, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - ), - ), - ), - ), - ] - .divide(const SizedBox(width: 20.0)) - .addToStart(const SizedBox(width: 20.0)) - .addToEnd(const SizedBox(width: 20.0)), - ), - ), - ), - ), - ); - } -} diff --git a/lib/components/organism_components/menu_component/menu_component_model.dart b/lib/components/organism_components/menu_component/menu_component_model.dart deleted file mode 100644 index 1be59d82..00000000 --- a/lib/components/organism_components/menu_component/menu_component_model.dart +++ /dev/null @@ -1,525 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; -import 'package:hub/components/atomic_components/menu_button_item/menu_button_item_widget.dart'; -import 'package:hub/components/atomic_components/menu_card_item/menu_card_item.dart'; -import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; -import 'package:hub/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart'; -import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart'; -import 'package:hub/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart'; -import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart'; -import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/extensions/dialog_extensions.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; -import 'package:hub/shared/services/authentication/authentication_service.dart'; -import 'package:material_symbols_icons/symbols.dart'; - -import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart'; -import 'menu_component_widget.dart' show MenuComponentWidget; - -class MenuComponentModel extends FlutterFlowModel { - final MenuView style; - final MenuItem item; - final bool expandable; - final List menuOptions; - - MenuComponentModel({required this.style, required this.item, required this.expandable, required this.menuOptions}); - - bool isGrid = false; - - late MenuListViewComponentModel menuListViewComponentModel; - late MenuStaggeredViewComponentModel menuStaggeredViewComponentModel; - late VoidCallback safeSetState; - late List menuEntries; - - @override - void initState(BuildContext context) { - menuListViewComponentModel = createModel(context, () => MenuListViewComponentModel()); - menuStaggeredViewComponentModel = createModel(context, () => MenuStaggeredViewComponentModel()); - } - - @override - void dispose() { - menuListViewComponentModel.dispose(); - menuStaggeredViewComponentModel.dispose(); - } - - List generateMenuEntries(BuildContext context, MenuItem item, List options) { - List entries = []; - MenuEntry? addMenuEntry(IconData icon, String enText, String ptText, Function() action) { - entries.add( - item == MenuItem.button - ? MenuButtonWidget( - icon: icon, - action: action, - title: FFLocalizations.of(context).getVariableText(enText: enText, ptText: ptText), - safeSetState: safeSetState) - : item == MenuItem.card - ? MenuCardItem( - icon: icon, - action: action, - title: FFLocalizations.of(context).getVariableText(enText: enText, ptText: ptText), - safeSetState: safeSetState) - : item == MenuItem.tile - ? MenuCardItem( - icon: icon, - action: action, - title: FFLocalizations.of(context).getVariableText(enText: enText, ptText: ptText), - safeSetState: safeSetState) - : null, - ); - return null; - } - - if (options.contains(MenuOption.WorkersOnTheProperty)) - addMenuEntry(Icons.engineering_outlined, 'Schedule Providers', 'Agendar Prestadores', () async { - if (await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true') - await open(context, '/provisionalSchedule'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.DeliverySchedule)) - addMenuEntry(Icons.sports_motorsports_outlined, 'Schedule Deliveries', 'Agendar Entregas', () async { - if (await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true') - await open(context, '/deliverySchedule'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.FastPassSchedule)) - addMenuEntry(Icons.attach_email_outlined, 'Invite Visitor', 'Convidar Visitante', () async { - if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true') - await open(context, '/fastPassPage'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.CompleteSchedule)) - addMenuEntry(Icons.event, 'Complete Schedule', 'Agenda Completa', () async { - await open(context, '/scheduleCompleteVisitPage'); - safeSetState; - }); - if (options.contains(MenuOption.PackagesOnTheProperty)) - addMenuEntry(Icons.inventory_2_outlined, 'Orders', 'Encomendas', () async { - if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true') - await open(context, '/packageOrder'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.ReservationsOnTheLocal)) - addMenuEntry(Icons.event_available, 'Reservations', 'Reservas', () async { - if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true') - await open(context, '/reservation'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.VisitorsRegister)) - addMenuEntry(Icons.person_add_alt_1_outlined, 'Register Visitor', 'Cadastrar Visitante', () async { - await open(context, '/registerVisitorPage'); - safeSetState; - }); - if (options.contains(MenuOption.QRCodeAccessInProperty)) - addMenuEntry(Icons.qr_code, 'QRCode Access', 'QRCode de Acesso', () async { - await open(context, '/qrCodePage'); - safeSetState; - }); - if (options.contains(MenuOption.PetsOnTheProperty)) - addMenuEntry(Icons.pets, 'Pets', 'Pets', () async { - if (await StorageHelper().get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == 'true') - await open(context, '/petsOnThePropertyPage'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.PetsRegister)) - addMenuEntry(Icons.pets, 'Pets Register', 'Cadastrar Pet', () async { - if (await StorageHelper().get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == 'true') - await open(context, '/petsPage'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.AccessOnTheProperty)) - addMenuEntry(Icons.transfer_within_a_station_outlined, 'Access History', 'Consultar Acessos', () async { - await open(context, '/acessHistoryPage'); - safeSetState; - }); - if (options.contains(MenuOption.ResidentsOnTheProperty)) - addMenuEntry(Icons.groups, 'Residents', 'Moradores', () async { - await open(context, '/peopleOnThePropertyPage'); - safeSetState; - }); - if (options.contains(MenuOption.LiberationsOnTheProperty)) - addMenuEntry(Icons.how_to_reg_outlined, 'Liberations History', 'Consultar Liberações', () async { - await open(context, '/liberationHistory'); - safeSetState; - }); - if (options.contains(MenuOption.MessagesOnTheProperty)) - addMenuEntry(Icons.chat_outlined, 'Message History', 'Consultar Mensagens', () async { - await open(context, '/messageHistoryPage'); - safeSetState; - }); - if (options.contains(MenuOption.VehiclesOnTheProperty)) - addMenuEntry(Symbols.directions_car, 'Vehicles', 'Veículos', () async { - await open(context, '/vehiclesOnThePropertyPage'); - safeSetState; - }); - if (options.contains(MenuOption.VisitsOnTheProperty)) - addMenuEntry(Symbols.perm_contact_calendar, 'Opened Visits', 'Visitas em Aberto', () async { - await open(context, '/visitsOnThePropertyPage'); - safeSetState; - }); - - if (options.contains(MenuOption.AboutProperty)) - addMenuEntry(Icons.home, 'About Property', 'Sobre a Propriedade', () async { - if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true') - await open(context, '/aboutProperty'); - else - DialogUnavailable.unavailableFeature(context); - safeSetState; - }); - if (options.contains(MenuOption.SettingsOnTheApp)) - addMenuEntry(Icons.settings, 'System Settings', 'Opções do Sistema', () async { - await open(context, '/preferencesSettings'); - safeSetState; - }); - if (options.contains(MenuOption.LogoutOnTheApp)) - addMenuEntry(Icons.logout, 'Logout', 'Sair', () async { - await out(context); - safeSetState; - }); - - return entries; - } - - Future open(BuildContext context, String link) async { - context.push( - link, - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future out(BuildContext context) async { - final String title = FFLocalizations.of(context).getVariableText( - ptText: 'Sair', - enText: 'Logout', - ); - final String content = FFLocalizations.of(context).getVariableText( - ptText: 'Tem certeza que deseja sair?', - enText: 'Are you sure you want to logout?', - ); - showAlertDialog(context, title, content, () async => await AuthenticationService.signOut(context)); - } - - Future openDeliverySchedule(BuildContext context) async { - final bool isProvisional = - await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true'; - if (isProvisional == true) { - context.push( - '/deliverySchedule', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future openProvisionalSchedule(BuildContext context) async { - final isProvisional = - await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true'; - if (isProvisional == true) { - context.push( - '/provisionalSchedule', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future openFastPassSchedule(BuildContext context) async { - final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true'; - if (isWpp) { - context.push( - '/fastPassPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future showSchedules(BuildContext context) async { - final routesListStr = [ - 'scheduleProvisionalVisitPage', - 'fastPassPage', - 'scheduleCompleteVisitPage', - ]; - final iconsListIcon = [ - Icons.date_range_rounded, - Icons.date_range_rounded, - Icons.date_range_rounded, - ]; - final nameListStr = [ - FFLocalizations.of(context).getVariableText( - ptText: 'Visita\nProvisória', - enText: 'Provisional\nSchedule', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Visita\nRápida', - enText: 'Fast\nSchedule', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Visita\nCompleta', - enText: 'Complete\nSchedule', - ), - ]; - await showAdaptiveDialog( - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: OptionSelectionModalWidget( - routesListStr: routesListStr, - iconsListIcon: iconsListIcon, - nameListStr: nameListStr, - ), - ); - }, - ); - } - - Future openVisitorsRegister(BuildContext context) async { - context.push( - '/registerVisitorPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openPoepleOnTheProperty(BuildContext context) async { - context.push( - '/peopleOnThePropertyPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future Logout(BuildContext context) async { - final String title = FFLocalizations.of(context).getVariableText( - ptText: 'Sair', - enText: 'Logout', - ); - final String content = FFLocalizations.of(context).getVariableText( - ptText: 'Tem certeza que deseja sair?', - enText: 'Are you sure you want to logout?', - ); - showAlertDialog(context, title, content, () async => await AuthenticationService.signOut(context)); - } - - Future openPreferencesSettings(BuildContext context) async { - context.push( - '/preferencesSettings', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openMyOrders(BuildContext context) async { - final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true'; - ; - if (isWpp) { - context.push( - '/packageOrder', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future openReservations(BuildContext context) async { - final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true'; - ; - if (isWpp) { - context.push( - '/reservation', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future showHistories(BuildContext context) async { - await showAdaptiveDialog( - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // enableDrag: false, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: OptionSelectionModalWidget( - routesListStr: const [ - 'liberationHistory', - 'acessHistoryPage', - 'scheduleCompleteVisitPage', - 'messageHistoryPage' - ], - iconsListIcon: const [ - Icons.history_rounded, - Icons.history_rounded, - Icons.history_rounded, - Icons.history_rounded, - ], - nameListStr: [ - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Liberação', - enText: 'Liberation\nHistory', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Acesso', - enText: 'Access\nHistory', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Visita', - enText: 'Visit\nHistory', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Mensagens', - enText: 'Message\nHistory', - ), - ], - ), - ); - }, - ); - } - - Future openLiberationsHistory(BuildContext context) async { - context.push( - '/liberationHistory', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openAccessHistory(BuildContext context) async { - context.push( - '/acessHistoryPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openVisitsHistory(BuildContext context) async { - context.push( - '/scheduleCompleteVisitPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openMessagesHistory(BuildContext context) async { - context.push( - '/messageHistoryPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openPetsRegister(BuildContext context) async { - bool isPet = await StorageHelper().get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == 'true'; - ; - if (isPet) { - context.push( - '/petsPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } -} diff --git a/lib/components/organism_components/menu_component/menu_component_widget.dart b/lib/components/organism_components/menu_component/menu_component_widget.dart deleted file mode 100644 index 795982cd..00000000 --- a/lib/components/organism_components/menu_component/menu_component_widget.dart +++ /dev/null @@ -1,78 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; - -import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart'; -import '/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart'; -import '/flutter_flow/flutter_flow_util.dart'; -import 'menu_component_model.dart'; - -export 'menu_component_model.dart'; - -class MenuComponentWidget extends StatefulWidget { - final MenuComponentModel model; - const MenuComponentWidget({super.key, required this.model}); - - @override - State createState() => _MenuComponentWidgetState(); -} - -class _MenuComponentWidgetState extends State { - @override - void setState(VoidCallback callback) { - super.setState(callback); - widget.model.onUpdate(); - } - - @override - void initState() { - super.initState(); - widget.model.safeSetState = () => safeSetState(() {}); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - widget.model.menuEntries = widget.model.generateMenuEntries(context, widget.model.item, widget.model.menuOptions); - } - - @override - void dispose() { - widget.model.maybeDispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Builder( - builder: (context) { - if (widget.model.style == MenuView.list_grid) - return wrapWithModel( - model: widget.model.menuStaggeredViewComponentModel, - updateCallback: () => setState(() {}), - updateOnChange: true, - child: MenuStaggeredViewComponentWidget( - options: widget.model.menuEntries, - expandable: widget.model.expandable, - item: widget.model.item, - changeMenuStyle: () async {}, - isGrid: widget.model.isGrid, - ), - ); - if (widget.model.style == MenuView.list) - return wrapWithModel( - model: widget.model.menuListViewComponentModel, - updateCallback: () => setState(() {}), - updateOnChange: true, - child: MenuListViewComponentWidget( - options: widget.model.menuEntries, - expandable: widget.model.expandable, - item: widget.model.item, - changeMenuStyle: () async {}, - ), - ); - - return const SizedBox(); - }, - ); - } -} diff --git a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart b/lib/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart deleted file mode 100644 index d15273ee..00000000 --- a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart +++ /dev/null @@ -1,11 +0,0 @@ -import '/flutter_flow/flutter_flow_util.dart'; -import 'menu_list_view_component_widget.dart' show MenuListViewComponentWidget; -import 'package:flutter/material.dart'; - -class MenuListViewComponentModel extends FlutterFlowModel { - @override - void initState(BuildContext context) {} - - @override - void dispose() {} -} diff --git a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart deleted file mode 100644 index cb0efe51..00000000 --- a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart'; - -import '/flutter_flow/flutter_flow_util.dart'; - -import 'package:flutter/material.dart'; - -class MenuStaggeredViewComponentModel extends FlutterFlowModel { - @override - void initState(BuildContext context) {} - - @override - void dispose() {} -} diff --git a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart deleted file mode 100644 index 64161e26..00000000 --- a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart +++ /dev/null @@ -1,193 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; -import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; -import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart'; -import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; -import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -import 'package:hub/flutter_flow/flutter_flow_util.dart'; - -class MenuStaggeredViewComponentWidget extends StatefulWidget { - const MenuStaggeredViewComponentWidget( - {super.key, - required this.changeMenuStyle, - required this.expandable, - required this.item, - required this.options, - required this.isGrid}); - - final bool expandable; - final MenuItem item; - final bool isGrid; - - final List options; - final Future Function()? changeMenuStyle; - - @override - State createState() => _MenuStaggeredViewComponentWidgetState(); -} - -class _MenuStaggeredViewComponentWidgetState extends State { - late MenuStaggeredViewComponentModel _model; - - @override - void setState(VoidCallback callback) { - super.setState(callback); - _model.onUpdate(); - } - - @override - void initState() { - super.initState(); - _model = createModel(context, () => MenuStaggeredViewComponentModel()); - } - - @override - void dispose() { - _model.maybeDispose(); - - super.dispose(); - } - - @override - Widget build(BuildContext context) { - final textScaler = MediaQuery.textScalerOf(context); - final double scaledFontSize = 14 * textScaler.scale(1); - final int crossAxisCount = scaledFontSize >= 26 - ? 1 - : scaledFontSize >= 18 - ? 2 - : 3; - - return Column( - children: [ - GridView.builder( - physics: const NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: crossAxisCount, - crossAxisSpacing: 10.0, - mainAxisSpacing: 10.0, - childAspectRatio: 1, - mainAxisExtent: 100, - ), - itemCount: widget.options.length, - padding: const EdgeInsets.symmetric(horizontal: 14), - shrinkWrap: true, - itemBuilder: (context, index) { - return Container( - height: MediaQuery.of(context).size.height, - width: MediaQuery.of(context).size.width, - alignment: Alignment.center, - padding: const EdgeInsets.all(0), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(0), - color: Colors.transparent, - boxShadow: const [ - BoxShadow( - color: Colors.transparent, - blurRadius: 4, - offset: Offset(0, 2), - ), - ], - ), - child: Center(child: widget.options[index]), - ); - }, - ), - ].addToStart(const SizedBox(height: 30)).addToEnd(const SizedBox(height: 30)), - ); - } - - Widget collapseExpandMethod(BuildContext context) { - if (widget.isGrid == true) { - return Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: Container( - decoration: const BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(0.0), - bottomRight: Radius.circular(0.0), - topLeft: Radius.circular(0.0), - topRight: Radius.circular(0.0), - ), - ), - alignment: const AlignmentDirectional(0.0, 0.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Text( - FFLocalizations.of(context).getVariableText( - enText: 'Minimize', - ptText: 'Minimizar', - ), - style: FlutterFlowTheme.of(context).title1.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 12.0, - fontWeight: FontWeight.w600, - fontStyle: FontStyle.normal, - ), - ), - Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 20.0, - borderWidth: 1.0, - buttonSize: 50.0, - fillColor: const Color(0x00FFFFFF), - icon: Icon( - Icons.keyboard_arrow_up_sharp, - color: FlutterFlowTheme.of(context).primary, - ), - onPressed: () async { - await widget.changeMenuStyle?.call(); - }, - ), - ), - ], - ), - ), - ); - } else { - return Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Text( - FFLocalizations.of(context).getVariableText( - enText: 'Expand', - ptText: 'Expandir', - ), - style: FlutterFlowTheme.of(context).title1.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 12.0, - fontWeight: FontWeight.w600, - fontStyle: FontStyle.normal, - ), - ), - Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 20.0, - borderWidth: 0.0, - buttonSize: 50.0, - fillColor: const Color(0x00FFFFFF), - icon: Icon( - Icons.keyboard_arrow_down_outlined, - color: FlutterFlowTheme.of(context).primary, - ), - onPressed: () async { - await widget.changeMenuStyle?.call(); - }, - ), - ), - ], - ); - } - } -} diff --git a/lib/components/organism_components/message_well_component/message_well_component_model.dart b/lib/components/organism_components/message_well_component/message_well_component_model.dart index d18746ee..cf2a7682 100644 --- a/lib/components/organism_components/message_well_component/message_well_component_model.dart +++ b/lib/components/organism_components/message_well_component/message_well_component_model.dart @@ -1,44 +1,44 @@ -import 'package:hub/backend/api_requests/api_manager.dart'; -import 'package:hub/flutter_flow/request_manager.dart'; +// import 'package:hub/backend/api_requests/api_manager.dart'; +// import 'package:hub/flutter_flow/request_manager.dart'; -import '/flutter_flow/flutter_flow_util.dart'; -import 'message_well_component_widget.dart' show MessageWellComponentWidget; -import 'package:flutter/material.dart'; +// import '/flutter_flow/flutter_flow_util.dart'; +// import 'message_well_component_widget.dart' show MessageWellComponentWidget; +// import 'package:flutter/material.dart'; -class MessageWellComponentModel extends FlutterFlowModel { - final unfocusNode = FocusNode(); - // State field(s) for TextField widget. - FocusNode? textFieldFocusNode; - TextEditingController? textController; - String? Function(BuildContext, String?)? textControllerValidator; +// class MessageWellComponentModel extends FlutterFlowModel { +// final unfocusNode = FocusNode(); +// // State field(s) for TextField widget. +// FocusNode? textFieldFocusNode; +// TextEditingController? textController; +// String? Function(BuildContext, String?)? textControllerValidator; - /// Query cache managers for this widget. +// /// Query cache managers for this widget. - final _getLiberationsManager = StreamRequestManager(); - Stream getLiberations({ - String? uniqueQueryKey, - bool? overrideCache, - required Stream Function() requestFn, - }) => - _getLiberationsManager.performRequest( - uniqueQueryKey: uniqueQueryKey, - overrideCache: overrideCache, - requestFn: requestFn, - ); - void clearGetLiberationsCache() => _getLiberationsManager.clear(); - void clearGetLiberationsCacheKey(String? uniqueKey) => _getLiberationsManager.clearRequest(uniqueKey); +// final _getLiberationsManager = StreamRequestManager(); +// Stream getLiberations({ +// String? uniqueQueryKey, +// bool? overrideCache, +// required Stream Function() requestFn, +// }) => +// _getLiberationsManager.performRequest( +// uniqueQueryKey: uniqueQueryKey, +// overrideCache: overrideCache, +// requestFn: requestFn, +// ); +// void clearGetLiberationsCache() => _getLiberationsManager.clear(); +// void clearGetLiberationsCacheKey(String? uniqueKey) => _getLiberationsManager.clearRequest(uniqueKey); - @override - void initState(BuildContext context) {} +// @override +// void initState(BuildContext context) {} - @override - void dispose() { - unfocusNode.dispose(); - textFieldFocusNode?.dispose(); - textController?.dispose(); +// @override +// void dispose() { +// unfocusNode.dispose(); +// textFieldFocusNode?.dispose(); +// textController?.dispose(); - /// Dispose query cache managers for this widget. +// /// Dispose query cache managers for this widget. - clearGetLiberationsCache(); - } -} +// clearGetLiberationsCache(); +// } +// } diff --git a/lib/components/organism_components/message_well_component/message_well_component_widget.dart b/lib/components/organism_components/message_well_component/message_well_component_widget.dart index 97b52e31..d4b93fc9 100644 --- a/lib/components/organism_components/message_well_component/message_well_component_widget.dart +++ b/lib/components/organism_components/message_well_component/message_well_component_widget.dart @@ -1,379 +1,379 @@ -import 'dart:async'; -import 'dart:collection'; +// import 'dart:async'; +// import 'dart:collection'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:provider/provider.dart'; -import 'package:rxdart/rxdart.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_riverpod/flutter_riverpod.dart'; +// import 'package:hub/backend/api_requests/api_calls.dart'; +// import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +// import 'package:hub/flutter_flow/flutter_flow_util.dart'; +// import 'package:provider/provider.dart'; +// import 'package:rxdart/rxdart.dart'; -// +// // -final dropdown = BehaviorSubject>.seeded( - LinkedHashMap.from({ - 'All': 'A', - }), -); +// final dropdown = BehaviorSubject>.seeded( +// LinkedHashMap.from({ +// 'All': 'A', +// }), +// ); -class MessageWellComponentWidget extends StatefulWidget { - const MessageWellComponentWidget({super.key}); +// class MessageWellComponentWidget extends StatefulWidget { +// const MessageWellComponentWidget({super.key}); - @override - State createState() => _MessageWellComponentWidgetState(); -} +// @override +// State createState() => _MessageWellComponentWidgetState(); +// } -class _MessageWellComponentWidgetState extends State { - StreamSubscription? _dropdownSubscription; +// class _MessageWellComponentWidgetState extends State { +// StreamSubscription? _dropdownSubscription; - @override - void initState() { - super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) { - context.read().fetchMessages(); - }); +// @override +// void initState() { +// super.initState(); +// WidgetsBinding.instance.addPostFrameCallback((_) { +// context.read().fetchMessages(); +// }); - _dropdownSubscription = dropdown.stream.listen((_) { - context.read().fetchMessages(); - }); - } +// _dropdownSubscription = dropdown.stream.listen((_) { +// context.read().fetchMessages(); +// }); +// } - @override - void dispose() { - _dropdownSubscription?.cancel(); - super.dispose(); - } +// @override +// void dispose() { +// _dropdownSubscription?.cancel(); +// super.dispose(); +// } - @override - Widget build(BuildContext context) { - final messages = context.read().getMessages(); - return Align( - alignment: Alignment.center, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 40.0), - child: SizedBox( - height: MediaQuery.of(context).size.height * 0.8, - child: Column( - children: [ - _buildHandleMessageWell(context, FlutterFlowTheme.of(context)), - _buildMenuMessageWell(context, FlutterFlowTheme.of(context)), - Expanded( - child: ListView.builder( - itemCount: messages.length, - shrinkWrap: true, - physics: const AlwaysScrollableScrollPhysics(), - itemBuilder: (context, index) { - var message = messages[index]; - return _buildMessageItem(context, message, index); - }, - ), - ), - ], - ), - ), - ), - ); - } +// @override +// Widget build(BuildContext context) { +// final messages = context.read().getMessages(); +// return Align( +// alignment: Alignment.center, +// child: Padding( +// padding: const EdgeInsets.symmetric(vertical: 40.0), +// child: SizedBox( +// height: MediaQuery.of(context).size.height * 0.8, +// child: Column( +// children: [ +// _buildHandleMessageWell(context, FlutterFlowTheme.of(context)), +// _buildMenuMessageWell(context, FlutterFlowTheme.of(context)), +// Expanded( +// child: ListView.builder( +// itemCount: messages.length, +// shrinkWrap: true, +// physics: const AlwaysScrollableScrollPhysics(), +// itemBuilder: (context, index) { +// var message = messages[index]; +// return _buildMessageItem(context, message, index); +// }, +// ), +// ), +// ], +// ), +// ), +// ), +// ); +// } - Widget _buildMenuMessageWell(BuildContext context, FlutterFlowTheme theme) { - final dropdownItems = LinkedHashMap.from({ - 'All': 'A', - 'Personal': 'O', - 'Global': 'C', - }); - return SizedBox( - key: UniqueKey(), - width: 200, - height: 40, - child: StreamBuilder( - stream: dropdown.stream.map((event) => event.keys.first), - builder: (context, snapshot) { - final value = snapshot.data; - return DropdownButtonFormField( - value: value, - decoration: InputDecoration( - isDense: true, - contentPadding: const EdgeInsets.symmetric(horizontal: 10.0), - errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: theme.error, - width: 2, - ), - borderRadius: BorderRadius.circular(10), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: theme.primary, - width: 2, - ), - borderRadius: BorderRadius.circular(10), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: theme.primary, - width: 2, - ), - borderRadius: BorderRadius.circular(10), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: theme.primary, - width: 2, - ), - borderRadius: BorderRadius.circular(10), - ), - focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: theme.error, - width: 2, - ), - borderRadius: BorderRadius.circular(10), - ), - border: OutlineInputBorder( - borderSide: BorderSide( - color: theme.primary, - width: 2, - ), - borderRadius: BorderRadius.circular(10), - ), - filled: true, - fillColor: theme.primary, - ), - onChanged: (String? newValue) { - safeSetState(() => dropdown.value = LinkedHashMap.from({newValue!: dropdownItems[newValue].toString()})); - }, - items: dropdownItems.entries - .map((entry) => DropdownMenuItem( - value: entry.key, - child: Text(entry.key), - )) - .toList(), - style: theme.bodyMedium.copyWith( - color: theme.primaryText, - ), - ); - }, - ), - ); - } +// Widget _buildMenuMessageWell(BuildContext context, FlutterFlowTheme theme) { +// final dropdownItems = LinkedHashMap.from({ +// 'All': 'A', +// 'Personal': 'O', +// 'Global': 'C', +// }); +// return SizedBox( +// key: UniqueKey(), +// width: 200, +// height: 40, +// child: StreamBuilder( +// stream: dropdown.stream.map((event) => event.keys.first), +// builder: (context, snapshot) { +// final value = snapshot.data; +// return DropdownButtonFormField( +// value: value, +// decoration: InputDecoration( +// isDense: true, +// contentPadding: const EdgeInsets.symmetric(horizontal: 10.0), +// errorBorder: OutlineInputBorder( +// borderSide: BorderSide( +// color: theme.error, +// width: 2, +// ), +// borderRadius: BorderRadius.circular(10), +// ), +// enabledBorder: OutlineInputBorder( +// borderSide: BorderSide( +// color: theme.primary, +// width: 2, +// ), +// borderRadius: BorderRadius.circular(10), +// ), +// focusedBorder: OutlineInputBorder( +// borderSide: BorderSide( +// color: theme.primary, +// width: 2, +// ), +// borderRadius: BorderRadius.circular(10), +// ), +// disabledBorder: OutlineInputBorder( +// borderSide: BorderSide( +// color: theme.primary, +// width: 2, +// ), +// borderRadius: BorderRadius.circular(10), +// ), +// focusedErrorBorder: OutlineInputBorder( +// borderSide: BorderSide( +// color: theme.error, +// width: 2, +// ), +// borderRadius: BorderRadius.circular(10), +// ), +// border: OutlineInputBorder( +// borderSide: BorderSide( +// color: theme.primary, +// width: 2, +// ), +// borderRadius: BorderRadius.circular(10), +// ), +// filled: true, +// fillColor: theme.primary, +// ), +// onChanged: (String? newValue) { +// safeSetState(() => dropdown.value = LinkedHashMap.from({newValue!: dropdownItems[newValue].toString()})); +// }, +// items: dropdownItems.entries +// .map((entry) => DropdownMenuItem( +// value: entry.key, +// child: Text(entry.key), +// )) +// .toList(), +// style: theme.bodyMedium.copyWith( +// color: theme.primaryText, +// ), +// ); +// }, +// ), +// ); +// } - Text _buildHandleMessageWell(BuildContext context, FlutterFlowTheme theme) { - return Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Mural de Mensagens', - enText: 'Message Wall', - ), - style: theme.bodyMedium.copyWith( - fontFamily: 'Nunito Sans', - letterSpacing: 0.0, - ), - ); - } +// Text _buildHandleMessageWell(BuildContext context, FlutterFlowTheme theme) { +// return Text( +// FFLocalizations.of(context).getVariableText( +// ptText: 'Mural de Mensagens', +// enText: 'Message Wall', +// ), +// style: theme.bodyMedium.copyWith( +// fontFamily: 'Nunito Sans', +// letterSpacing: 0.0, +// ), +// ); +// } - Widget _buildMessageItem(BuildContext context, dynamic message, int index) { - FlutterFlowTheme.of(context); - String formatMessageOrigin(String messageOrigin) { - final words = messageOrigin.split(' '); - final formattedWords = words.map((word) { - if (word.isEmpty) return word; // Handle empty words - final firstLetter = word.substring(0, 1).toUpperCase(); - final remainingLetters = word.length > 1 ? word.substring(1).toLowerCase() : ''; - return '$firstLetter$remainingLetters'; - }); - return formattedWords.join(' '); - } +// Widget _buildMessageItem(BuildContext context, dynamic message, int index) { +// FlutterFlowTheme.of(context); +// String formatMessageOrigin(String messageOrigin) { +// final words = messageOrigin.split(' '); +// final formattedWords = words.map((word) { +// if (word.isEmpty) return word; // Handle empty words +// final firstLetter = word.substring(0, 1).toUpperCase(); +// final remainingLetters = word.length > 1 ? word.substring(1).toLowerCase() : ''; +// return '$firstLetter$remainingLetters'; +// }); +// return formattedWords.join(' '); +// } - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 30), - child: Card( - color: FlutterFlowTheme.of(context).primaryBackground, - child: Container( - // height: 100, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Icon( - message['MSG_DESTINO_TP'] == 'T' - ? Icons.language - : message['MSG_DESTINO_TP'] == 'P' - ? Icons.person - : Icons.home, - color: FlutterFlowTheme.of(context).primary, - size: 25, - ), - Expanded( - child: Text( - message['MSG_ORIGEM_DESC'].toString(), - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15, - color: FlutterFlowTheme.of(context).primary, - ), - overflow: TextOverflow.fade, - ), - ), - ].divide(const SizedBox(width: 10)), - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: const EdgeInsets.only(left: 5), - child: Icon( - Icons.history, - color: FlutterFlowTheme.of(context).customColor6, - size: 15, - ), - ), - Expanded( - child: Text( - message['MSG_DATE'].toString(), - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 10, - color: FlutterFlowTheme.of(context).customColor6, - ), - overflow: TextOverflow.ellipsis, - ), - ), - ].divide(const SizedBox(width: 15)), - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: const EdgeInsets.only(left: 5), - child: Icon( - Icons.message, - color: FlutterFlowTheme.of(context).customColor6, - size: 15, - ), - ), - Expanded( - child: Text( - message['MSG_TEXTO'].toString(), - ), - ), - ].divide(const SizedBox(width: 15)), - ), - ].divide(const SizedBox(height: 4)), - ), - ), - // Row( - // children: [ - // Icon( - // Icons.message, - // color: FlutterFlowTheme.of(context).customColor6, - // size: 15, - // ), - // Expanded( - // child: Padding( - // padding: const EdgeInsets.all(8.0), - // child: Text( - // message['MSG_TEXTO'].toString(), - // ), - // ), - // ), - // ] - // .addToStart(const SizedBox(width: 8)) - // .addToEnd(const SizedBox(width: 8))), - ].divide( - const SizedBox(height: 8), - ), - ), - ), - ), - )); - } -} +// return Padding( +// padding: const EdgeInsets.symmetric(horizontal: 30), +// child: Card( +// color: FlutterFlowTheme.of(context).primaryBackground, +// child: Container( +// // height: 100, +// child: Padding( +// padding: const EdgeInsets.all(8.0), +// child: Column( +// mainAxisAlignment: MainAxisAlignment.center, +// children: [ +// Padding( +// padding: const EdgeInsets.symmetric(horizontal: 15.0), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Row( +// mainAxisAlignment: MainAxisAlignment.start, +// mainAxisSize: MainAxisSize.max, +// children: [ +// Icon( +// message['MSG_DESTINO_TP'] == 'T' +// ? Icons.language +// : message['MSG_DESTINO_TP'] == 'P' +// ? Icons.person +// : Icons.home, +// color: FlutterFlowTheme.of(context).primary, +// size: 25, +// ), +// Expanded( +// child: Text( +// message['MSG_ORIGEM_DESC'].toString(), +// style: TextStyle( +// fontWeight: FontWeight.bold, +// fontSize: 15, +// color: FlutterFlowTheme.of(context).primary, +// ), +// overflow: TextOverflow.fade, +// ), +// ), +// ].divide(const SizedBox(width: 10)), +// ), +// Row( +// mainAxisAlignment: MainAxisAlignment.start, +// mainAxisSize: MainAxisSize.max, +// children: [ +// Padding( +// padding: const EdgeInsets.only(left: 5), +// child: Icon( +// Icons.history, +// color: FlutterFlowTheme.of(context).customColor6, +// size: 15, +// ), +// ), +// Expanded( +// child: Text( +// message['MSG_DATE'].toString(), +// style: TextStyle( +// fontWeight: FontWeight.bold, +// fontSize: 10, +// color: FlutterFlowTheme.of(context).customColor6, +// ), +// overflow: TextOverflow.ellipsis, +// ), +// ), +// ].divide(const SizedBox(width: 15)), +// ), +// Row( +// mainAxisAlignment: MainAxisAlignment.start, +// mainAxisSize: MainAxisSize.max, +// children: [ +// Padding( +// padding: const EdgeInsets.only(left: 5), +// child: Icon( +// Icons.message, +// color: FlutterFlowTheme.of(context).customColor6, +// size: 15, +// ), +// ), +// Expanded( +// child: Text( +// message['MSG_TEXTO'].toString(), +// ), +// ), +// ].divide(const SizedBox(width: 15)), +// ), +// ].divide(const SizedBox(height: 4)), +// ), +// ), +// // Row( +// // children: [ +// // Icon( +// // Icons.message, +// // color: FlutterFlowTheme.of(context).customColor6, +// // size: 15, +// // ), +// // Expanded( +// // child: Padding( +// // padding: const EdgeInsets.all(8.0), +// // child: Text( +// // message['MSG_TEXTO'].toString(), +// // ), +// // ), +// // ), +// // ] +// // .addToStart(const SizedBox(width: 8)) +// // .addToEnd(const SizedBox(width: 8))), +// ].divide( +// const SizedBox(height: 8), +// ), +// ), +// ), +// ), +// )); +// } +// } -class MessageWellState { - final List messages; - int pageNumber; - final bool allowScrollInSingleChildScrollView; +// class MessageWellState { +// final List messages; +// int pageNumber; +// final bool allowScrollInSingleChildScrollView; - MessageWellState({ - required this.messages, - this.pageNumber = 1, - required this.allowScrollInSingleChildScrollView, - }); +// MessageWellState({ +// required this.messages, +// this.pageNumber = 1, +// required this.allowScrollInSingleChildScrollView, +// }); - MessageWellState copyWith({ - List? messages, - int? pageNumber, - bool? allowScrollInSingleChildScrollView, - }) { - return MessageWellState( - messages: messages ?? this.messages, - pageNumber: pageNumber ?? this.pageNumber, - allowScrollInSingleChildScrollView: allowScrollInSingleChildScrollView ?? this.allowScrollInSingleChildScrollView, - ); - } -} +// MessageWellState copyWith({ +// List? messages, +// int? pageNumber, +// bool? allowScrollInSingleChildScrollView, +// }) { +// return MessageWellState( +// messages: messages ?? this.messages, +// pageNumber: pageNumber ?? this.pageNumber, +// allowScrollInSingleChildScrollView: allowScrollInSingleChildScrollView ?? this.allowScrollInSingleChildScrollView, +// ); +// } +// } -class MessageWellNotifier extends StateNotifier { - var _totalPageNumber = 1; - int get totalPageNumber => _totalPageNumber; +// class MessageWellNotifier extends StateNotifier { +// var _totalPageNumber = 1; +// int get totalPageNumber => _totalPageNumber; - set totalPageNumber(int value) { - _totalPageNumber = value; - } +// set totalPageNumber(int value) { +// _totalPageNumber = value; +// } - MessageWellNotifier() - : super(MessageWellState( - messages: [], - allowScrollInSingleChildScrollView: true, - )) { - fetchMessages(); - } +// MessageWellNotifier() +// : super(MessageWellState( +// messages: [], +// allowScrollInSingleChildScrollView: true, +// )) { +// fetchMessages(); +// } - void fetchMessages() async { - if (state.pageNumber <= totalPageNumber) { - var apiCall = GetMessagesCall(); - var response = await apiCall.call( - pageSize: '100', - pageNumber: state.pageNumber.toString(), - tipoDestino: dropdown.value.values.first, - ); - if (response.statusCode == 200) { - var messagesData = response.jsonBody['mensagens']; - var newMessages = [...state.messages, ...messagesData]; - state = state.copyWith(messages: newMessages); - // var rExp = RegExp(r'\d+') - // .allMatches(newMessages.toString()) - // .map((e) => e.group(0)) - // .toList(); - // Provider.of(context, listen: false).setCounter(int.parse(response.jsonBody['total_pages'])); - // totalPageNumber = int.parse(response.jsonBody['total_pages']); - } else {} - } else {} - } +// void fetchMessages() async { +// if (state.pageNumber <= totalPageNumber) { +// var apiCall = GetMessagesCall(); +// var response = await apiCall.call( +// pageSize: '100', +// pageNumber: state.pageNumber.toString(), +// tipoDestino: dropdown.value.values.first, +// ); +// if (response.statusCode == 200) { +// var messagesData = response.jsonBody['mensagens']; +// var newMessages = [...state.messages, ...messagesData]; +// state = state.copyWith(messages: newMessages); +// // var rExp = RegExp(r'\d+') +// // .allMatches(newMessages.toString()) +// // .map((e) => e.group(0)) +// // .toList(); +// // Provider.of(context, listen: false).setCounter(int.parse(response.jsonBody['total_pages'])); +// // totalPageNumber = int.parse(response.jsonBody['total_pages']); +// } else {} +// } else {} +// } - List getMessages() { - return state.messages; - } +// List getMessages() { +// return state.messages; +// } - void incrementPageNumber() { - if (state.pageNumber <= totalPageNumber) { - state = state.copyWith(pageNumber: state.pageNumber + 1); - } - } -} +// void incrementPageNumber() { +// if (state.pageNumber <= totalPageNumber) { +// state = state.copyWith(pageNumber: state.pageNumber + 1); +// } +// } +// } -final messageWellProvider = StateNotifierProvider((ref) { - return MessageWellNotifier(); -}); +// final messageWellProvider = StateNotifierProvider((ref) { +// return MessageWellNotifier(); +// }); diff --git a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart index f65158fa..6802b685 100644 --- a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart +++ b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart @@ -2,8 +2,9 @@ import 'package:flutter/material.dart'; import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + // ignore: unused_import import 'package:intl/intl.dart'; @@ -56,9 +57,9 @@ class ScheduleVisitDetailModel extends FlutterFlowModel initDB() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 b1733956..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 @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:hub/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel { late final String devUUID; @@ -16,10 +16,10 @@ class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel initDB() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + 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 1de0af97..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 @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -32,9 +32,9 @@ class AccessNotificationModalTemplateComponentModel } Future initDB() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 90395b06..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 @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -49,7 +49,7 @@ class _PassKeyTemplateWidgetState extends State { } Future _initialize() async { - _accessPass = await StorageHelper().get(SecureStorageKey.accessPass.value, Storage.SecureStorage) ?? ''; + _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 26e45baa..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 @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:hub/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class LiberationHistoryItemDetailsTemplateComponentModel extends FlutterFlowModel { @@ -27,9 +27,9 @@ class LiberationHistoryItemDetailsTemplateComponentModel void initState(BuildContext context) {} Future initDatabase() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 7c86e00d..95937bac 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 @@ -4,14 +4,14 @@ import 'package:flutter/material.dart'; import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class ScheduleProvisionalVisitPageModel extends FlutterFlowModel { String cliUUID = ''; String devUUID = ''; String userUUID = ''; - String cliName = ''; + String ownerName = ''; String ownerUUID = ''; VoidCallback? setState; @@ -58,7 +58,6 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel init() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - ; - cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; - ownerUUID = (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + ownerName = (await StorageHelper().get(KeychainStorageKey.ownerName.value)) ?? ''; + ownerUUID = (await StorageHelper().get(KeychainStorageKey.ownerUUID.value)) ?? ''; setState?.call(); } } diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart index df0b3610..debd346b 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart @@ -153,7 +153,7 @@ class _ScheduleProvisionalVisitPageWidgetState extends State initializeDatabase() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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_in_template_component/sign_in_template_component_widget.dart b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart index e476c98a..d339f173 100644 --- a/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart +++ b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart'; -import 'package:hub/shared/components/atoms/atom_terms_of_use.dart'; +import 'package:hub/shared/components/atoms/term_of_use/atom_terms_of_use.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; @@ -215,8 +215,7 @@ class _SignInTemplateComponentWidgetState extends State EasyDebounce.debounce('_model.passwordTextController', - const Duration(milliseconds: 500), () => setState(() {})), + onChanged: (_) => EasyDebounce.debounce('_model.passwordTextController', const Duration(milliseconds: 500), () => setState(() {})), autofocus: true, autofillHints: const [AutofillHints.password], textInputAction: TextInputAction.send, obscureText: !_model.passwordVisibility, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of(context).getText('2x19ce8k' /* Senha */), + labelText: FFLocalizations.of(context).getText('2x19ce8k' /* Senha */), labelStyle: FlutterFlowTheme.of(context).labelLarge.override( fontFamily: 'Plus Jakarta Sans', color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: - GoogleFonts.asMap().containsKey('Plus Jakarta Sans')), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans')), enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).customColor1, width: 0.25), + borderSide: BorderSide(color: FlutterFlowTheme.of(context).customColor1, width: 0.25), borderRadius: BorderRadius.circular(12.0), ), errorStyle: TextStyle( @@ -310,9 +303,7 @@ class _SignInTemplateComponentWidgetState extends State setState( - () => _model.passwordVisibility = !_model.passwordVisibility), + onTap: () => setState(() => _model.passwordVisibility = !_model.passwordVisibility), focusNode: FocusNode(skipTraversal: true), - child: Icon( - _model.passwordVisibility - ? Icons.visibility_outlined - : Icons.visibility_off_outlined, - color: FlutterFlowTheme.of(context).accent1, - size: 24.0), + child: Icon(_model.passwordVisibility ? Icons.visibility_outlined : Icons.visibility_off_outlined, + color: FlutterFlowTheme.of(context).accent1, size: 24.0), ), ), style: FlutterFlowTheme.of(context).bodyLarge.override( @@ -341,8 +327,7 @@ class _SignInTemplateComponentWidgetState extends State('toggleSignUpPage'), onPressed: () async => await widget.toggleSignUpPage?.call(), - text: FFLocalizations.of(context) - .getText('jwvd4ai1' /* Cadastrar */), + text: FFLocalizations.of(context).getText('jwvd4ai1' /* Cadastrar */), options: FFButtonOptions( width: double.infinity, height: 44.0, - padding: - const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), - iconPadding: - const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).customColor1, textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'Plus Jakarta Sans', @@ -513,8 +483,7 @@ class _SignInTemplateComponentWidgetState extends State _initialize() async { - _deviceType = (await StorageHelper().get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? ''; + _deviceType = (await StorageHelper().get(SecureStorageKey.deviceType.value)) ?? ''; } @override @@ -111,9 +111,7 @@ class _SignUpTemplateComponentWidgetState extends State('passwordVisibilitySuffixIcon'), onTap: () => setState( - () => _model.passwordRegisterFormVisibility = - !_model.passwordRegisterFormVisibility, + () => _model.passwordRegisterFormVisibility = !_model.passwordRegisterFormVisibility, ), focusNode: FocusNode(skipTraversal: true), child: Icon( - _model.passwordRegisterFormVisibility - ? Icons.visibility_outlined - : Icons.visibility_off_outlined, + _model.passwordRegisterFormVisibility ? Icons.visibility_outlined : Icons.visibility_off_outlined, color: FlutterFlowTheme.of(context).accent1, size: 24.0, ), @@ -477,11 +465,9 @@ class _SignUpTemplateComponentWidgetState extends State { } Future initializeDatabase() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 eb9d3806..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 @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel { late final String devUUID; @@ -35,9 +35,9 @@ class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel initDatabase() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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_widget.dart b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart index d4c1921c..6c3ea0f2 100644 --- a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart +++ b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart @@ -341,7 +341,6 @@ class _VisitorSearchModalTemplateComponentWidgetState extends State sendVisitors(BuildContext context) async { await widget.getVisitors?.call(_model.visitors); - log('() => docs: ${_model.docs}'); await widget.getDocs?.call(_model.docs); context.pop(); } diff --git a/lib/core/meta/anotations.dart b/lib/core/meta/anotations.dart new file mode 100644 index 00000000..af721eaa --- /dev/null +++ b/lib/core/meta/anotations.dart @@ -0,0 +1,7 @@ +import 'package:meta/meta.dart'; + +class DeadCode { + final String? desc; + + const DeadCode([this.desc = '']); +} diff --git a/lib/features/_template_/data/data_sources/index.dart b/lib/features/_template_/data/data_sources/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/data/index.dart b/lib/features/_template_/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/features/_template_/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/features/_template_/data/models/index.dart b/lib/features/_template_/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/data/repositories/index.dart b/lib/features/_template_/data/repositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/domain/entities/index.dart b/lib/features/_template_/domain/entities/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/domain/index.dart b/lib/features/_template_/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/features/_template_/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/features/_template_/domain/respositories/index.dart b/lib/features/_template_/domain/respositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/domain/usecases/index.dart b/lib/features/_template_/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/index.dart b/lib/features/_template_/index.dart new file mode 100644 index 00000000..aa560630 --- /dev/null +++ b/lib/features/_template_/index.dart @@ -0,0 +1,3 @@ +export 'data/index.dart'; +export 'domain/index.dart'; +export 'presentation/index.dart'; diff --git a/lib/features/_template_/presentation/blocs/index.dart b/lib/features/_template_/presentation/blocs/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/presentation/index.dart b/lib/features/_template_/presentation/index.dart new file mode 100644 index 00000000..48b6447a --- /dev/null +++ b/lib/features/_template_/presentation/index.dart @@ -0,0 +1,3 @@ +export 'blocs/index.dart'; +export 'pages/index.dart'; +export 'widgets/index.dart'; diff --git a/lib/features/_template_/presentation/pages/index.dart b/lib/features/_template_/presentation/pages/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/_template_/presentation/widgets/index.dart b/lib/features/_template_/presentation/widgets/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/home/data/data_sources/index.dart b/lib/features/home/data/data_sources/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/home/data/index.dart b/lib/features/home/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/features/home/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/features/home/data/models/index.dart b/lib/features/home/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/home/data/repositories/index.dart b/lib/features/home/data/repositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/home/domain/entities/index.dart b/lib/features/home/domain/entities/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/home/domain/index.dart b/lib/features/home/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/features/home/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/features/home/domain/respositories/index.dart b/lib/features/home/domain/respositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/home/domain/usecases/index.dart b/lib/features/home/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/home/index.dart b/lib/features/home/index.dart new file mode 100644 index 00000000..aa560630 --- /dev/null +++ b/lib/features/home/index.dart @@ -0,0 +1,3 @@ +export 'data/index.dart'; +export 'domain/index.dart'; +export 'presentation/index.dart'; diff --git a/lib/features/home/presentation/blocs/home_bloc.dart b/lib/features/home/presentation/blocs/home_bloc.dart new file mode 100644 index 00000000..5829df5f --- /dev/null +++ b/lib/features/home/presentation/blocs/home_bloc.dart @@ -0,0 +1,38 @@ + +import 'dart:async'; + +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + +import '../../../../shared/components/molecules/locals/index.dart'; +import 'index.dart'; + +class HomeBloc extends Bloc { + late StreamSubscription _completer; + + HomeBloc() : super(HomeState()) { + on(_onHomeEvent); + _completer = LocalsRepositoryImpl.license.stream.listen((v) { + add(HomeEvent()); + }); + } + + Future _onHomeEvent(HomeEvent event, Emitter emit) async { + 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, + userUUID: userUUID, + cliUUID: cliUUID, + userName: userName, + userEmail: userEmail, + )); + } +} + + diff --git a/lib/features/home/presentation/blocs/home_events.dart b/lib/features/home/presentation/blocs/home_events.dart new file mode 100644 index 00000000..bb0442c1 --- /dev/null +++ b/lib/features/home/presentation/blocs/home_events.dart @@ -0,0 +1 @@ +class HomeEvent {} diff --git a/lib/features/home/presentation/blocs/home_state.dart b/lib/features/home/presentation/blocs/home_state.dart new file mode 100644 index 00000000..b2a0c708 --- /dev/null +++ b/lib/features/home/presentation/blocs/home_state.dart @@ -0,0 +1,35 @@ +class HomeState { + final bool isGrid; + final String devUUID; + final String cliUUID; + final String userUUID; + final String userName; + final String userEmail; + + HomeState({ + this.isGrid = false, + this.devUUID = '', + this.cliUUID = '', + this.userUUID = '', + this.userName = '', + this.userEmail = '', + }); + + HomeState copyWith({ + bool? isGrid, + String? devUUID, + String? cliUUID, + String? userUUID, + String? userName, + String? userEmail, + }) { + return HomeState( + isGrid: isGrid ?? this.isGrid, + devUUID: devUUID ?? this.devUUID, + cliUUID: cliUUID ?? this.cliUUID, + userUUID: userUUID ?? this.userUUID, + userName: userName ?? this.userName, + userEmail: userEmail ?? this.userEmail, + ); + } +} diff --git a/lib/features/home/presentation/blocs/index.dart b/lib/features/home/presentation/blocs/index.dart new file mode 100644 index 00000000..d06783d6 --- /dev/null +++ b/lib/features/home/presentation/blocs/index.dart @@ -0,0 +1,3 @@ +export 'home_bloc.dart'; +export 'home_events.dart'; +export 'home_state.dart'; diff --git a/lib/features/home/presentation/index.dart b/lib/features/home/presentation/index.dart new file mode 100644 index 00000000..48b6447a --- /dev/null +++ b/lib/features/home/presentation/index.dart @@ -0,0 +1,3 @@ +export 'blocs/index.dart'; +export 'pages/index.dart'; +export 'widgets/index.dart'; diff --git a/lib/pages/home_page/home_page_widget.dart b/lib/features/home/presentation/pages/home_page.dart similarity index 64% rename from lib/pages/home_page/home_page_widget.dart rename to lib/features/home/presentation/pages/home_page.dart index ca2ff3ce..350ae9a2 100644 --- a/lib/pages/home_page/home_page_widget.dart +++ b/lib/features/home/presentation/pages/home_page.dart @@ -1,60 +1,65 @@ + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/components/organism_components/local_profile_component/local_profile_component_widget.dart'; -import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart'; + import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/pages/home_page/home_page_model.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; -import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart'; +import 'package:hub/shared/components/molecules/drawer/index.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; + class HomePageWidget extends StatefulWidget { - const HomePageWidget({super.key}); + const HomePageWidget(this.update, {super.key}); + final Future Function(BuildContext context)? update; @override State createState() => _HomePageWidgetState(); } -class _HomePageWidgetState extends State { - late HomePageModel _model; +class _HomePageWidgetState extends State with WidgetsBindingObserver { final scaffoldKey = GlobalKey(); - late LocalProfileComponentWidget _localProfileComponentWidget; - - _HomePageWidgetState() { - _localProfileComponentWidget = LocalProfileComponentWidget(); - } - - @override - void dispose() { - super.dispose(); - _model.dispose(); - } - @override void initState() { super.initState(); - - _model = createModel(context, () => HomePageModel(safeSetState: () => safeSetState(() {}))); - - _model.textController ??= TextEditingController(); - _model.textFieldFocusNode ??= FocusNode(); + WidgetsBinding.instance.addObserver(this); + WidgetsBinding.instance.addPostFrameCallback((_) async { + await LocalsRepositoryImpl().check(context); + if (widget.update != null) { + await widget.update!(context); + } + }); } + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + @override Widget build(BuildContext context) { - StorageHelper().context = context; - return Scaffold( - key: scaffoldKey, - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - // drawer: buildDrawer(context), - drawerEnableOpenDragGesture: true, - drawerDragStartBehavior: DragStartBehavior.start, - drawer: CustomDrawer(model: _model), - appBar: buildAppBar(context), - body: buildPage(context), + return Builder( + builder: (context) { + // LocalsRepositoryImpl.license.add(false); + // context.read().add(LocalProfileEvent()); + // context.read().add(MenuEvent()); + LocalsRepositoryImpl.license.add(true); + + return Scaffold( + key: scaffoldKey, + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + drawerEnableOpenDragGesture: true, + drawerDragStartBehavior: DragStartBehavior.start, + drawer: CustomDrawer(), + appBar: buildAppBar(context), + body: buildPage(context), + ); + }, ); } @@ -139,25 +144,18 @@ class _HomePageWidgetState extends State { Widget buildBody() { return Container( color: FlutterFlowTheme.of(context).primaryBackground, - child: wrapWithModel( - model: _model.homeMenuComponentModel, - updateOnChange: true, - updateCallback: () => setState(() {}), - child: Padding( - padding: const EdgeInsets.only(bottom: 40), - child: MenuComponentWidget( - model: _model.homeMenuComponentModel, - ), + child: Padding( + padding: const EdgeInsets.only(bottom: 40), + child: Menufactory( + entry: MenuEntry.getEntriesByType(MenuEntryType.Home), + item: EnumMenuItem.button, + view: MenuView.list_grid, ), ), ); } Widget buildLocal() { - return wrapWithModel( - model: _model.localComponentModel, - updateCallback: () => safeSetState(() {}), - child: _localProfileComponentWidget, - ); + return LocalProfileComponentWidget(); } } diff --git a/lib/features/home/presentation/pages/index.dart b/lib/features/home/presentation/pages/index.dart new file mode 100644 index 00000000..e4ff2696 --- /dev/null +++ b/lib/features/home/presentation/pages/index.dart @@ -0,0 +1 @@ +export 'home_page.dart'; diff --git a/lib/features/home/presentation/widgets/index.dart b/lib/features/home/presentation/widgets/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/data/data_sources/index.dart b/lib/features/property/data/data_sources/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/data/index.dart b/lib/features/property/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/features/property/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/features/property/data/models/index.dart b/lib/features/property/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/data/repositories/index.dart b/lib/features/property/data/repositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/domain/entities/index.dart b/lib/features/property/domain/entities/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/domain/index.dart b/lib/features/property/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/features/property/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/features/property/domain/respositories/index.dart b/lib/features/property/domain/respositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/domain/usecases/index.dart b/lib/features/property/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/index.dart b/lib/features/property/index.dart new file mode 100644 index 00000000..aa560630 --- /dev/null +++ b/lib/features/property/index.dart @@ -0,0 +1,3 @@ +export 'data/index.dart'; +export 'domain/index.dart'; +export 'presentation/index.dart'; diff --git a/lib/features/property/presentation/blocs/index.dart b/lib/features/property/presentation/blocs/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/presentation/index.dart b/lib/features/property/presentation/index.dart new file mode 100644 index 00000000..48b6447a --- /dev/null +++ b/lib/features/property/presentation/index.dart @@ -0,0 +1,3 @@ +export 'blocs/index.dart'; +export 'pages/index.dart'; +export 'widgets/index.dart'; diff --git a/lib/pages/about_property_page/about_property_screen.dart b/lib/features/property/presentation/pages/about_property_screen.dart similarity index 61% rename from lib/pages/about_property_page/about_property_screen.dart rename to lib/features/property/presentation/pages/about_property_screen.dart index 9a80615a..7560cc25 100644 --- a/lib/pages/about_property_page/about_property_screen.dart +++ b/lib/features/property/presentation/pages/about_property_screen.dart @@ -1,12 +1,31 @@ // ignore: must_be_immutable import 'package:flutter/material.dart'; +import 'package:hub/backend/schema/enums/enums.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/appbar.dart'; -import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/pages/about_property_page/about_property_model.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/shared/components/molecules/modules/index.dart'; + +class AboutPropertyModel extends FlutterFlowModel { + dynamic item; + + VoidCallback? safeSetState; + + Future initAsync() async { + safeSetState?.call(); + } + + @override + void initState(BuildContext context) { + initAsync(); + } + + @override + void dispose() {} +} // ignore: must_be_immutable class AboutPropertyPage extends StatefulWidget { @@ -43,15 +62,11 @@ class _AboutPropertyPageState extends State with SingleTicker @override Widget build(BuildContext context) { - return Scaffold( - appBar: _buildAppBar(context), - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - body: _buildBody(context)); + return Scaffold(appBar: _buildAppBar(context), backgroundColor: FlutterFlowTheme.of(context).primaryBackground, body: _buildBody(context)); } PreferredSizeWidget _buildAppBar(BuildContext context) { - final String title = - FFLocalizations.of(context).getVariableText(ptText: "Sobre a Propriedade", enText: "About the Property"); + final String title = FFLocalizations.of(context).getVariableText(ptText: "Sobre a Propriedade", enText: "About the Property"); return AppBarUtil( title: title, onBackButtonPressed: () => context.pop(), @@ -62,13 +77,10 @@ class _AboutPropertyPageState extends State with SingleTicker return SingleChildScrollView( child: Container( color: FlutterFlowTheme.of(context).primaryBackground, - child: wrapWithModel( - model: _model.menuComponentModel, - updateCallback: () => setState(() {}), - child: Padding( - padding: EdgeInsets.only(bottom: 40), - child: MenuComponentWidget(model: _model.menuComponentModel), - ), + child: Menufactory( + entry: MenuEntry.getEntriesByType(MenuEntryType.Property), + item: EnumMenuItem.button, + view: MenuView.list_grid, ), ), ); diff --git a/lib/features/property/presentation/pages/index.dart b/lib/features/property/presentation/pages/index.dart new file mode 100644 index 00000000..f997df03 --- /dev/null +++ b/lib/features/property/presentation/pages/index.dart @@ -0,0 +1 @@ +export 'about_property_screen.dart'; diff --git a/lib/features/property/presentation/widgets/index.dart b/lib/features/property/presentation/widgets/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/flutter_flow/custom_functions.dart b/lib/flutter_flow/custom_functions.dart index ddd01694..155966e4 100644 --- a/lib/flutter_flow/custom_functions.dart +++ b/lib/flutter_flow/custom_functions.dart @@ -33,6 +33,25 @@ String jsonListToStr(List visitorList) { return result.substring(0, result.length - 1); } +Future> stringToMap(String v) async { + try { + return Future.value(Map.fromEntries( + v.split(',').map((part) { + final keyValue = part.split(':'); + if (keyValue.length < 2) { + throw FormatException('Invalid key-value pair: $part of $v'); + } + final key = keyValue[0].trim(); + final value = keyValue.sublist(1).join(':').trim(); // Join the remaining parts to handle DateTime correctly + return MapEntry(key, value); + }), + )); + } catch (e) { + print('Error parsing string to map: $e'); + return Future.value({}); + } +} + List listStrJsonToJsonList( dynamic jsonList, List strList, diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index 07f4bbfb..25209384 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -4,14 +4,14 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:hub/backend/schema/util/schema_util.dart'; +import 'package:hub/features/home/index.dart'; +import 'package:hub/features/property/index.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/pages/about_property_page/about_property_screen.dart'; import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart'; import 'package:hub/pages/delivery_schedule_page/delivery_schedule_widget.dart'; import 'package:hub/pages/fast_pass_page/fast_pass_page_widget.dart'; import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart'; -import 'package:hub/pages/home_page/home_page_widget.dart'; import 'package:hub/pages/liberation_history/liberation_history_widget.dart'; import 'package:hub/pages/message_history_page/message_history_page_widget.dart'; import 'package:hub/pages/package_order_page/package_order_page.dart'; @@ -24,14 +24,16 @@ import 'package:hub/pages/qr_code_page/qr_code_page_widget.dart'; import 'package:hub/pages/reception_page/reception_page_widget.dart'; import 'package:hub/pages/register_visitor_page/register_visitor_page_widget.dart'; import 'package:hub/pages/reservation_page/reservation_page_widget.dart'; +import 'package:hub/pages/residents_on_the_property/residents_on_the_property_screen.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart'; import 'package:hub/pages/sign_in_page/sign_in_page_widget.dart'; import 'package:hub/pages/sign_up_page/sign_up_page_widget.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart'; import 'package:hub/pages/visits_on_the_property/visits_on_the_property_screen.dart'; import 'package:hub/pages/welcome_page/welcome_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:provider/provider.dart'; export 'package:go_router/go_router.dart'; @@ -40,7 +42,7 @@ export 'serialization_util.dart'; const kTransitionInfoKey = '__transition_info__'; -final GlobalKey key = GlobalKey(); +final GlobalKey navigatorKey = GlobalKey(); class AppStateNotifier extends ChangeNotifier { AppStateNotifier._(); @@ -58,7 +60,7 @@ class AppStateNotifier extends ChangeNotifier { GoRouter createRouter(AppStateNotifier appStateNotifier) { return GoRouter( - navigatorKey: key, + navigatorKey: navigatorKey, initialLocation: '/', debugLogDiagnostics: true, redirect: (context, state) { @@ -84,28 +86,13 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { builder: (context, _) { return FutureBuilder( future: () async { - final bool isLogged = await StorageHelper().get( - SecureStorageKey.isLogged.value, Storage.SecureStorage) == - 'true'; - final bool haveLocal = await StorageHelper().get( - SecureStorageKey.haveLocal.value, - Storage.SecureStorage) == - 'true'; - final bool haveUserUUID = (await StorageHelper().get( - SQLiteStorageKey.userUUID.value, - Storage.SQLiteStorage)) - ?.isNotEmpty ?? - false; - final bool haveDevUUID = (await StorageHelper().get( - SQLiteStorageKey.devUUID.value, - Storage.SQLiteStorage)) - ?.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(); + return haveLocal ? HomePageWidget(LocalsRepositoryImpl().update) : const ReceptionPageWidget(); } else { return const WelcomePageWidget(); } @@ -126,62 +113,40 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { FFRoute( name: 'forgotPassword', path: '/forgotPassword', - builder: (context, params) => ForgotPasswordScreen( + builder: (context, params) { + late final String email = params.getParam('email', ParamType.String); + late final String token = params.getParam('token', ParamType.String); + + return ForgotPasswordScreen( key: UniqueKey(), - email: params.getParam('email', ParamType.String), - token: params.getParam('token', ParamType.String))), - FFRoute(name: 'homePage', path: '/homePage', builder: (context, params) => HomePageWidget(key: UniqueKey())), - FFRoute( - name: 'petsOnThePropertyPage', - path: '/petsOnThePropertyPage', - builder: (context, params) => Scaffold(body: const PetsHistoryScreen(isApp: true))), - FFRoute( - name: 'vehiclesOnThePropertyPage', - path: '/vehiclesOnThePropertyPage', - builder: (context, params) => const VehicleOnTheProperty()), - FFRoute( - name: 'visitsOnThePropertyPage', - path: '/visitsOnThePropertyPage', - builder: (context, params) => const VisitsOnTheProperty()), + email: email, + token: token, + ); + }), + FFRoute(name: 'homePage', path: '/homePage', builder: (context, params) { + final Future Function(BuildContext context)? update = params.getParam('update', ParamType.Function); + return HomePageWidget(key: UniqueKey(), update); + + }), + FFRoute(name: 'petsOnThePropertyPage', path: '/petsOnThePropertyPage', builder: (context, params) => Scaffold(body: const PetsHistoryScreen(isApp: true))), + FFRoute(name: 'vehiclesOnThePropertyPage', path: '/vehiclesOnThePropertyPage', builder: (context, params) => const VehicleOnTheProperty()), FFRoute(name: 'receptionPage', path: '/receptionPage', builder: (context, params) => const ReceptionPageWidget()), - FFRoute( - name: 'messageHistoryPage', - path: '/messageHistoryPage', - builder: (context, params) => const MessageHistoryPageWidget()), - FFRoute( - name: 'registerVisitorPage', - path: '/registerVisitorPage', - builder: (context, params) => const RegisterVisitorPageWidget()), - FFRoute( - name: 'scheduleCompleteVisitPage', - path: '/scheduleCompleteVisitPage', - builder: (context, params) => const ScheduleCompleteVisitPageWidget()), - FFRoute( - name: 'deliverySchedule', path: '/deliverySchedule', builder: (context, params) => const DeliverySchedule()), - FFRoute( - name: 'provisionalSchedule', - path: '/provisionalSchedule', - builder: (context, params) => const ProvisionalSchedule()), - FFRoute( - name: 'fastPassPage', path: '/fastPassPage', builder: (context, params) => /*const*/ FastPassPageWidget()), - FFRoute( - name: 'preferencesSettings', - path: '/preferencesSettings', - builder: (context, params) => PreferencesPageWidget()), + FFRoute(name: 'messageHistoryPage', path: '/messageHistoryPage', builder: (context, params) => const MessageHistoryPageWidget()), + FFRoute(name: 'registerVisitorPage', path: '/registerVisitorPage', builder: (context, params) => const RegisterVisitorPageWidget()), + FFRoute(name: 'scheduleCompleteVisitPage', path: '/scheduleCompleteVisitPage', builder: (context, params) => const ScheduleCompleteVisitPageWidget()), + FFRoute(name: 'deliverySchedule', path: '/deliverySchedule', builder: (context, params) => const DeliverySchedule()), + FFRoute(name: 'provisionalSchedule', path: '/provisionalSchedule', builder: (context, params) => const ProvisionalSchedule()), + FFRoute(name: 'fastPassPage', path: '/fastPassPage', builder: (context, params) => /*const*/ FastPassPageWidget()), + FFRoute(name: 'preferencesSettings', path: '/preferencesSettings', builder: (context, params) => PreferencesPageWidget()), FFRoute(name: 'aboutProperty', path: '/aboutProperty', builder: (context, params) => AboutPropertyPage()), - FFRoute( - name: 'peopleOnThePropertyPage', - path: '/peopleOnThePropertyPage', - builder: (context, params) => PeopleOnThePropertyPage()), + FFRoute(name: 'residentsOnThePropertyPage', path: '/residentsOnThePropertyPage', builder: (context, params) => ResidentsOnTheProperty()), + FFRoute(name: 'visitsOnThePropertyPage', path: '/visitsOnThePropertyPage', builder: (context, params) => VisitsOnTheProperty()), + FFRoute(name: 'peopleOnThePropertyPage', path: '/peopleOnThePropertyPage', builder: (context, params) => PeopleOnThePropertyPage()), FFRoute( name: 'acessHistoryPage', path: '/acessHistoryPage', - builder: (context, params) => - AccessHistoryScreen(opt: const {'personType': '.*', 'accessType': '.*', 'search': '.*'})), - FFRoute( - name: 'liberationHistory', - path: '/liberationHistory', - builder: (context, params) => const LiberationHistoryWidget()), + builder: (context, params) => AccessHistoryScreen(opt: const {'personType': '.*', 'accessType': '.*', 'search': '.*'})), + FFRoute(name: 'liberationHistory', path: '/liberationHistory', builder: (context, params) => const LiberationHistoryWidget()), FFRoute(name: 'signInPage', path: '/signInPage', builder: (context, params) => const SignInPageWidget()), FFRoute(name: 'signUpPage', path: '/signUpPage', builder: (context, params) => const SignUpPageWidget()), FFRoute(name: 'welcomePage', path: '/welcomePage', builder: (context, params) => const WelcomePageWidget()), @@ -204,9 +169,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { extension NavParamExtensions on Map { Map get withoutNulls => Map.fromEntries( - entries - .where((e) => e.value != null) - .map((e) => MapEntry(e.key, e.value!)), + entries.where((e) => e.value != null).map((e) => MapEntry(e.key, e.value!)), ); } @@ -220,23 +183,18 @@ extension NavigationExtensions on BuildContext { } extension _GoRouterStateExtensions on GoRouterState { - Map get extraMap => - extra != null ? extra as Map : {}; + Map get extraMap => extra != null ? extra as Map : {}; Map get allParams => {} ..addAll(pathParameters) ..addAll(uri.queryParameters) ..addAll(extraMap); - TransitionInfo get transitionInfo => extraMap.containsKey(kTransitionInfoKey) - ? extraMap[kTransitionInfoKey] as TransitionInfo - : TransitionInfo.appDefault(); + TransitionInfo get transitionInfo => extraMap.containsKey(kTransitionInfoKey) ? extraMap[kTransitionInfoKey] as TransitionInfo : TransitionInfo.appDefault(); } extension GoRouterLocationExtension on GoRouter { String getCurrentLocation() { final RouteMatch lastMatch = routerDelegate.currentConfiguration.last; - final RouteMatchList matchList = lastMatch is ImperativeRouteMatch - ? lastMatch.matches - : routerDelegate.currentConfiguration; + final RouteMatchList matchList = lastMatch is ImperativeRouteMatch ? lastMatch.matches : routerDelegate.currentConfiguration; return matchList.uri.toString(); } } @@ -248,18 +206,13 @@ class FFParameters { final Map Function(String)> asyncParams; Map futureParamValues = {}; - bool get isEmpty => - state.allParams.isEmpty || - (state.allParams.length == 1 && - state.extraMap.containsKey(kTransitionInfoKey)); - bool isAsyncParam(MapEntry param) => - asyncParams.containsKey(param.key) && param.value is String; + bool get isEmpty => state.allParams.isEmpty || (state.allParams.length == 1 && state.extraMap.containsKey(kTransitionInfoKey)); + bool isAsyncParam(MapEntry param) => asyncParams.containsKey(param.key) && param.value is String; bool get hasFutures => state.allParams.entries.any(isAsyncParam); Future completeFutures() => Future.wait( state.allParams.entries.where(isAsyncParam).map( (param) async { - final doc = await asyncParams[param.key]!(param.value) - .onError((_, __) => null); + final doc = await asyncParams[param.key]!(param.value).onError((_, __) => null); if (doc != null) { futureParamValues[param.key] = doc; return true; @@ -314,9 +267,7 @@ class FFRoute { key: state.pageKey, child: child, transitionDuration: transitionInfo.duration, - transitionsBuilder: - (context, animation, secondaryAnimation, child) => - PageTransition( + transitionsBuilder: (context, animation, secondaryAnimation, child) => PageTransition( type: transitionInfo.transitionType, duration: transitionInfo.duration, reverseDuration: transitionInfo.duration, @@ -343,8 +294,7 @@ class TransitionInfo { final Duration duration; final Alignment? alignment; - static TransitionInfo appDefault() => - const TransitionInfo(hasTransition: false); + static TransitionInfo appDefault() => const TransitionInfo(hasTransition: false); } class RootPageContext { @@ -356,11 +306,8 @@ class RootPageContext { final rootPageContext = context.read(); final isRootPage = rootPageContext?.isRootPage ?? false; final location = GoRouterState.of(context).uri.toString(); - return isRootPage && - location != '/' && - location != rootPageContext?.errorRoute; + return isRootPage && location != '/' && location != rootPageContext?.errorRoute; } - static Widget wrap(Widget child, {String? errorRoute}) => - Provider.value(value: RootPageContext(true, errorRoute), child: child); + static Widget wrap(Widget child, {String? errorRoute}) => Provider.value(value: RootPageContext(true, errorRoute), child: child); } diff --git a/lib/flutter_flow/nav/serialization_util.dart b/lib/flutter_flow/nav/serialization_util.dart index 02f636c4..18018306 100644 --- a/lib/flutter_flow/nav/serialization_util.dart +++ b/lib/flutter_flow/nav/serialization_util.dart @@ -150,7 +150,7 @@ enum ParamType { FFPlace, FFUploadedFile, JSON, - + Function, DataStruct, Enum, } @@ -186,6 +186,8 @@ dynamic deserializeParam( switch (paramType) { case ParamType.int: return int.tryParse(param); + case ParamType.Function: + return param; case ParamType.double: return double.tryParse(param); case ParamType.String: diff --git a/lib/index.dart b/lib/index.dart index 73ea1557..8b137891 100644 --- a/lib/index.dart +++ b/lib/index.dart @@ -1,12 +1 @@ -export 'pages/acess_history_page/acess_history_page_widget.dart' show AccessHistoryScreen; -export 'pages/home_page/home_page_widget.dart' show HomePageWidget; -export 'pages/liberation_history/liberation_history_widget.dart' show LiberationHistoryWidget; -export 'pages/people_on_the_property_page/people_on_the_property_page_widget.dart' show PeopleOnThePropertyPageWidget; -export 'pages/preferences_settings_page/preferences_settings_widget.dart' show PreferencesPageWidget; -export 'pages/qr_code_page/qr_code_page_widget.dart' show QrCodePageWidget; -export 'pages/register_visitor_page/register_visitor_page_widget.dart' show RegisterVisitorPageWidget; -export 'pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart' - show ScheduleCompleteVisitPageWidget; -export 'pages/sign_in_page/sign_in_page_widget.dart' show SignInPageWidget; -export 'pages/sign_up_page/sign_up_page_widget.dart' show SignUpPageWidget; -export 'pages/welcome_page/welcome_page_widget.dart' show WelcomePageWidget; + diff --git a/lib/initialization.dart b/lib/initialization.dart new file mode 100644 index 00000000..564b073f --- /dev/null +++ b/lib/initialization.dart @@ -0,0 +1,61 @@ +import 'dart:developer'; + +import 'package:app_tracking_transparency/app_tracking_transparency.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_crashlytics/firebase_crashlytics.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_web_plugins/url_strategy.dart'; +import 'package:hub/backend/notifications/notification_service.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + +Future initializeApp() async { + WidgetsFlutterBinding.ensureInitialized(); + await _initializeTracking(); + await StorageHelper().init(); + + await _initializeFirebase(); + await _initializeNotificationService(); + _initializeUrlStrategy(); + _initializeSystemSettings(); + await _initializeFlutterFlow(); +} + +Future _initializeTracking() async { + await AppTrackingTransparency.requestTrackingAuthorization(); +} + +Future _initializeFirebase() async { + await Firebase.initializeApp(); +} + +Future _initializeNotificationService() async { + await NotificationService.initialize(); +} + +void _initializeUrlStrategy() { + setUrlStrategy(PathUrlStrategy()); +} + +void _initializeSystemSettings() { + SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + if (kDebugMode) { + log("Aplicativo em Debug Mode, crashlytics desabilitado!"); + } else { + final crashlyticsInstance = FirebaseCrashlytics.instance; + if (crashlyticsInstance.isCrashlyticsCollectionEnabled) { + FlutterError.onError = crashlyticsInstance.recordFlutterError; + } + } +} + +Future _initializeFlutterFlow() async { + await FlutterFlowTheme.initialize(); + await FFLocalizations.initialize(); + GoRouter.optionURLReflectsImperativeAPIs = true; + usePathUrlStrategy(); +} diff --git a/lib/main.dart b/lib/main.dart index 44f93c98..7ada3253 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,103 +2,51 @@ import 'dart:async'; import 'dart:developer'; import 'dart:io'; -import 'package:app_tracking_transparency/app_tracking_transparency.dart'; -import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:flutter_web_plugins/url_strategy.dart'; import 'package:hub/backend/notifications/notification_service.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -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/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/components/molecules/locals/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/deeplink/deep_link_service.dart'; -import 'package:hub/shared/services/localization/localization_service.dart'; - import 'package:responsive_framework/responsive_framework.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:hub/shared/extensions/string_extensions.dart'; import 'backend/notifications/firebase_messaging_service.dart'; +import 'features/home/index.dart'; +import 'initialization.dart'; +import 'shared/components/molecules/menu/index.dart'; +import 'shared/components/molecules/modules/index.dart'; final GlobalKey navigatorKey = GlobalKey(); void main() async { await initializeApp(); - runApp(const App()); + runApp(const ProviderScope(child: App())); FirebaseMessaging.onBackgroundMessage(_backgroundHandlerMessage); } -Future initializeApp() async { - WidgetsFlutterBinding.ensureInitialized(); - await _initializeTracking(); - await StorageHelper().init(); - - await _initializeFirebase(); - await _initializeNotificationService(); - _initializeUrlStrategy(); - _initializeSystemSettings(); - await _initializeFlutterFlow(); -} - -Future _initializeTracking() async { - await AppTrackingTransparency.requestTrackingAuthorization(); -} - -Future _initializeFirebase() async { - await Firebase.initializeApp(); -} - -Future _initializeNotificationService() async { - await NotificationService.initialize(); -} - -void _initializeUrlStrategy() { - setUrlStrategy(PathUrlStrategy()); -} - -void _initializeSystemSettings() { - SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); - if (kDebugMode) { - log("Aplicativo em Debug Mode, crashlytics desabilitado!"); - } else { - final crashlyticsInstance = FirebaseCrashlytics.instance; - if (crashlyticsInstance.isCrashlyticsCollectionEnabled) { - FlutterError.onError = crashlyticsInstance.recordFlutterError; - } - } -} - -Future _initializeFlutterFlow() async { - await FlutterFlowTheme.initialize(); - await FFLocalizations.initialize(); - GoRouter.optionURLReflectsImperativeAPIs = true; - usePathUrlStrategy(); -} - Future _foregroundHandlerMessage(RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - await StorageHelper() - .set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); StorageHelper().context?.go('/homePage'); } if (!Platform.isIOS) { - NotificationService.show( - title: message.notification!.title!, - body: message.notification!.body!, - payload: Map.from(message.data)); + NotificationService.show(title: message.notification!.title!, body: message.notification!.body!, payload: Map.from(message.data)); } } Future _backgroundHandlerMessage(RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - await StorageHelper() - .set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); StorageHelper().context?.go('/homePage'); } } @@ -109,11 +57,10 @@ class App extends StatefulWidget { @override State createState() => _AppState(); - static _AppState of(BuildContext context) => - context.findAncestorStateOfType<_AppState>()!; + static _AppState of(BuildContext context) => context.findAncestorStateOfType<_AppState>()!; } -class _AppState extends State with WidgetsBindingObserver { +class _AppState extends State { Locale? _locale = FFLocalizations.getStoredLocale(); ThemeMode _themeMode = FlutterFlowTheme.themeMode; late AppStateNotifier _appStateNotifier; @@ -152,8 +99,7 @@ class _AppState extends State with WidgetsBindingObserver { }), ), ); - final Iterable>? localizationsDelegates = - const [ + final Iterable>? localizationsDelegates = const [ FFLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, @@ -192,19 +138,16 @@ 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().set( - SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); log('onMessageOpenedApp'); } else { - onMessageReceived(message.data, message.notification!.body, - message.data['click_action']); + onMessageReceived(message.data, message.notification!.body, message.data['click_action']); } }); FirebaseMessaging.instance.getInitialMessage().then((message) async { if (message != null) { if (message.data['click_action'] == 'enroll_cond') { - await StorageHelper().set( - SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); log('getInitialMessage'); } } @@ -226,8 +169,7 @@ class _AppState extends State with WidgetsBindingObserver { @override void initState() { super.initState(); - WidgetsBinding.instance.addObserver(this); - + FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); _appStateNotifier = AppStateNotifier.instance; _router = createRouter(_appStateNotifier); @@ -242,31 +184,41 @@ class _AppState extends State with WidgetsBindingObserver { @override void dispose() { - WidgetsBinding.instance.removeObserver(this); super.dispose(); } - @override - void didChangeAppLifecycleState(AppLifecycleState state) async { - if (state == AppLifecycleState.detached) { - await LocalizationService.processLocals(context); - FirebaseMessagingService().updateDeviceToken(); - } - } @override Widget build(BuildContext context) { - return MaterialApp.router( - key: navigatorKey, - title: 'FRE ACCESS HUB', - builder: builder, - localizationsDelegates: localizationsDelegates, - locale: _locale, - supportedLocales: supportedLocales, - theme: _theme, - darkTheme: _darkTheme, - themeMode: _themeMode, - routerConfig: _router, + return MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => MenuBloc( + style: MenuView.list_grid, + item: EnumMenuItem.button, + entries: MenuEntry.getEntriesByType(MenuEntryType.Home), + )..add(MenuEvent()), + ), + BlocProvider( + create: (context) => HomeBloc()..add(HomeEvent()), + ), + BlocProvider( + create: (context) => LocalProfileBloc()..add(LocalProfileEvent()), + ), + ], + child: MaterialApp.router( + key: navigatorKey, + title: 'FRE ACCESS HUB', + builder: builder, + localizationsDelegates: localizationsDelegates, + locale: _locale, + supportedLocales: supportedLocales, + theme: _theme, + darkTheme: _darkTheme, + themeMode: _themeMode, + routerConfig: _router, + ), ); } + } diff --git a/lib/pages/about_property_page/about_property_model.dart b/lib/pages/about_property_page/about_property_model.dart deleted file mode 100644 index 4bd5e867..00000000 --- a/lib/pages/about_property_page/about_property_model.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:hub/backend/schema/enums/enums.dart'; -import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; -import 'package:hub/components/organism_components/menu_component/menu_component_model.dart'; -import 'package:hub/flutter_flow/flutter_flow_model.dart'; - -import 'package:hub/pages/about_property_page/about_property_screen.dart'; - -class AboutPropertyModel extends FlutterFlowModel { - dynamic item; - - VoidCallback? safeSetState; - - late MenuComponentModel menuComponentModel; - - Future initAsync() async { - safeSetState?.call(); - } - - @override - void initState(BuildContext context) { - menuComponentModel = createModel( - context, - () => MenuComponentModel(expandable: true, style: MenuView.list_grid, item: MenuItem.button, menuOptions: [ - MenuOption.PetsOnTheProperty, - MenuOption.ResidentsOnTheProperty, - MenuOption.VisitsOnTheProperty, - MenuOption.VehiclesOnTheProperty, - MenuOption.PackagesOnTheProperty, - ])); - - initAsync(); - } - - @override - void dispose() {} -} 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 e42c0cf5..429ae806 100644 --- a/lib/pages/acess_history_page/acess_history_page_model.dart +++ b/lib/pages/acess_history_page/acess_history_page_model.dart @@ -4,8 +4,8 @@ import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_ import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class AcessHistoryPageModel extends FlutterFlowModel { late final String devUUID; @@ -33,9 +33,9 @@ class AcessHistoryPageModel extends FlutterFlowModel { } Future initDatabase() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 087752bd..31bb70eb 100644 --- a/lib/pages/fast_pass_page/fast_pass_page_widget.dart +++ b/lib/pages/fast_pass_page/fast_pass_page_widget.dart @@ -7,8 +7,8 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart' as hub; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/webview_util.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -25,11 +25,11 @@ class _FastPassPageWidgetState extends State { late InAppWebViewController _controllerIOS; Future> initVariables() async { - final email = await StorageHelper().get(hub.SecureStorageKey.email.value, hub.Storage.SecureStorage) ?? ''; - final name = await StorageHelper().get(hub.SQLiteStorageKey.userName.value, hub.Storage.SQLiteStorage) ?? ''; - final devUUID = await StorageHelper().get(hub.SQLiteStorageKey.devUUID.value, hub.Storage.SQLiteStorage) ?? ''; - final userUUID = await StorageHelper().get(hub.SQLiteStorageKey.userUUID.value, hub.Storage.SQLiteStorage) ?? ''; - final cliUUID = await StorageHelper().get(hub.SQLiteStorageKey.clientUUID.value, hub.Storage.SQLiteStorage) ?? ''; + 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/forgot_password_page/forgot_password_screen.dart b/lib/pages/forgot_password_page/forgot_password_screen.dart index c29cad1b..d63d2017 100644 --- a/lib/pages/forgot_password_page/forgot_password_screen.dart +++ b/lib/pages/forgot_password_page/forgot_password_screen.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import '../../flutter_flow/flutter_flow_animations.dart'; import '../../flutter_flow/flutter_flow_icon_button.dart'; diff --git a/lib/pages/home_page/home_page_model.dart b/lib/pages/home_page/home_page_model.dart deleted file mode 100644 index 6fb86a4d..00000000 --- a/lib/pages/home_page/home_page_model.dart +++ /dev/null @@ -1,95 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; -import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; -import 'package:hub/components/organism_components/local_profile_component/local_profile_component_model.dart'; -import 'package:hub/components/organism_components/menu_component/menu_component_model.dart'; -import 'package:hub/components/organism_components/message_well_component/message_well_component_model.dart'; -import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/pages/home_page/home_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; - -class HomePageModel extends FlutterFlowModel { - HomePageModel({required this.safeSetState}); - late final VoidCallback safeSetState; - - bool isGrid = false; - late final String devUUID; - late final String cliUUID; - late final String userUUID; - late final String userName; - late final String userEmail; - - final unfocusNode = FocusNode(); - FocusNode? textFieldFocusNode; - TextEditingController? textController; - String? Function(BuildContext, String?)? textControllerValidator; - late LocalProfileComponentModel localComponentModel; - late MenuComponentModel homeMenuComponentModel; - late MenuComponentModel drawerMenuComponentModel; - late MessageWellComponentModel messageWellComponentModel; - - Future _initVariable() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - userName = (await StorageHelper().get(SQLiteStorageKey.userName.value, Storage.SQLiteStorage)) ?? ''; - userEmail = (await StorageHelper().get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? ''; - safeSetState.call(); - } - - @override - void initState(BuildContext context) { - _initVariable(); - localComponentModel = createModel(context, () => LocalProfileComponentModel()); - homeMenuComponentModel = createModel( - context, - () => MenuComponentModel(expandable: true, style: MenuView.list_grid, item: MenuItem.button, menuOptions: [ - MenuOption.SettingsOnTheApp, - MenuOption.MessagesOnTheProperty, - MenuOption.AccessOnTheProperty, - MenuOption.PetsRegister, - MenuOption.VisitorsRegister, - MenuOption.ReservationsOnTheLocal, - MenuOption.PackagesOnTheProperty, - MenuOption.DeliverySchedule, - MenuOption.WorkersOnTheProperty, - MenuOption.AboutProperty, - MenuOption.CompleteSchedule, - MenuOption.FastPassSchedule, - MenuOption.LiberationsOnTheProperty, - MenuOption.QRCodeAccessInProperty, - ])); - drawerMenuComponentModel = createModel( - context, - () => MenuComponentModel(expandable: false, style: MenuView.list, item: MenuItem.tile, menuOptions: [ - MenuOption.SettingsOnTheApp, - MenuOption.MessagesOnTheProperty, - MenuOption.AccessOnTheProperty, - MenuOption.PetsRegister, - MenuOption.VisitorsRegister, - MenuOption.ReservationsOnTheLocal, - MenuOption.PackagesOnTheProperty, - MenuOption.DeliverySchedule, - MenuOption.WorkersOnTheProperty, - MenuOption.AboutProperty, - MenuOption.CompleteSchedule, - MenuOption.FastPassSchedule, - MenuOption.LiberationsOnTheProperty, - MenuOption.QRCodeAccessInProperty, - MenuOption.LogoutOnTheApp, - ])); - messageWellComponentModel = createModel(context, () => MessageWellComponentModel()); - } - - @override - void dispose() { - unfocusNode.dispose(); - textFieldFocusNode?.dispose(); - textController?.dispose(); - - localComponentModel.dispose(); - homeMenuComponentModel.dispose(); - messageWellComponentModel.dispose(); - } -} diff --git a/lib/pages/liberation_history/liberation_history_model.dart b/lib/pages/liberation_history/liberation_history_model.dart index d0ff3638..8c016069 100644 --- a/lib/pages/liberation_history/liberation_history_model.dart +++ b/lib/pages/liberation_history/liberation_history_model.dart @@ -3,8 +3,8 @@ import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/liberation_history/liberation_history_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class LiberationHistoryModel extends FlutterFlowModel { late final String devUUID; @@ -36,9 +36,9 @@ class LiberationHistoryModel extends FlutterFlowModel { } Future init() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 e8fdacbc..1a2cd70d 100644 --- a/lib/pages/message_history_page/message_history_page_model.dart +++ b/lib/pages/message_history_page/message_history_page_model.dart @@ -3,8 +3,8 @@ import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/message_history_page/message_history_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class MessageHistoryPageModel extends FlutterFlowModel { late final String devUUID; @@ -39,9 +39,9 @@ class MessageHistoryPageModel extends FlutterFlowModel } Future init() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 26ba4504..980c5c0b 100644 --- a/lib/pages/package_order_page/package_order_page.dart +++ b/lib/pages/package_order_page/package_order_page.dart @@ -9,8 +9,8 @@ import 'package:hub/components/templates_components/details_component/details_co import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; @@ -64,7 +64,7 @@ class _PackageOrderPage extends State { } Future initDatabase() async { - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value) ?? ''); } @override @@ -417,4 +417,4 @@ class _PackageOrderPage extends State { body: _appBody(context), ); } -} +} \ No newline at end of file diff --git a/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart b/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart index 6e7114f8..de07033f 100644 --- a/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart +++ b/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart @@ -1,27 +1,14 @@ import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/pages/people_on_the_property_page/people_on_the_property_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; class PeopleOnThePropertyPageModel extends FlutterFlowModel { - PeopleOnThePropertyPageModel({this.onRefresh}); - late final VoidCallback? onRefresh; + /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); - late final String devUUID; - late final String cliUUID; @override - void initState(BuildContext context) { - initVariables(); - } - - void initVariables() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - onRefresh?.call(); - } + void initState(BuildContext context) {} @override void dispose() { diff --git a/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart b/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart index be16c18d..a1146aeb 100644 --- a/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart +++ b/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart @@ -1,135 +1,68 @@ +import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/people_on_the_property_page/people_on_the_property_page_model.dart'; -import 'package:hub/shared/utils/dialog_util.dart'; -import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/log_util.dart'; + +import '../../shared/utils/log_util.dart'; class PeopleOnThePropertyPage extends StatefulWidget { const PeopleOnThePropertyPage({super.key}); @override - _PeopleOnThePropertyPageState createState() => _PeopleOnThePropertyPageState(); + State createState() => _PeopleOnThePropertyPageState(); } -class _PeopleOnThePropertyPageState extends State with TickerProviderStateMixin { - late ScrollController _scrollController; +class _PeopleOnThePropertyPageState extends State { + late PeopleOnThePropertyPageModel _model; - int _pageNumber = 1; - bool _hasData = false; - bool _loading = false; - int count = 0; - - late final PeopleOnThePropertyPageModel model; - - late Future _future; - List _wrap = []; + final scaffoldKey = GlobalKey(); @override void initState() { super.initState(); - model = createModel(context, () => PeopleOnThePropertyPageModel(onRefresh: () => safeSetState(() {}))); - _future = _fetchVisits(); - - _scrollController = ScrollController() - ..addListener(() { - if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { - _loadMore(); - } - }); + _model = createModel(context, () => PeopleOnThePropertyPageModel()); } @override void dispose() { - _scrollController.dispose(); + _model.dispose(); + super.dispose(); } @override Widget build(BuildContext context) { - late final limitedHeaderTextSize = LimitedFontSizeUtil.getHeaderFontSize(context); - return Scaffold( - appBar: _appBar(context), + key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - body: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - if (_hasData == false && _pageNumber <= 1 && _loading == false) - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Center( - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Nenhum morador encontrado!", - enText: "No residents found!", - ), - style: TextStyle( - fontFamily: 'Nunito', - fontSize: limitedHeaderTextSize, - ), - ), - ) - ], - ), - ) - else if (_hasData == true || _pageNumber >= 1) - Expanded( - child: FutureBuilder( - future: _future, - builder: (context, snapshot) { - return ListView.builder( - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - controller: _scrollController, - itemCount: _wrap.length + 1, - itemBuilder: (context, index) { - if (index == 0) { - // Add your item here - return Padding( - padding: const EdgeInsets.only(right: 30, top: 10), - child: Text( - '', - textAlign: TextAlign.right, - ), - ); - } else { - final item = _wrap[index - 1]; - return _item(context, item); - } - }); - }, - )), - if (_hasData == true && _loading == true) - Container( - padding: const EdgeInsets.only(top: 15, bottom: 15), - child: Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - FlutterFlowTheme.of(context).primary, - ), - ), - ), - ) - ].addToStart(const SizedBox(height: 0)), - ), - ); - } - - PreferredSizeWidget _appBar(BuildContext context) { - return AppBar( - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - automaticallyImplyLeading: false, - title: Text(FFLocalizations.of(context).getVariableText(ptText: 'Moradores', enText: 'Residents'), + appBar: AppBar( + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + automaticallyImplyLeading: false, + forceMaterialTransparency: true, + leading: FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 30.0, + borderWidth: 1.0, + buttonSize: 60.0, + icon: Icon( + Icons.keyboard_arrow_left, + color: FlutterFlowTheme.of(context).primaryText, + size: 30.0, + ), + onPressed: () async { + context.pop(); + }, + ), + title: Text( + FFLocalizations.of(context).getText( + 'nsu13r5d' /* Pessoas na Propriedade */, + ), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, @@ -137,114 +70,103 @@ class _PeopleOnThePropertyPageState extends State with letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - )), - leading: _backButton(context, FlutterFlowTheme.of(context)), - centerTitle: true, - elevation: 0.0, - actions: [], - ); - } - - Widget _backButton(BuildContext context, FlutterFlowTheme theme) { - return FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 30.0, - borderWidth: 1.0, - buttonSize: 60.0, - icon: Icon( - Icons.keyboard_arrow_left, - color: theme.primaryText, - size: 30.0, - ), - onPressed: () => Navigator.of(context).pop(), - ); - } - - Future _fetchVisits() async { - try { - setState(() => _loading = true); - - var response = await PhpGroup.getResidentsByProperty.call(_pageNumber.toString()); - - final List residents = response.jsonBody['residents'] ?? []; - safeSetState(() => count = response.jsonBody['total_rows'] ?? 0); - - if (residents.isNotEmpty) { - setState(() { - _wrap.addAll(residents); - _hasData = true; - _loading = false; - }); - - return response; - } - - _showNoMoreDataSnackBar(context); - - setState(() { - _hasData = false; - _loading = false; - }); - - return null; - } catch (e, s) { - DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de moradores", e, s); - setState(() { - _hasData = false; - _loading = false; - }); - } - return null; - } - - void _loadMore() { - if (_hasData == true) { - _pageNumber++; - - _future = _fetchVisits(); - } - } - - void _showNoMoreDataSnackBar(BuildContext context) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", - enText: "No more data.", - ), - style: TextStyle( - color: Colors.white, - fontSize: LimitedFontSizeUtil.getBodyFontSize(context), - ), + ), ), - duration: const Duration(seconds: 3), - backgroundColor: FlutterFlowTheme.of(context).primary, + actions: const [], + centerTitle: true, + elevation: 0.0, ), - ); - } - - Widget _item(BuildContext context, dynamic uItem) { - return CardItemTemplateComponentWidget( - imagePath: - 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${model.devUUID}&cliID=${model.cliUUID}&atividade=getFoto&Documento=${uItem['documento']}&tipo=Z', - labelsHashMap: { - '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['nome'] ?? '', - //statusweb - '${FFLocalizations.of(context).getVariableText(ptText: "Possui App", enText: "Has App")}:': - uItem['statusweb'] == "A" - ? FFLocalizations.of(context).getVariableText( - ptText: 'Sim', - enText: 'Yes', - ) - : FFLocalizations.of(context).getVariableText( - ptText: 'Não', - enText: 'No', + body: SafeArea( + top: true, + child: FutureBuilder( + future: PhpGroup.getPessoasLocalCall.call(), + builder: (context, snapshot) { + // Customize what your widget looks like when it's loading. + if (!snapshot.hasData) { + return Center( + child: SizedBox( + width: 50.0, + height: 50.0, + child: SpinKitCircle( + color: FlutterFlowTheme.of(context).primary, + size: 50.0, ), - }, - statusHashMap: [], - onTapCardItemAction: () async {}, + ), + ); + } + + if (snapshot.hasError || snapshot.data?.exception != null) { + if (snapshot.error != null && snapshot.stackTrace != null) { + LogUtil.requestAPIFailed('getPessoasLocal.php', "", 'Busca Pessoas no Local', snapshot.error, snapshot.stackTrace!); + } + + return Center( + child: SizedBox( + width: double.infinity, + height: 100, + child: Text( + FFLocalizations.of(context).getVariableText(ptText: "Pessoas não encontradas", enText: "Persons not found"), + textAlign: TextAlign.center, + ), + ), + ); + } + + final columnGetPessoasLocalResponse = snapshot.data!; + final getPoepleProperty = PhpGroup.getPessoasLocalCall + .pessoas( + columnGetPessoasLocalResponse.jsonBody, + ) + ?.toList() ?? + []; + + return ListView.builder( + physics: const AlwaysScrollableScrollPhysics(), + shrinkWrap: true, + itemCount: getPoepleProperty.length, + itemBuilder: (context, index) { + final getPoeplePropertyItem = getPoepleProperty[index]; + return Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(4.0), + child: Container( + width: 50.0, + height: 50.0, + clipBehavior: Clip.antiAlias, + decoration: const BoxDecoration( + shape: BoxShape.circle, + ), + child: CachedNetworkImage( + fadeInDuration: const Duration(milliseconds: 500), + fadeOutDuration: const Duration(milliseconds: 500), + imageUrl: + 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', + fit: BoxFit.cover, + ), + ), + ), + Text( + getJsonField( + getPoeplePropertyItem, + r'''$.USU_NOME''', + ).toString(), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + fontSize: 14.0, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + ), + ), + ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 40.0)), + ); + }, + ); + }, + ), + ), ); } } 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 3e4efbba..b32ba509 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 @@ -8,8 +8,8 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/pages/pets_page/pets_page_model.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; @@ -58,7 +58,10 @@ class _PetsHistoryScreenState extends State with TickerProvid return AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, automaticallyImplyLeading: false, - title: Text(FFLocalizations.of(context).getVariableText(enText: 'Pets', ptText: 'Pets'), + title: Text(FFLocalizations.of(context).getVariableText( + ptText: 'Pets', + enText: 'Pets', + ), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, @@ -291,10 +294,10 @@ class _PetsHistoryScreenState extends State with TickerProvid } ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - final cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + 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 3bef02ac..aeb213a9 100644 --- a/lib/pages/pets_page/pets_page_model.dart +++ b/lib/pages/pets_page/pets_page_model.dart @@ -12,8 +12,8 @@ import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/form_field_controller.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/pets_page/pets_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/image_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; @@ -116,10 +116,8 @@ class PetsPageModel extends FlutterFlowModel { ); dropDownValueController1 = FormFieldController(dropDownValue1 ??= defaultDropDownText); dropDownValueController2 = FormFieldController(dropDownValue2 ??= defaultDropDownText); - log('() => ): $devUUID'); safeSetState?.call(); - log('() => ): $devUUID'); } @override @@ -149,15 +147,14 @@ class PetsPageModel extends FlutterFlowModel { textControllerObservation = TextEditingController(); WidgetsBinding.instance.addPostFrameCallback((_) async { - devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? ''; - userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? ''; - cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage) ?? ''; - petAmountRegister = await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage) ?? ''; + 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) ?? ''; }); } void setEditForm() { - log('item: $item'); if (item != null) petId = item['id']; diff --git a/lib/pages/pets_page/pets_page_widget.dart b/lib/pages/pets_page/pets_page_widget.dart index 4beac680..a2d7c1f7 100644 --- a/lib/pages/pets_page/pets_page_widget.dart +++ b/lib/pages/pets_page/pets_page_widget.dart @@ -75,7 +75,10 @@ class _PetsPageWidgetState extends State with SingleTickerProvid PreferredSizeWidget _buildAppBar(BuildContext context) { return AppBarUtil( - title: 'Pets', + title: FFLocalizations.of(context).getVariableText( + ptText: 'Cadastrar Pets', + enText: 'Pets Register', + ), onBackButtonPressed: () => context.pop(), ); } diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 2b57ed67..2f8adda5 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -5,10 +5,10 @@ import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/components/molecules/locals/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/services/localization/localization_service.dart'; import 'package:share_plus/share_plus.dart'; import '../../shared/utils/snackbar_util.dart'; @@ -23,11 +23,11 @@ class PreferencesPageModel with ChangeNotifier { late bool isPanic = false; Future _initialize() async { - isFingerprint = await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true'; - isPerson = await StorageHelper().get(SQLiteStorageKey.person.value, Storage.SQLiteStorage) == 'true'; - isNotify = await StorageHelper().get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true'; - isAccess = await StorageHelper().get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true'; - isPanic = await StorageHelper().get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == '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,8 +36,7 @@ class PreferencesPageModel with ChangeNotifier { } Future enablePerson(BuildContext context) async { - final String userDevUUID = - (await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userDevUUID = (await StorageHelper().get(KeychainStorageKey.userDevUUID.value)) ?? ''; notifyListeners(); Share.share( FFLocalizations.of(context).getVariableText( @@ -64,8 +63,7 @@ class PreferencesPageModel with ChangeNotifier { .call(notifica: value) .then((value) async { if (value.jsonBody['error'] == false) { - await StorageHelper() - .set(SQLiteStorageKey.notify.value, isNotify ? 'false' : 'true', Storage.SQLiteStorage); + await StorageHelper().set(KeychainStorageKey.notify.value, isNotify ? 'false' : 'true'); content = FFLocalizations.of(context).getVariableText( enText: 'Notification changed successfully', ptText: 'Notificação alterada com sucesso', @@ -81,15 +79,13 @@ class PreferencesPageModel with ChangeNotifier { } }) .catchError((e, s) { - log('toggleNotify', error: e, stackTrace: s); content = FFLocalizations.of(context).getVariableText( enText: 'Error changing notification', ptText: 'Erro ao alterar notificação', ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => - isNotify = await StorageHelper().get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true') + .then((_) async => isNotify = await StorageHelper().get(KeychainStorageKey.notify.value) == 'true') .whenComplete(() => notifyListeners()); context.pop(); } @@ -138,14 +134,13 @@ class PreferencesPageModel with ChangeNotifier { Future toggleAccess(BuildContext context) async { onChange(String key) async { - await StorageHelper().set(SecureStorageKey.accessPass.value, key, Storage.SecureStorage); + 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() - .set(SQLiteStorageKey.access.value, isAccess ? 'false' : 'true', Storage.SQLiteStorage); + await StorageHelper().set(KeychainStorageKey.access.value, isAccess ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Access pass changed successfully', @@ -167,8 +162,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => - isAccess = await StorageHelper().get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true') + .then((_) async => isAccess = await StorageHelper().get(KeychainStorageKey.access.value) == 'true') .whenComplete(() => notifyListeners()); } @@ -177,14 +171,13 @@ class PreferencesPageModel with ChangeNotifier { Future togglePanic(BuildContext context) async { onChange(String key) async { - await StorageHelper().set(SecureStorageKey.panicPass.value, key, Storage.SecureStorage); + 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() - .set(SQLiteStorageKey.panic.value, isPanic ? 'false' : 'true', Storage.SQLiteStorage); + await StorageHelper().set(KeychainStorageKey.panic.value, isPanic ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Panic password changed successfully', @@ -206,8 +199,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => - isPanic = await StorageHelper().get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true') + .then((_) async => isPanic = await StorageHelper().get(KeychainStorageKey.panic.value) == 'true') .whenComplete(() => notifyListeners()); } @@ -222,12 +214,11 @@ class PreferencesPageModel with ChangeNotifier { onChange(String? key) async { isFingerprint = !isFingerprint; - await StorageHelper().set(SecureStorageKey.fingerprintPass.value, key ?? '', Storage.SecureStorage); - await StorageHelper() - .set(SQLiteStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false', Storage.SQLiteStorage); + await StorageHelper().set(SecureStorageKey.fingerprintPass.value, key ?? ''); + await StorageHelper().set(KeychainStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false'); notifyListeners(); SnackBarUtil.showSnackBar(context, content); - isFingerprint = await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true'; + isFingerprint = await StorageHelper().get(KeychainStorageKey.fingerprint.value) == 'true'; } isFingerprint ? onChange(null) : _showPassKey(context, onChange); @@ -270,7 +261,7 @@ class PreferencesPageModel with ChangeNotifier { enText: 'Are you sure you want to unlink your device?', ptText: 'Tem certeza que deseja desvincular seu dispositivo?', ); - onConfirm() async => LocalizationService.unlinkLocal(context); + onConfirm() async => LocalsRepositoryImpl().unlinkLocal(context); showAlertDialog(context, title, content, onConfirm); } 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 514f99b2..41df6e77 100644 --- a/lib/pages/qr_code_page/qr_code_page_model.dart +++ b/lib/pages/qr_code_page/qr_code_page_model.dart @@ -4,8 +4,8 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/pages/qr_code_page/qr_code_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:qr_flutter/qr_flutter.dart'; class QrCodePageModel extends FlutterFlowModel { @@ -29,8 +29,8 @@ class QrCodePageModel extends FlutterFlowModel { } Future initVariable() async { - isFingerprint = await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true'; - userDevUUID = await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage) ?? ''; + 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 43d904df..6aad1599 100644 --- a/lib/pages/qr_code_page/qr_code_page_widget.dart +++ b/lib/pages/qr_code_page/qr_code_page_widget.dart @@ -17,8 +17,8 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/qr_code_page/qr_code_page_model.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/biometric_util.dart'; import 'package:hub/shared/utils/limited_text_size.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().get(SecureStorageKey.fingerprintPass.value, Storage.SecureStorage); + 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 ad6c4b2e..239f675a 100644 --- a/lib/pages/reception_page/reception_page_model.dart +++ b/lib/pages/reception_page/reception_page_model.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/internationalization.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:share_plus/share_plus.dart'; class ReceptionPageModel with ChangeNotifier { Future getIdenfifier(BuildContext context) async { - final String userDevUUID = - (await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 77d4c65f..a29e194b 100644 --- a/lib/pages/reception_page/reception_page_widget.dart +++ b/lib/pages/reception_page/reception_page_widget.dart @@ -10,9 +10,9 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/pages/reception_page/reception_page_model.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/services/authentication/authentication_service.dart'; -import 'package:hub/shared/services/localization/localization_service.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:provider/provider.dart'; @@ -30,11 +30,10 @@ class _ReceptionPageWidgetState extends State with WidgetsB WidgetsBinding.instance.addObserver(this); () async { final lifecycle = await AwesomeNotifications().getAppLifeCycle(); - log('lifecycle: $lifecycle'); }(); FirebaseMessagingService().updateDeviceToken(); - LocalizationService.checkLocals(context); + LocalsRepositoryImpl().validateLocal(context); } @override @@ -45,10 +44,9 @@ class _ReceptionPageWidgetState extends State with WidgetsB @override void didChangeAppLifecycleState(AppLifecycleState state) { - log('() => state: $state'); if (state == AppLifecycleState.resumed) { setState(() { - LocalizationService.checkLocals(context); + LocalsRepositoryImpl().validateLocal(context); }); } } @@ -75,9 +73,8 @@ class _ReceptionPageWidgetState extends State with WidgetsB Padding( padding: const EdgeInsets.fromLTRB(45, 20, 45, 15.0), child: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Falta pouco para você utilizar o FRE Access Hub...', - enText: 'You are close to using the FRE Access Hub...'), + FFLocalizations.of(context) + .getVariableText(ptText: 'Falta pouco para você utilizar o FRE Access Hub...', enText: 'You are close to using the FRE Access Hub...'), textAlign: TextAlign.center, style: FlutterFlowTheme.of(context).displayLarge.override( fontFamily: 'Plus Jakarta Sans', @@ -94,8 +91,7 @@ class _ReceptionPageWidgetState extends State with WidgetsB padding: const EdgeInsets.fromLTRB(70, 30, 70.0, 40), child: Text( FFLocalizations.of(context).getVariableText( - ptText: - 'Envie seu identificador para seu condomínio para vincularem sua conta aos nossos sistemas.', + ptText: 'Envie seu identificador para seu condomínio para vincularem sua conta aos nossos sistemas.', enText: 'Send your identifier to your condominium to link your account to our systems.'), textAlign: TextAlign.center, style: FlutterFlowTheme.of(context).displaySmall.override( @@ -115,10 +111,8 @@ class _ReceptionPageWidgetState extends State with WidgetsB Padding( padding: const EdgeInsets.fromLTRB(60, 0, 60, 10), child: Tooltip( - message: FFLocalizations.of(context).getVariableText( - ptText: - 'Seu identificador é utilizado para efetuar\no vínculo do seu APP com o condominio.', - enText: 'My Identifier'), + message: FFLocalizations.of(context) + .getVariableText(ptText: 'Seu identificador é utilizado para efetuar\no vínculo do seu APP com o condominio.', enText: 'My Identifier'), textStyle: FlutterFlowTheme.of(context).labelSmall.override( fontFamily: 'Nunito Sans', color: FlutterFlowTheme.of(context).secondaryText, @@ -129,8 +123,7 @@ class _ReceptionPageWidgetState extends State with WidgetsB ), child: FFButtonWidget( onPressed: () => model.getIdenfifier(context), - text: FFLocalizations.of(context) - .getVariableText(ptText: 'Meu Identificador', enText: 'My Identifier'), + text: FFLocalizations.of(context).getVariableText(ptText: 'Meu Identificador', enText: 'My Identifier'), options: FFButtonOptions( width: double.infinity, height: 30, @@ -164,8 +157,7 @@ class _ReceptionPageWidgetState extends State with WidgetsB AuthenticationService.signOut(context); setState(() {}); }, - text: FFLocalizations.of(context) - .getVariableText(ptText: 'Sair da Conta', enText: 'Logout'), + text: FFLocalizations.of(context).getVariableText(ptText: 'Sair da Conta', enText: 'Logout'), options: FFButtonOptions( width: double.infinity, height: 30, diff --git a/lib/pages/reservation_page/reservation_page_widget.dart b/lib/pages/reservation_page/reservation_page_widget.dart index 31422dfd..4d9091ac 100644 --- a/lib/pages/reservation_page/reservation_page_widget.dart +++ b/lib/pages/reservation_page/reservation_page_widget.dart @@ -5,8 +5,8 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart' as hub; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/webview_util.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -22,11 +22,11 @@ class _ReservationPageWidgetState extends State { late WebViewController _controllerAll; Future> initVariables() async { - final email = await StorageHelper().get(hub.SecureStorageKey.email.value, hub.Storage.SecureStorage) ?? ''; - final name = await StorageHelper().get(hub.SQLiteStorageKey.userName.value, hub.Storage.SQLiteStorage) ?? ''; - final devUUID = await StorageHelper().get(hub.SQLiteStorageKey.devUUID.value, hub.Storage.SQLiteStorage) ?? ''; - final userUUID = await StorageHelper().get(hub.SQLiteStorageKey.userUUID.value, hub.Storage.SQLiteStorage) ?? ''; - final clientId = await StorageHelper().get(hub.SQLiteStorageKey.clientUUID.value, hub.Storage.SQLiteStorage) ?? ''; + 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 new file mode 100644 index 00000000..4883ceb3 --- /dev/null +++ b/lib/pages/residents_on_the_property/residents_on_the_property_model.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/flutter_flow_model.dart'; +import 'package:hub/pages/residents_on_the_property/residents_on_the_property_screen.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + +class ResidentsOnThePropertyModel extends FlutterFlowModel { + ResidentsOnThePropertyModel({this.onRefresh}); + late final VoidCallback? onRefresh; + + final unfocusNode = FocusNode(); + late final String devUUID; + late final String cliUUID; + + @override + void initState(BuildContext context) { + initVariables(); + } + + void initVariables() async { + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + onRefresh?.call(); + } + + @override + void dispose() { + unfocusNode.dispose(); + } +} diff --git a/lib/pages/residents_on_the_property/residents_on_the_property_screen.dart b/lib/pages/residents_on_the_property/residents_on_the_property_screen.dart new file mode 100644 index 00000000..cdc96579 --- /dev/null +++ b/lib/pages/residents_on_the_property/residents_on_the_property_screen.dart @@ -0,0 +1,248 @@ +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/pages/residents_on_the_property/residents_on_the_property_model.dart'; +import 'package:hub/shared/utils/dialog_util.dart'; +import 'package:hub/shared/utils/limited_text_size.dart'; +import 'package:hub/shared/utils/log_util.dart'; + +class ResidentsOnTheProperty extends StatefulWidget { + const ResidentsOnTheProperty({super.key}); + + @override + _ResidentsOnThePropertyState createState() => _ResidentsOnThePropertyState(); +} + +class _ResidentsOnThePropertyState extends State with TickerProviderStateMixin { + late ScrollController _scrollController; + + int _pageNumber = 1; + bool _hasData = false; + bool _loading = false; + int count = 0; + + late final ResidentsOnThePropertyModel model; + + late Future _future; + List _wrap = []; + + @override + void initState() { + super.initState(); + model = createModel(context, () => ResidentsOnThePropertyModel(onRefresh: () => safeSetState(() {}))); + _future = _fetch(); + + _scrollController = ScrollController() + ..addListener(() { + if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { + _loadMore(); + } + }); + } + + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + late final limitedHeaderTextSize = LimitedFontSizeUtil.getHeaderFontSize(context); + + return Scaffold( + appBar: _appBar(context), + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + body: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + if (_hasData == false && _pageNumber <= 1 && _loading == false) + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Center( + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: "Nenhum morador encontrado!", + enText: "No residents found!", + ), + style: TextStyle( + fontFamily: 'Nunito', + fontSize: limitedHeaderTextSize, + ), + ), + ) + ], + ), + ) + else if (_hasData == true || _pageNumber >= 1) + Expanded( + child: FutureBuilder( + future: _future, + builder: (context, snapshot) { + return ListView.builder( + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + controller: _scrollController, + itemCount: _wrap.length + 1, + itemBuilder: (context, index) { + if (index == 0) { + // Add your item here + return Padding( + padding: const EdgeInsets.only(right: 30, top: 10), + child: Text( + '', + textAlign: TextAlign.right, + ), + ); + } else { + final item = _wrap[index - 1]; + return _item(context, item); + } + }); + }, + )), + if (_hasData == true && _loading == true) + Container( + padding: const EdgeInsets.only(top: 15, bottom: 15), + child: Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + FlutterFlowTheme.of(context).primary, + ), + ), + ), + ) + ].addToStart(const SizedBox(height: 0)), + ), + ); + } + + PreferredSizeWidget _appBar(BuildContext context) { + return AppBar( + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + automaticallyImplyLeading: false, + title: Text(FFLocalizations.of(context).getVariableText(ptText: 'Moradores', enText: 'Residents'), + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 15.0, + letterSpacing: 0.0, + fontWeight: FontWeight.bold, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + )), + leading: _backButton(context, FlutterFlowTheme.of(context)), + centerTitle: true, + elevation: 0.0, + actions: [], + ); + } + + Widget _backButton(BuildContext context, FlutterFlowTheme theme) { + return FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 30.0, + borderWidth: 1.0, + buttonSize: 60.0, + icon: Icon( + Icons.keyboard_arrow_left, + color: theme.primaryText, + size: 30.0, + ), + onPressed: () => Navigator.of(context).pop(), + ); + } + + Future _fetch() async { + try { + setState(() => _loading = true); + + var response = await PhpGroup.getResidentsByProperty.call(_pageNumber.toString()); + + final List residents = response.jsonBody['residents'] ?? []; + safeSetState(() => count = response.jsonBody['total_rows'] ?? 0); + + if (residents.isNotEmpty) { + setState(() { + _wrap.addAll(residents); + _hasData = true; + _loading = false; + }); + + return response; + } + + _showNoMoreDataSnackBar(context); + + setState(() { + _hasData = false; + _loading = false; + }); + + return null; + } catch (e, s) { + DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de moradores", e, s); + setState(() { + _hasData = false; + _loading = false; + }); + } + return null; + } + + void _loadMore() { + if (_hasData == true) { + _pageNumber++; + + _future = _fetch(); + } + } + + void _showNoMoreDataSnackBar(BuildContext context) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: "Não há mais dados.", + enText: "No more data.", + ), + style: TextStyle( + color: Colors.white, + fontSize: LimitedFontSizeUtil.getBodyFontSize(context), + ), + ), + duration: const Duration(seconds: 3), + backgroundColor: FlutterFlowTheme.of(context).primary, + ), + ); + } + + Widget _item(BuildContext context, dynamic uItem) { + return CardItemTemplateComponentWidget( + imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${model.devUUID}&cliID=${model.cliUUID}&atividade=getFoto&Documento=${uItem['documento']}&tipo=Z', + labelsHashMap: { + '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['nome'] ?? '', + //statusweb + '${FFLocalizations.of(context).getVariableText(ptText: "Possui App", enText: "Has App")}:': uItem['statusweb'] == "A" + ? FFLocalizations.of(context).getVariableText( + ptText: 'Sim', + enText: 'Yes', + ) + : FFLocalizations.of(context).getVariableText( + ptText: 'Não', + enText: 'No', + ), + }, + statusHashMap: [], + onTapCardItemAction: () async {}, + ); + } +} diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart index c5c93bae..1821c93b 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart @@ -8,8 +8,9 @@ import 'package:hub/flutter_flow/form_field_controller.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + import 'package:hub/shared/mixins/status_mixin.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:share_plus/share_plus.dart'; @@ -217,9 +218,9 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel } Future _initVariables() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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 29edd444..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 @@ -5,8 +5,8 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/mixins/status_mixin.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; @@ -35,10 +35,9 @@ class _VisitHistoryWidgetState extends State with TickerProv List _visitWrap = []; Future _initVariables() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - safeSetState(() {}); + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; } @override @@ -246,10 +245,10 @@ class _VisitHistoryWidgetState extends State with TickerProv }, ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - final userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; - final cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - final cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + 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/sign_in_page/sign_in_page_widget.dart b/lib/pages/sign_in_page/sign_in_page_widget.dart index 0e79d9e1..4ae72793 100644 --- a/lib/pages/sign_in_page/sign_in_page_widget.dart +++ b/lib/pages/sign_in_page/sign_in_page_widget.dart @@ -1,4 +1,4 @@ -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; import 'package:hub/shared/services/deeplink/deep_link_service.dart'; diff --git a/lib/pages/sign_up_page/sign_up_page_widget.dart b/lib/pages/sign_up_page/sign_up_page_widget.dart index 05146e41..2eaed633 100644 --- a/lib/pages/sign_up_page/sign_up_page_widget.dart +++ b/lib/pages/sign_up_page/sign_up_page_widget.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; import 'package:hub/shared/services/deeplink/deep_link_service.dart'; diff --git a/lib/pages/visits_on_the_property/model.dart b/lib/pages/visits_on_the_property/model.dart index fe59a038..357ab6dd 100644 --- a/lib/pages/visits_on_the_property/model.dart +++ b/lib/pages/visits_on_the_property/model.dart @@ -4,8 +4,8 @@ import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class VisitsModel extends FlutterFlowModel { static VisitsModel? _instance; @@ -30,8 +30,8 @@ class VisitsModel extends FlutterFlowModel { void dispose() {} Future initAsync() async { - devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; - cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; onRefresh?.call(); } @@ -43,6 +43,11 @@ class VisitsModel extends FlutterFlowModel { return DetailsComponentWidget( buttons: [], labelsHashMap: Map.from({ + if (item['VTA_NOME'] != null && item['VTA_NOME'] != '') + '${FFLocalizations.of(context).getVariableText( + ptText: "Nome", + enText: "Name", + )}:': item['VTA_NOME'].toString().toUpperCase(), if (item['MOT_DESCRICAO'] != null && item['MOT_DESCRICAO'] != '') '${FFLocalizations.of(context).getVariableText( ptText: "Motivo", @@ -75,13 +80,16 @@ class VisitsModel extends FlutterFlowModel { imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&cliID=${cliUUID}&atividade=getFoto&Documento=${item['VDO_DOCUMENTO']}&tipo=E', statusHashMap: [ - if (item['VTA_FIXA'] != null) - Map.from({ - item['VTA_FIXA'] - ? FFLocalizations.of(context).getVariableText(ptText: "Entrada Única", enText: "Single Entry") - : FFLocalizations.of(context).getVariableText( - ptText: "Entrada Recorrente", enText: "Recurrent Entry"): FlutterFlowTheme.of(context).warning - }), - ]); + Map.from({ + if (item['VTA_FIXA'] != null) + FFLocalizations.of(context).getVariableText( + ptText: item['VTA_FIXA'] ? "Entrada Única" : "Entrada Recorrente", + enText: item['VTA_FIXA'] ? "Single Entry" : "Recurrent Entry", + ): item['VTA_FIXA'] == true + ? FlutterFlowTheme.of(context).success + : FlutterFlowTheme.of(context).warning, + }) + ], + ); } } diff --git a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart index b4a283eb..ddc81d31 100644 --- a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart +++ b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart @@ -232,14 +232,14 @@ class _VisitsOnThePropertyState extends State with TickerPr uItem['MOT_DESCRICAO'][0].toUpperCase() + uItem['MOT_DESCRICAO'].substring(1).toLowerCase(), }, statusHashMap: [ - if (uItem['VTA_FIXA'] == true) + if (uItem['VTA_FIXA'] == false) { FFLocalizations.of(context).getVariableText( ptText: 'Recorrente', enText: 'Recurrent', ): FlutterFlowTheme.of(context).warning, }, - if (uItem['VTA_FIXA'] == false) + if (uItem['VTA_FIXA'] == true) { FFLocalizations.of(context).getVariableText( ptText: 'Única', diff --git a/lib/pages/welcome_page/welcome_page_widget.dart b/lib/pages/welcome_page/welcome_page_widget.dart index e8399f32..53ac8018 100644 --- a/lib/pages/welcome_page/welcome_page_widget.dart +++ b/lib/pages/welcome_page/welcome_page_widget.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; import 'package:hub/shared/services/deeplink/deep_link_service.dart'; @@ -32,16 +32,13 @@ class _WelcomePageWidgetState extends State { // On page load action. SchedulerBinding.instance.addPostFrameCallback((_) async { if (isAndroid == true) { - await StorageHelper().set(SecureStorageKey.deviceType.value, 'Android', - Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.deviceType.value, 'Android'); setState(() {}); } else if (isiOS == true) { - await StorageHelper().set( - SecureStorageKey.deviceType.value, 'iOS', Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.deviceType.value, 'iOS'); setState(() {}); } else { - await StorageHelper().set( - SecureStorageKey.deviceType.value, 'Web', Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.deviceType.value, 'Web'); setState(() {}); } }); diff --git a/lib/shared/widgets/image_cropper_widget/image_cropper.dart b/lib/shared/components/atoms/image_cropper/image_cropper.dart similarity index 100% rename from lib/shared/widgets/image_cropper_widget/image_cropper.dart rename to lib/shared/components/atoms/image_cropper/image_cropper.dart diff --git a/lib/shared/components/atoms/atom_terms_of_use.dart b/lib/shared/components/atoms/term_of_use/atom_terms_of_use.dart similarity index 88% rename from lib/shared/components/atoms/atom_terms_of_use.dart rename to lib/shared/components/atoms/term_of_use/atom_terms_of_use.dart index b9f14a30..470d61f8 100644 --- a/lib/shared/components/atoms/atom_terms_of_use.dart +++ b/lib/shared/components/atoms/term_of_use/atom_terms_of_use.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; -import '../../../flutter_flow/flutter_flow_theme.dart'; -import '../../../flutter_flow/flutter_flow_util.dart'; - class AtomTermsOfUse extends StatelessWidget { const AtomTermsOfUse({super.key}); diff --git a/lib/shared/widgets/drawer_widget/drawer_widget.dart b/lib/shared/components/molecules/drawer/drawer_widget.dart similarity index 62% rename from lib/shared/widgets/drawer_widget/drawer_widget.dart rename to lib/shared/components/molecules/drawer/drawer_widget.dart index 0e43594b..0eac540d 100644 --- a/lib/shared/widgets/drawer_widget/drawer_widget.dart +++ b/lib/shared/components/molecules/drawer/drawer_widget.dart @@ -1,37 +1,68 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:hub/components/organism_components/menu_component/menu_component_widget.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/features/home/index.dart'; + import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/pages/home_page/home_page_model.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/shared/components/molecules/modules/index.dart'; class CustomDrawer extends StatelessWidget { - const CustomDrawer({super.key, required this.model}); - final HomePageModel model; + const CustomDrawer({super.key}); @override Widget build(BuildContext context) { - return SafeArea( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.8, - child: Drawer( - elevation: 16.0, - child: Container( - color: FlutterFlowTheme.of(context).primaryBackground, - child: Column( - children: [ - _buildDrawerHeader(context), - // _buildSearchBar(context), - _buildDrawerBody(), - ].addToStart(const SizedBox(height: 20)), + return StreamBuilder( + stream: LocalsRepositoryImpl.stream, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center( + child: CircularProgressIndicator(), + ); + } else if (snapshot.hasError) { + return Center( + child: Text('Error: ${snapshot.error}'), + ); + } else if (!snapshot.hasData || snapshot.data! == false) { + return Center( + child: Padding( + padding: EdgeInsets.only(top: MediaQuery.of(context).size.height / 10), + child: CircularProgressIndicator( + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + color: FlutterFlowTheme.of(context).primary, + ), ), - ), - ), - ), + ); + } + return BlocBuilder( + builder: (context, state) { + return SafeArea( + child: SizedBox( + width: MediaQuery.of(context).size.width * 0.8, + child: Drawer( + elevation: 16.0, + child: Container( + color: FlutterFlowTheme.of(context).primaryBackground, + child: Column( + children: [ + _buildDrawerHeader(context, state), + // _buildSearchBar(context, state), + _buildDrawerBody(context), + ].addToStart(const SizedBox(height: 20)), + ), + ), + ), + ), + ); + }, + ); + }, ); } - Container _buildDrawerHeader(BuildContext context) { + Container _buildDrawerHeader(BuildContext context, HomeState state) { return Container( decoration: const BoxDecoration( borderRadius: BorderRadius.only( @@ -56,7 +87,7 @@ class CustomDrawer extends StatelessWidget { child: CachedNetworkImage( imageUrl: valueOrDefault( 'assets/images/person.jpg', - 'https://freaccess.com.br/freaccess/Images/Clients/${model.cliUUID}.png', + 'https://freaccess.com.br/freaccess/Images/Clients/${state.cliUUID}.png', ), width: 80.0, height: 80.0, @@ -75,7 +106,7 @@ class CustomDrawer extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - model.userName, + state.userName, style: FlutterFlowTheme.of(context).bodyLarge.override( fontFamily: 'Nunito Sans', color: FlutterFlowTheme.of(context).primaryText, @@ -85,7 +116,7 @@ class CustomDrawer extends StatelessWidget { ), ), Text( - model.userEmail, + state.userEmail, style: FlutterFlowTheme.of(context).bodySmall.override( fontFamily: 'Nunito Sans', color: FlutterFlowTheme.of(context).primaryText, @@ -102,7 +133,7 @@ class CustomDrawer extends StatelessWidget { ); } - Padding _buildSearchBar(BuildContext context) { + Padding _buildSearchBar(BuildContext context, HomeState state) { final theme = FlutterFlowTheme.of(context); final errorColor = theme.error; final primaryColor = theme.primary; @@ -111,8 +142,8 @@ class CustomDrawer extends StatelessWidget { return Padding( padding: const EdgeInsets.symmetric(vertical: 10.0), child: TextFormField( - controller: model.textController, - focusNode: model.textFieldFocusNode, + controller: TextEditingController(), // Replace with appropriate controller + focusNode: FocusNode(), // Replace with appropriate focus node autofocus: false, obscureText: false, decoration: InputDecoration( @@ -153,16 +184,16 @@ class CustomDrawer extends StatelessWidget { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, ), - validator: model.textControllerValidator.asValidator(context), + // validator: model.textControllerValidator.asValidator(context), ), ); } - Widget _buildDrawerBody() { - return wrapWithModel( - model: model.drawerMenuComponentModel, - updateCallback: () {}, - child: MenuComponentWidget(model: model.drawerMenuComponentModel), + Widget _buildDrawerBody(BuildContext context) { + return Menufactory( + entry: MenuEntry.getEntriesByType(MenuEntryType.Drawer), + item: EnumMenuItem.tile, + view: MenuView.list, ); } } diff --git a/lib/shared/components/molecules/drawer/index.dart b/lib/shared/components/molecules/drawer/index.dart new file mode 100644 index 00000000..bbb9bc10 --- /dev/null +++ b/lib/shared/components/molecules/drawer/index.dart @@ -0,0 +1 @@ +export 'drawer_widget.dart'; diff --git a/lib/shared/components/molecules/locals/data/data_sources/index.dart b/lib/shared/components/molecules/locals/data/data_sources/index.dart new file mode 100644 index 00000000..225b76e9 --- /dev/null +++ b/lib/shared/components/molecules/locals/data/data_sources/index.dart @@ -0,0 +1,2 @@ +export 'locals_local_data_source.dart'; +export 'locals_remote_data_source.dart'; diff --git a/lib/shared/components/molecules/locals/data/data_sources/locals_local_data_source.dart b/lib/shared/components/molecules/locals/data/data_sources/locals_local_data_source.dart new file mode 100644 index 00000000..64d78e27 --- /dev/null +++ b/lib/shared/components/molecules/locals/data/data_sources/locals_local_data_source.dart @@ -0,0 +1,16 @@ +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + +abstract class LocalsLocalDataSource { + Future unlinkLocal(); +} + +class LocalsLocalDataSourceImpl { + + Future unlinkLocal() async { + await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(KeychainStorageKey.clientName.value, ''); + await StorageHelper().set(KeychainStorageKey.ownerName.value, ''); + } + +} 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 new file mode 100644 index 00000000..2520b990 --- /dev/null +++ b/lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart @@ -0,0 +1,249 @@ +// ignore_for_file: curly_braces_in_flow_control_structures, use_build_context_synchronously, unrelated_type_equality_checks + +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; +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/snackbar_util.dart'; + +abstract class LocalsRemoteDataSource { + Future linkLocal(BuildContext context); + Future checkLocals(BuildContext context); + Future processLocals(BuildContext context) ; + Future processData(BuildContext context); + Future selectLocal(BuildContext context, ApiCallResponse? response) ; + Future detachLocal(BuildContext context); +} + +class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { + static final LocalsRemoteDataSourceImpl _instance = LocalsRemoteDataSourceImpl._internal(); + factory LocalsRemoteDataSourceImpl() => _instance; + LocalsRemoteDataSourceImpl._internal(); + + @override + Future linkLocal(BuildContext context) async { + try { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + var response = await callback.call(); + final bool? isError = response.jsonBody['error']; + + if (isError == true) { + LocalUtil.handleError(context, response.jsonBody['error_msg']); + return; + } + if (response.jsonBody == null) { + final String errorMsg = FFLocalizations.of(context).getVariableText( + enText: 'Verify your connection', + ptText: 'Verifique sua conexão', + ); + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, response)); + return; + } + + final List locals = response.jsonBody['locais'] ?? []; + final bool isEmpty = locals.isEmpty; + final bool isActive = locals.where((local) => local['CLU_STATUS'] != 'B').isNotEmpty; + final bool isEnable = !isEmpty && isActive; + + if (isEnable) { + await StorageHelper().set(SecureStorageKey.haveLocal.value, true); + await StorageHelper().set(SecureStorageKey.isLogged.value, true); + await WidgetsBinding.instance.endOfFrame; + await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(KeychainStorageKey.ownerUUID.value, ''); + StorageHelper().context?.go('/homePage'); + } + } catch (e, s) { + log(e.toString(), stackTrace: s); + } + } + + @override + Future processLocals(BuildContext context) async { + log('() => processLocals'); + try { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + final ApiCallResponse response = await callback.call(); + final bool? isError = response.jsonBody['error']; + + if (isError == true) { + final String errorMsg = response.jsonBody['error_msg']; + LocalUtil.handleError(context, errorMsg); + return false; + } + if (response.jsonBody == null) { + final String errorMsg = FFLocalizations.of(context).getVariableText( + enText: 'Verify your connection', + ptText: 'Verifique sua conexão', + ); + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, response)); + return false; + } + + final List locals = response.jsonBody['locais'].toList() ?? []; + LocalUtil.logLocalsStatus(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 LocalUtil.isUnselected(); + final bool isSelected = await LocalUtil.isSelected(isInactived); + final bool isUnavailable = isPending && isUnselected && isUnique; + final bool isAvailable = await LocalUtil.isAvailable(); + + if (isDisabled) { + AuthenticationService.signOut(context); + return true; + } else if (isUnavailable) { + return await selectLocal(context, response); + } else if (isEnabled) { + return await LocalUtil.handleEnabled(context, locals[0]); + } else if (isUnselected) { + log('() => isUnselected'); + return await selectLocal(context, response); + } else if (isSelected) { + log('() => isSelected'); + return await processData(context); + } else if (isAvailable) { + log('() => isAvailable'); + return await processData(context); + } else { + if (!isUnique && !isActive) log('() => not unique and not active'); + if (!isUnique && isInactived) log('() => not unique and inactived'); + if (!isUnique && isPending) log('() => not unique and pending'); + if (!isUnique && isBlocked) log('() => not unique and blocked'); + log('() => else'); + return await selectLocal(context, response); + } + } catch (e, s) { + log('() => stack: $s'); + log('() => catch: $e', stackTrace: s); + // return await selectLocal(context); + final String errorMsg = FFLocalizations.of(context).getVariableText( + enText: 'Error getting locals, verify your connection', + ptText: 'Erro ao obter locais, verifique sua conexão', + ); + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, null)); + return false; + } + } + + @override + Future checkLocals(BuildContext context) async { + String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + return cliUUID.isEmpty && cliName.isEmpty; + } + + @override + Future processData(BuildContext context) async { + try { + final GetDadosCall callback = PhpGroup.getDadosCall; + ApiCallResponse? response = await callback.call(); + if (response.jsonBody == null) { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + response = await callback.call(); + final String errorMsg = FFLocalizations.of(context).getVariableText( + enText: 'Verify your connection', + ptText: 'Verifique sua conexão', + ); + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, response)); + return false; + } + + final bool? isError = response.jsonBody['error']; + if (isError == true) { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + response = await callback.call(); + final String errorMsg = response.jsonBody['error_msg'] ?? 'Local indisponível'; + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, response)); + return false; + } else { + await LocalUtil.updateStorageUtil(response.jsonBody); + return await LicenseRepositoryImpl().updateLicense(); + } + } catch (e, s) { + log('() => error processData: $e', stackTrace: s); + final String errorMsg = FFLocalizations.of(context).getVariableText( + enText: 'Error getting data, verify your connection', + ptText: 'Erro ao obter dados, verifique sua conexão', + ); + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, null)); + return false; + } + } + + @override + Future selectLocal(BuildContext context, ApiCallResponse? response) async { + return await showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + enableDrag: false, + isDismissible: false, + showDragHandle: false, + useSafeArea: true, + context: context, + builder: (context) => PopScope( + canPop: false, + child: Padding( + padding: MediaQuery.viewInsetsOf(context), + child: BottomArrowLinkedLocalsComponentWidget(response: response), + ), + ), + ).then((_) async => await processData(context)); + } + + @override + Future detachLocal(BuildContext context) async { + String content; + try { + content = FFLocalizations.of(context).getVariableText( + enText: 'Device unlinked successfully', + ptText: 'Dispositivo desvinculado com sucesso', + ); + + await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { + if (value.jsonBody['error'] == false) { + await StorageHelper().set(KeychainStorageKey.clientName.value, ''); + await StorageHelper().set(KeychainStorageKey.ownerName.value, ''); + await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + context.pop(); + context.go('/homePage', extra: {'update': LocalsRepositoryImpl().update}); + SnackBarUtil.showSnackBar(context, content); + } + }).catchError((err, stack) { + context.pop(); + content = FFLocalizations.of(context).getVariableText( + enText: 'Error unlinking device', + ptText: 'Erro ao desvincular dispositivo', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + }); + } catch (err, stack) { + context.pop(); + log(err.toString(), stackTrace: stack); + content = FFLocalizations.of(context).getVariableText( + enText: 'Error unlinking device', + ptText: 'Erro ao desvincular dispositivo', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + } + } + + +} diff --git a/lib/shared/components/molecules/locals/data/index.dart b/lib/shared/components/molecules/locals/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/shared/components/molecules/locals/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/shared/components/molecules/locals/data/models/index.dart b/lib/shared/components/molecules/locals/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/locals/data/repositories/index.dart b/lib/shared/components/molecules/locals/data/repositories/index.dart new file mode 100644 index 00000000..80856dae --- /dev/null +++ b/lib/shared/components/molecules/locals/data/repositories/index.dart @@ -0,0 +1 @@ +export 'locals_repository_impl.dart'; 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 new file mode 100644 index 00000000..51c48596 --- /dev/null +++ b/lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart @@ -0,0 +1,89 @@ +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/backend/notifications/firebase_messaging_service.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/components/molecules/menu/presentation/blocs/menu_bloc.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/utils/dialog_util.dart'; +import 'package:rxdart/rxdart.dart'; + +class LocalsRepositoryImpl implements LocalsRepository { + final LocalsRemoteDataSource remoteDataSource = LocalsRemoteDataSourceImpl(); + final LocalsLocalDataSourceImpl localDataSource = LocalsLocalDataSourceImpl(); + + static final license = BehaviorSubject(); + static get stream => license.stream; + + @override + Future validateLocal(BuildContext context) async { + return await remoteDataSource.linkLocal(context); + } + + @override + Future update(BuildContext context) async { + LocalsRepositoryImpl.license.add(false); + final bool response = await _handleReponse(context); + LocalsRepositoryImpl.license.add(response); + return response; + } + + Future select(BuildContext context) async { + await localDataSource.unlinkLocal(); + await update(context); + } + + Future check(BuildContext context) async { + final String? cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value); + final String? ownerUUID = await StorageHelper().get(KeychainStorageKey.ownerUUID.value); + final bool haveCli = cliUUID != null && cliUUID.isNotEmpty; + final bool haveOwner = ownerUUID != null && ownerUUID.isNotEmpty; + if (!haveCli && !haveOwner) { + await update(context); + await FirebaseMessagingService().updateDeviceToken(); + } + } + + Future _handleReponse(BuildContext context) async { + bool response = false; + final bool isUnselected = await remoteDataSource.checkLocals(context); + if (isUnselected) { + while (!response) { + try { + response = await remoteDataSource.processLocals(context); + if (!response) { + await _handleUpdateError(context); + } + } catch (e, s) { + log('Error updating locals: $e', stackTrace: s); + await _handleUpdateError(context); + } + } + } else { + return true; + } + return response; + } + + Future _handleUpdateError(BuildContext context) async { + await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + const String errorMsg = 'Erro ao atualizar locais'; + await DialogUtil.error(context, errorMsg); + } + + Future _notifyBlocs(BuildContext context) async { + + context.read().add(LocalProfileEvent()); + context.read().add(MenuEvent()); + + } + + @override + Future unlinkLocal(BuildContext context) async { + await remoteDataSource.detachLocal(context); + await select(context); + } +} diff --git a/lib/shared/components/molecules/locals/domain/entities/index.dart b/lib/shared/components/molecules/locals/domain/entities/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/locals/domain/index.dart b/lib/shared/components/molecules/locals/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/shared/components/molecules/locals/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/shared/components/molecules/locals/domain/respositories/index.dart b/lib/shared/components/molecules/locals/domain/respositories/index.dart new file mode 100644 index 00000000..55f6b77a --- /dev/null +++ b/lib/shared/components/molecules/locals/domain/respositories/index.dart @@ -0,0 +1 @@ +export 'locals_repository.dart'; diff --git a/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart b/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart new file mode 100644 index 00000000..1862d79c --- /dev/null +++ b/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart @@ -0,0 +1,7 @@ +import 'package:flutter/material.dart'; + +abstract class LocalsRepository { + Future validateLocal(BuildContext context) async {} + Future update(BuildContext context) async => false; + Future unlinkLocal(BuildContext context) async {} +} diff --git a/lib/shared/components/molecules/locals/domain/usecases/index.dart b/lib/shared/components/molecules/locals/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/locals/index.dart b/lib/shared/components/molecules/locals/index.dart new file mode 100644 index 00000000..c6e39062 --- /dev/null +++ b/lib/shared/components/molecules/locals/index.dart @@ -0,0 +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/index.dart b/lib/shared/components/molecules/locals/presentation/blocs/index.dart new file mode 100644 index 00000000..488c36aa --- /dev/null +++ b/lib/shared/components/molecules/locals/presentation/blocs/index.dart @@ -0,0 +1 @@ +export 'local_profile_bloc.dart'; 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 new file mode 100644 index 00000000..d19459a1 --- /dev/null +++ b/lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart @@ -0,0 +1,79 @@ +import 'dart:async'; +import 'dart:developer'; + +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/flutter_flow_model.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + +class LocalProfileEvent { + +} + +class LocalProfileState { + final String cliName; + final String cliUUID; + final String ownerName; + + LocalProfileState({this.cliName = '', this.cliUUID = '', this.ownerName = ''}); + + LocalProfileState copyWith({String? cliName, String? ownerName, String? cliUUID}) { + + return LocalProfileState( + cliName: cliName ?? this.cliName, + ownerName: ownerName ?? this.ownerName, + cliUUID: cliUUID ?? this.cliUUID, + ); + } +} + +class LocalProfileBloc extends Bloc { + late StreamSubscription _completer; + + LocalProfileBloc() : super(LocalProfileState()) { + on(_onLocalProfileEvent); + _completer = LocalsRepositoryImpl.license.stream.listen((v) { + add(LocalProfileEvent()); + }); + } + + Future _onLocalProfileEvent(LocalProfileEvent event, Emitter emit) async { + final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + final ownerName = (await StorageHelper().get(KeychainStorageKey.ownerName.value)) ?? ''; + final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + emit(state.copyWith(cliName: cliName, cliUUID: cliUUID, ownerName: ownerName)); + } + + // void updateProfile(BuildContext context) { + // LocalsRepositoryImpl.license.add(false); + // context.read().add(MenuEvent()); + // add(LocalProfileEvent()); + // LocalsRepositoryImpl.license.add(true); + // } +} + +class LocalProfileComponentModel extends FlutterFlowModel { + String cliName = ''; + String cliUUID = ''; + String ownerName = ''; + VoidCallback? setStateCallback; + + @override + void initState(BuildContext context) { + getData(); + } + + Future getData() async { + cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + ownerName = (await StorageHelper().get(KeychainStorageKey.ownerName.value)) ?? ''; + cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + setStateCallback?.call(); + } + + @override + void dispose() {} +} diff --git a/lib/shared/components/molecules/locals/presentation/index.dart b/lib/shared/components/molecules/locals/presentation/index.dart new file mode 100644 index 00000000..688818c6 --- /dev/null +++ b/lib/shared/components/molecules/locals/presentation/index.dart @@ -0,0 +1,2 @@ +export 'blocs/index.dart'; +export 'widgets/index.dart'; diff --git a/lib/shared/components/molecules/locals/presentation/widgets/index.dart b/lib/shared/components/molecules/locals/presentation/widgets/index.dart new file mode 100644 index 00000000..e0361f45 --- /dev/null +++ b/lib/shared/components/molecules/locals/presentation/widgets/index.dart @@ -0,0 +1 @@ +export 'local_profile/index.dart'; \ No newline at end of file diff --git a/lib/shared/components/molecules/locals/presentation/widgets/local_profile/index.dart b/lib/shared/components/molecules/locals/presentation/widgets/local_profile/index.dart new file mode 100644 index 00000000..211db207 --- /dev/null +++ b/lib/shared/components/molecules/locals/presentation/widgets/local_profile/index.dart @@ -0,0 +1 @@ +export 'local_profile_widget.dart'; 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 new file mode 100644 index 00000000..77994112 --- /dev/null +++ b/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart @@ -0,0 +1,273 @@ +import 'dart:developer'; + +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/flutter_flow/custom_functions.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/components/molecules/modules/data/index.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:provider/provider.dart'; + +class LocalProfileComponentWidget extends StatefulWidget { + const LocalProfileComponentWidget({super.key}); + + @override + State createState() => _LocalProfileComponentWidgetState(); +} + +class _LocalProfileComponentWidgetState extends State { + bool _isLoading = false; + + Future retrieveProfileInfo() async { + + setState(() {_isLoading = true;}); + await LocalsRepositoryImpl().select(context); + setState(() {_isLoading = false;}); + } + + @override + Widget build(BuildContext context) { + + + return StreamBuilder( + stream: LocalsRepositoryImpl.stream, + builder: (context, snapshot) { + final textScaler = MediaQuery.textScalerOf(context); + final double baseFontSize = 14.0; + final double scaledFontSize = baseFontSize * textScaler.scale(1); + final double limitedFontSize = scaledFontSize > 20 ? 12 : scaledFontSize; + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data! == false) { + + return BlocBuilder( + builder: (context, state) { + return _buildDefaultLocalProfile(context, limitedFontSize); + }, + ); + } + + return BlocBuilder( + builder: (context, state) { + return _buildAsyncLocalProfile(context, state, limitedFontSize); + }, + ); + + }, + ); + + } + + Container _buildDefaultLocalProfile(BuildContext context, double limitedFontSize) { + return Container( + decoration: const BoxDecoration(), + child: Align( + alignment: const AlignmentDirectional(0.0, -1.0), + child: Material( + color: Colors.transparent, + elevation: 0.0, + child: Container( + width: double.infinity, + height: 119.0, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primary, + border: Border.all( + color: FlutterFlowTheme.of(context).primary, + ), + ), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Align( + alignment: const AlignmentDirectional(-1.0, 0.0), + child: Padding( + padding: const EdgeInsets.all(2.0), + child: InkWell( + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: _isLoading ? null : retrieveProfileInfo, + child: ClipRRect( + borderRadius: BorderRadius.circular(200.0), + child: CachedNetworkImage( + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + imageUrl: 'assets/images/home.png', + width: 80.0, + height: 80.0, + fit: BoxFit.cover, + alignment: const Alignment(0.0, 0.0), + placeholder: (context, url) => Image.asset('assets/images/home.png'), + errorListener: (_) => Image.asset('assets/images/home.png'), + errorWidget: (_, __, ___) => Image.asset('assets/images/home.png'), + ), + )), + ), + ), + Expanded( + child: Tooltip( + message: FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).info, + fontSize: limitedFontSize, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), + ), + ), + ), + ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)), + ), + ), + ), + ), + ); + } + + Container _buildAsyncLocalProfile(BuildContext context, LocalProfileState state, double limitedFontSize) { + return Container( + decoration: const BoxDecoration(), + child: Align( + alignment: const AlignmentDirectional(0.0, -1.0), + child: Material( + color: Colors.transparent, + elevation: 0.0, + child: Container( + width: double.infinity, + height: 119.0, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primary, + border: Border.all( + color: FlutterFlowTheme.of(context).primary, + ), + ), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Align( + alignment: const AlignmentDirectional(-1.0, 0.0), + child: Padding( + padding: const EdgeInsets.all(2.0), + child: InkWell( + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: _isLoading ? null : retrieveProfileInfo, + child: ClipRRect( + borderRadius: BorderRadius.circular(200.0), + child: CachedNetworkImage( + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + imageUrl: valueOrDefault('https://freaccess.com.br/freaccess/Images/Clients/${state.cliUUID}.png', 'assets/images/home.png'), + width: 80.0, + height: 80.0, + fit: BoxFit.cover, + alignment: const Alignment(0.0, 0.0), + placeholder: (context, url) => Image.asset('assets/images/home.png'), + errorListener: (_) => Image.asset('assets/images/home.png'), + errorWidget: (_, __, ___) => Image.asset('assets/images/home.png'), + ), + )), + ), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Tooltip( + message: valueOrDefault( + convertToUppercase(state.cliName), + FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + ), + child: Text( + valueOrDefault( + convertToUppercase(state.cliName), + FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + ), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).info, + fontSize: limitedFontSize, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), + ), + ), + Tooltip( + message: valueOrDefault( + ' '+state.ownerName, + '' + ), + child: Text( + valueOrDefault( + state.ownerName.length > 30 ? '${state.ownerName.substring(0, 20)}...' : state.ownerName, + '' + ), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).info, + fontSize: limitedFontSize, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), + ), + ), + ], + ), + ), + ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)), + ), + ), + ), + ), + ); + + + } +} diff --git a/lib/shared/components/molecules/locals/utils/index.dart b/lib/shared/components/molecules/locals/utils/index.dart new file mode 100644 index 00000000..d1febb55 --- /dev/null +++ b/lib/shared/components/molecules/locals/utils/index.dart @@ -0,0 +1 @@ +export 'local_util.dart'; diff --git a/lib/shared/components/molecules/locals/utils/local_util.dart b/lib/shared/components/molecules/locals/utils/local_util.dart new file mode 100644 index 00000000..9aaa7772 --- /dev/null +++ b/lib/shared/components/molecules/locals/utils/local_util.dart @@ -0,0 +1,136 @@ + + +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/shared/utils/dialog_util.dart'; +import 'package:hub/shared/utils/log_util.dart'; + +class LocalUtil { + + static void handleError(BuildContext context, String errorMsg) async { + final String devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; + final String userUUID = await StorageHelper().get(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 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']); + await StorageHelper().set(KeychainStorageKey.ownerName.value, locals[0]['CLU_OWNER_DSC']); + + 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, ''); + await StorageHelper().set(KeychainStorageKey.ownerName.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.ownerName.value, local['CLU_OWNER_DSC']); + 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'] ?? ''); + await StorageHelper().set(KeychainStorageKey.userEmail.value, jsonBody['visitado']['VDO_EMAIL'] ?? ''); + + 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 new file mode 100644 index 00000000..8b421899 --- /dev/null +++ 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..113df0e4 --- /dev/null +++ b/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart @@ -0,0 +1,101 @@ + + +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'; + +import '../../../modules/domain/entities/index.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 handleMenu(EnumMenuItem item, EnumDisplay display, MenuEntry opt, List entries); + Future processStartDate(String startDate, MenuEntry entry); + Future processExpirationDate(String expirationDate, MenuEntry entry); +} + +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.key == 'FRE-HUB-LOGOUT') { + await addMenuEntry(item, entries, opt.icon, opt.name, () async { + await AuthenticationService.signOut(navigatorKey.currentContext!); + }); + return true; + + } + else return false; + } + + @override + Future handleMenu(EnumMenuItem item, EnumDisplay display, MenuEntry opt, List entries) async { + try { + switch (display.value) { + 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.key}: $e'); + } + } + + @override + Future processStartDate(String startDate, MenuEntry opt) async { + try { + if (startDate.isEmpty) return true; + final start = DateTime.tryParse(startDate); + if (start == null) return false; + return DateTime.now().isAfter(start); + } catch (e) { + log('Error processing start date for module ${opt.key}: $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.key}: $e'); + } + return false; + } + + + +} \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/data/index.dart b/lib/shared/components/molecules/menu/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/shared/components/molecules/menu/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/shared/components/molecules/menu/data/models/index.dart b/lib/shared/components/molecules/menu/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/menu/data/repositories/index.dart b/lib/shared/components/molecules/menu/data/repositories/index.dart new file mode 100644 index 00000000..f3a81afb --- /dev/null +++ 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..2a05bb85 --- /dev/null +++ b/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart @@ -0,0 +1,79 @@ + + +import 'dart:convert'; +import 'dart:developer'; + +import 'package:hub/flutter_flow/custom_functions.dart'; +import 'package:hub/main.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'; +import 'package:hub/shared/extensions/string_extensions.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; + + +class MenuRepositoryImpl implements MenuRepository { + final MenuLocalDataSource menuDataSource = MenuLocalDataSourceImpl(); + + + @override + Future> generateMenuEntries(List menuEntries, EnumMenuItem item) async { + List entries = []; + // final bool isNewVersion = await StorageHelper().get(KeychainStorageKey.isNewVersion.value).then((v) => v.toBoolean()); + + try { + for (var entry in menuEntries) { + final bool isDefault = await menuDataSource.processDisplayDefault(item, entry, entries); + if (isDefault) continue; + final licenseValue = await LicenseRepositoryImpl().getLicense(entry.key); + if (licenseValue != null) { + final licenseMap = await stringToMap(licenseValue); + final display = EnumDisplay.fromString(licenseMap['display']); + final startDate = licenseMap['startDate'] ?? ''; + final expirationDate = licenseMap['expirationDate'] ?? ''; + final isStarted = await menuDataSource.processStartDate(startDate, entry); + final isExpired = await menuDataSource.processExpirationDate(expirationDate, entry); + if (isStarted && !isExpired) { + await menuDataSource.handleMenu(item, display, entry, entries); + } + if (isExpired) { + log('Entry ${entry.key} is expired'); + await menuDataSource.handleMenu(item, EnumDisplay.inactive, entry, entries); + } + if (!isStarted) { + log('Entry ${entry.key} is not started'); + await menuDataSource.handleMenu(item, EnumDisplay.inactive, entry, entries); + } + } + } + } catch (e, s) { + log('Error generating menu entries: $e', stackTrace: s); + } + return entries; + } + + Future processDisplay(Map module, bool isNewVersion) async { + + + if (await _shouldUpdateDisplay(module, isNewVersion)) { + final displayValue = module['display'] == EnumDisplay.active ? 'VISIVEL' : 'INVISIVEL'; + await LicenseLocalDataSourceImpl().setDisplayByKey(['FRE-HUB-ABOUT-PROPERTY'], displayValue); + return EnumDisplay.fromString(displayValue); + } + + return EnumDisplay.fromString(module['display']); + } + + Future _shouldUpdateDisplay(Map module, bool isNewVersion) async { + const keysToCheck = [ + LicenseKeys.residents, + LicenseKeys.vehicles, + LicenseKeys.openedVisits + ]; + return isNewVersion && keysToCheck.any((key) => module['key'] == key.value); + } + + +} \ 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 new file mode 100644 index 00000000..329a4c9c --- /dev/null +++ b/lib/shared/components/molecules/menu/domain/entities/index.dart @@ -0,0 +1 @@ +export 'menu_item.dart'; diff --git a/lib/shared/components/molecules/menu/domain/entities/menu_item.dart b/lib/shared/components/molecules/menu/domain/entities/menu_item.dart new file mode 100644 index 00000000..31b36da6 --- /dev/null +++ b/lib/shared/components/molecules/menu/domain/entities/menu_item.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; + +enum EnumMenuItem { + button, + card, + tile; + + MenuItem getInstance(final Function() action, final String title, final IconData icon) { + switch (this) { + case EnumMenuItem.button: + return ButtonMenuItem(action: action, title: title, icon: icon); + case EnumMenuItem.card: + return CardMenuItem(action: action, title: title, icon: icon); + case EnumMenuItem.tile: + return CardMenuItem(action: action, title: title, icon: icon); + } + } +} + +abstract class MenuItem extends StatefulWidget { + const MenuItem({ + super.key, + required this.action, + required this.title, + required this.icon, + }); + + final Function() action; + final String title; + final IconData icon; + + + factory MenuItem.create( + EnumMenuItem type, { + Key? key, + required Function() action, + required String title, + required IconData icon, + }) { + return type.getInstance(action, title, icon); + } +} diff --git a/lib/shared/components/molecules/menu/domain/index.dart b/lib/shared/components/molecules/menu/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/shared/components/molecules/menu/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/shared/components/molecules/menu/domain/respositories/index.dart b/lib/shared/components/molecules/menu/domain/respositories/index.dart new file mode 100644 index 00000000..e69de29b 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..495dc332 --- /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 menuEntries, EnumMenuItem item); +} \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/domain/usecases/index.dart b/lib/shared/components/molecules/menu/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/menu/index.dart b/lib/shared/components/molecules/menu/index.dart new file mode 100644 index 00000000..aa560630 --- /dev/null +++ b/lib/shared/components/molecules/menu/index.dart @@ -0,0 +1,3 @@ +export 'data/index.dart'; +export 'domain/index.dart'; +export 'presentation/index.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/blocs/index.dart b/lib/shared/components/molecules/menu/presentation/blocs/index.dart new file mode 100644 index 00000000..3f1ac83b --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/blocs/index.dart @@ -0,0 +1,3 @@ +export 'menu_bloc.dart'; +export 'menu_item_bloc.dart'; +export 'menu_view_bloc.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart b/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart new file mode 100644 index 00000000..ed513784 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart @@ -0,0 +1,59 @@ + +import 'dart:async'; +import 'dart:developer'; + +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/components/molecules/locals/index.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:flutter_bloc/flutter_bloc.dart'; + + +class MenuEvent {} + +class MenuState { + final List menuEntries; + final bool isGrid; + + MenuState({this.menuEntries = const [], this.isGrid = false}); + + MenuState copyWith({List? menuEntries, bool? isGrid}) { + return MenuState( + menuEntries: menuEntries ?? this.menuEntries, + isGrid: isGrid ?? this.isGrid, + ); + } +} + +class MenuBloc extends Bloc { + final MenuView style; + final EnumMenuItem item; + final List entries; + late StreamSubscription _completer; + + MenuBloc({required this.style, required this.item, required this.entries}) : super(MenuState()) { + on(_onMenuEvent); + _completer = LocalsRepositoryImpl.license.stream.listen((v) { + add(MenuEvent()); + }); + } + + Future _onMenuEvent(MenuEvent event, Emitter emit) async { + await LicenseRemoteDataSourceImpl().waitForSaveCompletion(); + + final List newEntries = await MenuRepositoryImpl().generateMenuEntries(entries, item); + emit(state.copyWith(menuEntries: newEntries)); + } + + @override + Future close() { + _completer.cancel(); + return super.close(); + } + + +} diff --git a/lib/shared/components/molecules/menu/presentation/blocs/menu_item_bloc.dart b/lib/shared/components/molecules/menu/presentation/blocs/menu_item_bloc.dart new file mode 100644 index 00000000..608fa51d --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/blocs/menu_item_bloc.dart @@ -0,0 +1,9 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +class MenuItemEvent {} + +class MenuItemState {} + +class MenuItemBloc extends Bloc { + MenuItemBloc() : super(MenuItemState()); +} 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 new file mode 100644 index 00000000..bd77e2de --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/blocs/menu_view_bloc.dart @@ -0,0 +1,11 @@ + + +import 'package:flutter_bloc/flutter_bloc.dart'; + +class MenuViewEvent {} + +class MenuViewState {} + +class MenuViewBloc extends Bloc { + MenuViewBloc() : super(MenuViewState()); +} diff --git a/lib/shared/components/molecules/menu/presentation/index.dart b/lib/shared/components/molecules/menu/presentation/index.dart new file mode 100644 index 00000000..2bb09756 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/index.dart @@ -0,0 +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..02b59717 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart @@ -0,0 +1,233 @@ +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 key; + final IconData icon; + final String name; + final String route; + final List types; + + const MenuEntry({ + required this.key, + required this.icon, + required this.name, + required this.route, + required this.types, + }); + + static List entries = [ + MenuEntry( + key: 'FRE-HUB-AGE-PROV-PREST', + icon: Icons.engineering_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Agendar Prestadores', + enText: 'Schedule Providers', + ), + route: '/provisionalSchedule', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + key: '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( + key: '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( + key: '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( + key: 'FRE-HUB-RESIDENTS', + icon: Icons.groups, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Moradores', + enText: 'Residents', + ), + route: '/residentsOnThePropertyPage', + types: [MenuEntryType.Property], + ), + MenuEntry( + key: 'FRE-HUB-VEHICLES', + icon: Icons.directions_car, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Veículos', + enText: 'Vehicles', + ), + route: '/vehiclesOnThePropertyPage', + types: [MenuEntryType.Property], + ), + MenuEntry( + key: 'FRE-HUB-OPENED-VISITS', + icon: Icons.perm_contact_calendar, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Visitas Abertas', + enText: 'Opened Visits', + ), + route: '/visitsOnThePropertyPage', + types: [MenuEntryType.Property], + ), + MenuEntry( + key: 'FRE-HUB-PETS-HISTORY', + icon: Icons.pets, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Pets', + enText: 'Pets', + ), + route: '/petsOnThePropertyPage', + types: [MenuEntryType.Property], + ), + MenuEntry( + key: 'FRE-HUB-ORDERS', + icon: Icons.inventory_2_outlined, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Encomendas', + enText: 'Orders', + ), + route: '/packageOrder', + types: [MenuEntryType.Home, MenuEntryType.Drawer, MenuEntryType.Property], + ), + MenuEntry( + key: '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( + key: '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( + key: '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( + key: 'FRE-HUB-PETS', + icon: Icons.pets, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Cadastrar Pets', + enText: 'Pets Register' + ), + route: '/petsPage', + types: [MenuEntryType.Home, MenuEntryType.Drawer], + ), + MenuEntry( + key: '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( + key: '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( + key: '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( + key: 'FRE-HUB-ABOUT-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( + key: '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( + key: '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( + key: 'FRE-HUB-LOGOUT', + icon: Icons.exit_to_app, + name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + ptText: 'Sair', + enText: 'Logout', + ), + route: '/WelcomePage', + types: [MenuEntryType.Drawer], + ), + ]; + + 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 new file mode 100644 index 00000000..800e0aa8 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/widgets/index.dart @@ -0,0 +1,4 @@ +export 'menu_item/index.dart'; +export 'menu_view/index.dart'; + +export 'menu_factory.dart'; \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart new file mode 100644 index 00000000..79bf3454 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart @@ -0,0 +1,74 @@ +import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +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 Menufactory extends StatelessWidget { + final MenuView view; + final EnumMenuItem item; + final List entry; + + const Menufactory({ + super.key, + required this.view, + required this.item, + required this.entry, + }); + + @override + Widget build(BuildContext context) { + return StreamBuilder( + stream: LocalsRepositoryImpl.stream, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data! == false) { + return LoadingUtil.buildLoadingIndicator(context); + } + return _buildMenuBloc(context); + }, + ); + } + + Widget buildMenu(BuildContext context) { + return _buildMenuBloc(context); + } + + + + Widget _buildMenuBloc(BuildContext context) { + return BlocProvider( + create: (context) => MenuBloc( + style: view, + item: item, + entries: entry, + )..add(MenuEvent()), + child: BlocBuilder( + builder: (context, state) { + if (view == MenuView.list_grid) { + return MenuStaggeredView( + options: state.menuEntries, + item: item, + changeMenuStyle: () async {}, + isGrid: state.isGrid, + ); + } else if (view == MenuView.list) { + return MenuListView( + options: state.menuEntries, + item: item, + changeMenuStyle: () async {}, + ); + } + return const SizedBox(); + }, + ), + ); + } +} 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 new file mode 100644 index 00000000..6380393e --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/index.dart @@ -0,0 +1,2 @@ +export 'menu_item_button.dart'; +export 'menu_item_card.dart'; diff --git a/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart similarity index 88% rename from lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart rename to lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart index ced0373e..7e861894 100644 --- a/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; -class MenuButtonWidget extends MenuEntry { - const MenuButtonWidget({ + +class ButtonMenuItem extends MenuItem { + const ButtonMenuItem({ super.key, required this.action, required this.title, required this.icon, - required super.safeSetState, }) : super(action: action, title: title, icon: icon); @override @@ -23,8 +23,7 @@ class MenuButtonWidget extends MenuEntry { _MenuButtonWidgetState createState() => _MenuButtonWidgetState(); } -class _MenuButtonWidgetState extends State { - get action => action; +class _MenuButtonWidgetState extends State { bool _isProcessing = false; @override @@ -61,10 +60,7 @@ class _MenuButtonWidgetState extends State { BoxShadow( blurRadius: 4.0, color: FlutterFlowTheme.of(context).customColor5, - offset: const Offset( - 0.0, - 2.0, - ), + offset: const Offset(0.0, 2.0), ) ], borderRadius: BorderRadius.circular(24.0), @@ -95,7 +91,7 @@ class _MenuButtonWidgetState extends State { child: Padding( padding: const EdgeInsets.only(left: 10.0), child: Text( - widget.title ?? '', + widget.title, overflow: TextOverflow.ellipsis, maxLines: 2, textAlign: TextAlign.start, @@ -103,7 +99,6 @@ class _MenuButtonWidgetState extends State { fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedFontSize, - letterSpacing: 0.0, fontWeight: FontWeight.w500, useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), ), diff --git a/lib/components/atomic_components/menu_card_item/menu_card_item.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart similarity index 86% rename from lib/components/atomic_components/menu_card_item/menu_card_item.dart rename to lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart index 5696f83a..b120a09d 100644 --- a/lib/components/atomic_components/menu_card_item/menu_card_item.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; -class MenuCardItem extends MenuEntry { - const MenuCardItem({ + +class CardMenuItem extends MenuItem { + const CardMenuItem({ super.key, required this.action, required this.title, required this.icon, - required super.safeSetState, }) : super(action: action, title: title, icon: icon); @override @@ -23,8 +23,7 @@ class MenuCardItem extends MenuEntry { _MenuCardItemState createState() => _MenuCardItemState(); } -class _MenuCardItemState extends State { - get action => action; +class _MenuCardItemState extends State { bool _isProcessing = false; @override @@ -66,7 +65,6 @@ class _MenuCardItemState extends State { alignment: const AlignmentDirectional(0.0, 0.0), child: Icon( widget.icon, - fill: null, color: FlutterFlowTheme.of(context).accent1, size: 24.0, ), @@ -75,13 +73,11 @@ class _MenuCardItemState extends State { ), Flexible( child: Text( - widget.title ?? '', - // overflow: TextOverflow.ellipsis, + widget.title, style: FlutterFlowTheme.of(context).titleLarge.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, fontSize: 14.0, - letterSpacing: 0.0, fontWeight: FontWeight.w500, useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), ), 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 new file mode 100644 index 00000000..fae17fc0 --- /dev/null +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/index.dart @@ -0,0 +1,2 @@ +export 'menu_list_view.dart'; +export 'menu_staggered_view.dart'; diff --git a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart similarity index 52% rename from lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart rename to lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart index 88f6153e..277fd2c3 100644 --- a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart @@ -1,37 +1,38 @@ import 'package:flutter/material.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; -import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; +import 'package:hub/shared/components/molecules/menu/index.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; -import 'menu_list_view_component_model.dart'; -export 'menu_list_view_component_model.dart'; +enum MenuView { list_grid, list, grid } -/// +class MenuListViewModel extends FlutterFlowModel { + @override + void initState(BuildContext context) {} -class MenuListViewComponentWidget extends StatefulWidget { - const MenuListViewComponentWidget({ + @override + void dispose() {} +} + +class MenuListView extends StatefulWidget { + const MenuListView({ super.key, required this.changeMenuStyle, - required this.expandable, required this.item, required this.options, }); - final bool expandable; - final MenuItem item; - - final List options; + final EnumMenuItem item; + final List options; final Future Function()? changeMenuStyle; @override - State createState() => _MenuListViewComponentWidgetState(); + State createState() => _MenuListViewState(); } -class _MenuListViewComponentWidgetState extends State { - late MenuListViewComponentModel _model; +class _MenuListViewState extends State { + late MenuListViewModel _model; @override void setState(VoidCallback callback) { @@ -42,7 +43,7 @@ class _MenuListViewComponentWidgetState extends State MenuListViewComponentModel()); + _model = createModel(context, () => MenuListViewModel()); } @override @@ -59,53 +60,59 @@ class _MenuListViewComponentWidgetState extends State { + @override + void initState(BuildContext context) {} + + @override + void dispose() {} +} + +class MenuStaggeredView extends StatefulWidget { + const MenuStaggeredView({super.key, required this.changeMenuStyle, required this.item, required this.options, required this.isGrid}); + + final EnumMenuItem item; + final bool isGrid; + final List options; + final Future Function()? changeMenuStyle; + + @override + State createState() => _MenuStaggeredViewState(); +} + +class _MenuStaggeredViewState extends State { + late MenuStaggeredViewModel _model; + + @override + void setState(VoidCallback callback) { + super.setState(callback); + _model.onUpdate(); + } + + @override + void initState() { + super.initState(); + _model = createModel(context, () => MenuStaggeredViewModel()); + } + + @override + void dispose() { + _model.maybeDispose(); + + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final textScaler = MediaQuery.textScalerOf(context); + final double scaledFontSize = 14 * textScaler.scale(1); + final int crossAxisCount = _calculateCrossAxisCount(scaledFontSize); + + return Column( + children: [ + _buildGridView(crossAxisCount), + ].addToStart(const SizedBox(height: 30)).addToEnd(const SizedBox(height: 30)), + ); + } + + int _calculateCrossAxisCount(double scaledFontSize) { + if (scaledFontSize >= 26) return 1; + if (scaledFontSize >= 18) return 2; + return 3; + } + + Widget _buildGridView(int crossAxisCount) { + return GridView.builder( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: crossAxisCount, + crossAxisSpacing: 10.0, + mainAxisSpacing: 10.0, + childAspectRatio: 1, + mainAxisExtent: 100, + ), + itemCount: widget.options.length, + padding: const EdgeInsets.symmetric(horizontal: 14), + shrinkWrap: true, + itemBuilder: (context, index) { + return Container( + height: MediaQuery.of(context).size.height, + width: MediaQuery.of(context).size.width, + alignment: Alignment.center, + padding: const EdgeInsets.all(0), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(0), + color: Colors.transparent, + boxShadow: const [ + BoxShadow( + color: Colors.transparent, + blurRadius: 4, + offset: Offset(0, 2), + ), + ], + ), + child: Center(child: widget.options[index]), + ); + }, + ); + } + + Widget collapseExpandMethod(BuildContext context) { + if (widget.isGrid) { + return _buildCollapseButton(context); + } else { + return _buildExpandButton(context); + } + } + + Widget _buildCollapseButton(BuildContext context) { + return Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: Container( + decoration: const BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(0.0), + bottomRight: Radius.circular(0.0), + topLeft: Radius.circular(0.0), + topRight: Radius.circular(0.0), + ), + ), + alignment: const AlignmentDirectional(0.0, 0.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Text( + FFLocalizations.of(context).getVariableText( + enText: 'Minimize', + ptText: 'Minimizar', + ), + style: FlutterFlowTheme.of(context).title1.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 12.0, + fontWeight: FontWeight.w600, + fontStyle: FontStyle.normal, + ), + ), + Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 20.0, + borderWidth: 1.0, + buttonSize: 50.0, + fillColor: const Color(0x00FFFFFF), + icon: Icon( + Icons.keyboard_arrow_up_sharp, + color: FlutterFlowTheme.of(context).primary, + ), + onPressed: () async { + await widget.changeMenuStyle?.call(); + }, + ), + ), + ], + ), + ), + ); + } + + Widget _buildExpandButton(BuildContext context) { + return Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + FFLocalizations.of(context).getVariableText( + enText: 'Expand', + ptText: 'Expandir', + ), + style: FlutterFlowTheme.of(context).title1.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 12.0, + fontWeight: FontWeight.w600, + fontStyle: FontStyle.normal, + ), + ), + Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 20.0, + borderWidth: 0.0, + buttonSize: 50.0, + fillColor: const Color(0x00FFFFFF), + icon: Icon( + Icons.keyboard_arrow_down_outlined, + color: FlutterFlowTheme.of(context).primary, + ), + onPressed: () async { + await widget.changeMenuStyle?.call(); + }, + ), + ), + ], + ); + } +} diff --git a/lib/shared/components/molecules/modules/constants/index.dart b/lib/shared/components/molecules/modules/constants/index.dart new file mode 100644 index 00000000..20bc3626 --- /dev/null +++ b/lib/shared/components/molecules/modules/constants/index.dart @@ -0,0 +1 @@ +export 'license_constants.dart'; \ No newline at end of file diff --git a/lib/shared/components/molecules/modules/constants/license_constants.dart b/lib/shared/components/molecules/modules/constants/license_constants.dart new file mode 100644 index 00000000..6a4a2fcc --- /dev/null +++ b/lib/shared/components/molecules/modules/constants/license_constants.dart @@ -0,0 +1,84 @@ + + const String tableLicense = 'license'; + + class LicenseConstants { + static String get createLicenseTable => ''' + CREATE TABLE IF NOT EXISTS $tableLicense ( + key TEXT UNIQUE, + display TEXT, + expirationDate TEXT, + startDate TEXT, + quantity TEXT + ); + '''; + + static String get deleteLicenseTable => 'DROP TABLE IF EXISTS $tableLicense;'; + + static String get updatePetsHistoryTrigger => ''' + CREATE TRIGGER update_fre_hub_pets_history + AFTER INSERT ON $tableLicense + WHEN NEW.key = 'FRE-HUB-PETS' + BEGIN + INSERT OR REPLACE INTO $tableLicense (key, display, expirationDate, startDate, quantity) + VALUES ('FRE-HUB-PETS-HISTORY', NEW.display, NEW.expirationDate, NEW.startDate, NEW.quantity); + END; + '''; + + static String get dropPetsHistoryTrigger => 'DROP TRIGGER IF EXISTS update_fre_hub_pets_history;'; + + static String get updateDisplayTrigger => ''' + CREATE TRIGGER update_display_trigger + AFTER UPDATE ON $tableLicense + WHEN NEW.key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') + BEGIN + INSERT OR REPLACE INTO $tableLicense (key, display, expirationDate, startDate, quantity) + VALUES ( + 'FRE-HUB-ABOUT-PROPERTY', + CASE + WHEN (SELECT COUNT(*) FROM $tableLicense WHERE key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') AND display = 'VISIVEL') > 0 + THEN 'VISIVEL' + ELSE 'INVISIVEL' + END, + NULL, NULL, NULL + ); + END; + '''; + + static String get dropUpdateDisplayTrigger => 'DROP TRIGGER IF EXISTS update_display_trigger;'; + + static String get insertDisplayTrigger => ''' + CREATE TRIGGER insert_display_trigger + AFTER INSERT ON $tableLicense + WHEN NEW.key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') + BEGIN + UPDATE $tableLicense + SET display = + CASE + WHEN (SELECT COUNT(*) FROM $tableLicense WHERE key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') AND display = 'VISIVEL') > 0 + THEN 'VISIVEL' + ELSE 'INVISIVEL' + END + WHERE key = 'FRE-HUB-ABOUT-PROPERTY'; + END; + '''; + + static String get dropInsertDisplayTrigger => 'DROP TRIGGER IF EXISTS insert_display_trigger;'; + + static String get updatePeopleDisplayTrigger => ''' + CREATE TRIGGER update_people_display_trigger + AFTER UPDATE ON $tableLicense + WHEN NEW.key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') + BEGIN + UPDATE $tableLicense + SET display = + CASE + WHEN (SELECT COUNT(*) FROM $tableLicense WHERE key IN ('FRE-HUB-OPENED-VISITS', 'FRE-HUB-VEHICLES', 'FRE-HUB-RESIDENTS') AND display = 'VISIVEL') > 0 + THEN 'VISIVEL' + ELSE 'INVISIVEL' + END + WHERE key = 'FRE-HUB-ABOUT-PROPERTY'; + END; + '''; + + static String get dropPeopleDisplayTrigger => 'DROP TRIGGER IF EXISTS update_people_display_trigger;'; + } \ No newline at end of file diff --git a/lib/shared/components/molecules/modules/data/data_sources/index.dart b/lib/shared/components/molecules/modules/data/data_sources/index.dart new file mode 100644 index 00000000..1d1649f7 --- /dev/null +++ b/lib/shared/components/molecules/modules/data/data_sources/index.dart @@ -0,0 +1,2 @@ +export 'license_local_data_source.dart'; +export 'license_remote_data_source.dart'; 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 new file mode 100644 index 00000000..ff502e5f --- /dev/null +++ b/lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart @@ -0,0 +1,87 @@ + +import 'dart:developer'; + +import 'package:hub/shared/components/molecules/modules/index.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 'package:hub/shared/extensions/string_extensions.dart'; +import 'package:sqflite/sqflite.dart'; + +abstract class LicenseLocalDataSource { + Future init(); + Future setDisplayByKey(final List key, final String display); + Future isNewVersion(); + Future get(String key); + Future set(String key, T value); + Future del(String key); + Future clear(); +} + +class LicenseLocalDataSourceImpl implements LicenseLocalDataSource { + static final LicenseLocalDataSourceImpl _instance = LicenseLocalDataSourceImpl._internal(); + factory LicenseLocalDataSourceImpl() => _instance; + LicenseLocalDataSourceImpl._internal(); + + + @override + Future init() async { + await DatabaseStorage.instance.init(); + } + + @override + Future setDisplayByKey(final List keys, final String display) async { + if (keys.isEmpty) return; + final validKeys = keys.where((key) => key.isNotEmpty).toList(); + for (var key in validKeys) { + await set(key, { + 'display': display, + 'expirationDate': '', + 'startDate': '', + 'quantity': '', + }); + } + } + + @override + Future isNewVersion() async { + final String? reponse = await StorageHelper().get(KeychainStorageKey.isNewVersion.value); + final bool isNewVersion = reponse.toBoolean(); + return isNewVersion; + } + + @override + Future get(String key) async { + var response = await DatabaseStorage.database.query(tableLicense, where: 'key = ?', whereArgs: [key]); + if (response.isEmpty) { + return null; + } + + + return response.toString(); + } + + @override + Future set(String key, T value) async { + value as Map; + if (value.isEmpty) return; + if (key == 'null') return; + + await DatabaseStorage.database.rawInsert( + 'INSERT OR REPLACE INTO $tableLicense (key, display, expirationDate, startDate, quantity) VALUES (?, ?, ?, ?, ?)', + [key, value['display'], value['expirationDate'], value['startDate'], value['quantity']], + ); + return; + } + + @override + Future del(String key) async { + await DatabaseStorage.database.delete(tableLicense, where: 'key = ?', whereArgs: [key]); + } + + @override + Future clear() async { + await DatabaseStorage.database.delete(tableLicense); + + } +} 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 new file mode 100644 index 00000000..9927d370 --- /dev/null +++ b/lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart @@ -0,0 +1,123 @@ +// ignore_for_file: curly_braces_in_flow_control_structures, prefer_is_empty + +import 'dart:async'; +import 'dart:developer'; + +import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/shared/components/molecules/locals/index.dart'; +import 'package:hub/shared/components/molecules/modules/index.dart'; +import 'package:hub/shared/helpers/database/database_helper.dart'; + +import 'package:sqflite/sqflite.dart'; + +abstract class LicenseRemoteDataSource { + Future fetchLicenses(bool isNewVersion); + Future cleanLicense(); + Future processLicense(); + Future setupLicense(Database database, bool isNewVersion); +} + +class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource { + static final LicenseRemoteDataSourceImpl _instance = LicenseRemoteDataSourceImpl._internal(); + factory LicenseRemoteDataSourceImpl() => _instance; + LicenseRemoteDataSourceImpl._internal(); + + + + + + @override + Future processLicense() async {} + + @override + Future cleanLicense() async { + LocalsRepositoryImpl.license.add(false); + + } + + @override + Future setupLicense(Database database, bool isNewVersion) async { + log('Setting up license...'); + try { + final License license = await License.getLicense(isNewVersion); + + final List inactiveModuleKey = license.modules + .where((module) => module.display == ModuleStatus.inactive.key) + .map((module) => module.key) + .toList(); + + final List activeModuleKey = license.modules + .where((module) => module.display == ModuleStatus.active.key) + .map((module) => module.key) + .toList(); + + final List disabledModuleKey = license.modules + .where((module) => module.display == ModuleStatus.disabled.key) + .map((module) => module.key) + .toList(); + + await LicenseLocalDataSourceImpl().setDisplayByKey(inactiveModuleKey, 'INVISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(activeModuleKey, 'VISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(disabledModuleKey, 'DESABILITADO'); + + + + return true; + } catch (e, s) { + log('Erro ao configurar licenças: $e', stackTrace: s); + return false; + } + } + + @override + Future fetchLicenses(bool isNewVersion) async { + log('Fetching licenses...'); + try { + final response = await PhpGroup.getLicense(); + final dynamic responseBody = response.jsonBody; + + + if (responseBody == []) { + return true; + } + else if (response.jsonBody is! List) { + late final String error; + if (response.jsonBody is Map) + error = response.jsonBody['error_msg']; + else + error = 'Erro desconhecido'; + + throw Exception('Erro ao consultar licenças: $error'); + } + + + + List> saveOperations = []; + for (var element in responseBody) { + if (licenseContainsKey(element['key'])) { + saveOperations.add(_saveModule(element)); + } + } + await Future.wait(saveOperations); + return true; + } catch (e, s) { + log('Erro ao obter licenças: $e', stackTrace: s); + // return await setupLicense(DatabaseStorage.database, isNewVersion); + return false; + } + } + + Future waitForSaveCompletion() async { + await LocalsRepositoryImpl.stream; + } + + static bool licenseContainsKey(final String key) { + + return LicenseKeys.values.map((e) => e.value).toList().contains(key); + } + + static Future _saveModule(final dynamic body) async { + if (body is! Map) return; + await LicenseRepositoryImpl().setLicense(body['key'], body); + } +} diff --git a/lib/shared/components/molecules/modules/data/index.dart b/lib/shared/components/molecules/modules/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/shared/components/molecules/modules/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/shared/components/molecules/modules/data/models/index.dart b/lib/shared/components/molecules/modules/data/models/index.dart new file mode 100644 index 00000000..2ce303b5 --- /dev/null +++ b/lib/shared/components/molecules/modules/data/models/index.dart @@ -0,0 +1,2 @@ +export 'license_model.dart'; +export 'module_model.dart'; diff --git a/lib/shared/components/molecules/modules/data/models/license_model.dart b/lib/shared/components/molecules/modules/data/models/license_model.dart new file mode 100644 index 00000000..1bbf5d3f --- /dev/null +++ b/lib/shared/components/molecules/modules/data/models/license_model.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'module_model.dart'; + +part 'license_model.freezed.dart'; +part 'license_model.g.dart'; + +@freezed +class LicenseModel with _$LicenseModel { + const factory LicenseModel({ + required List modules, + }) = _LicenseModel; + + factory LicenseModel.fromJson(Map json) => _$LicenseModelFromJson(json); +} diff --git a/lib/shared/components/molecules/modules/data/models/license_model.freezed.dart b/lib/shared/components/molecules/modules/data/models/license_model.freezed.dart new file mode 100644 index 00000000..8481cf6f --- /dev/null +++ b/lib/shared/components/molecules/modules/data/models/license_model.freezed.dart @@ -0,0 +1,172 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'license_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +LicenseModel _$LicenseModelFromJson(Map json) { + return _LicenseModel.fromJson(json); +} + +/// @nodoc +mixin _$LicenseModel { + List get modules => throw _privateConstructorUsedError; + + /// Serializes this LicenseModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of LicenseModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $LicenseModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LicenseModelCopyWith<$Res> { + factory $LicenseModelCopyWith( + LicenseModel value, $Res Function(LicenseModel) then) = + _$LicenseModelCopyWithImpl<$Res, LicenseModel>; + @useResult + $Res call({List modules}); +} + +/// @nodoc +class _$LicenseModelCopyWithImpl<$Res, $Val extends LicenseModel> + implements $LicenseModelCopyWith<$Res> { + _$LicenseModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of LicenseModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? modules = null, + }) { + return _then(_value.copyWith( + modules: null == modules + ? _value.modules + : modules // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$LicenseModelImplCopyWith<$Res> + implements $LicenseModelCopyWith<$Res> { + factory _$$LicenseModelImplCopyWith( + _$LicenseModelImpl value, $Res Function(_$LicenseModelImpl) then) = + __$$LicenseModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({List modules}); +} + +/// @nodoc +class __$$LicenseModelImplCopyWithImpl<$Res> + extends _$LicenseModelCopyWithImpl<$Res, _$LicenseModelImpl> + implements _$$LicenseModelImplCopyWith<$Res> { + __$$LicenseModelImplCopyWithImpl( + _$LicenseModelImpl _value, $Res Function(_$LicenseModelImpl) _then) + : super(_value, _then); + + /// Create a copy of LicenseModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? modules = null, + }) { + return _then(_$LicenseModelImpl( + modules: null == modules + ? _value._modules + : modules // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$LicenseModelImpl implements _LicenseModel { + const _$LicenseModelImpl({required final List modules}) + : _modules = modules; + + factory _$LicenseModelImpl.fromJson(Map json) => + _$$LicenseModelImplFromJson(json); + + final List _modules; + @override + List get modules { + if (_modules is EqualUnmodifiableListView) return _modules; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_modules); + } + + @override + String toString() { + return 'LicenseModel(modules: $modules)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LicenseModelImpl && + const DeepCollectionEquality().equals(other._modules, _modules)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_modules)); + + /// Create a copy of LicenseModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$LicenseModelImplCopyWith<_$LicenseModelImpl> get copyWith => + __$$LicenseModelImplCopyWithImpl<_$LicenseModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$LicenseModelImplToJson( + this, + ); + } +} + +abstract class _LicenseModel implements LicenseModel { + const factory _LicenseModel({required final List modules}) = + _$LicenseModelImpl; + + factory _LicenseModel.fromJson(Map json) = + _$LicenseModelImpl.fromJson; + + @override + List get modules; + + /// Create a copy of LicenseModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$LicenseModelImplCopyWith<_$LicenseModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/shared/components/molecules/modules/data/models/license_model.g.dart b/lib/shared/components/molecules/modules/data/models/license_model.g.dart new file mode 100644 index 00000000..2689837b --- /dev/null +++ b/lib/shared/components/molecules/modules/data/models/license_model.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'license_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$LicenseModelImpl _$$LicenseModelImplFromJson(Map json) => + _$LicenseModelImpl( + modules: (json['modules'] as List) + .map((e) => ModuleModel.fromJson(e as Map)) + .toList(), + ); + +Map _$$LicenseModelImplToJson(_$LicenseModelImpl instance) => + { + 'modules': instance.modules, + }; diff --git a/lib/shared/components/molecules/modules/data/models/module_model.dart b/lib/shared/components/molecules/modules/data/models/module_model.dart new file mode 100644 index 00000000..c45efffe --- /dev/null +++ b/lib/shared/components/molecules/modules/data/models/module_model.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'module_model.freezed.dart'; +part 'module_model.g.dart'; + +@freezed +class ModuleModel with _$ModuleModel { + const factory ModuleModel({ + required String key, + required String display, + required String expirationDate, + required String startDate, + required int quantity, + }) = _ModuleModel; + + factory ModuleModel.fromJson(Map json) => _$ModuleModelFromJson(json); +} diff --git a/lib/shared/components/molecules/modules/data/models/module_model.freezed.dart b/lib/shared/components/molecules/modules/data/models/module_model.freezed.dart new file mode 100644 index 00000000..5b26bcdb --- /dev/null +++ b/lib/shared/components/molecules/modules/data/models/module_model.freezed.dart @@ -0,0 +1,252 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'module_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +ModuleModel _$ModuleModelFromJson(Map json) { + return _ModuleModel.fromJson(json); +} + +/// @nodoc +mixin _$ModuleModel { + String get key => throw _privateConstructorUsedError; + String get display => throw _privateConstructorUsedError; + String get expirationDate => throw _privateConstructorUsedError; + String get startDate => throw _privateConstructorUsedError; + int get quantity => throw _privateConstructorUsedError; + + /// Serializes this ModuleModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of ModuleModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ModuleModelCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ModuleModelCopyWith<$Res> { + factory $ModuleModelCopyWith( + ModuleModel value, $Res Function(ModuleModel) then) = + _$ModuleModelCopyWithImpl<$Res, ModuleModel>; + @useResult + $Res call( + {String key, + String display, + String expirationDate, + String startDate, + int quantity}); +} + +/// @nodoc +class _$ModuleModelCopyWithImpl<$Res, $Val extends ModuleModel> + implements $ModuleModelCopyWith<$Res> { + _$ModuleModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of ModuleModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? display = null, + Object? expirationDate = null, + Object? startDate = null, + Object? quantity = null, + }) { + return _then(_value.copyWith( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + display: null == display + ? _value.display + : display // ignore: cast_nullable_to_non_nullable + as String, + expirationDate: null == expirationDate + ? _value.expirationDate + : expirationDate // ignore: cast_nullable_to_non_nullable + as String, + startDate: null == startDate + ? _value.startDate + : startDate // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ModuleModelImplCopyWith<$Res> + implements $ModuleModelCopyWith<$Res> { + factory _$$ModuleModelImplCopyWith( + _$ModuleModelImpl value, $Res Function(_$ModuleModelImpl) then) = + __$$ModuleModelImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String key, + String display, + String expirationDate, + String startDate, + int quantity}); +} + +/// @nodoc +class __$$ModuleModelImplCopyWithImpl<$Res> + extends _$ModuleModelCopyWithImpl<$Res, _$ModuleModelImpl> + implements _$$ModuleModelImplCopyWith<$Res> { + __$$ModuleModelImplCopyWithImpl( + _$ModuleModelImpl _value, $Res Function(_$ModuleModelImpl) _then) + : super(_value, _then); + + /// Create a copy of ModuleModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? display = null, + Object? expirationDate = null, + Object? startDate = null, + Object? quantity = null, + }) { + return _then(_$ModuleModelImpl( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as String, + display: null == display + ? _value.display + : display // ignore: cast_nullable_to_non_nullable + as String, + expirationDate: null == expirationDate + ? _value.expirationDate + : expirationDate // ignore: cast_nullable_to_non_nullable + as String, + startDate: null == startDate + ? _value.startDate + : startDate // ignore: cast_nullable_to_non_nullable + as String, + quantity: null == quantity + ? _value.quantity + : quantity // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ModuleModelImpl implements _ModuleModel { + const _$ModuleModelImpl( + {required this.key, + required this.display, + required this.expirationDate, + required this.startDate, + required this.quantity}); + + factory _$ModuleModelImpl.fromJson(Map json) => + _$$ModuleModelImplFromJson(json); + + @override + final String key; + @override + final String display; + @override + final String expirationDate; + @override + final String startDate; + @override + final int quantity; + + @override + String toString() { + return 'ModuleModel(key: $key, display: $display, expirationDate: $expirationDate, startDate: $startDate, quantity: $quantity)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ModuleModelImpl && + (identical(other.key, key) || other.key == key) && + (identical(other.display, display) || other.display == display) && + (identical(other.expirationDate, expirationDate) || + other.expirationDate == expirationDate) && + (identical(other.startDate, startDate) || + other.startDate == startDate) && + (identical(other.quantity, quantity) || + other.quantity == quantity)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, key, display, expirationDate, startDate, quantity); + + /// Create a copy of ModuleModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ModuleModelImplCopyWith<_$ModuleModelImpl> get copyWith => + __$$ModuleModelImplCopyWithImpl<_$ModuleModelImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ModuleModelImplToJson( + this, + ); + } +} + +abstract class _ModuleModel implements ModuleModel { + const factory _ModuleModel( + {required final String key, + required final String display, + required final String expirationDate, + required final String startDate, + required final int quantity}) = _$ModuleModelImpl; + + factory _ModuleModel.fromJson(Map json) = + _$ModuleModelImpl.fromJson; + + @override + String get key; + @override + String get display; + @override + String get expirationDate; + @override + String get startDate; + @override + int get quantity; + + /// Create a copy of ModuleModel + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ModuleModelImplCopyWith<_$ModuleModelImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/shared/components/molecules/modules/data/models/module_model.g.dart b/lib/shared/components/molecules/modules/data/models/module_model.g.dart new file mode 100644 index 00000000..b2ab688f --- /dev/null +++ b/lib/shared/components/molecules/modules/data/models/module_model.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'module_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ModuleModelImpl _$$ModuleModelImplFromJson(Map json) => + _$ModuleModelImpl( + key: json['key'] as String, + display: json['display'] as String, + expirationDate: json['expirationDate'] as String, + startDate: json['startDate'] as String, + quantity: (json['quantity'] as num).toInt(), + ); + +Map _$$ModuleModelImplToJson(_$ModuleModelImpl instance) => + { + 'key': instance.key, + 'display': instance.display, + 'expirationDate': instance.expirationDate, + 'startDate': instance.startDate, + 'quantity': instance.quantity, + }; diff --git a/lib/shared/components/molecules/modules/data/repositories/index.dart b/lib/shared/components/molecules/modules/data/repositories/index.dart new file mode 100644 index 00000000..8474837b --- /dev/null +++ b/lib/shared/components/molecules/modules/data/repositories/index.dart @@ -0,0 +1 @@ +export 'license_repository_impl.dart'; 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 new file mode 100644 index 00000000..1ef3589a --- /dev/null +++ b/lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart @@ -0,0 +1,50 @@ +import 'dart:developer'; + +import 'package:hub/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart'; +import 'package:hub/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart'; +import 'package:hub/shared/components/molecules/modules/domain/respositories/license_repository.dart'; +import 'package:hub/shared/helpers/database/database_helper.dart'; +import 'package:sqflite/sqflite.dart'; + +typedef LicenseStatus = bool; + +class LicenseRepositoryImpl implements LicenseRepository { + final LicenseLocalDataSource localDataSource = LicenseLocalDataSourceImpl(); + final LicenseRemoteDataSource remoteDataSource = LicenseRemoteDataSourceImpl(); + final Database database = DatabaseStorage.database; + + LicenseRepositoryImpl(); + + + + @override + Future updateLicense() async { + log('updateLicense'); + bool result = false; + final bool isNewVersion = await localDataSource.isNewVersion(); + result = await remoteDataSource.setupLicense(database, isNewVersion); + if (isNewVersion) { + result = await remoteDataSource.fetchLicenses(isNewVersion); + } + + + return result; + + } + + @override + Future cleanLicense() async { + return await remoteDataSource.cleanLicense(); + } + + @override + Future getLicense(String key) async { + final response = await localDataSource.get(key); + return response; + } + + @override + Future setLicense(String key, T value) async { + return await localDataSource.set(key, value); + } +} diff --git a/lib/shared/components/molecules/modules/domain/entities/base_module.dart b/lib/shared/components/molecules/modules/domain/entities/base_module.dart new file mode 100644 index 00000000..ef2c82a8 --- /dev/null +++ b/lib/shared/components/molecules/modules/domain/entities/base_module.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; + + + +abstract class BaseModule { + String get key; + String get name; + IconData get icon; + String get route; +} diff --git a/lib/shared/components/molecules/modules/domain/entities/index.dart b/lib/shared/components/molecules/modules/domain/entities/index.dart new file mode 100644 index 00000000..957da76e --- /dev/null +++ b/lib/shared/components/molecules/modules/domain/entities/index.dart @@ -0,0 +1,4 @@ +export 'base_module.dart'; + +export 'license.dart'; +export 'module.dart'; diff --git a/lib/shared/components/molecules/modules/domain/entities/license.dart b/lib/shared/components/molecules/modules/domain/entities/license.dart new file mode 100644 index 00000000..d643e322 --- /dev/null +++ b/lib/shared/components/molecules/modules/domain/entities/license.dart @@ -0,0 +1,238 @@ + + +import 'package:hub/shared/extensions/string_extensions.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('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-PREST'), + deliverySchedule('FRE-HUB-AGE-PROV-DELIVERY'), + property('FRE-HUB-ABOUT-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); +} + + + + +class License { + final List modules; + + const License( + this.modules, + ); + + + static Future _processWithoutModule(LicenseKeys key) async { + switch(key) { + case LicenseKeys.reservations: + return await _precessWpp(); + case LicenseKeys.orders: + return await _precessWpp(); + case LicenseKeys.fastPass: + return await _precessWpp(); + case LicenseKeys.providerSchedule: + return await _processProvisional(); + case LicenseKeys.deliverySchedule: + return await _processProvisional(); + case LicenseKeys.pets: + return await _processPets(); + case LicenseKeys.petsHistory: + return await _processPets(); + default: + return ModuleStatus.active.key; + } + } + + static Future _precessWpp() async { + 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().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().get(KeychainStorageKey.pets.value).then((v) => v.toBoolean()); + if (pets) return ModuleStatus.active.key; + else return ModuleStatus.inactive.key; + } + + static getKeyByModule(String s) { + + } + + /// Returns a [License] object with the modules and their status. + /// @param isNewVersion: Indica que é sistema novo que possui modularização. + static Future getLicense(bool isNewVersionWithModule) async { + return License([ + Module( + key: LicenseKeys.messages.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.liberations.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.reservations.value, + display: await _processWithoutModule(LicenseKeys.reservations), + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.access.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.openedVisits.value, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.vehicles.value, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.residents.value, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.pets.value, + display: await _processWithoutModule(LicenseKeys.pets), + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.orders.value, + display: await _processWithoutModule(LicenseKeys.orders), + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.completeSchedule.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.providerSchedule.value, + display: await _processWithoutModule(LicenseKeys.providerSchedule), + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.deliverySchedule.value, + display: await _processWithoutModule(LicenseKeys.deliverySchedule), + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.fastPass.value, + display: await _processWithoutModule(LicenseKeys.fastPass), + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.qrCode.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.visitors.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.property.value, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.people.value, + display: isNewVersionWithModule ? ModuleStatus.inactive.key : ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.petsHistory.value, + display: await _processWithoutModule(LicenseKeys.pets), + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.settings.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.logout.value, + display: ModuleStatus.active.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + + ]); + } +} + diff --git a/lib/shared/components/molecules/modules/domain/entities/module.dart b/lib/shared/components/molecules/modules/domain/entities/module.dart new file mode 100644 index 00000000..7dc2e8c2 --- /dev/null +++ b/lib/shared/components/molecules/modules/domain/entities/module.dart @@ -0,0 +1,82 @@ +import 'package:hub/shared/components/molecules/modules/data/models/module_model.dart'; + + +enum ModuleStatus { active, inactive, disabled } + +enum EnumDisplay { + active('VISIVEL'), + inactive('INVISIVEL'), + expired('DESABILITADO'); + + final String value; + const EnumDisplay(this.value); + + static EnumDisplay fromString(String? value) { + if (value == null) return EnumDisplay.inactive; + switch (value) { + case 'VISIVEL': + return EnumDisplay.active; + case 'INVISIVEL': + return EnumDisplay.inactive; + case 'DESABILITADO': + return EnumDisplay.expired; + default: + return EnumDisplay.inactive; + } + } +} + + +extension ModuleStatusExtension on ModuleStatus { + String get key { + switch (this) { + case ModuleStatus.active: + return 'VISIVEL'; + case ModuleStatus.inactive: + return 'INVISIVEL'; + case ModuleStatus.disabled: + return 'DESABILITADO'; + } + } +} + + +class Module { + final String key; + final String display; + final String expirationDate; + final String startDate; + final int quantity; + + + Module({ + required this.key, + required this.display, + required this.expirationDate, + required this.startDate, + required this.quantity, + + }); + + factory Module.fromModel(ModuleModel model) { + return Module( + key: model.key, + display: model.display, + expirationDate: model.expirationDate, + startDate: model.startDate, + quantity: model.quantity, + ); + } + + ModuleModel toModel() { + return ModuleModel( + key: key, + display: display, + expirationDate: expirationDate, + startDate: startDate, + quantity: quantity, + ); + } + + +} diff --git a/lib/shared/components/molecules/modules/domain/index.dart b/lib/shared/components/molecules/modules/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/shared/components/molecules/modules/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/shared/components/molecules/modules/domain/respositories/index.dart b/lib/shared/components/molecules/modules/domain/respositories/index.dart new file mode 100644 index 00000000..7f6be535 --- /dev/null +++ b/lib/shared/components/molecules/modules/domain/respositories/index.dart @@ -0,0 +1 @@ +export 'license_repository.dart'; diff --git a/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart b/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart new file mode 100644 index 00000000..732e7baf --- /dev/null +++ b/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart @@ -0,0 +1,7 @@ +abstract class LicenseRepository { + Future updateLicense(); + Future cleanLicense(); + + Future getLicense(String key); + Future setLicense(String key, T value); +} diff --git a/lib/shared/components/molecules/modules/domain/usecases/index.dart b/lib/shared/components/molecules/modules/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/modules/index.dart b/lib/shared/components/molecules/modules/index.dart new file mode 100644 index 00000000..385ad97a --- /dev/null +++ b/lib/shared/components/molecules/modules/index.dart @@ -0,0 +1,4 @@ +export 'data/index.dart'; +export 'domain/index.dart'; +export 'presentation/index.dart'; +export 'constants/index.dart'; \ No newline at end of file diff --git a/lib/shared/components/molecules/modules/presentation/blocs/index.dart b/lib/shared/components/molecules/modules/presentation/blocs/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/modules/presentation/index.dart b/lib/shared/components/molecules/modules/presentation/index.dart new file mode 100644 index 00000000..688818c6 --- /dev/null +++ b/lib/shared/components/molecules/modules/presentation/index.dart @@ -0,0 +1,2 @@ +export 'blocs/index.dart'; +export 'widgets/index.dart'; diff --git a/lib/shared/components/molecules/modules/presentation/widgets/index.dart b/lib/shared/components/molecules/modules/presentation/widgets/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/constants/index.dart b/lib/shared/constants/index.dart new file mode 100644 index 00000000..a810e4ce --- /dev/null +++ b/lib/shared/constants/index.dart @@ -0,0 +1 @@ +export 'keychain_constants.dart'; diff --git a/lib/shared/constants/keychain_constants.dart b/lib/shared/constants/keychain_constants.dart new file mode 100644 index 00000000..0aac6594 --- /dev/null +++ b/lib/shared/constants/keychain_constants.dart @@ -0,0 +1,13 @@ + const String tableKeychain = 'keychain'; + + String get createKeychainTable => ''' + CREATE TABLE IF NOT EXISTS $tableKeychain ( + key TEXT UNIQUE, + value TEXT, + type TEXT, + updateAt TEXT, + resolvedAt TEXT, + createdAt TEXT + ); + '''; + String get deleteKeychainTable => 'DROP TABLE IF EXISTS $tableKeychain;'; \ No newline at end of file diff --git a/lib/shared/extensions/string_extensions.dart b/lib/shared/extensions/string_extensions.dart new file mode 100644 index 00000000..20fa5f75 --- /dev/null +++ b/lib/shared/extensions/string_extensions.dart @@ -0,0 +1,12 @@ +extension StringNullableExtensions on String? { + bool toBoolean() { + if (this == null) return false; + return this!.toLowerCase() == 'true'; + } +} + +extension StringExtensions on String { + bool toBoolean() { + return this.toLowerCase() == 'true'; + } +} diff --git a/lib/shared/helpers/database/database_helper.dart b/lib/shared/helpers/database/database_helper.dart new file mode 100644 index 00000000..1fe11f02 --- /dev/null +++ b/lib/shared/helpers/database/database_helper.dart @@ -0,0 +1,95 @@ +import 'package:hub/shared/components/molecules/modules/index.dart'; +import 'package:hub/shared/constants/index.dart'; +import 'package:hub/shared/helpers/storage/keychain_storage.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:path/path.dart'; +import 'dart:developer'; + +class DatabaseStorage { + static const String _dbName = 'database.db'; + static const int _dbVersion = 2; + + static final DatabaseStorage instance = DatabaseStorage._internal(); + factory DatabaseStorage() => instance; + DatabaseStorage._internal(); + + static Database? _database; + static Database get database { + if (_database == null) { + throw Exception('Database has not been initialized. Call init() first.'); + } + return _database!; + } + + static bool isInitialized = false; + + Future init() async { + if (isInitialized) return; + + _database = await openDatabase( + join(await getDatabasesPath(), _dbName), + version: _dbVersion, + onCreate: _onCreate, + onUpgrade: _onUpgrade, + onDowngrade: _onDowngrade, + onOpen: _onOpen, + onConfigure: _onConfigure, + ); + await LicenseRepositoryImpl().updateLicense(); + isInitialized = true; + } + + Future _onConfigure(Database database) async { + print('Configuring database...'); + } + + Future _onOpen(Database database) async { + print('Opening database...'); + await _executePragmas(database); + } + + Future _onCreate(Database database, int version) async { + print('Creating database...'); + await _createTables(database, version); + } + + Future _onUpgrade(Database database, int oldVersion, int newVersion) async { + print('Upgrading database from version $oldVersion to $newVersion...'); + if (oldVersion < 2 && newVersion >= 2) { + await _createTables(database, newVersion); + } + } + + Future _onDowngrade(Database database, int oldVersion, int newVersion) async { + print('Downgrading database from version $oldVersion to $newVersion...'); + if (oldVersion >= 2 && newVersion < 2) { + await _dropTables(database); + } + } + + Future _executePragmas(Database database) async { + // await database.execute('PRAGMA journal_mode = WAL;'); + // await database.execute('PRAGMA synchronous = NORMAL;'); + // await database.execute('PRAGMA temp_store = MEMORY;'); + // await database.execute('PRAGMA foreign_keys = ON;'); + } + + Future _createTables(Database database, int version) async { + await database.execute(createKeychainTable); + await database.execute(LicenseConstants.createLicenseTable); + if (version >= 2) { + await database.execute(LicenseConstants.updatePetsHistoryTrigger); + await database.execute(LicenseConstants.updateDisplayTrigger); + await database.execute(LicenseConstants.insertDisplayTrigger); + await database.execute(LicenseConstants.updatePeopleDisplayTrigger); + } + } + + Future _dropTables(Database database) async { + await database.execute(LicenseConstants.deleteLicenseTable); + await database.execute(LicenseConstants.dropPeopleDisplayTrigger); + await database.execute(LicenseConstants.dropInsertDisplayTrigger); + await database.execute(LicenseConstants.dropUpdateDisplayTrigger); + await database.execute(LicenseConstants.dropPetsHistoryTrigger); + } +} diff --git a/lib/shared/helpers/secure_storage.dart b/lib/shared/helpers/secure_storage.dart deleted file mode 100644 index b1ac5cf0..00000000 --- a/lib/shared/helpers/secure_storage.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; - -class SecureStorage implements BaseStorage { - SecureStorage._(); - - static final SecureStorage instance = SecureStorage._(); - - late final FlutterSecureStorage _secureStorage; - - @override - Future init() async { - _secureStorage = const FlutterSecureStorage(); - } - - @override - Future get(String key) async { - return await _secureStorage.read(key: key); - } - - @override - Future set(String key, String value) async { - await _secureStorage.write(key: key, value: value); - } - - @override - Future delete(String key) async { - await _secureStorage.delete(key: key); - } - - @override - Future clearAll() async { - await _secureStorage.deleteAll(); - } -} diff --git a/lib/shared/helpers/sqlite_storage.dart b/lib/shared/helpers/sqlite_storage.dart deleted file mode 100644 index 774a9afe..00000000 --- a/lib/shared/helpers/sqlite_storage.dart +++ /dev/null @@ -1,104 +0,0 @@ -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:sqflite/sqflite.dart'; -import 'package:sqflite/sqlite_api.dart'; -import 'package:path/path.dart'; - -class SQLiteStorage implements BaseStorage { - SQLiteStorage._(); - - static final String _dbName = 'database.db'; - static final int _dbVersion = 1; - - static const String tableKeychain = 'keychain'; - - static final SQLiteStorage instance = SQLiteStorage._(); - - late final _database; - - @override - Future init() async { - _database = await openDatabase( - join(await getDatabasesPath(), _dbName), - version: _dbVersion, - onCreate: _onCreate, - onUpgrade: _onUpdate, - onDowngrade: _onDowngrade, - ); - // await _onInitLocalVariables(_database); - } - - _onCreate(Database database, int version) async { - await database.execute(_tableKeychain); - } - - _onUpdate(Database database, int oldVersion, int newVersion) async {} - _onDowngrade(Database database, int oldVersion, int newVersion) async {} - - String get _tableKeychain => ''' - CREATE TABLE keychain ( - key TEXT UNIQUE, - value TEXT, - type TEXT, - updateAt TEXT, - resolvedAt TEXT, - createdAt TEXT - ); - '''; - - List> get _localVariables => [ - {'key': SQLiteStorageKey.devUUID.value, 'value': '', 'type': 'user'}, - {'key': SQLiteStorageKey.userUUID.value, 'value': '', 'type': 'user'}, - {'key': SQLiteStorageKey.userDevUUID.value, 'value': '', 'type': 'user'}, - {'key': SQLiteStorageKey.status.value, 'value': '', 'type': 'user'}, - {'key': SQLiteStorageKey.userName.value, 'value': '', 'type': 'user'}, - {'key': SQLiteStorageKey.clientUUID.value, 'value': '', 'type': 'local'}, - {'key': SQLiteStorageKey.ownerUUID.value, 'value': '', 'type': 'local'}, - {'key': SQLiteStorageKey.clientName.value, 'value': '', 'type': 'local'}, - {'key': SQLiteStorageKey.whatsapp.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.provisional.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.pets.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.local.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.notify.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.fingerprint.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.access.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.panic.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.person.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.requestOSNotification.value, 'value': 'false', 'type': 'util'}, - {'key': SQLiteStorageKey.petAmount.value, 'value': '', 'type': 'local'}, - ]; - - @override - Future get(String key) async { - var response = await _database.query('keychain', where: 'key = ?', whereArgs: [key]); - if (response.isEmpty) { - return null; - } - return response.first['value']; - } - - @override - Future set(String key, String value) async { - var date = DateTime.now().toIso8601String(); - await _database.insert( - tableKeychain, - { - 'key': key, - 'value': value, - 'type': 'local', - 'updateAt': date, - 'resolvedAt': date, - 'createdAt': date, - }, - conflictAlgorithm: ConflictAlgorithm.replace); - } - - @override - Future delete(String key) async { - await _database.delete('keychain', where: 'key = ?', whereArgs: [key]); - } - - @override - Future clearAll() async { - await _database.delete('keychain'); - } -} diff --git a/lib/shared/helpers/base_storage.dart b/lib/shared/helpers/storage/base_storage.dart similarity index 66% rename from lib/shared/helpers/base_storage.dart rename to lib/shared/helpers/storage/base_storage.dart index 11bc2509..27892246 100644 --- a/lib/shared/helpers/base_storage.dart +++ b/lib/shared/helpers/storage/base_storage.dart @@ -1,7 +1,7 @@ abstract class BaseStorage { Future init(); - Future set(String key, String value); + Future set(String key, T value); Future get(String key); @@ -11,9 +11,9 @@ abstract class BaseStorage { } enum Storage { - SecureStorage, - SharedPreferences, - SQLiteStorage, + secureStorage, + sharedPreferences, + databaseStorage, } enum SharedPreferencesKey { @@ -73,13 +73,15 @@ extension SecureStorageKeyExtension on SecureStorageKey { } } -enum SQLiteStorageKey { +enum KeychainStorageKey { devUUID, userUUID, userDevUUID, status, userName, + userEmail, clientUUID, + ownerName, ownerUUID, clientName, petAmount, @@ -93,49 +95,56 @@ enum SQLiteStorageKey { panic, person, requestOSNotification, + isNewVersion, } -extension SQLIteStorageKeyExtension on SQLiteStorageKey { +extension KeychainStorageKeyExtension on KeychainStorageKey { String get value { switch (this) { - case SQLiteStorageKey.devUUID: + case KeychainStorageKey.userEmail: + return 'fre_userEmail'; + case KeychainStorageKey.devUUID: return 'fre_devUUID'; - case SQLiteStorageKey.userUUID: + case KeychainStorageKey.userUUID: return 'fre_userUUID'; - case SQLiteStorageKey.userDevUUID: + case KeychainStorageKey.userDevUUID: return 'fre_userDevUUID'; - case SQLiteStorageKey.status: + case KeychainStorageKey.status: return 'fre_status'; - case SQLiteStorageKey.userName: + case KeychainStorageKey.userName: return 'fre_userName'; - case SQLiteStorageKey.clientUUID: + case KeychainStorageKey.clientUUID: return 'fre_cliUUID'; - case SQLiteStorageKey.ownerUUID: + case KeychainStorageKey.ownerUUID: return 'fre_ownerUUID'; - case SQLiteStorageKey.clientName: + case KeychainStorageKey.clientName: return 'fre_cliName'; - case SQLiteStorageKey.petAmount: + case KeychainStorageKey.ownerName: + return 'fre_ownerName'; + case KeychainStorageKey.petAmount: return 'fre_petAmountRegister'; - case SQLiteStorageKey.whatsapp: + case KeychainStorageKey.whatsapp: return 'fre_whatsapp'; - case SQLiteStorageKey.provisional: + case KeychainStorageKey.provisional: return 'fre_provisional'; - case SQLiteStorageKey.pets: + case KeychainStorageKey.pets: return 'fre_pets'; - case SQLiteStorageKey.local: + case KeychainStorageKey.local: return 'fre_local'; - case SQLiteStorageKey.notify: + case KeychainStorageKey.notify: return 'fre_notify'; - case SQLiteStorageKey.fingerprint: + case KeychainStorageKey.fingerprint: return 'fre_fingerprint'; - case SQLiteStorageKey.access: + case KeychainStorageKey.access: return 'fre_access'; - case SQLiteStorageKey.panic: + case KeychainStorageKey.panic: return 'fre_panic'; - case SQLiteStorageKey.person: + case KeychainStorageKey.person: return 'fre_person'; - case SQLiteStorageKey.requestOSNotification: + case KeychainStorageKey.requestOSNotification: return 'fre_requestOSnotification'; + case KeychainStorageKey.isNewVersion: + return 'fre_isNewVersion'; default: return ''; } diff --git a/lib/shared/helpers/storage/keychain_storage.dart b/lib/shared/helpers/storage/keychain_storage.dart new file mode 100644 index 00000000..b86cb7f9 --- /dev/null +++ b/lib/shared/helpers/storage/keychain_storage.dart @@ -0,0 +1,70 @@ +import 'dart:developer'; + +import 'package:hub/shared/constants/index.dart'; +import 'package:hub/shared/helpers/database/database_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:sqflite/sqflite.dart'; + +class KeychainHelper implements BaseStorage { + KeychainHelper._(); + + static final KeychainHelper instance = KeychainHelper._(); + + bool _isInitialized = false; + + + + @override + Future init() async { + if (_isInitialized) return; + await DatabaseStorage.instance.init(); + _isInitialized = true; + } + + @override + Future get(String key) async { + + var response = await DatabaseStorage.database.query(tableKeychain, where: 'key = ?', whereArgs: [key]); + if (response.isEmpty) { + return null; + } + // log('() => get keychain: $key : ${response.first['value']}'); + return response.first['value'].toString(); + } + + @override + Future set(String key, T value) async { + + var date = DateTime.now().toIso8601String(); + await DatabaseStorage.database.insert( + tableKeychain, + { + 'key': key, + 'value': value.toString(), + 'type': 'local', + 'updateAt': date, + 'resolvedAt': date, + 'createdAt': date, + }, + conflictAlgorithm: ConflictAlgorithm.replace); + // log('() => set keychain: $key : $value'); + } + + @override + Future delete(String key) async { + await DatabaseStorage.database.delete(tableKeychain, where: 'key = ?', whereArgs: [key]); + } + + @override + Future clearAll() async { + try { + await DatabaseStorage.database.delete(tableKeychain); + + + } catch (e, s) { + log('() => clearAll keychain: $e', stackTrace: s); + } + } + + +} diff --git a/lib/shared/helpers/storage/secure_storage.dart b/lib/shared/helpers/storage/secure_storage.dart new file mode 100644 index 00000000..e1138229 --- /dev/null +++ b/lib/shared/helpers/storage/secure_storage.dart @@ -0,0 +1,54 @@ +import 'dart:developer'; + +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; + +class SecureStorage implements BaseStorage { + SecureStorage._(); + + static final SecureStorage instance = SecureStorage._(); + + late final FlutterSecureStorage _secureStorage; + bool _isInitialized = false; + + @override + Future init() async { + if (_isInitialized) return; + _secureStorage = const FlutterSecureStorage(); + _isInitialized = true; + } + + @override + Future get(String key) async { + return await _secureStorage.read(key: key); + } + + @override + Future set(String key, T value) async { + log('Setting value: $value'); + try { + await _secureStorage.write(key: key, value: value.toString()); + } catch (e, s) { + log('Error setting value: $e', stackTrace: s); + } + } + + @override + Future delete(String key) async { + await _secureStorage.delete(key: key); + } + + @override + Future clearAll() async { + log('Clearing SecureStorage'); + try{ + await _secureStorage.deleteAll( + aOptions: AndroidOptions(), + iOptions: IOSOptions(), + ); + } catch (e, s) { + log('Error clearing all: $e', stackTrace: s); + } + + } +} diff --git a/lib/shared/helpers/shared_preferences_storage.dart b/lib/shared/helpers/storage/shared_preferences_storage.dart similarity index 71% rename from lib/shared/helpers/shared_preferences_storage.dart rename to lib/shared/helpers/storage/shared_preferences_storage.dart index e419a570..a2561e2a 100644 --- a/lib/shared/helpers/shared_preferences_storage.dart +++ b/lib/shared/helpers/storage/shared_preferences_storage.dart @@ -1,4 +1,4 @@ -import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SharedPreferencesStorage implements BaseStorage { @@ -7,10 +7,13 @@ class SharedPreferencesStorage implements BaseStorage { static final SharedPreferencesStorage instance = SharedPreferencesStorage._(); late final SharedPreferences _prefs; + bool _isInitialized = false; @override Future init() async { + if (_isInitialized) return; _prefs = await SharedPreferences.getInstance(); + _isInitialized = true; } @override @@ -19,8 +22,8 @@ class SharedPreferencesStorage implements BaseStorage { } @override - Future set(String key, String value) async { - await _prefs.setString(key, value); + Future set(String key, T value) async { + await _prefs.setString(key, value.toString()); } @override diff --git a/lib/shared/helpers/storage/storage_helper.dart b/lib/shared/helpers/storage/storage_helper.dart new file mode 100644 index 00000000..c157698f --- /dev/null +++ b/lib/shared/helpers/storage/storage_helper.dart @@ -0,0 +1,72 @@ +import 'dart:developer'; + +import 'package:flutter/cupertino.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/keychain_storage.dart'; +import 'package:hub/shared/helpers/storage/secure_storage.dart'; +import 'package:hub/shared/helpers/storage/shared_preferences_storage.dart'; + +class StorageHelper { + static final StorageHelper _instance = StorageHelper._internal(); + factory StorageHelper() => _instance; + StorageHelper._internal(); + + late BuildContext? _context; + BuildContext? get context => _context; + set context(BuildContext? context) => _context = context; + + late bool _isRecovered = false; + bool get isRecovered => _isRecovered; + set isRecovered(bool isRecovered) => _isRecovered = isRecovered; + + Future init() async { + await SecureStorage.instance.init(); + await SharedPreferencesStorage.instance.init(); + await KeychainHelper.instance.init(); + + String? isFirstRun = await SharedPreferencesStorage.instance.get(SharedPreferencesKey.isFirstRun.value); + + if (isFirstRun != 'false') { + log('First run'); + await SharedPreferencesStorage.instance.set(SharedPreferencesKey.isFirstRun.value, false); + await SecureStorage.instance.set(SecureStorageKey.isLogged.value, false); + } + } + + static BaseStorage getInstance(Storage storage) { + switch (storage) { + case Storage.secureStorage: + return SecureStorage.instance; + case Storage.sharedPreferences: + return SharedPreferencesStorage.instance; + default: + return KeychainHelper.instance; + } + } + + static BaseStorage getInstanceByKey(String key) { + if (SecureStorageKey.values.map((e) => e.value).toList().contains(key)) { + return SecureStorage.instance; + } else if (SharedPreferencesKey.values.map((e) => e.value).toList().contains(key)) { + return SharedPreferencesStorage.instance; + } else { + return KeychainHelper.instance; + } + } + + Future get(String key) async { + return await getInstanceByKey(key).get(key); + } + + Future set(String key, T value) async { + return await getInstanceByKey(key).set(key, value); + } + + Future del(String key) async { + return await getInstanceByKey(key).delete(key); + } + + Future clean(Storage storage) async { + return await getInstance(storage).clearAll(); + } +} diff --git a/lib/shared/helpers/storage_helper.dart b/lib/shared/helpers/storage_helper.dart deleted file mode 100644 index a7aa9e84..00000000 --- a/lib/shared/helpers/storage_helper.dart +++ /dev/null @@ -1,77 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/secure_storage.dart'; -import 'package:hub/shared/helpers/shared_preferences_storage.dart'; -import 'package:hub/shared/helpers/sqlite_storage.dart'; - -class StorageHelper { - static final StorageHelper _instance = StorageHelper._internal(); - factory StorageHelper() => _instance; - StorageHelper._internal(); - - late BuildContext? _context; - - BuildContext? get context => _context; - set context(BuildContext? context) => _context = context; - - late bool _isRecovered = false; - bool get isRecovered => _isRecovered; - set isRecovered(bool isRecovered) => _isRecovered = isRecovered; - - Future init() async { - await SecureStorage.instance.init(); - await SharedPreferencesStorage.instance.init(); - await SQLiteStorage.instance.init(); - - String? isFirstRun = await SharedPreferencesStorage.instance.get(SharedPreferencesKey.isFirstRun.value); - - if (isFirstRun != 'false') { - await SharedPreferencesStorage.instance.set(SharedPreferencesKey.isFirstRun.value, 'false'); - await SecureStorage.instance.set(SecureStorageKey.isLogged.value, 'false'); - } - } - - Future get(String key, Storage storage) { - switch (storage) { - case Storage.SecureStorage: - return SecureStorage.instance.get(key); - case Storage.SharedPreferences: - return SharedPreferencesStorage.instance.get(key); - case Storage.SQLiteStorage: - return SQLiteStorage.instance.get(key); - } - } - - Future set(String key, String value, Storage storage) { - switch (storage) { - case Storage.SecureStorage: - return SecureStorage.instance.set(key, value); - case Storage.SharedPreferences: - return SharedPreferencesStorage.instance.set(key, value); - case Storage.SQLiteStorage: - return SQLiteStorage.instance.set(key, value); - } - } - - Future delete(String key, Storage storage) { - switch (storage) { - case Storage.SecureStorage: - return SecureStorage.instance.delete(key); - case Storage.SharedPreferences: - return SharedPreferencesStorage.instance.delete(key); - case Storage.SQLiteStorage: - return SQLiteStorage.instance.delete(key); - } - } - - Future clearAll(Storage storage) { - switch (storage) { - case Storage.SecureStorage: - return SecureStorage.instance.clearAll(); - case Storage.SharedPreferences: - return SharedPreferencesStorage.instance.clearAll(); - case Storage.SQLiteStorage: - return SQLiteStorage.instance.clearAll(); - } - } -} diff --git a/lib/shared/index.dart b/lib/shared/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/services/authentication/authentication_service.dart b/lib/shared/services/authentication/authentication_service.dart index dea0c7de..522382bc 100644 --- a/lib/shared/services/authentication/authentication_service.dart +++ b/lib/shared/services/authentication/authentication_service.dart @@ -1,37 +1,50 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/features/home/presentation/pages/home_page.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/components/molecules/modules/data/repositories/license_repository_impl.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 'package:hub/shared/utils/snackbar_util.dart'; import '../../../backend/api_requests/api_calls.dart'; import '../../../flutter_flow/flutter_flow_util.dart'; import '../../../flutter_flow/random_data_util.dart'; +import '../../components/molecules/locals/data/index.dart'; +import '../../components/molecules/locals/index.dart'; +import '../../components/molecules/menu/index.dart'; import '../../utils/device_util.dart'; import '../../utils/dialog_util.dart'; import '../../utils/log_util.dart'; class AuthenticationService { static Future login(BuildContext context) async { - final GetLocalsCall callback = PhpGroup.getLocalsCall; + try { + final GetLocalsCall callback = PhpGroup.getLocalsCall; + final response = await callback.call(); - final response = await callback.call(); + if (response.jsonBody['error']) { + await DialogUtil.errorDefault(context); + return; + } - if (response.jsonBody['error']) { + List locals = response.jsonBody['locais'] ?? []; + + if (locals.isEmpty) { + await StorageHelper().set(SecureStorageKey.haveLocal.value, false); + context.go('/receptionPage'); + } else { + await StorageHelper().set(SecureStorageKey.isLogged.value, true); + context.go('/homePage', extra: {'update': LocalsRepositoryImpl().update}); + } + } catch (e, s) { await DialogUtil.errorDefault(context); - return; + LogUtil.requestAPIFailed('getLocals.php', '', "Get Locals", e, s); } - List locals = response.jsonBody['locais'] ?? []; - - if (locals.isEmpty) { - await StorageHelper().set(SecureStorageKey.haveLocal.value, 'false', Storage.SecureStorage); - context.go('/receptionPage'); - } else { - await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); - context.go('/homePage'); - } - - await StorageHelper().set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage); } static Future signIn( @@ -44,7 +57,7 @@ class AuthenticationService { final ApiCallResponse? response; final LoginCall callback = PhpGroup.loginCall; String deviceDescription = randomString(10, 10, true, false, false); - await StorageHelper().set(SecureStorageKey.deviceDescription.value, deviceDescription, Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.deviceDescription.value, deviceDescription); final String? devUUID; final String userUUID; @@ -59,9 +72,9 @@ class AuthenticationService { devUUID = await DeviceUtil.getDevUUID(); if ((email != '') && (passwd != '')) { - await StorageHelper().set(SecureStorageKey.email.value, email, Storage.SecureStorage); - await StorageHelper().set(SecureStorageKey.password.value, passwd, Storage.SecureStorage); - await StorageHelper().set(SQLiteStorageKey.devUUID.value, devUUID!, Storage.SQLiteStorage); + 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) { @@ -70,10 +83,10 @@ class AuthenticationService { userDevUUID = response.jsonBody['user']['dev_id']; userName = response.jsonBody['user']['name']; - await StorageHelper().set(SQLiteStorageKey.userUUID.value, userUUID, Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.userDevUUID.value, userDevUUID, Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.status.value, status, Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.userName.value, userName, Storage.SQLiteStorage); + 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 { @@ -81,7 +94,6 @@ class AuthenticationService { await DialogUtil.errorDefault(context); } else { await DialogUtil.error(context, response.jsonBody['error_msg'].toString()); - await DialogUtil.error(context, response.jsonBody['error_msg'].toString()); } } } @@ -137,8 +149,13 @@ class AuthenticationService { alignment: Alignment.bottomCenter, ), }; - await StorageHelper().clearAll(Storage.SecureStorage); - await StorageHelper().clearAll(Storage.SQLiteStorage); + + await StorageHelper().clean(Storage.databaseStorage); + await StorageHelper().clean(Storage.secureStorage); + await LicenseRepositoryImpl().cleanLicense(); + DatabaseStorage.isInitialized = false; + await StorageHelper().init(); + context.go('/welcomePage', extra: extra); } @@ -193,21 +210,13 @@ class AuthenticationService { String content; try { await PhpGroup.deleteAccount.call().then((value) async { - final Map extra = { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }; if (value.jsonBody['error'] == false) { content = FFLocalizations.of(context).getVariableText( enText: 'Account deleted successfully', ptText: 'Conta deletada com sucesso', ); - await StorageHelper().clearAll(Storage.SecureStorage); - context.pop(); - context.go('/welcomePage', extra: extra); + return await signOut(context); + } }).catchError((err) { context.pop(); @@ -215,7 +224,8 @@ class AuthenticationService { enText: 'Error deleting account', ptText: 'Erro ao deletar conta', ); - SnackBarUtil.showSnackBar(context, content); + SnackBarUtil.showSnackBar(context, content); + return; }); } catch (err) { context.pop(); @@ -224,6 +234,7 @@ class AuthenticationService { ptText: 'Erro ao deletar conta', ); SnackBarUtil.showSnackBar(context, content, isError: true); + return; } } } diff --git a/lib/shared/services/deeplink/deep_link_service.dart b/lib/shared/services/deeplink/deep_link_service.dart index 76715219..5df6ff67 100644 --- a/lib/shared/services/deeplink/deep_link_service.dart +++ b/lib/shared/services/deeplink/deep_link_service.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; class DeepLinkService { static final DeepLinkService _instance = DeepLinkService._internal(); @@ -49,7 +49,6 @@ class DeepLinkService { } } catch (e, s) { print('Error handling deep link: $e, $s'); - log('Error handling', error: e, stackTrace: s); } } @@ -57,14 +56,13 @@ class DeepLinkService { try { WidgetsBinding.instance.addPostFrameCallback((_) async { await showModalBottomSheet( - context: key.currentContext!, + context: navigatorKey.currentContext!, builder: (context) => Padding( padding: MediaQuery.viewInsetsOf(context), child: ForgotPasswordScreen(email: email, token: token), ), isScrollControlled: true, - backgroundColor: - FlutterFlowTheme.of(key.currentContext!).primaryBackground, + backgroundColor: FlutterFlowTheme.of(navigatorKey.currentContext!).primaryBackground, showDragHandle: true, useSafeArea: true, enableDrag: true, @@ -75,7 +73,6 @@ class DeepLinkService { }); } catch (e, s) { print('Error showing forgot password screen: $e, $s'); - log('Error handling', error: e, stackTrace: s); } } diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart deleted file mode 100644 index e1319084..00000000 --- a/lib/shared/services/localization/localization_service.dart +++ /dev/null @@ -1,343 +0,0 @@ -// ignore_for_file: curly_braces_in_flow_control_structures, use_build_context_synchronously, unrelated_type_equality_checks - -import 'dart:developer'; - -import 'package:flutter/material.dart'; -import 'package:http/src/response.dart'; -import 'package:hub/backend/api_requests/api_manager.dart'; -import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; -import 'package:hub/shared/utils/device_util.dart'; -import 'package:hub/shared/utils/dialog_util.dart'; - -import '../../../backend/api_requests/api_calls.dart'; -import '../../../components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; -import '../../../flutter_flow/flutter_flow_util.dart'; -import '../../utils/log_util.dart'; -import '../../utils/snackbar_util.dart'; -import '../authentication/authentication_service.dart'; - -class LocalizationService { - static Future checkLocals(BuildContext context) async { - try { - final GetLocalsCall callback = PhpGroup.getLocalsCall; - var response = await callback.call(); - final bool? isError = response.jsonBody['error']; - - if (isError == true) { - _handleError(context, response.jsonBody['error_msg']); - return; - } - if (response.jsonBody == null) { - final String errorMsg = FFLocalizations.of(context).getVariableText( - enText: 'Verify your connection', - ptText: 'Verifique sua conexão', - ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); - return; - } - - final List locals = response.jsonBody['locais'] ?? []; - final bool isEmpty = locals.isEmpty; - final bool isActive = locals.where((local) => local['CLU_STATUS'] != 'B').isNotEmpty; - final bool isEnable = !isEmpty && isActive; - - if (isEnable) { - await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); - await StorageHelper().set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage); - await WidgetsBinding.instance.endOfFrame; - await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage); - StorageHelper().context?.go('/homePage'); - } - } catch (e, s) { - log(e.toString(), stackTrace: s); - } - } - - static Future processLocals(BuildContext context) async { - try { - final GetLocalsCall callback = PhpGroup.getLocalsCall; - final ApiCallResponse response = await callback.call(); - final bool? isError = response.jsonBody['error']; - - if (isError == true) { - final String errorMsg = response.jsonBody['error_msg']; - _handleError(context, errorMsg); - return false; - } - if (response.jsonBody == null) { - final String errorMsg = FFLocalizations.of(context).getVariableText( - enText: 'Verify your connection', - ptText: 'Verifique sua conexão', - ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); - return false; - } - - final List locals = response.jsonBody['locais'].toList() ?? []; - _logLocalsStatus(locals); - - final bool isActive = _isActive(locals); - final bool isInactived = await _isInactived(locals); - final bool isPending = _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 isUnavailable = isPending && isUnselected && isUnique; - final bool isAvailable = await _isAvailable(); - - if (isDisabled) { - AuthenticationService.signOut(context); - return true; - } else if (isUnavailable) { - return await _handleUnavailable(context, locals); - } else if (isEnabled) { - return await _handleEnabled(context, locals[0]); - } else if (isUnselected) { - log('() => isUnselected'); - return await selectLocal(context, response); - } else if (isSelected) { - log('() => isSelected'); - return await processData(context); - } else if (isAvailable) { - log('() => isAvailable'); - return await processData(context); - } else { - if (!isUnique && !isActive) log('() => not unique and not active'); - if (!isUnique && isInactived) log('() => not unique and inactived'); - if (!isUnique && isPending) log('() => not unique and pending'); - if (!isUnique && isBlocked) log('() => not unique and blocked'); - log('() => else'); - return await selectLocal(context, response); - } - } catch (e, s) { - log('() => stack: $s'); - log('() => catch: $e', stackTrace: s); - // return await selectLocal(context); - final String errorMsg = FFLocalizations.of(context).getVariableText( - enText: 'Error getting locals, verify your connection', - ptText: 'Erro ao obter locais, verifique sua conexão', - ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null)); - return false; - } - } - - static Future processData(BuildContext context) async { - try { - final GetDadosCall callback = PhpGroup.getDadosCall; - ApiCallResponse? response = await callback.call(); - final bool? isError = response.jsonBody['error']; - - if (isError == true) { - final GetLocalsCall callback = PhpGroup.getLocalsCall; - response = await callback.call(); - final String errorMsg = response.jsonBody['error_msg']; - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); - return false; - } else if (response.jsonBody == null) { - final GetLocalsCall callback = PhpGroup.getLocalsCall; - response = await callback.call(); - final String errorMsg = FFLocalizations.of(context).getVariableText( - enText: 'Verify your connection', - ptText: 'Verifique sua conexão', - ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); - return false; - } else { - await _updateStorageUtil(response.jsonBody); - return true; - } - } catch (e, s) { - log('() => stack processData: $s'); - log('() => error processData: $e', stackTrace: s); - final String errorMsg = FFLocalizations.of(context).getVariableText( - enText: 'Error getting data, verify your connection', - ptText: 'Erro ao obter dados, verifique sua conexão', - ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null)); - return false; - } - } - - static Future selectLocal(BuildContext context, ApiCallResponse? response) async { - return await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, - isDismissible: false, - showDragHandle: false, - useSafeArea: true, - context: context, - builder: (context) => PopScope( - canPop: false, - child: Padding( - padding: MediaQuery.viewInsetsOf(context), - child: BottomArrowLinkedLocalsComponentWidget(response: response), - ), - ), - ).then((_) async => await processData(context)); - } - - static Future unlinkLocal(BuildContext context) async { - String content; - try { - content = FFLocalizations.of(context).getVariableText( - enText: 'Device unlinked successfully', - ptText: 'Dispositivo desvinculado com sucesso', - ); - - await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { - if (value.jsonBody['error'] == false) { - await StorageHelper().set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); - context.pop(); - context.go( - '/homePage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - SnackBarUtil.showSnackBar(context, content); - } - }).catchError((err, stack) { - context.pop(); - content = FFLocalizations.of(context).getVariableText( - enText: 'Error unlinking device', - ptText: 'Erro ao desvincular dispositivo', - ); - SnackBarUtil.showSnackBar(context, content, isError: true); - }); - } catch (err, stack) { - context.pop(); - log(err.toString(), stackTrace: stack); - content = FFLocalizations.of(context).getVariableText( - enText: 'Error unlinking device', - ptText: 'Erro ao desvincular dispositivo', - ); - SnackBarUtil.showSnackBar(context, content, isError: true); - } - } - - static void _handleError(BuildContext context, String errorMsg) async { - final String devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? ''; - final String userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? ''; - final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty; - final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); - log('() => isLinked: $errorMsg'); - 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)); - } - - static Future _handleUnavailable(BuildContext context, List locals) async { - log('() => isUnavailable'); - try { - await StorageHelper().set(SQLiteStorageKey.clientUUID.value, locals[0]['CLI_ID'], Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID'], Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.clientName.value, locals[0]['CLI_NOME'], Storage.SQLiteStorage); - var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); - if (response.jsonBody['error'] == true) { - await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage); - 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; - } - - static Future _handleEnabled(BuildContext context, dynamic local) async { - log('() => isEnabled'); - await StorageHelper().set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.userName.value, local['USU_NOME'], Storage.SQLiteStorage); - return await processData(context); - } - - static void _logLocalsStatus(List locals) { - for (var local in locals) { - final String status = local['CLU_STATUS']; - log('() => CLU_STATUS: $status'); - } - } - - 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(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - 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(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; - String ownerUUID = (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? ''; - return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty; - } - - static Future _isSelected(bool isInactived) async { - String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; - return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived; - } - - static Future _isAvailable() async { - String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; - String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; - return cliUUID.isNotEmpty && cliName.isNotEmpty; - } - - static Future _updateStorageUtil(Map jsonBody) async { - await StorageHelper().set(SQLiteStorageKey.whatsapp.value, - jsonBody['whatsapp'] != null && jsonBody['whatsapp'] ? 'true' : 'false', Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.provisional.value, - jsonBody['provisional'] != null && jsonBody['provisional'] ? 'true' : 'false', Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.pets.value, - jsonBody['pet'] != null && jsonBody['pet'] ? 'true' : 'false', Storage.SQLiteStorage); - await StorageHelper().set( - SQLiteStorageKey.petAmount.value, - jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty - ? '0' - : jsonBody['petAmountRegister'].toString(), - Storage.SQLiteStorage); - await StorageHelper().set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage); - } -} diff --git a/lib/shared/utils/loading_util.dart b/lib/shared/utils/loading_util.dart new file mode 100644 index 00000000..d30dfec3 --- /dev/null +++ b/lib/shared/utils/loading_util.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; + +class LoadingUtil { + static Widget buildLoadingIndicator(BuildContext context) { + return Center( + child: Padding( + padding: EdgeInsets.only(top: MediaQuery.of(context).size.height / 10), + child: CircularProgressIndicator( + backgroundColor: FlutterFlowTheme.of(navigatorKey.currentContext!).primaryBackground, + color: FlutterFlowTheme.of(navigatorKey.currentContext!).primary, + ), + ), + ); + } +} \ No newline at end of file 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 0922c268..e04e11bf 100644 --- a/lib/shared/utils/share_util.dart +++ b/lib/shared/utils/share_util.dart @@ -1,11 +1,11 @@ -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:share_plus/share_plus.dart'; class ShareUtil { static Future showShare(payload) async { - final cliName = await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage); - final cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage); + 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(''' diff --git a/lib/shared/widgets/menu.dart b/lib/shared/widgets/menu.dart deleted file mode 100644 index 7624f6e3..00000000 --- a/lib/shared/widgets/menu.dart +++ /dev/null @@ -1,56 +0,0 @@ -// // LinkedHashMap menu = LinkedHashMap.from({ -// "Schedule": -// [{ -// "title": "Schedule\nVisit", -// "icon": Icons.settings, -// "route": "/Schedule", -// }, -// { -// "title": "Complete\Schedule", -// "icon": Icons.calendar_today, -// "route": "/Complete", -// }, -// { -// "title": "Provisional\Schedule", -// "icon": Icons.calendar_today, -// "route": "/Provisional", -// }, -// { -// "title": "Fast\Schedule", -// "icon": Icons.calendar_today, -// "route": "/Fast", -// }], -// "Consult": -// [{ -// "title": "Consult", -// "icon": Icons.search, -// "route": "/consult", -// }, -// { -// "title": "Liberation\nConsult", -// "icon": Icons.search, -// "route": "/Liberation", -// }, -// { -// "title": "Access\nConsult", -// "icon": Icons.search, -// "route": "/Access", -// }, -// { -// "title": "Poeple\nConsult", -// "icon": Icons.search, -// "route": "/Poeple", -// }, -// { -// "title": "QR Code\nConsult", -// "icon": Icons.search, -// "route": "/qrcode", -// }], -// "Preferences": -// [{ -// "title": "Preferences", -// "icon": Icons.settings, -// "route": "/preferences", -// }], - -// }); diff --git a/pubspec.lock b/pubspec.lock index b0e34950..3dc25f42 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834 + url: "https://pub.dev" + source: hosted + version: "72.0.0" _flutterfire_internals: dependency: transitive description: @@ -9,6 +17,19 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.41" + _macros: + dependency: transitive + description: dart + source: sdk + version: "0.3.2" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139 + url: "https://pub.dev" + source: hosted + version: "6.7.0" app_links: dependency: "direct main" description: @@ -121,6 +142,70 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "79b2aef6ac2ed00046867ed354c88778c9c0f029df8a20fe10b5436826721ef9" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "028819cfb90051c6b5440c7e574d1896f8037e3c96cf17aaeb054c9311cfbf4d" + url: "https://pub.dev" + source: hosted + version: "2.4.13" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: f8126682b87a7282a339b871298cc12009cb67109cfa1614d6436fb0289193e0 + url: "https://pub.dev" + source: hosted + version: "7.3.2" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb + url: "https://pub.dev" + source: hosted + version: "8.9.2" cached_network_image: dependency: "direct main" description: @@ -145,46 +230,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" - camera: - dependency: "direct main" - description: - name: camera - sha256: "26ff41045772153f222ffffecba711a206f670f5834d40ebf5eed3811692f167" - url: "https://pub.dev" - source: hosted - version: "0.11.0+2" - camera_android_camerax: - dependency: transitive - description: - name: camera_android_camerax - sha256: e3627fdc2132d89212b8a8676679f5b07008c7e3d8ae00cea775c3397f9e742b - url: "https://pub.dev" - source: hosted - version: "0.6.10" - camera_avfoundation: - dependency: transitive - description: - name: camera_avfoundation - sha256: "2e4c568f70e406ccb87376bc06b53d2f5bebaab71e2fbcc1a950e31449381bcf" - url: "https://pub.dev" - source: hosted - version: "0.9.17+5" - camera_platform_interface: - dependency: transitive - description: - name: camera_platform_interface - sha256: b3ede1f171532e0d83111fe0980b46d17f1aa9788a07a2fbed07366bbdbb9061 - url: "https://pub.dev" - source: hosted - version: "2.8.0" - camera_web: - dependency: transitive - description: - name: camera_web - sha256: "595f28c89d1fb62d77c73c633193755b781c6d2e0ebcd8dc25b763b514e6ba8f" - url: "https://pub.dev" - source: hosted - version: "0.3.5" characters: dependency: transitive description: @@ -217,6 +262,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" + url: "https://pub.dev" + source: hosted + version: "4.10.1" collection: dependency: "direct main" description: @@ -225,30 +278,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" - connectivity_plus: - dependency: "direct main" - description: - name: connectivity_plus - sha256: "876849631b0c7dc20f8b471a2a03142841b482438e3b707955464f5ffca3e4c3" - url: "https://pub.dev" - source: hosted - version: "6.1.0" - connectivity_plus_platform_interface: + convert: dependency: transitive description: - name: connectivity_plus_platform_interface - sha256: "42657c1715d48b167930d5f34d00222ac100475f73d10162ddf43e714932f204" + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 url: "https://pub.dev" source: hosted - version: "2.0.1" - crop_your_image: - dependency: "direct main" - description: - name: crop_your_image - sha256: "9ae3b33042de5bda5321fc48aad41054c196bf2cc28350cd30cb8a85c1a7b1bd" - url: "https://pub.dev" - source: hosted - version: "1.1.0" + version: "3.1.2" cross_file: dependency: transitive description: @@ -258,7 +295,7 @@ packages: source: hosted version: "0.3.4+2" crypto: - dependency: "direct main" + dependency: transitive description: name: crypto sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" @@ -281,14 +318,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" - dbus: + dart_style: dependency: transitive description: - name: dbus - sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac" + name: dart_style + sha256: "7856d364b589d1f08986e140938578ed36ed948581fbc3bc9aef1805039ac5ab" url: "https://pub.dev" source: hosted - version: "0.7.10" + version: "2.3.7" device_info_plus: dependency: "direct main" description: @@ -305,22 +342,6 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.1" - dio: - dependency: "direct main" - description: - name: dio - sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260" - url: "https://pub.dev" - source: hosted - version: "5.7.0" - dio_web_adapter: - dependency: transitive - description: - name: dio_web_adapter - sha256: "33259a9276d6cea88774a0000cfae0d861003497755969c92faa223108620dc8" - url: "https://pub.dev" - source: hosted - version: "2.0.0" dropdown_button2: dependency: "direct main" description: @@ -341,10 +362,10 @@ packages: dependency: "direct main" description: name: equatable - sha256: b35578f687b79243d39008c44d638474d93e9091e578c970efef41ce0c3fa000 + sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7" url: "https://pub.dev" source: hosted - version: "2.0.6" + version: "2.0.7" fake_async: dependency: transitive description: @@ -381,10 +402,10 @@ packages: dependency: transitive description: name: file_selector_linux - sha256: b2b91daf8a68ecfa4a01b778a6f52edef9b14ecd506e771488ea0f2e0784198b + sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33" url: "https://pub.dev" source: hosted - version: "0.9.3+1" + version: "0.9.3+2" file_selector_macos: dependency: transitive description: @@ -445,10 +466,10 @@ packages: dependency: transitive description: name: firebase_core_platform_interface - sha256: e30da58198a6d4b49d5bce4e852f985c32cb10db329ebef9473db2b9f09ce810 + sha256: b94b217e3ad745e784960603d33d99471621ecca151c99c670869b76e50ad2a6 url: "https://pub.dev" source: hosted - version: "5.3.0" + version: "5.3.1" firebase_core_web: dependency: transitive description: @@ -514,10 +535,10 @@ packages: dependency: "direct main" description: name: flutter_animate - sha256: "7c8a6594a9252dad30cc2ef16e33270b6248c4dedc3b3d06c86c4f3f4dc05ae5" + sha256: "7befe2d3252728afb77aecaaea1dec88a89d35b9b1d2eea6d04479e8af9117b5" url: "https://pub.dev" source: hosted - version: "4.5.0" + version: "4.5.2" flutter_bloc: dependency: "direct main" description: @@ -527,21 +548,13 @@ packages: source: hosted version: "8.1.6" flutter_cache_manager: - dependency: "direct main" + dependency: transitive description: name: flutter_cache_manager sha256: "400b6592f16a4409a7f2bb929a9a7e38c72cceb8ffb99ee57bbf2cb2cecf8386" url: "https://pub.dev" source: hosted version: "3.4.1" - flutter_expandable_fab: - dependency: "direct main" - description: - name: flutter_expandable_fab - sha256: "85275279d19faf4fbe5639dc1f139b4555b150e079d056f085601a45688af12c" - url: "https://pub.dev" - source: hosted - version: "2.3.0" flutter_inappwebview: dependency: "direct main" description: @@ -562,10 +575,10 @@ packages: dependency: transitive description: name: flutter_inappwebview_internal_annotations - sha256: "5f80fd30e208ddded7dbbcd0d569e7995f9f63d45ea3f548d8dd4c0b473fb4c8" + sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" flutter_inappwebview_ios: dependency: transitive description: @@ -602,10 +615,10 @@ packages: dependency: "direct dev" description: name: flutter_launcher_icons - sha256: "619817c4b65b322b5104b6bb6dfe6cda62d9729bd7ad4303ecc8b4e690a67a77" + sha256: "31cd0885738e87c72d6f055564d37fabcdacee743b396b78c7636c169cac64f5" url: "https://pub.dev" source: hosted - version: "0.14.1" + version: "0.14.2" flutter_lints: dependency: "direct dev" description: @@ -620,7 +633,7 @@ packages: source: sdk version: "0.0.0" flutter_plugin_android_lifecycle: - dependency: "direct main" + dependency: transitive description: name: flutter_plugin_android_lifecycle sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398" @@ -711,10 +724,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "936d9c1c010d3e234d1672574636f3352b4941ca3decaddd3cafaeb9ad49c471" + sha256: "54900a1a1243f3c4a5506d853a2b5c2dbc38d5f27e52a52618a8054401431123" url: "https://pub.dev" source: hosted - version: "2.0.15" + version: "2.0.16" flutter_test: dependency: "direct dev" description: flutter @@ -741,6 +754,22 @@ packages: url: "https://pub.dev" source: hosted version: "10.8.0" + freezed: + dependency: "direct dev" + description: + name: freezed + sha256: "44c19278dd9d89292cf46e97dc0c1e52ce03275f40a97c5a348e802a924bf40e" + url: "https://pub.dev" + source: hosted + version: "2.5.7" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + url: "https://pub.dev" + source: hosted + version: "2.4.4" from_css_color: dependency: "direct main" description: @@ -749,14 +778,30 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" go_router: dependency: "direct main" description: name: go_router - sha256: "8ae664a70174163b9f65ea68dd8673e29db8f9095de7b5cd00e167c621f4fef5" + sha256: "2fd11229f59e23e967b0775df8d5948a519cd7e1e8b6e849729e010587b46539" url: "https://pub.dev" source: hosted - version: "14.6.0" + version: "14.6.2" google_fonts: dependency: "direct main" description: @@ -781,6 +826,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.12.0" + graphs: + dependency: transitive + description: + name: graphs + sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0" + url: "https://pub.dev" + source: hosted + version: "2.3.2" gtk: dependency: transitive description: @@ -797,6 +850,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" http_parser: dependency: transitive description: @@ -825,10 +886,10 @@ packages: dependency: "direct main" description: name: image_picker_android - sha256: "8faba09ba361d4b246dc0a17cb4289b3324c2b9f6db7b3d457ee69106a86bd32" + sha256: fa8141602fde3f7e2f81dbf043613eb44dfa325fa0bcf93c0f142c9f7a2c193e url: "https://pub.dev" source: hosted - version: "0.8.12+17" + version: "0.8.12+18" image_picker_for_web: dependency: "direct main" description: @@ -885,6 +946,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.19.0" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" iregexp: dependency: transitive description: @@ -917,6 +986,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.4" + json_serializable: + dependency: "direct dev" + description: + name: json_serializable + sha256: c2fcb3920cf2b6ae6845954186420fca40bc0a8abcc84903b7801f17d7050d7c + url: "https://pub.dev" + source: hosted + version: "6.9.0" leak_tracker: dependency: transitive description: @@ -997,6 +1074,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + macros: + dependency: transitive + description: + name: macros + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" + url: "https://pub.dev" + source: hosted + version: "0.1.2-main.4" matcher: dependency: transitive description: @@ -1017,10 +1102,10 @@ packages: dependency: "direct main" description: name: material_symbols_icons - sha256: "1dea2aef1c83434f832f14341a5ffa1254e76b68e4d90333f95f8a2643bf1024" + sha256: a783133f87c58e10b1cc19797f7c3192ff9c2bab301c4ade90312d8f2aed01b2 url: "https://pub.dev" source: hosted - version: "4.2799.0" + version: "4.2800.2" maybe_just_nothing: dependency: transitive description: @@ -1061,14 +1146,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" - nm: - dependency: transitive - description: - name: nm - sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254" - url: "https://pub.dev" - source: hosted - version: "0.5.0" octo_image: dependency: transitive description: @@ -1077,6 +1154,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" page_transition: dependency: "direct main" description: @@ -1113,18 +1198,18 @@ packages: dependency: "direct main" description: name: path_provider_android - sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a + sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7" url: "https://pub.dev" source: hosted - version: "2.2.12" + version: "2.2.14" path_provider_foundation: dependency: "direct main" description: name: path_provider_foundation - sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16 + sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.1" path_provider_linux: dependency: transitive description: @@ -1153,10 +1238,10 @@ packages: dependency: "direct main" description: name: percent_indicator - sha256: c37099ad833a883c9d71782321cb65c3a848c21b6939b6185f0ff6640d05814c + sha256: "0d77d5c6fa9b7f60202cedf748b568ba9ba38d3f30405d6ceae4da76f5185462" url: "https://pub.dev" source: hosted - version: "4.2.3" + version: "4.2.4" permission_handler: dependency: "direct main" description: @@ -1237,6 +1322,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" provider: dependency: "direct main" description: @@ -1245,6 +1338,22 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.2" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8 + url: "https://pub.dev" + source: hosted + version: "1.3.0" qr: dependency: transitive description: @@ -1321,10 +1430,10 @@ packages: dependency: "direct main" description: name: shared_preferences_android - sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab" + sha256: "7f172d1b06de5da47b6264c2692ee2ead20bbbc246690427cdb4fc301cd0c549" url: "https://pub.dev" source: hosted - version: "2.3.3" + version: "2.3.4" shared_preferences_foundation: dependency: "direct main" description: @@ -1365,11 +1474,43 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.1" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 + url: "https://pub.dev" + source: hosted + version: "2.0.1" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + source_helper: + dependency: transitive + description: + name: source_helper + sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd" + url: "https://pub.dev" + source: hosted + version: "1.3.4" source_span: dependency: transitive description: @@ -1498,6 +1639,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.7.0" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" typed_data: dependency: transitive description: @@ -1526,10 +1675,10 @@ packages: dependency: "direct main" description: name: url_launcher_ios - sha256: e43b677296fadce447e987a2f519dcf5f6d1e527dc35d01ffab4fff5b8a7063e + sha256: "16a513b6c12bb419304e72ea0ae2ab4fed569920d1c7cb850263fe3acc824626" url: "https://pub.dev" source: hosted - version: "6.3.1" + version: "6.3.2" url_launcher_linux: dependency: transitive description: @@ -1542,10 +1691,10 @@ packages: dependency: transitive description: name: url_launcher_macos - sha256: "769549c999acdb42b8bcfa7c43d72bf79a382ca7441ab18a808e101149daf672" + sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2" url: "https://pub.dev" source: hosted - version: "3.2.1" + version: "3.2.2" url_launcher_platform_interface: dependency: "direct main" description: @@ -1598,10 +1747,10 @@ packages: dependency: transitive description: name: vector_graphics_compiler - sha256: ab9ff38fc771e9ee1139320adbe3d18a60327370c218c60752068ebee4b49ab1 + sha256: "1b4b9e706a10294258727674a340ae0d6e64a7231980f9f9a3d12e4b42407aad" url: "https://pub.dev" source: hosted - version: "1.1.15" + version: "1.1.16" vector_math: dependency: transitive description: @@ -1618,6 +1767,14 @@ packages: url: "https://pub.dev" source: hosted version: "14.2.5" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" web: dependency: transitive description: @@ -1626,6 +1783,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83" + url: "https://pub.dev" + source: hosted + version: "0.1.6" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f" + url: "https://pub.dev" + source: hosted + version: "3.0.1" webview_flutter: dependency: "direct main" description: @@ -1654,10 +1827,10 @@ packages: dependency: transitive description: name: webview_flutter_wkwebview - sha256: "3be297aa4ca78205abdd284cf55f168c35246c75b3079990ad8ba9d257681a30" + sha256: b7e92f129482460951d96ef9a46b49db34bd2e1621685de26e9eaafd9674e7eb url: "https://pub.dev" source: hosted - version: "3.16.2" + version: "3.16.3" win32: dependency: "direct overridden" description: diff --git a/pubspec.yaml b/pubspec.yaml index 2ee3a661..9d2540c4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: rxdart: ^0.28.0 collection: 1.18.0 app_links: ^6.3.2 - crop_your_image: 1.1.0 + # crop_your_image: 1.1.0 csv: 6.0.0 device_info_plus: ^10.1.2 firebase_messaging: ^15.1.0 @@ -30,13 +30,13 @@ dependencies: easy_debounce: 2.0.3 equatable: ^2.0.6 file_picker: ^8.0.7 - flutter_expandable_fab: ^2.1.0 + # flutter_expandable_fab: ^2.1.0 firebase_analytics: ^11.3.0 - flutter_animate: 4.5.0 - flutter_cache_manager: ^3.4.1 - flutter_plugin_android_lifecycle: ^2.0.23 + flutter_animate: ^4.5.2 + # flutter_cache_manager: ^3.4.1 + # flutter_plugin_android_lifecycle: ^2.0.23 share_plus: ^10.0.0 - connectivity_plus: ^6.0.5 + # connectivity_plus: ^6.0.5 flutter_secure_storage: 9.2.2 flutter_secure_storage_linux: 1.2.1 flutter_secure_storage_macos: 3.1.2 @@ -59,14 +59,14 @@ dependencies: image_picker_platform_interface: 2.10.0 local_auth: ^2.2.0 intl: ^0.19.0 - camera: ^0.11.0+2 + # camera: ^0.11.0+2 json_path: ^0.7.4 mime_type: ^1.0.1 page_transition: 2.1.0 path_provider: ^2.1.4 path_provider_android: ^2.2.12 google_mlkit_face_detection: ^0.12.0 - path_provider_foundation: 2.4.0 + path_provider_foundation: ^2.4.1 path_provider_platform_interface: 2.1.2 percent_indicator: ^4.2.3 plugin_platform_interface: 2.1.8 @@ -99,8 +99,10 @@ dependencies: firebase_crashlytics: ^4.0.1 awesome_notifications: ^0.10.0 app_tracking_transparency: ^2.0.6 - dio: ^5.7.0 - crypto: ^3.0.5 + # dio: ^5.7.0 + # crypto: ^3.0.5 + freezed_annotation: ^2.4.4 + # json_annotation: ^4.9.0 dependency_overrides: http: 1.2.1 @@ -119,6 +121,9 @@ dev_dependencies: flutter_test: sdk: flutter + build_runner: ^2.4.13 + freezed: ^2.5.7 + json_serializable: ^6.9.0 flutter_launcher_icons: android: "launcher_icon" diff --git a/test/integration_test/app_test.dart b/test/integration_test/app_test.dart index f8ab2568..f5a03e8c 100644 --- a/test/integration_test/app_test.dart +++ b/test/integration_test/app_test.dart @@ -1,210 +1,210 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:hub/flutter_flow/random_data_util.dart'; -import 'package:hub/main.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -import 'package:hub/shared/helpers/storage_helper.dart'; -import 'package:integration_test/integration_test.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter/services.dart'; +// import 'package:flutter_test/flutter_test.dart'; +// import 'package:hub/flutter_flow/random_data_util.dart'; +// import 'package:hub/main.dart'; +// import 'package:hub/shared/helpers/storage/base_storage.dart'; +// import 'package:hub/shared/helpers/storage/storage_helper.dart'; +// import 'package:integration_test/integration_test.dart'; -late WidgetTester widget; +// late WidgetTester widget; -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); +// void main() { +// IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - group('Initialization', () { - group('Navigation', () { - setUpAll(() async => await initializeApp().then( - (_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))); - testWidgets('Test Welcome', (WidgetTester tester) async { - widget = tester; - await _testWelcome(); - }); - }); +// group('Initialization', () { +// group('Navigation', () { +// setUpAll(() async => +// await initializeApp().then((_) async => await StorageHelper().s(SecureStorageKey.isLogged.value, 'false'))); +// testWidgets('Test Welcome', (WidgetTester tester) async { +// widget = tester; +// await _testWelcome(); +// }); +// }); - group('Terms of Use', () {}); - }); - group('Authentication', () { - group('Sign in', () { - setUpAll(() async => await initializeApp().then( - (_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))); - testWidgets('Test Sign In', (WidgetTester tester) async { - widget = tester; - await _testSignIn(); - }); - }); - group('Sign up', () { - setUpAll(() async => await initializeApp().then( - (_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))); - testWidgets('Test Sign Up', (WidgetTester tester) async { - widget = tester; - await _testSignUp(); - }); - }); - group('Sign Out', () { - // Add tests for Sign Out here - }); - group('Forgot Password', () { - // setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); - // testWidgets('Test Forgot Password', (WidgetTester tester) async { - // widget = tester; - // await _testForgotPassword(); - // }); - }); - }); - group('Localization', () { - // Add tests for Localization here - }); - group('Networking', () { - // Add tests for Networking here - }); - group('Functionality', () { - // Add tests for Functionality here - }); - group('Usability', () { - // Add tests for Usability here - }); - group('Performance', () { - // Add tests for Performance here - }); - group('Security', () { - // Add tests for Security here - }); - group('Accessibility', () { - // Add tests for Accessibility here - }); - group('Compatibility', () { - // Add tests for Compatibility here - }); - group('Internationalization', () { - // Add tests for Internationalization here - }); -} +// group('Terms of Use', () {}); +// }); +// group('Authentication', () { +// group('Sign in', () { +// setUpAll(() async => +// await initializeApp().then((_) async => await StorageHelper().s(SecureStorageKey.isLogged.value, 'false'))); +// testWidgets('Test Sign In', (WidgetTester tester) async { +// widget = tester; +// await _testSignIn(); +// }); +// }); +// group('Sign up', () { +// setUpAll(() async => +// await initializeApp().then((_) async => await StorageHelper().s(SecureStorageKey.isLogged.value, 'false'))); +// testWidgets('Test Sign Up', (WidgetTester tester) async { +// widget = tester; +// await _testSignUp(); +// }); +// }); +// group('Sign Out', () { +// // Add tests for Sign Out here +// }); +// group('Forgot Password', () { +// // setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); +// // testWidgets('Test Forgot Password', (WidgetTester tester) async { +// // widget = tester; +// // await _testForgotPassword(); +// // }); +// }); +// }); +// group('Localization', () { +// // Add tests for Localization here +// }); +// group('Networking', () { +// // Add tests for Networking here +// }); +// group('Functionality', () { +// // Add tests for Functionality here +// }); +// group('Usability', () { +// // Add tests for Usability here +// }); +// group('Performance', () { +// // Add tests for Performance here +// }); +// group('Security', () { +// // Add tests for Security here +// }); +// group('Accessibility', () { +// // Add tests for Accessibility here +// }); +// group('Compatibility', () { +// // Add tests for Compatibility here +// }); +// group('Internationalization', () { +// // Add tests for Internationalization here +// }); +// } -Future _testWelcome() async { - await widget.pumpWidget(const App()); - await widget.pumpAndSettle(); - await _navigateToSignIn(); - await _navigateToSignUp(); - await widget.pumpAndSettle(); - await widget.pumpWidget(const App()); - await widget.pumpAndSettle(); - await _navigateToSignUp(); - await _navigateToSignIn(); - await widget.pumpAndSettle(); -} +// Future _testWelcome() async { +// await widget.pumpWidget(const App()); +// await widget.pumpAndSettle(); +// await _navigateToSignIn(); +// await _navigateToSignUp(); +// await widget.pumpAndSettle(); +// await widget.pumpWidget(const App()); +// await widget.pumpAndSettle(); +// await _navigateToSignUp(); +// await _navigateToSignIn(); +// await widget.pumpAndSettle(); +// } -Future _testSignIn() async { - await widget.pumpWidget(const App()); - await _navigateToSignIn(); - await _auth({'emailTextFormField': 'erro@exemplo.com', 'passwordTextFormField': '12345678'}); - await _auth({'emailTextFormField': 'email_app@exemplo.com', 'passwordTextFormField': '12345678'}); -} +// Future _testSignIn() async { +// await widget.pumpWidget(const App()); +// await _navigateToSignIn(); +// await _auth({'emailTextFormField': 'erro@exemplo.com', 'passwordTextFormField': '12345678'}); +// await _auth({'emailTextFormField': 'email_app@exemplo.com', 'passwordTextFormField': '12345678'}); +// } -Future _testSignUp() async { - await widget.pumpWidget(const App()); - await _navigateToSignUp(); +// Future _testSignUp() async { +// await widget.pumpWidget(const App()); +// await _navigateToSignUp(); - var credentials = { - 'nameTextFormField': 'app', - 'emailTextFormField': 'email_app@exemplo.com', - 'passwordTextFormField': '12345678' - }; - await _auth(credentials); +// var credentials = { +// 'nameTextFormField': 'app', +// 'emailTextFormField': 'email_app@exemplo.com', +// 'passwordTextFormField': '12345678' +// }; +// await _auth(credentials); - var name = randomString(7, 7, true, true, true); - var email = '$name@example.com'; - var password = '12345678'; - credentials = {'nameTextFormField': name, 'emailTextFormField': email, 'passwordTextFormField': password}; - await _navigateToSignUp(); - await _auth(credentials); - credentials = {'emailTextFormField': email, 'passwordTextFormField': password}; - await _auth(credentials); -} +// var name = randomString(7, 7, true, true, true); +// var email = '$name@example.com'; +// var password = '12345678'; +// credentials = {'nameTextFormField': name, 'emailTextFormField': email, 'passwordTextFormField': password}; +// await _navigateToSignUp(); +// await _auth(credentials); +// credentials = {'emailTextFormField': email, 'passwordTextFormField': password}; +// await _auth(credentials); +// } -Future _testForgotPassword() async { - await widget.pumpWidget(const App()); - await _navigateToSignIn(); - await _recoveryPassword(); +// Future _testForgotPassword() async { +// await widget.pumpWidget(const App()); +// await _navigateToSignIn(); +// await _recoveryPassword(); - var addr = randomString(5, 5, true, true, true); - var credentials = {'recoveryTextFormField': '$addr@exemple.com'}; - await _send(credentials); +// var addr = randomString(5, 5, true, true, true); +// var credentials = {'recoveryTextFormField': '$addr@exemple.com'}; +// await _send(credentials); - await Future.delayed(const Duration(seconds: 2)); +// await Future.delayed(const Duration(seconds: 2)); - await _recoveryPassword(); - credentials = {'recoveryTextFormField': 'email_app@exemple.com'}; - await _send(credentials); -} +// await _recoveryPassword(); +// credentials = {'recoveryTextFormField': 'email_app@exemple.com'}; +// await _send(credentials); +// } -Future _recoveryPassword() async { - await widget.pumpAndSettle(); - final Finder forgotPassword = find.byKey(const ValueKey('ForgotPassword')); - if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword); - await widget.ensureVisible(forgotPassword); - await widget.pumpAndSettle(); -} +// Future _recoveryPassword() async { +// await widget.pumpAndSettle(); +// final Finder forgotPassword = find.byKey(const ValueKey('ForgotPassword')); +// if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword); +// await widget.ensureVisible(forgotPassword); +// await widget.pumpAndSettle(); +// } -Future _navigateBackUsingSystemGesture() async => - IntegrationTestWidgetsFlutterBinding.instance.keyboard.isLogicalKeyPressed(LogicalKeyboardKey.escape); -Future _navigateToSignUp() async { - await widget.pumpAndSettle(); - final Finder navToSignUp = find.byKey(const ValueKey('toggleSignUpPage')); - if (navToSignUp.evaluate().isNotEmpty) { - await widget.tap(navToSignUp); - await widget.pumpAndSettle(); - } -} +// Future _navigateBackUsingSystemGesture() async => +// IntegrationTestWidgetsFlutterBinding.instance.keyboard.isLogicalKeyPressed(LogicalKeyboardKey.escape); +// Future _navigateToSignUp() async { +// await widget.pumpAndSettle(); +// final Finder navToSignUp = find.byKey(const ValueKey('toggleSignUpPage')); +// if (navToSignUp.evaluate().isNotEmpty) { +// await widget.tap(navToSignUp); +// await widget.pumpAndSettle(); +// } +// } -Future _navigateToSignIn() async { - await widget.pumpAndSettle(); - final Finder navToSignIn = find.byKey(const ValueKey('toggleSignInPage')); - expect(navToSignIn, findsOneWidget); - if (navToSignIn.evaluate().isNotEmpty) { - await widget.tap(navToSignIn); - await widget.pumpAndSettle(); - } -} +// Future _navigateToSignIn() async { +// await widget.pumpAndSettle(); +// final Finder navToSignIn = find.byKey(const ValueKey('toggleSignInPage')); +// expect(navToSignIn, findsOneWidget); +// if (navToSignIn.evaluate().isNotEmpty) { +// await widget.tap(navToSignIn); +// await widget.pumpAndSettle(); +// } +// } -Future _auth(Map credentials) async { - await _enterCredentials(credentials); - await _submit('SubmitButtonWidget'); -} +// Future _auth(Map credentials) async { +// await _enterCredentials(credentials); +// await _submit('SubmitButtonWidget'); +// } -Future _send(Map credentials) async { - await _enterCredentials(credentials); - await _submit('SendButtonWidget'); -} +// Future _send(Map credentials) async { +// await _enterCredentials(credentials); +// await _submit('SendButtonWidget'); +// } -Future _enterCredentials(Map credentials) async { - await widget.pumpAndSettle(); - for (var entry in credentials.entries) { - final Finder field = find.byKey(ValueKey(entry.key)); - await widget.pumpAndSettle(); - expect(field, findsOneWidget); - await widget.enterText(field, entry.value); - await widget.pumpAndSettle(); - } - await widget.pumpAndSettle(); -} +// Future _enterCredentials(Map credentials) async { +// await widget.pumpAndSettle(); +// for (var entry in credentials.entries) { +// final Finder field = find.byKey(ValueKey(entry.key)); +// await widget.pumpAndSettle(); +// expect(field, findsOneWidget); +// await widget.enterText(field, entry.value); +// await widget.pumpAndSettle(); +// } +// await widget.pumpAndSettle(); +// } -Future _submit(String key) async { - await widget.pumpAndSettle(); - final Finder submitButton = find.byKey(ValueKey(key)); - await widget.pumpAndSettle(); - if (submitButton.evaluate().isNotEmpty) { - await widget.tap(submitButton); - await widget.pumpAndSettle(); - } +// Future _submit(String key) async { +// await widget.pumpAndSettle(); +// final Finder submitButton = find.byKey(ValueKey(key)); +// await widget.pumpAndSettle(); +// if (submitButton.evaluate().isNotEmpty) { +// await widget.tap(submitButton); +// await widget.pumpAndSettle(); +// } - final Finder throwExceptionWidget = find.byKey(const ValueKey('ThrowExceptionWidget')); - await widget.pumpAndSettle(); - if (throwExceptionWidget.evaluate().isNotEmpty) { - await widget.ensureVisible(throwExceptionWidget); - await widget.tap(throwExceptionWidget); - await widget.pumpAndSettle(); - } else { - await _navigateBackUsingSystemGesture(); - } -} +// final Finder throwExceptionWidget = find.byKey(const ValueKey('ThrowExceptionWidget')); +// await widget.pumpAndSettle(); +// if (throwExceptionWidget.evaluate().isNotEmpty) { +// await widget.ensureVisible(throwExceptionWidget); +// await widget.tap(throwExceptionWidget); +// await widget.pumpAndSettle(); +// } else { +// await _navigateBackUsingSystemGesture(); +// } +// }