diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index bc0c68d4..1de34639 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -92,9 +92,9 @@ class TestCall { class GetLicense { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'getLicense', @@ -123,8 +123,8 @@ class GetLicense { class UnregisterDevice { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'unregisterDevice', @@ -151,9 +151,9 @@ class UnregisterDevice { class DeletePet { Future call({final int? petID = 0}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'excluirPet'; return ApiManager.instance.makeApiCall( @@ -196,9 +196,9 @@ class UpdatePet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'atualizarPet'; return ApiManager.instance.makeApiCall( @@ -242,9 +242,9 @@ class GetPets { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'consultaPets'; return ApiManager.instance.makeApiCall( @@ -276,9 +276,9 @@ class GetPetPhoto { Future call({final int? petId}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'consultaFotoPet'; return ApiManager.instance.makeApiCall( @@ -319,9 +319,9 @@ class RegisterPet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'cadastrarPet'; return ApiManager.instance.makeApiCall( @@ -364,9 +364,9 @@ class BuscaEnconcomendas { final String? adresseeType, final String? status, }) async { - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'getEncomendas'; final String baseUrl = PhpGroup.getBaseUrl(); @@ -408,9 +408,9 @@ class CancelaVisita { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'cancelaVisita'; return ApiManager.instance.makeApiCall( @@ -442,8 +442,8 @@ class CancelaVisita { class DeleteAccount { Future call() async { - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; final String baseUrl = PhpGroup.getBaseUrl(); return ApiManager.instance.makeApiCall( @@ -474,9 +474,9 @@ class ChangePanic { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'updVisitado'; return ApiManager.instance.makeApiCall( @@ -510,9 +510,9 @@ class ChangePass { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'updVisitado'; return ApiManager.instance.makeApiCall( @@ -546,9 +546,9 @@ class RespondeVinculo { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'respondeVinculo', @@ -580,9 +580,9 @@ class ChangeNotifica { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'updVisitado'; return ApiManager.instance.makeApiCall( @@ -614,10 +614,10 @@ class UpdateIDE { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - final String newIde = (await StorageHelper().g(SQLiteStorageKey.userDevUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final String newIde = (await StorageHelper().g(KeychainStorageKey.userDevUUID.value)) ?? ''; const String atividade = 'updVisitado'; return ApiManager.instance.makeApiCall( @@ -649,8 +649,8 @@ class UpdToken { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; final String token = (await StorageHelper().g(SecureStorageKey.token.value)) ?? ''; return ApiManager.instance.makeApiCall( @@ -678,7 +678,7 @@ class UpdToken { class LoginCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; final String email = (await StorageHelper().g(SecureStorageKey.email.value)) ?? ''; final String password = (await StorageHelper().g(SecureStorageKey.password.value)) ?? ''; final String type = (await StorageHelper().g(SecureStorageKey.deviceType.value)) ?? ''; @@ -765,9 +765,9 @@ class ChangePasswordCall { required final String psswd, }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'changePassword', @@ -826,8 +826,8 @@ class GetLocalsCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = await StorageHelper().g(SQLiteStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().g(SQLiteStorageKey.userUUID.value) ?? ''; + final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; + final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; return ApiManager.instance.makeApiCall( callName: 'getLocals', @@ -866,9 +866,9 @@ class PostScheduleVisitorCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'putVisitante'; return ApiManager.instance.makeApiCall( @@ -921,9 +921,9 @@ class PostScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'putVisita'; return ApiManager.instance.makeApiCall( @@ -975,9 +975,9 @@ class GetScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getVisitas'; return ApiManager.instance.makeApiCall( @@ -1249,9 +1249,9 @@ class GetDadosCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getDados'; return ApiManager.instance.makeApiCall( @@ -1482,9 +1482,9 @@ class GetVisitorByDocCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'getVisitante'; return ApiManager.instance.makeApiCall( @@ -1536,9 +1536,9 @@ class GetFotoVisitanteCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'getFotoVisitante'; return ApiManager.instance.makeApiCall( @@ -1575,9 +1575,9 @@ class PostProvVisitSchedulingCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'putAgendamentoProv'; return ApiManager.instance.makeApiCall( @@ -1624,9 +1624,9 @@ class GetVisitsCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'getVisitas'; return ApiManager.instance.makeApiCall( @@ -1887,9 +1887,9 @@ class DeleteVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + 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 = 'cancelaVisita'; return ApiManager.instance.makeApiCall( @@ -1930,10 +1930,10 @@ class GetPessoasLocalCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String ownerUUID = (await StorageHelper().g(SQLiteStorageKey.ownerUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'getPessoasLocal', @@ -1996,9 +1996,9 @@ class RespondeSolicitacaoCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'respondeSolicitacao'; return ApiManager.instance.makeApiCall( @@ -2046,9 +2046,9 @@ class GetAccessCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getAcessos'; return ApiManager.instance.makeApiCall( @@ -2295,9 +2295,9 @@ class GetLiberationsCall { final StreamController controller = StreamController(); Future.microtask(() async { - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getSolicitacoes'; try { @@ -2487,9 +2487,9 @@ class GetMessagesCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final String userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; const String atividade = 'getMensagens'; return ApiManager.instance.makeApiCall( diff --git a/lib/backend/notifications/notification_service.dart b/lib/backend/notifications/notification_service.dart index f97f7a63..b40ad38a 100644 --- a/lib/backend/notifications/notification_service.dart +++ b/lib/backend/notifications/notification_service.dart @@ -15,7 +15,7 @@ import 'package:hub/shared/utils/dialog_util.dart'; Future onMessageReceived(Map payload, String? extra, String? handleClick) async { final localId = jsonDecode(payload['local']!)['CLI_ID']; - final cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; answersRequest( {required BuildContext context, @@ -271,11 +271,11 @@ class NotificationService { await AwesomeNotifications().isNotificationAllowed().then((isAllowed) async { final bool requestOSnotification = - (await StorageHelper().g(SQLiteStorageKey.requestOSNotification.value)) == 'true'; + (await StorageHelper().g(KeychainStorageKey.requestOSNotification.value)) == 'true'; if (requestOSnotification == false) { if (isAllowed == false) { - await StorageHelper().s(SQLiteStorageKey.requestOSNotification.value, 'true'); + await StorageHelper().s(KeychainStorageKey.requestOSNotification.value, 'true'); await AwesomeNotifications().requestPermissionToSendNotifications(); } } diff --git a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart index b9a930ed..8b7c9df2 100644 --- a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart @@ -105,9 +105,9 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State _fetchResponseLink(String status, String cliID) async { try { - await StorageHelper().s(SQLiteStorageKey.clientUUID.value, cliID); + await StorageHelper().s(KeychainStorageKey.clientUUID.value, cliID); var response = await PhpGroup.resopndeVinculo.call(tarefa: status); if (response.jsonBody['error'] == false) { @@ -147,7 +147,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State getData() async { - cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; setStateCallback?.call(); } 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 index 2b47bcc0..13b497f0 100644 --- 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 @@ -97,7 +97,7 @@ class _LocalProfileComponentWidgetState extends State onUpdate()); }, child: ClipRRect( diff --git a/lib/components/organism_components/menu_component/menu_component_model.dart b/lib/components/organism_components/menu_component/menu_component_model.dart index 7b1579f8..4c58370d 100644 --- a/lib/components/organism_components/menu_component/menu_component_model.dart +++ b/lib/components/organism_components/menu_component/menu_component_model.dart @@ -60,7 +60,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openDeliverySchedule(BuildContext context) async { - final bool isProvisional = await StorageHelper().g(SQLiteStorageKey.provisional.value) == 'true'; + final bool isProvisional = await StorageHelper().g(KeychainStorageKey.provisional.value) == 'true'; if (isProvisional == true) { context.push( '/deliverySchedule', @@ -78,7 +78,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openProvisionalSchedule(BuildContext context) async { - final isProvisional = await StorageHelper().g(SQLiteStorageKey.provisional.value) == 'true'; + final isProvisional = await StorageHelper().g(KeychainStorageKey.provisional.value) == 'true'; if (isProvisional == true) { context.push( '/provisionalSchedule', @@ -96,7 +96,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openFastPassSchedule(BuildContext context) async { - final isWpp = await StorageHelper().g(SQLiteStorageKey.whatsapp.value) == 'true'; + final isWpp = await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true'; if (isWpp) { context.push( '/fastPassPage', @@ -205,7 +205,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openMyOrders(BuildContext context) async { - final isWpp = await StorageHelper().g(SQLiteStorageKey.whatsapp.value) == 'true'; + final isWpp = await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true'; ; if (isWpp) { context.push( @@ -224,7 +224,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openReservations(BuildContext context) async { - final isWpp = await StorageHelper().g(SQLiteStorageKey.whatsapp.value) == 'true'; + final isWpp = await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true'; ; if (isWpp) { context.push( @@ -341,7 +341,7 @@ class MenuComponentModel extends FlutterFlowModel { } Future openPetsRegister(BuildContext context) async { - bool isPet = await StorageHelper().g(SQLiteStorageKey.pets.value) == 'true'; + bool isPet = await StorageHelper().g(KeychainStorageKey.pets.value) == 'true'; ; if (isPet) { context.push( 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 81050e87..a8ae03e4 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 @@ -56,9 +56,9 @@ class ScheduleVisitDetailModel extends FlutterFlowModel initDB() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(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 c808f15d..211ab6ce 100644 --- a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart +++ b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart @@ -16,10 +16,10 @@ class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel initDB() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; } @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 b076651b..5e38346f 100644 --- a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart +++ b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart @@ -32,9 +32,9 @@ class AccessNotificationModalTemplateComponentModel } Future initDB() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.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 9bf42aee..b9865a35 100644 --- a/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart +++ b/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart @@ -27,9 +27,9 @@ class LiberationHistoryItemDetailsTemplateComponentModel void initState(BuildContext context) {} Future initDatabase() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(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 41a8c60e..f7366c79 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 @@ -138,12 +138,12 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel init() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; ; - cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; - ownerUUID = (await StorageHelper().g(SQLiteStorageKey.ownerUUID.value)) ?? ''; + cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; setState?.call(); } } diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart index 0aaecec6..494337f1 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart @@ -129,9 +129,9 @@ class RegisiterVistorTemplateComponentModel extends FlutterFlowModel initializeDatabase() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; ; } diff --git a/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart b/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart index ae428c74..c9153f31 100644 --- a/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart +++ b/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart @@ -37,9 +37,9 @@ class ViewVisitDetailModel extends FlutterFlowModel { } Future initializeDatabase() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(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 4c9ef4c0..aee5f3da 100644 --- a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart +++ b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart @@ -35,9 +35,9 @@ class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel initDatabase() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; ; } diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index fe46ac17..01982757 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -82,8 +82,9 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { future: () async { final bool isLogged = await StorageHelper().g(SecureStorageKey.isLogged.value) == 'true'; final bool haveLocal = await StorageHelper().g(SecureStorageKey.haveLocal.value) == 'true'; - final bool haveUserUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value))?.isNotEmpty ?? false; - final bool haveDevUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value))?.isNotEmpty ?? false; + final bool haveUserUUID = + (await StorageHelper().g(KeychainStorageKey.userUUID.value))?.isNotEmpty ?? false; + final bool haveDevUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value))?.isNotEmpty ?? false; if (isLogged && haveDevUUID && haveUserUUID) { return haveLocal ? const HomePageWidget() : const ReceptionPageWidget(); diff --git a/lib/main.dart b/lib/main.dart index b864eb60..e7d08f3c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -21,7 +21,6 @@ import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart'; import 'package:hub/shared/helpers/base_storage.dart'; import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/services/localization/localization_service.dart'; -import 'package:hub/shared/utils/device_util.dart'; import 'package:responsive_framework/responsive_framework.dart'; import 'backend/notifications/firebase_messaging_service.dart'; 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 eb2fc0c1..046011df 100644 --- a/lib/pages/acess_history_page/acess_history_page_model.dart +++ b/lib/pages/acess_history_page/acess_history_page_model.dart @@ -33,9 +33,9 @@ class AcessHistoryPageModel extends FlutterFlowModel { } Future initDatabase() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(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 fc06c01c..f5123a00 100644 --- a/lib/pages/fast_pass_page/fast_pass_page_widget.dart +++ b/lib/pages/fast_pass_page/fast_pass_page_widget.dart @@ -24,10 +24,10 @@ class _FastPassPageWidgetState extends State { Future> initVariables() async { final email = (await StorageHelper().g(hub.SecureStorageKey.email.value)) ?? ''; - final name = (await StorageHelper().g(hub.SQLiteStorageKey.userName.value)) ?? ''; - final devUUID = (await StorageHelper().g(hub.SQLiteStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(hub.SQLiteStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().g(hub.SQLiteStorageKey.clientUUID.value)) ?? ''; + final name = (await StorageHelper().g(hub.KeychainStorageKey.userName.value)) ?? ''; + final devUUID = (await StorageHelper().g(hub.KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().g(hub.KeychainStorageKey.userUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().g(hub.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/home_page/home_page_model.dart b/lib/pages/home_page/home_page_model.dart index bfa6dafa..b3032db6 100644 --- a/lib/pages/home_page/home_page_model.dart +++ b/lib/pages/home_page/home_page_model.dart @@ -24,10 +24,10 @@ class HomePageModel extends FlutterFlowModel { late MessageWellComponentModel messageWellComponentModel; Future _initVariable() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - userName = (await StorageHelper().g(SQLiteStorageKey.userName.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + userName = (await StorageHelper().g(KeychainStorageKey.userName.value)) ?? ''; userEmail = (await StorageHelper().g(SecureStorageKey.email.value)) ?? ''; } diff --git a/lib/pages/liberation_history/liberation_history_model.dart b/lib/pages/liberation_history/liberation_history_model.dart index a6296804..c7b7ea6e 100644 --- a/lib/pages/liberation_history/liberation_history_model.dart +++ b/lib/pages/liberation_history/liberation_history_model.dart @@ -36,9 +36,9 @@ class LiberationHistoryModel extends FlutterFlowModel { } Future init() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(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 bb6852d0..b51112df 100644 --- a/lib/pages/message_history_page/message_history_page_model.dart +++ b/lib/pages/message_history_page/message_history_page_model.dart @@ -39,9 +39,9 @@ class MessageHistoryPageModel extends FlutterFlowModel } Future init() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(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 b7412d3f..93394c26 100644 --- a/lib/pages/package_order_page/package_order_page.dart +++ b/lib/pages/package_order_page/package_order_page.dart @@ -64,7 +64,7 @@ class _PackageOrderPage extends State { } Future initDatabase() async { - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; } @override diff --git a/lib/pages/pets_page/pets_history_screen.dart b/lib/pages/pets_page/pets_history_screen.dart index 74249fb2..ea951820 100644 --- a/lib/pages/pets_page/pets_history_screen.dart +++ b/lib/pages/pets_page/pets_history_screen.dart @@ -229,10 +229,10 @@ class _PetsHistoryScreenState extends State with TickerProvid } ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - final cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; + final devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliName = (await StorageHelper().g(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 94bf39b9..a7d1dca7 100644 --- a/lib/pages/pets_page/pets_page_model.dart +++ b/lib/pages/pets_page/pets_page_model.dart @@ -144,10 +144,10 @@ class PetsPageModel extends FlutterFlowModel { textControllerObservation = TextEditingController(); WidgetsBinding.instance.addPostFrameCallback((_) async { - devUUID = await StorageHelper().g(SQLiteStorageKey.devUUID.value) ?? ''; - userUUID = await StorageHelper().g(SQLiteStorageKey.userUUID.value) ?? ''; - cliUUID = await StorageHelper().g(SQLiteStorageKey.clientUUID.value) ?? ''; - petAmountRegister = await StorageHelper().g(SQLiteStorageKey.petAmount.value) ?? ''; + devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; + userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; + cliUUID = await StorageHelper().g(KeychainStorageKey.clientUUID.value) ?? ''; + petAmountRegister = await StorageHelper().g(KeychainStorageKey.petAmount.value) ?? ''; }); } diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index af8623bf..f4fadd91 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -23,11 +23,11 @@ class PreferencesPageModel with ChangeNotifier { late bool isPanic = false; Future _initialize() async { - isFingerprint = await StorageHelper().g(SQLiteStorageKey.fingerprint.value) == 'true'; - isPerson = await StorageHelper().g(SQLiteStorageKey.person.value) == 'true'; - isNotify = await StorageHelper().g(SQLiteStorageKey.notify.value) == 'true'; - isAccess = await StorageHelper().g(SQLiteStorageKey.access.value) == 'true'; - isPanic = await StorageHelper().g(SQLiteStorageKey.panic.value) == 'true'; + isFingerprint = await StorageHelper().g(KeychainStorageKey.fingerprint.value) == 'true'; + isPerson = await StorageHelper().g(KeychainStorageKey.person.value) == 'true'; + isNotify = await StorageHelper().g(KeychainStorageKey.notify.value) == 'true'; + isAccess = await StorageHelper().g(KeychainStorageKey.access.value) == 'true'; + isPanic = await StorageHelper().g(KeychainStorageKey.panic.value) == 'true'; notifyListeners(); } @@ -36,7 +36,7 @@ class PreferencesPageModel with ChangeNotifier { } Future enablePerson(BuildContext context) async { - final String userDevUUID = (await StorageHelper().g(SQLiteStorageKey.userDevUUID.value)) ?? ''; + final String userDevUUID = (await StorageHelper().g(KeychainStorageKey.userDevUUID.value)) ?? ''; notifyListeners(); Share.share( FFLocalizations.of(context).getVariableText( @@ -63,7 +63,7 @@ class PreferencesPageModel with ChangeNotifier { .call(notifica: value) .then((value) async { if (value.jsonBody['error'] == false) { - await StorageHelper().s(SQLiteStorageKey.notify.value, isNotify ? 'false' : 'true'); + await StorageHelper().s(KeychainStorageKey.notify.value, isNotify ? 'false' : 'true'); content = FFLocalizations.of(context).getVariableText( enText: 'Notification changed successfully', ptText: 'Notificação alterada com sucesso', @@ -86,7 +86,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isNotify = await StorageHelper().g(SQLiteStorageKey.notify.value) == 'true') + .then((_) async => isNotify = await StorageHelper().g(KeychainStorageKey.notify.value) == 'true') .whenComplete(() => notifyListeners()); context.pop(); } @@ -141,7 +141,7 @@ class PreferencesPageModel with ChangeNotifier { .then((value) async { final String content; if (jsonDecode(value.jsonBody['error'].toString()) == false) { - await StorageHelper().s(SQLiteStorageKey.access.value, isAccess ? 'false' : 'true'); + await StorageHelper().s(KeychainStorageKey.access.value, isAccess ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Access pass changed successfully', @@ -163,7 +163,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isAccess = await StorageHelper().g(SQLiteStorageKey.access.value) == 'true') + .then((_) async => isAccess = await StorageHelper().g(KeychainStorageKey.access.value) == 'true') .whenComplete(() => notifyListeners()); } @@ -178,7 +178,7 @@ class PreferencesPageModel with ChangeNotifier { .then((value) async { final String content; if (jsonDecode(value.jsonBody['error'].toString()) == false) { - await StorageHelper().s(SQLiteStorageKey.panic.value, isPanic ? 'false' : 'true'); + await StorageHelper().s(KeychainStorageKey.panic.value, isPanic ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Panic password changed successfully', @@ -200,7 +200,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isPanic = await StorageHelper().g(SQLiteStorageKey.panic.value) == 'true') + .then((_) async => isPanic = await StorageHelper().g(KeychainStorageKey.panic.value) == 'true') .whenComplete(() => notifyListeners()); } @@ -216,10 +216,10 @@ class PreferencesPageModel with ChangeNotifier { onChange(String? key) async { isFingerprint = !isFingerprint; await StorageHelper().s(SecureStorageKey.fingerprintPass.value, key ?? ''); - await StorageHelper().s(SQLiteStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false'); + await StorageHelper().s(KeychainStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false'); notifyListeners(); SnackBarUtil.showSnackBar(context, content); - isFingerprint = await StorageHelper().g(SQLiteStorageKey.fingerprint.value) == 'true'; + isFingerprint = await StorageHelper().g(KeychainStorageKey.fingerprint.value) == 'true'; } isFingerprint ? onChange(null) : _showPassKey(context, onChange); diff --git a/lib/pages/qr_code_page/qr_code_page_model.dart b/lib/pages/qr_code_page/qr_code_page_model.dart index c2786b7b..6bd4c12b 100644 --- a/lib/pages/qr_code_page/qr_code_page_model.dart +++ b/lib/pages/qr_code_page/qr_code_page_model.dart @@ -29,8 +29,8 @@ class QrCodePageModel extends FlutterFlowModel { } Future initVariable() async { - isFingerprint = await StorageHelper().g(SQLiteStorageKey.fingerprint.value) == 'true'; - userDevUUID = await StorageHelper().g(SQLiteStorageKey.userDevUUID.value) ?? ''; + isFingerprint = await StorageHelper().g(KeychainStorageKey.fingerprint.value) == 'true'; + userDevUUID = await StorageHelper().g(KeychainStorageKey.userDevUUID.value) ?? ''; safeSetState?.call(); } diff --git a/lib/pages/reception_page/reception_page_model.dart b/lib/pages/reception_page/reception_page_model.dart index e406e8c1..bb4c4727 100644 --- a/lib/pages/reception_page/reception_page_model.dart +++ b/lib/pages/reception_page/reception_page_model.dart @@ -6,7 +6,7 @@ import 'package:share_plus/share_plus.dart'; class ReceptionPageModel with ChangeNotifier { Future getIdenfifier(BuildContext context) async { - final String userDevUUID = (await StorageHelper().g(SQLiteStorageKey.userDevUUID.value)) ?? ''; + final String userDevUUID = (await StorageHelper().g(KeychainStorageKey.userDevUUID.value)) ?? ''; notifyListeners(); Share.share( diff --git a/lib/pages/reservation_page/reservation_page_widget.dart b/lib/pages/reservation_page/reservation_page_widget.dart index 5200e03a..757293c9 100644 --- a/lib/pages/reservation_page/reservation_page_widget.dart +++ b/lib/pages/reservation_page/reservation_page_widget.dart @@ -23,10 +23,10 @@ class _ReservationPageWidgetState extends State { Future> initVariables() async { final email = (await StorageHelper().g(hub.SecureStorageKey.email.value)) ?? ''; - final name = (await StorageHelper().g(hub.SQLiteStorageKey.userName.value)) ?? ''; - final devUUID = (await StorageHelper().g(hub.SQLiteStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(hub.SQLiteStorageKey.userUUID.value)) ?? ''; - final clientId = (await StorageHelper().g(hub.SQLiteStorageKey.clientUUID.value)) ?? ''; + final name = (await StorageHelper().g(hub.KeychainStorageKey.userName.value)) ?? ''; + final devUUID = (await StorageHelper().g(hub.KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().g(hub.KeychainStorageKey.userUUID.value)) ?? ''; + final clientId = (await StorageHelper().g(hub.KeychainStorageKey.clientUUID.value)) ?? ''; const createdAt = '0000-00-00 00:00:00'; final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId'; 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 05440393..6f61ea9f 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 @@ -215,9 +215,9 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel } Future _initVariables() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(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 b95812ec..0f655b49 100644 --- a/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart @@ -35,9 +35,9 @@ class _VisitHistoryWidgetState extends State with TickerProv List _visitWrap = []; Future _initVariables() async { - devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; } @override @@ -245,10 +245,10 @@ class _VisitHistoryWidgetState extends State with TickerProv }, ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().g(SQLiteStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().g(SQLiteStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - final cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; + final devUUID = (await StorageHelper().g(KeychainStorageKey.devUUID.value)) ?? ''; + final userUUID = (await StorageHelper().g(KeychainStorageKey.userUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; await showDialog( useSafeArea: true, diff --git a/lib/shared/helpers/base_storage.dart b/lib/shared/helpers/base_storage.dart index 18712f8d..fd66d0de 100644 --- a/lib/shared/helpers/base_storage.dart +++ b/lib/shared/helpers/base_storage.dart @@ -14,8 +14,6 @@ enum Storage { secureStorage, sharedPreferences, databaseStorage, - sqliteStorage, - licenseStorage, } enum SharedPreferencesKey { @@ -75,7 +73,7 @@ extension SecureStorageKeyExtension on SecureStorageKey { } } -enum SQLiteStorageKey { +enum KeychainStorageKey { devUUID, userUUID, userDevUUID, @@ -97,46 +95,46 @@ enum SQLiteStorageKey { requestOSNotification, } -extension SQLIteStorageKeyExtension on SQLiteStorageKey { +extension KeychainStorageKeyExtension on KeychainStorageKey { String get value { switch (this) { - case SQLiteStorageKey.devUUID: + 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.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'; default: return ''; diff --git a/lib/shared/helpers/database_storage.dart b/lib/shared/helpers/database_storage.dart index ce0cec67..2a40d14e 100644 --- a/lib/shared/helpers/database_storage.dart +++ b/lib/shared/helpers/database_storage.dart @@ -1,10 +1,13 @@ +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/services/keychain/keychain_database_delegate.dart'; +import 'package:hub/shared/services/keychain/keychain_service.dart'; +import 'package:hub/shared/services/license/license_database_delegate.dart'; import 'package:hub/shared/services/license/license_service.dart'; -import 'package:hub/shared/services/sqlite/sqlite_service.dart'; import 'package:sqflite/sqflite.dart'; import 'package:path/path.dart'; import 'dart:developer'; -class DatabaseStorage { +class DatabaseStorage implements BaseStorage { static final String _dbName = 'database.db'; static final int _dbVersion = 2; @@ -15,6 +18,16 @@ class DatabaseStorage { static late final Database _database; static Database get database => _database; + static BaseStorage getInstanceByKey(String key) { + if (KeychainStorageKey.values.map((e) => e.value).toList().contains(key)) { + return KeychainDelegate.instance; + } + if (LicenseStorageKey.values.map((e) => e.value).toList().contains(key)) { + return LicenseDelegate.instance; + } + throw Exception('Storage not found'); + } + Future init() async { _database = await openDatabase( join(await getDatabasesPath(), _dbName), @@ -27,18 +40,40 @@ class DatabaseStorage { Future _onCreate(Database database, int version) async { log('Creating database...'); - await database.execute(SQLiteStorage.createTableQuery); - await database.execute(LicenseService.createTableQuery); + await database.execute(KeychainDelegate.createTableQuery); + await database.execute(LicenseDelegate.createTableQuery); await LicenseService.setupLicense(); } Future _onUpgrade(Database database, int oldVersion, int newVersion) async { log('Upgrading database from version $oldVersion to $newVersion...'); if (oldVersion < 2) { - await database.execute(LicenseService.createTableQuery); + await database.execute(LicenseDelegate.createTableQuery); await LicenseService.setupLicense(); } } Future _onDowngrade(Database database, int oldVersion, int newVersion) async {} + + @override + Future clearAll() async { + await _database.delete(KeychainDelegate.tableKeychain); + await _database.delete(LicenseDelegate.tableLicense); + return; + } + + @override + Future delete(String key) async { + return await getInstanceByKey(key).delete(key); + } + + @override + Future get(String key) async { + return await getInstanceByKey(key).get(key); + } + + @override + Future set(String key, String value) async { + return await getInstanceByKey(key).set(key, value); + } } diff --git a/lib/shared/helpers/storage_helper.dart b/lib/shared/helpers/storage_helper.dart index 7c233537..879c54a6 100644 --- a/lib/shared/helpers/storage_helper.dart +++ b/lib/shared/helpers/storage_helper.dart @@ -3,8 +3,8 @@ import 'package:hub/shared/helpers/base_storage.dart'; import 'package:hub/shared/helpers/database_storage.dart'; import 'package:hub/shared/helpers/secure_storage.dart'; import 'package:hub/shared/helpers/shared_preferences_storage.dart'; +import 'package:hub/shared/services/keychain/keychain_service.dart'; import 'package:hub/shared/services/license/license_service.dart'; -import 'package:hub/shared/services/sqlite/sqlite_service.dart'; class StorageHelper { static final StorageHelper _instance = StorageHelper._internal(); @@ -38,104 +38,34 @@ class StorageHelper { return SecureStorage.instance; case Storage.sharedPreferences: return SharedPreferencesStorage.instance; - case Storage.sqliteStorage: - return SQLiteStorage.instance; - case Storage.licenseStorage: - return LicenseService(); default: - throw Exception('Storage not found'); + return DatabaseStorage.instance; } } static BaseStorage getInstanceByKey(String key) { if (SecureStorageKey.values.map((e) => e.value).toList().contains(key)) { return SecureStorage.instance; - } - if (SharedPreferencesKey.values.map((e) => e.value).toList().contains(key)) { + } else if (SharedPreferencesKey.values.map((e) => e.value).toList().contains(key)) { return SharedPreferencesStorage.instance; + } else { + return DatabaseStorage.instance; } - if (SQLiteStorageKey.values.map((e) => e.value).toList().contains(key)) { - return SQLiteStorage.instance; - } - if (LicenseStorageKey.values.map((e) => e.value).toList().contains(key)) { - return LicenseService(); - } - throw Exception('Key not found'); } - Future g(String key) { - return getInstanceByKey(key).get(key); + Future g(String key) async { + return await getInstanceByKey(key).get(key); } - Future s(String key, String value) { - return getInstanceByKey(key).set(key, value); + Future s(String key, String value) async { + return await getInstanceByKey(key).set(key, value); } - Future d(String key) { - return getInstanceByKey(key).delete(key); + Future d(String key) async { + return await getInstanceByKey(key).delete(key); } - Future c(Storage storage) { - return getInstance(storage).clearAll(); + Future c(Storage storage) async { + return await getInstance(storage).clearAll(); } - - // 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); - // case Storage.LicenseStorage: - // return LicenseStorage.instance.get(key); - // default: - // throw Exception('Storage not found'); - // } - // } - - // 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); - // case Storage.LicenseStorage: - // return LicenseStorage.instance.set(key, value); - // default: - // throw Exception('Storage not found'); - // } - // } - - // 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); - // case Storage.LicenseStorage: - // return LicenseStorage.instance.delete(key); - // default: - // throw Exception('Storage not found'); - // } - // } - - // 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(); - // case Storage.LicenseStorage: - // return LicenseStorage.instance.clearAll(); - // default: - // throw Exception('Storage not found'); - // } - // } } diff --git a/lib/shared/services/authentication/authentication_service.dart b/lib/shared/services/authentication/authentication_service.dart index ebf94824..67da6484 100644 --- a/lib/shared/services/authentication/authentication_service.dart +++ b/lib/shared/services/authentication/authentication_service.dart @@ -61,7 +61,7 @@ class AuthenticationService { if ((email != '') && (passwd != '')) { await StorageHelper().s(SecureStorageKey.email.value, email); await StorageHelper().s(SecureStorageKey.password.value, passwd); - await StorageHelper().s(SQLiteStorageKey.devUUID.value, devUUID!); + await StorageHelper().s(KeychainStorageKey.devUUID.value, devUUID!); response = await callback.call(); if (response.jsonBody['error'] == false) { @@ -70,10 +70,10 @@ class AuthenticationService { userDevUUID = response.jsonBody['user']['dev_id']; userName = response.jsonBody['user']['name']; - await StorageHelper().s(SQLiteStorageKey.userUUID.value, userUUID); - await StorageHelper().s(SQLiteStorageKey.userDevUUID.value, userDevUUID); - await StorageHelper().s(SQLiteStorageKey.status.value, status); - await StorageHelper().s(SQLiteStorageKey.userName.value, userName); + await StorageHelper().s(KeychainStorageKey.userUUID.value, userUUID); + await StorageHelper().s(KeychainStorageKey.userDevUUID.value, userDevUUID); + await StorageHelper().s(KeychainStorageKey.status.value, status); + await StorageHelper().s(KeychainStorageKey.userName.value, userName); await login(context); } else { @@ -138,7 +138,7 @@ class AuthenticationService { ), }; await StorageHelper().c(Storage.secureStorage); - await StorageHelper().c(Storage.sqliteStorage); + await StorageHelper().c(Storage.databaseStorage); context.go('/welcomePage', extra: extra); } diff --git a/lib/shared/services/sqlite/sqlite_service.dart b/lib/shared/services/keychain/keychain_database_delegate.dart similarity index 89% rename from lib/shared/services/sqlite/sqlite_service.dart rename to lib/shared/services/keychain/keychain_database_delegate.dart index 4f17b4f7..42bb7fc3 100644 --- a/lib/shared/services/sqlite/sqlite_service.dart +++ b/lib/shared/services/keychain/keychain_database_delegate.dart @@ -1,13 +1,11 @@ -import 'dart:convert'; -import 'dart:developer'; +import 'package:hub/shared/helpers/base_storage.dart'; import 'package:hub/shared/helpers/database_storage.dart'; import 'package:sqflite/sqflite.dart'; -import 'package:hub/shared/helpers/base_storage.dart'; -class SQLiteStorage implements BaseStorage { - SQLiteStorage._(); +class KeychainDelegate implements BaseStorage { + KeychainDelegate._(); - static final SQLiteStorage instance = SQLiteStorage._(); + static final KeychainDelegate instance = KeychainDelegate._(); static const String tableKeychain = 'keychain'; diff --git a/lib/shared/services/keychain/keychain_service.dart b/lib/shared/services/keychain/keychain_service.dart new file mode 100644 index 00000000..4d14aa4d --- /dev/null +++ b/lib/shared/services/keychain/keychain_service.dart @@ -0,0 +1,11 @@ +import 'dart:convert'; +import 'dart:developer'; +import 'package:hub/shared/helpers/database_storage.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; + +class KeychainService { + static final KeychainService _instance = KeychainService._internal(); + factory KeychainService() => _instance; + KeychainService._internal(); +} diff --git a/lib/shared/services/license/license_database_delegate.dart b/lib/shared/services/license/license_database_delegate.dart new file mode 100644 index 00000000..e37e145b --- /dev/null +++ b/lib/shared/services/license/license_database_delegate.dart @@ -0,0 +1,66 @@ +import 'dart:convert'; +import 'dart:developer'; + +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/database_storage.dart'; +import 'package:sqflite/sqflite.dart'; + +class LicenseDelegate implements BaseStorage { + LicenseDelegate._(); + + static final LicenseDelegate instance = LicenseDelegate._(); + + static const String tableLicense = 'license'; + + static String get createTableQuery => ''' + CREATE TABLE $tableLicense ( + key TEXT UNIQUE, + display TEXT, + expirationDate TEXT, + startDate TEXT, + quantity TEXT + ); + '''; + + @override + Future init() async { + await DatabaseStorage.instance.init(); + } + + @override + Future get(String key) async { + var response = await DatabaseStorage.database.query(tableLicense, where: 'key = ?', whereArgs: [key]); + if (response.isEmpty) { + return null; + } + return response.first['value'].toString(); + } + + @override + Future set(String key, String value) async { + log('setLicense($key, $value)'); + Map valueMap = jsonDecode(value); + log('String to Map: $value to $valueMap'); + + await DatabaseStorage.database.insert( + tableLicense, + { + 'key': key, + 'display': valueMap['display'], + 'expirationDate': valueMap['expirationDate'], + 'startDate': valueMap['startDate'], + 'quantity': valueMap['quantity'], + }, + conflictAlgorithm: ConflictAlgorithm.replace); + } + + @override + Future delete(String key) async { + await DatabaseStorage.database.delete(tableLicense, where: 'key = ?', whereArgs: [key]); + } + + @override + Future clearAll() async { + await DatabaseStorage.database.delete(tableLicense); + } +} diff --git a/lib/shared/services/license/license_service.dart b/lib/shared/services/license/license_service.dart index 72bb5356..1dee9c9e 100644 --- a/lib/shared/services/license/license_service.dart +++ b/lib/shared/services/license/license_service.dart @@ -8,30 +8,21 @@ import 'package:hub/shared/helpers/database_storage.dart'; import 'dart:convert'; import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/services/license/license_database_delegate.dart'; import 'package:sqflite/sqflite.dart'; -class LicenseService implements BaseStorage { +class LicenseService { static final LicenseService _instance = LicenseService._internal(); factory LicenseService() => _instance; LicenseService._internal(); - static const String tableLicense = 'license'; - static String get createTableQuery => ''' - CREATE TABLE $tableLicense ( - key TEXT UNIQUE, - display TEXT, - expirationDate TEXT, - startDate TEXT, - quantity TEXT - ); - '''; static Future setupLicense() async { log('initLicense()'); for (var element in LicenseStorageKey.values.map((e) => e.value)) { await DatabaseStorage.database.insert( - tableLicense, + LicenseDelegate.tableLicense, { 'key': element, 'display': 'VISIVEL', @@ -44,47 +35,6 @@ class LicenseService implements BaseStorage { } } - @override - Future init() async { - await DatabaseStorage.instance.init(); - } - - @override - Future get(String key) async { - var response = await DatabaseStorage.database.query(tableLicense, where: 'key = ?', whereArgs: [key]); - if (response.isEmpty) { - return null; - } - return response.first['value'].toString(); - } - - @override - Future set(String key, String value) async { - log('setLicense($key, $value)'); - Map valueMap = jsonDecode(value); - log('String to Map: $value to $valueMap'); - - await DatabaseStorage.database.insert( - tableLicense, - { - 'key': key, - 'display': valueMap['display'], - 'expirationDate': valueMap['expirationDate'], - 'startDate': valueMap['startDate'], - 'quantity': valueMap['quantity'], - }, - conflictAlgorithm: ConflictAlgorithm.replace); - } - - @override - Future delete(String key) async { - await DatabaseStorage.database.delete(tableLicense, where: 'key = ?', whereArgs: [key]); - } - - @override - Future clearAll() async { - await DatabaseStorage.database.delete(tableLicense); - } static Future initLicenseService() async { // for (var element in LicenseStorageKey.values.map((e) => e.value)) { diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 124a460c..59e54cac 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -48,8 +48,8 @@ class LocalizationService { await StorageHelper().s(SecureStorageKey.haveLocal.value, 'true'); await StorageHelper().s(SecureStorageKey.isLogged.value, 'true'); await WidgetsBinding.instance.endOfFrame; - await StorageHelper().s(SQLiteStorageKey.clientUUID.value, ''); - await StorageHelper().s(SQLiteStorageKey.ownerUUID.value, ''); + await StorageHelper().s(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().s(KeychainStorageKey.ownerUUID.value, ''); StorageHelper().context?.go('/homePage'); } } catch (e, s) { @@ -195,8 +195,8 @@ class LocalizationService { await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { if (value.jsonBody['error'] == false) { - await StorageHelper().s(SQLiteStorageKey.clientName.value, ''); - await StorageHelper().s(SQLiteStorageKey.clientUUID.value, ''); + await StorageHelper().s(KeychainStorageKey.clientName.value, ''); + await StorageHelper().s(KeychainStorageKey.clientUUID.value, ''); context.pop(); context.go( '/homePage', @@ -230,8 +230,8 @@ class LocalizationService { } static void _handleError(BuildContext context, String errorMsg) async { - final String devUUID = await StorageHelper().g(SQLiteStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().g(SQLiteStorageKey.userUUID.value) ?? ''; + final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; + final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty; final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); log('() => isLinked: $errorMsg'); @@ -259,14 +259,14 @@ class LocalizationService { static Future _handleUnavailable(BuildContext context, List locals) async { log('() => isUnavailable'); try { - await StorageHelper().s(SQLiteStorageKey.clientUUID.value, locals[0]['CLI_ID']); - await StorageHelper().s(SQLiteStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']); - await StorageHelper().s(SQLiteStorageKey.clientName.value, locals[0]['CLI_NOME']); + await StorageHelper().s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']); + await StorageHelper().s(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']); + await StorageHelper().s(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']); var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); if (response.jsonBody['error'] == true) { - await StorageHelper().s(SQLiteStorageKey.clientUUID.value, ''); - await StorageHelper().s(SQLiteStorageKey.ownerUUID.value, ''); - await StorageHelper().s(SQLiteStorageKey.clientName.value, ''); + await StorageHelper().s(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().s(KeychainStorageKey.ownerUUID.value, ''); + await StorageHelper().s(KeychainStorageKey.clientName.value, ''); return false; } if (response.jsonBody['error'] == false) return await processData(context).then((value) => value); @@ -280,10 +280,10 @@ class LocalizationService { static Future _handleEnabled(BuildContext context, dynamic local) async { log('() => isEnabled'); - await StorageHelper().s(SQLiteStorageKey.clientUUID.value, local['CLI_ID']); - await StorageHelper().s(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID']); - await StorageHelper().s(SQLiteStorageKey.clientName.value, local['CLI_NOME']); - await StorageHelper().s(SQLiteStorageKey.userName.value, local['USU_NOME']); + await StorageHelper().s(KeychainStorageKey.clientUUID.value, local['CLI_ID']); + await StorageHelper().s(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']); + await StorageHelper().s(KeychainStorageKey.clientName.value, local['CLI_NOME']); + await StorageHelper().s(KeychainStorageKey.userName.value, local['USU_NOME']); return await processData(context); } @@ -296,16 +296,17 @@ class LocalizationService { static Future _updateStorageUtil(Map jsonBody) async { await StorageHelper() - .s(SQLiteStorageKey.whatsapp.value, jsonBody['whatsapp'] != null && jsonBody['whatsapp'] ? 'true' : 'false'); - await StorageHelper().s(SQLiteStorageKey.provisional.value, + .s(KeychainStorageKey.whatsapp.value, jsonBody['whatsapp'] != null && jsonBody['whatsapp'] ? 'true' : 'false'); + await StorageHelper().s(KeychainStorageKey.provisional.value, jsonBody['provisional'] != null && jsonBody['provisional'] ? 'true' : 'false'); - await StorageHelper().s(SQLiteStorageKey.pets.value, jsonBody['pet'] != null && jsonBody['pet'] ? 'true' : 'false'); + await StorageHelper() + .s(KeychainStorageKey.pets.value, jsonBody['pet'] != null && jsonBody['pet'] ? 'true' : 'false'); await StorageHelper().s( - SQLiteStorageKey.petAmount.value, + KeychainStorageKey.petAmount.value, jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString()); - await StorageHelper().s(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']); + await StorageHelper().s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']); } static bool _isActive(List locals) { @@ -313,7 +314,7 @@ class LocalizationService { } static Future _isInactived(List locals) async { - String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; + String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; } @@ -322,21 +323,21 @@ class LocalizationService { } static Future _isUnselected() async { - String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; - String ownerUUID = (await StorageHelper().g(SQLiteStorageKey.ownerUUID.value)) ?? ''; + String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + String ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty; } static Future _isSelected(bool isInactived) async { - String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; + String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived; } static Future _isAvailable() async { - String cliUUID = (await StorageHelper().g(SQLiteStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(SQLiteStorageKey.clientName.value)) ?? ''; + String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; return cliUUID.isNotEmpty && cliName.isNotEmpty; } } diff --git a/lib/shared/utils/share_util.dart b/lib/shared/utils/share_util.dart index b2313323..67a4e183 100644 --- a/lib/shared/utils/share_util.dart +++ b/lib/shared/utils/share_util.dart @@ -4,8 +4,8 @@ import 'package:share_plus/share_plus.dart'; class ShareUtil { static Future showShare(payload) async { - final cliName = await StorageHelper().g(SQLiteStorageKey.clientName.value); - final cliUUID = await StorageHelper().g(SQLiteStorageKey.clientUUID.value); + final cliName = await StorageHelper().g(KeychainStorageKey.clientName.value); + final cliUUID = await StorageHelper().g(KeychainStorageKey.clientUUID.value); for (var i = 0; i < payload['convites'].length; i++) { await Share.share('''