feat: refactory storage

This commit is contained in:
Ivan Antunes 2024-11-04 17:42:12 -03:00
parent 456398dfb2
commit a68c240c57
61 changed files with 907 additions and 1364 deletions

View File

@ -57,12 +57,12 @@ android {
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_18
targetCompatibility JavaVersion.VERSION_18
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "18"
jvmTarget = "11"
}
signingConfigs {

View File

@ -3,7 +3,8 @@ 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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:integration_test/integration_test.dart';
late WidgetTester widget;
@ -13,7 +14,9 @@ void main() {
group('Initialization', () {
group('Navigation', () {
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
setUpAll(() async => await initializeApp().then((_) async =>
StorageHelper.instance.set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))
);
testWidgets('Test Welcome', (WidgetTester tester) async {
widget = tester;
await _testWelcome();
@ -24,14 +27,18 @@ void main() {
});
group('Authentication', () {
group('Sign in', () {
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false));
setUpAll(() async => await initializeApp().then((_) async =>
StorageHelper.instance.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((_) => StorageUtil().isLogged = false));
setUpAll(() async => await initializeApp().then((_) async =>
StorageHelper.instance.set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))
);
testWidgets('Test Sign Up', (WidgetTester tester) async {
widget = tester;
await _testSignUp();

View File

@ -1 +0,0 @@

View File

@ -3,7 +3,8 @@ import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/utils/validator_util.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -56,8 +57,8 @@ class PhpGroup {
class UnregisterDevice {
Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall(
callName: 'unregisterDevice',
@ -84,9 +85,9 @@ class UnregisterDevice {
class DeletePet {
Future<ApiCallResponse> call({final int? petID = 0}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'excluirPet';
return ApiManager.instance.makeApiCall(
@ -129,9 +130,9 @@ class UpdatePet {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'atualizarPet';
return ApiManager.instance.makeApiCall(
@ -175,9 +176,9 @@ class GetPets {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'consultaPets';
return ApiManager.instance.makeApiCall(
@ -209,9 +210,9 @@ class GetPetPhoto {
Future<ApiCallResponse> call({final int? petId}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'consultaFotoPet';
return ApiManager.instance.makeApiCall(
@ -252,9 +253,9 @@ class RegisterPet {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'cadastrarPet';
return ApiManager.instance.makeApiCall(
@ -297,9 +298,9 @@ class BuscaEnconcomendas {
final String? adresseeType,
final String? status,
}) async {
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getEncomendas';
final String baseUrl = PhpGroup.getBaseUrl();
@ -341,9 +342,9 @@ class CancelaVisita {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'cancelaVisita';
return ApiManager.instance.makeApiCall(
@ -375,8 +376,8 @@ class CancelaVisita {
class DeleteAccount {
Future<ApiCallResponse> call() async {
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String baseUrl = PhpGroup.getBaseUrl();
return ApiManager.instance.makeApiCall(
@ -407,9 +408,9 @@ class ChangePanic {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'updVisitado';
return ApiManager.instance.makeApiCall(
@ -443,9 +444,9 @@ class ChangePass {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'updVisitado';
return ApiManager.instance.makeApiCall(
@ -479,9 +480,9 @@ class RespondeVinculo {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall(
callName: 'respondeVinculo',
@ -513,9 +514,9 @@ class ChangeNotifica {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'updVisitado';
return ApiManager.instance.makeApiCall(
@ -547,9 +548,9 @@ class UpdToken {
Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String token = StorageUtil().token;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String token = (await StorageHelper.instance.get(SecureStorageKey.token.value, Storage.SecureStorage)) ?? '';
return ApiManager.instance.makeApiCall(
callName: 'updToken',
@ -576,11 +577,11 @@ class UpdToken {
class LoginCall {
Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String email = StorageUtil().email;
final String password = StorageUtil().passwd;
final String type = StorageUtil().deviceType;
final String description = StorageUtil().deviceDescription;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String email = (await StorageHelper.instance.get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? '';
final String password = (await StorageHelper.instance.get(SecureStorageKey.password.value, Storage.SecureStorage)) ?? '';
final String type = (await StorageHelper.instance.get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? '';
final String description = (await StorageHelper.instance.get(SecureStorageKey.deviceDescription.value, Storage.SecureStorage)) ?? '';
final String token = await FirebaseMessagingService.getToken();
return ApiManager.instance.makeApiCall(
@ -655,9 +656,9 @@ class ChangePasswordCall {
required final String psswd,
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall(
callName: 'changePassword',
@ -716,8 +717,8 @@ class GetLocalsCall {
Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall(
callName: 'getLocals',
@ -756,9 +757,9 @@ class PostScheduleVisitorCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'putVisitante';
return ApiManager.instance.makeApiCall(
@ -811,9 +812,9 @@ class PostScheduleVisitCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'putVisita';
return ApiManager.instance.makeApiCall(
@ -865,9 +866,9 @@ class GetScheduleVisitCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliUUID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getVisitas';
return ApiManager.instance.makeApiCall(
@ -1139,9 +1140,9 @@ class GetDadosCall {
Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliUUID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getDados';
return ApiManager.instance.makeApiCall(
@ -1372,9 +1373,9 @@ class GetVisitorByDocCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getVisitante';
return ApiManager.instance.makeApiCall(
@ -1426,9 +1427,9 @@ class GetFotoVisitanteCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getFotoVisitante';
return ApiManager.instance.makeApiCall(
@ -1465,9 +1466,9 @@ class PostProvVisitSchedulingCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'putAgendamentoProv';
return ApiManager.instance.makeApiCall(
@ -1514,9 +1515,9 @@ class GetVisitsCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getVisitas';
return ApiManager.instance.makeApiCall(
@ -1777,9 +1778,9 @@ class DeleteVisitCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'cancelaVisita';
return ApiManager.instance.makeApiCall(
@ -1820,10 +1821,10 @@ class GetPessoasLocalCall {
Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String ownerUUID = StorageUtil().ownerUUID;
final String userUUID = StorageUtil().userUUID;
final String cliUUID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String ownerUUID = (await StorageHelper.instance.get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall(
callName: 'getPessoasLocal',
@ -1886,9 +1887,9 @@ class RespondeSolicitacaoCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliUUID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'respondeSolicitacao';
return ApiManager.instance.makeApiCall(
@ -1936,9 +1937,9 @@ class GetAccessCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliUUID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getAcessos';
return ApiManager.instance.makeApiCall(
@ -2185,9 +2186,9 @@ class GetLiberationsCall {
final StreamController<ApiCallResponse> controller = StreamController();
Future.microtask(() async {
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliUUID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getSolicitacoes';
try {
@ -2377,9 +2378,9 @@ class GetMessagesCall {
}) async {
final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID;
final String userUUID = StorageUtil().userUUID;
final String cliUUID = StorageUtil().cliUUID;
final String devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getMensagens';
return ApiManager.instance.makeApiCall(

View File

@ -2,8 +2,9 @@ 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/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'notification_service.dart';
@ -42,7 +43,7 @@ class FirebaseMessagingService {
final String? deviceToken = await _firebaseMessaging.getToken();
if (deviceToken != null) {
StorageUtil().token = deviceToken;
await StorageHelper.instance.set(SecureStorageKey.token.value, deviceToken, Storage.SecureStorage);
final ApiCallResponse? response;
response = await PhpGroup.updToken.call();

View File

@ -8,13 +8,15 @@ 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/utils/dialog_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
Future<void> onMessageReceived(Map<String, dynamic> payload, String? extra, String? handleClick) async {
final localId = jsonDecode(payload['local']!)['CLI_ID'];
final cliUUID = StorageUtil().cliUUID;
final cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
answersRequest(
{required BuildContext context,
required String? ref,
@ -41,7 +43,7 @@ Future<void> onMessageReceived(Map<String, dynamic> payload, String? extra, Stri
switch (handleClick) {
case 'visit_request':
showDialog(
context: StorageUtil().context!,
context: StorageHelper.instance.context!,
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (BuildContext context) {
@ -160,7 +162,7 @@ Future<void> onMessageReceived(Map<String, dynamic> payload, String? extra, Stri
break;
case 'access':
showDialog(
context: StorageUtil().context!,
context: StorageHelper.instance.context!,
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (BuildContext context) {
@ -217,7 +219,7 @@ Future<void> onMessageReceived(Map<String, dynamic> payload, String? extra, Stri
break;
case 'mensagem':
showDialog(
context: StorageUtil().context!,
context: StorageHelper.instance.context!,
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (BuildContext context) {
@ -237,8 +239,8 @@ Future<void> onMessageReceived(Map<String, dynamic> payload, String? extra, Stri
break;
case 'enroll_cond':
StorageUtil().haveLocal = true;
StorageUtil().context!.go('/homePage');
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
StorageHelper.instance.context!.go('/homePage');
break;
default:
break;
@ -268,11 +270,11 @@ class NotificationService {
debug: kDebugMode);
await AwesomeNotifications().isNotificationAllowed().then((isAllowed) async {
final bool requestOSnotification = StorageUtil().requestOSnotification;
final bool requestOSnotification = (await StorageHelper.instance.get(SQLiteStorageKey.requestOSNotification.value, Storage.SQLiteStorage)) == 'true';
if (requestOSnotification == false) {
if (isAllowed == false) {
StorageUtil().requestOSnotification = true;
await StorageHelper.instance.set(SQLiteStorageKey.requestOSNotification.value, 'true', Storage.SQLiteStorage);
await AwesomeNotifications().requestPermissionToSendNotifications();
}
}

View File

@ -2,8 +2,6 @@ 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/utils/dialog_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import '../../../shared/extensions/dialog_extensions.dart';
import '../../../shared/services/localization/localization_service.dart';

View File

@ -4,9 +4,8 @@ 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/helpers/secure_storage_helper.dart';
import 'package:hub/shared/utils/storage_util.dart';
class OrderFilterModalWidget extends StatefulWidget {
final String defaultAdresseeType;
@ -28,22 +27,22 @@ class _OrderFilterModalWidgetState extends State<OrderFilterModalWidget> {
late Map<String, dynamic> selected;
final List<Map<String, String>> adresseeTypeOptions = [
{
'title': FFLocalizations.of(StorageUtil().context!).getVariableText(enText: 'Resident', ptText: 'Morador'),
'title': FFLocalizations.of(StorageHelper.instance.context!).getVariableText(enText: 'Resident', ptText: 'Morador'),
'value': 'MOR'
},
{
'title': FFLocalizations.of(StorageUtil().context!).getVariableText(enText: 'Property', ptText: 'Propriedade'),
'title': FFLocalizations.of(StorageHelper.instance.context!).getVariableText(enText: 'Property', ptText: 'Propriedade'),
'value': 'PRO'
},
];
final List<Map<String, String>> statusOptions = [
{
'title': FFLocalizations.of(StorageUtil().context!)
'title': FFLocalizations.of(StorageHelper.instance.context!)
.getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'),
'value': 'notPickedUp'
},
{
'title': FFLocalizations.of(StorageUtil().context!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'),
'title': FFLocalizations.of(StorageHelper.instance.context!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'),
'value': 'pickedUp'
},
];

View File

@ -3,9 +3,10 @@ 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/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import '../../../shared/services/authentication/authentication_service.dart';
import '/backend/api_requests/api_calls.dart';
@ -94,9 +95,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
}
if (isEnabled) {
final local = locals[0];
StorageUtil().cliName = local['CLI_NOME'];
StorageUtil().cliUUID = local['CLI_ID'];
StorageUtil().ownerUUID = local['CLU_OWNER_ID'];
await StorageHelper.instance.set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
context.pop();
return response;
@ -123,13 +125,11 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
static void _handleError(BuildContext context, String errorMsg) {
AuthenticationService.signOut(context);
DialogUtil.error(context, errorMsg);
LogUtil.requestAPIFailed('getLocals.php', '{devUUID: ${StorageUtil().devUUID}, cliUUID: ${StorageUtil().userUUID}}',
'Get Locals', errorMsg, StackTrace.current);
}
Future<dynamic> _fetchResponseLink(String status, String cliID) async {
try {
StorageUtil().cliUUID = cliID;
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, cliID, Storage.SQLiteStorage);
var response = await PhpGroup.resopndeVinculo.call(tarefa: status);
if (response.jsonBody['error'] == false) {
@ -139,7 +139,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
.getVariableText(ptText: "Vínculo Ativado com Sucesso", enText: "Link Activated Successfully")
};
} else {
StorageUtil().cliUUID = '';
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
return response.jsonBody;
}
} catch (e, s) {
@ -187,9 +187,9 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
statusHashMap: [_statusHashMap(local)],
onTapCardItemAction: () async {
if (local['CLU_STATUS'] == 'A') {
StorageUtil().cliUUID = local['CLI_ID'];
StorageUtil().cliName = local['CLI_NOME'];
StorageUtil().ownerUUID = local['CLU_OWNER_ID'];
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
context.pop();
} else if (local['CLU_STATUS'] == 'B') {

View File

@ -1,4 +1,5 @@
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import '/flutter_flow/flutter_flow_util.dart';
import 'local_profile_component_widget.dart' show LocalProfileComponentWidget;
@ -17,8 +18,8 @@ class LocalProfileComponentModel extends FlutterFlowModel<LocalProfileComponentW
}
Future<void> getData() async {
cliName = StorageUtil().cliName;
cliUUID = StorageUtil().cliUUID;
cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';;
setStateCallback?.call();
}

View File

@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.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:hub/shared/utils/storage_util.dart';
import '../../../shared/services/localization/localization_service.dart';
import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -60,7 +60,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future openDeliverySchedule(BuildContext context) async {
final bool isProvisional = StorageUtil().provisional;
final bool isProvisional = await StorageHelper.instance.get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true';
if (isProvisional == true) {
context.push(
'/deliverySchedule',
@ -78,7 +78,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future openProvisionalSchedule(BuildContext context) async {
final isProvisional = StorageUtil().provisional;
final isProvisional = await StorageHelper.instance.get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true';
if (isProvisional == true) {
context.push(
'/provisionalSchedule',
@ -96,7 +96,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future openFastPassSchedule(BuildContext context) async {
final isWpp = StorageUtil().whatsapp;
final isWpp = await StorageHelper.instance.get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true';
if (isWpp) {
context.push(
'/fastPassPage',
@ -205,7 +205,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future openMyOrders(BuildContext context) async {
final isWpp = StorageUtil().whatsapp;
final isWpp = await StorageHelper.instance.get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true';;
if (isWpp) {
context.push(
'/packageOrder',
@ -223,7 +223,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future openReservations(BuildContext context) async {
final isWpp = StorageUtil().whatsapp;
final isWpp = await StorageHelper.instance.get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true';;
if (isWpp) {
context.push(
'/reservation',
@ -339,7 +339,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future openPetsRegister(BuildContext context) async {
bool isPet = StorageUtil().pets;
bool isPet = await StorageHelper.instance.get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == 'true';;
if (isPet) {
context.push(
'/petsPage',

View File

@ -2,9 +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';
// ignore: unused_import
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:intl/intl.dart';
class ScheduleVisitDetailModel extends FlutterFlowModel<ScheduleVisitDetailWidget> {
@ -56,9 +56,9 @@ class ScheduleVisitDetailModel extends FlutterFlowModel<ScheduleVisitDetailWidge
}
Future<void> initDB() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override

View File

@ -1,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel<UpArrowLinkedLocalsComponentWidget> {
late final String devUUID;
@ -15,10 +16,10 @@ class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel<UpArrowLinkedLo
}
Future<void> initDB() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
cliName = StorageUtil().cliName;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
}
@override

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import '/backend/api_requests/api_calls.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -31,9 +32,9 @@ class AccessNotificationModalTemplateComponentModel
}
Future<void> initDB() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override

View File

@ -3,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -27,6 +28,8 @@ class PassKeyTemplateWidget extends StatefulWidget {
class _PassKeyTemplateWidgetState extends State<PassKeyTemplateWidget> {
late PassKeyTemplateComponentModel _model;
late String _accessPass = '';
@override
void setState(VoidCallback callback) {
super.setState(callback);
@ -41,6 +44,12 @@ class _PassKeyTemplateWidgetState extends State<PassKeyTemplateWidget> {
_model.keyTextFieldTextController1 ??= TextEditingController();
_model.keyTextFieldFocusNode1 ??= FocusNode();
_model.keyTextFieldFocusNode1!.addListener(() => setState(() {}));
_initialize();
}
Future<void> _initialize() async {
_accessPass = await StorageHelper.instance.get(SecureStorageKey.accessPass.value, Storage.SecureStorage) ?? '';
}
@override
@ -124,7 +133,7 @@ class _PassKeyTemplateWidgetState extends State<PassKeyTemplateWidget> {
child: Text(
FFLocalizations.of(context).getVariableText(
enText: 'INSERT PASSWORD',
ptText: StorageUtil().accessPass != '' ? 'ALTERAR SENHA' : 'ADICIONAR SENHA',
ptText: _accessPass != '' ? 'ALTERAR SENHA' : 'ADICIONAR SENHA',
),
style: FlutterFlowTheme.of(context).headlineMedium.override(
fontFamily: 'Outfit',
@ -287,8 +296,8 @@ class _PassKeyTemplateWidgetState extends State<PassKeyTemplateWidget> {
context.pop(true);
},
text: FFLocalizations.of(context).getVariableText(
ptText: StorageUtil().accessPass != '' ? 'Alterar' : 'Adicionar',
enText: StorageUtil().accessPass != '' ? 'Change' : 'Add',
ptText: _accessPass != '' ? 'Alterar' : 'Adicionar',
enText: _accessPass != '' ? 'Change' : 'Add',
),
options: FFButtonOptions(
width: 270.0,

View File

@ -1,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class LiberationHistoryItemDetailsTemplateComponentModel
extends FlutterFlowModel<LiberationHistoryItemDetailsTemplateComponentWidget> {
@ -26,9 +27,9 @@ class LiberationHistoryItemDetailsTemplateComponentModel
void initState(BuildContext context) {}
Future<void> initDatabase() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';;
}
@override

View File

@ -2,7 +2,8 @@ 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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class ScheduleProvisionalVisitPageModel extends FlutterFlowModel<ScheduleProvisionalVisitPageWidget> {
String cliUUID = '';
@ -131,11 +132,11 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel<ScheduleProvisi
}
Future<void> init() async {
cliUUID = StorageUtil().cliUUID;
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliName = StorageUtil().cliName;
ownerUUID = StorageUtil().ownerUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';;
cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
ownerUUID = (await StorageHelper.instance.get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? '';
setState?.call();
}

View File

@ -1,5 +1,3 @@
import 'dart:developer';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:easy_debounce/easy_debounce.dart';
import 'package:flutter/material.dart';

View File

@ -1,7 +1,8 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/utils/validator_util.dart';
import '/backend/api_requests/api_calls.dart';
@ -128,9 +129,9 @@ class RegisiterVistorTemplateComponentModel extends FlutterFlowModel<RegisiterVi
}
Future<void> initializeDatabase() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';;
}
@override

View File

@ -4,7 +4,8 @@ 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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/utils/validator_util.dart';
import '/flutter_flow/flutter_flow_animations.dart';
@ -26,6 +27,7 @@ class SignUpTemplateComponentWidget extends StatefulWidget {
class _SignUpTemplateComponentWidgetState extends State<SignUpTemplateComponentWidget> with TickerProviderStateMixin {
late SignUpTemplateComponentModel _model;
final animationsMap = <String, AnimationInfo>{};
late String _deviceType;
@override
void setState(VoidCallback callback) {
@ -83,6 +85,12 @@ class _SignUpTemplateComponentWidgetState extends State<SignUpTemplateComponentW
],
),
});
_initialize();
}
Future<void> _initialize() async {
_deviceType = (await StorageHelper.instance.get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? '';
}
@override
@ -96,7 +104,6 @@ class _SignUpTemplateComponentWidgetState extends State<SignUpTemplateComponentW
Widget build(BuildContext context) {
final MediaQueryData mediaQuery = MediaQuery.of(context);
final double screenWidth = mediaQuery.size.width;
final double screenHeight = mediaQuery.size.height;
bool isFormInvalid() {
if (_model.nameRegisterFormTextController.text == '' ||
@ -486,7 +493,7 @@ class _SignUpTemplateComponentWidgetState extends State<SignUpTemplateComponentW
email: _model.emailRegisterFormTextController.text,
name: _model.nameRegisterFormTextController.text,
passwd: _model.passwordRegisterFormTextController.text,
device: StorageUtil().deviceType,
device: _deviceType,
);
shouldSetState = true;
if (_model.register == true)

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import '/backend/api_requests/api_calls.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -36,9 +37,9 @@ class ViewVisitDetailModel extends FlutterFlowModel<ViewVisitDetailWidget> {
}
Future<void> initializeDatabase() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';;
}
@override

View File

@ -2,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel<VisitorSearchModalTemplateComponentWidget> {
late final String devUUID;
@ -34,9 +35,9 @@ class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel<VisitorS
}
Future<void> initDatabase() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';;
}
@override

View File

@ -24,7 +24,6 @@ export 'dart:typed_data' show Uint8List;
export 'package:intl/intl.dart';
export 'package:page_transition/page_transition.dart';
export '/app_state.dart';
export 'custom_icons.dart' show FFIcons;
export 'flutter_flow_model.dart';
export 'internationalization.dart' show FFLocalizations;

View File

@ -12,8 +12,9 @@ import 'package:hub/pages/pets_page/pets_page_widget.dart';
import 'package:hub/pages/provisional_schedule_page/provisional_schedule_widget.dart';
import 'package:hub/pages/reception_page/reception_page_widget.dart';
import 'package:hub/pages/reservation_page/reservation_page_widget.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:provider/provider.dart';
import '../../shared/utils/dialog_util.dart';
@ -41,12 +42,18 @@ class AppStateNotifier extends ChangeNotifier {
}
}
initializeRouter() async {
final bool isLogged = await StorageHelper.instance.get(SecureStorageKey.isLogged.value, Storage.SecureStorage) == 'true';
final bool? haveLocal = await StorageHelper.instance.get(SecureStorageKey.haveLocal.value, Storage.SecureStorage) == 'true';;
final bool haveUserUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage))?.isNotEmpty ?? false;
final bool haveDevUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage))?.isNotEmpty ?? false;
}
GoRouter createRouter(AppStateNotifier appStateNotifier) {
final bool isLogged = StorageUtil().isLogged;
final bool? haveLocal = StorageUtil().haveLocal;
final bool haveUserUUID = StorageUtil().userUUID.isNotEmpty;
final bool haveDevUUID = StorageUtil().devUUID.isNotEmpty;
final bool isRecovered = StorageUtil().isRecovered;
final bool isLogged = await StorageHelper.instance.get(SecureStorageKey.isLogged.value, Storage.SecureStorage) == 'true';
final bool? haveLocal = await StorageHelper.instance.get(SecureStorageKey.haveLocal.value, Storage.SecureStorage) == 'true';;
final bool haveUserUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage))?.isNotEmpty ?? false;
final bool haveDevUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage))?.isNotEmpty ?? false;
log('() => isLogged: $isLogged');
log('() => haveLocal: $haveLocal');

View File

@ -18,10 +18,10 @@ 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/pages/forgot_password_page/forgot_password_screen.dart';
import 'package:hub/shared/helpers/shared_preferences_storage_helper.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:hub/shared/utils/storage_util.dart';
import 'package:responsive_framework/responsive_framework.dart';
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
@ -35,7 +35,7 @@ void main() async {
Future<void> initializeApp() async {
WidgetsFlutterBinding.ensureInitialized();
await _initializeTracking();
await _initializeStorageHelpers();
await StorageHelper.instance.init();
await _initializeFirebase();
await _initializeNotificationService();
@ -44,13 +44,6 @@ Future<void> initializeApp() async {
await _initializeFlutterFlow();
}
Future<void> _initializeStorageHelpers() async {
log('Initializing SharedPreferencesStorageHelper');
await SharedPreferencesStorageHelper().initialize();
log('Initializing SharedPreferencesStorageHelper');
await StorageUtil().ensureInitialization();
}
Future<void> _initializeTracking() async {
await AppTrackingTransparency.requestTrackingAuthorization();
}
@ -88,9 +81,10 @@ Future<void> _initializeFlutterFlow() async {
Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') {
StorageUtil().haveLocal = true;
StorageUtil().context?.go('/homePage');
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
StorageHelper.instance.context?.go('/homePage');
}
if (!Platform.isIOS) {
NotificationService.show(
title: message.notification!.title!,
@ -101,9 +95,8 @@ Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
Future<void> _backgroundHandlerMessage(RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') {
log('backgroundHandlerMessage');
StorageUtil().haveLocal = true;
StorageUtil().context?.go('/homePage');
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
StorageHelper.instance.context?.go('/homePage');
}
}
@ -187,23 +180,21 @@ class _AppState extends State<App> with WidgetsBindingObserver {
Future<void> initDeepLinks() async {
_appLinks = AppLinks();
_linkSubscription = _appLinks.uriLinkStream.listen((uri) {
final bool isRecovered = StorageUtil().isRecovered;
final bool isRecovered = StorageHelper.instance.isRecovered;
if (!isRecovered) openAppLink(uri);
});
}
void openAppLink(Uri uri) {
final bool isRecovered = StorageUtil().isRecovered;
final bool isRecovered = StorageHelper.instance.isRecovered;
log('isRecovered: $isRecovered');
if (isRecovered) return;
StorageUtil().isRecovered = true;
StorageHelper.instance.isRecovered = true;
final String email = uri.queryParameters['email'] ?? '';
final String token = uri.queryParameters['token'] ?? '';
final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty;
if (isNotEmpty) {
final BuildContext context = StorageUtil().context!;
final MediaQueryData mediaQuery = MediaQuery.of(context);
final double height = mediaQuery.size.height * 0.6;
final BuildContext context = StorageHelper.instance.context!;
final FlutterFlowTheme theme = FlutterFlowTheme.of(context);
final Widget screen = ForgotPasswordScreen(email: email, token: token);
builder(context) => screen;
@ -217,7 +208,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
useSafeArea: true,
enableDrag: true,
// isDismissible: true,
).whenComplete(() => StorageUtil().isRecovered = false);
).whenComplete(() => StorageHelper.instance.isRecovered = false);
}
}
@ -230,18 +221,18 @@ class _AppState extends State<App> with WidgetsBindingObserver {
}
FirebaseMessaging.onMessage.listen(_foregroundHandlerMessage);
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') {
StorageUtil().haveLocal = true;
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
log('onMessageOpenedApp');
} else {
onMessageReceived(message.data, message.notification!.body, message.data['click_action']);
}
});
FirebaseMessaging.instance.getInitialMessage().then((message) {
FirebaseMessaging.instance.getInitialMessage().then((message) async {
if (message != null) {
if (message.data['click_action'] == 'enroll_cond') {
StorageUtil().haveLocal = true;
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
log('getInitialMessage');
}
}
@ -286,8 +277,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
@override
void didChangeAppLifecycleState(AppLifecycleState state) async {
bool initialize = await StorageUtil().ensureInitialization();
if (initialize) await LocalizationService.processLocals(context);
await LocalizationService.processLocals(context);
}
@override

View File

@ -4,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
late final String devUUID;
@ -32,9 +33,9 @@ class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
}
Future<void> initDatabase() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override

View File

@ -5,7 +5,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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart' as hub;
import 'package:hub/shared/helpers/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 +23,11 @@ class _FastPassPageWidgetState extends State<FastPassPageWidget> {
late InAppWebViewController _controllerIOS;
Future<Map<String, String>> initVariables() async {
final email = StorageUtil().email;
final name = StorageUtil().userName;
final userUUID = StorageUtil().userUUID;
final devUUID = StorageUtil().devUUID;
final cliUUID = StorageUtil().cliUUID;
final email = (await StorageHelper.instance.get(hub.SecureStorageKey.email.value, hub.Storage.SecureStorage)) ?? '';
final name = (await StorageHelper.instance.get(hub.SQLiteStorageKey.userName.value, hub.Storage.SQLiteStorage)) ?? '';
final devUUID = (await StorageHelper.instance.get(hub.SQLiteStorageKey.devUUID.value, hub.Storage.SQLiteStorage)) ?? '';
final userUUID = (await StorageHelper.instance.get(hub.SQLiteStorageKey.userUUID.value, hub.Storage.SQLiteStorage)) ?? '';
final cliUUID = (await StorageHelper.instance.get(hub.SQLiteStorageKey.clientUUID.value, hub.Storage.SQLiteStorage)) ?? '';
const createdAt = '0000-00-00 00:00:00';
final url = 'https://hub.freaccess.com.br/hub/fast-pass/$cliUUID';
final freUserData =

View File

@ -3,9 +3,8 @@ 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/utils/storage_util.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import '../../components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart';
import '../../flutter_flow/flutter_flow_animations.dart';
import '../../flutter_flow/flutter_flow_icon_button.dart';
import '../../flutter_flow/flutter_flow_model.dart';
@ -13,7 +12,6 @@ import '../../flutter_flow/flutter_flow_theme.dart';
import '../../flutter_flow/flutter_flow_widgets.dart';
import '../../flutter_flow/internationalization.dart';
import '../../shared/services/authentication/authentication_service.dart';
import '../../shared/utils/validator_util.dart';
import 'forgot_password_model.dart';
class ForgotPasswordScreen extends StatefulWidget {
@ -112,7 +110,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
),
onPressed: () async {
context.pop();
StorageUtil().isRecovered = false;
StorageHelper.instance.isRecovered = false;
},
),
title: Text(

View File

@ -4,7 +4,8 @@ import 'package:hub/components/organism_components/menu_component/menu_component
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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class HomePageModel extends FlutterFlowModel<HomePageWidget> {
bool isGrid = false;
@ -23,11 +24,11 @@ class HomePageModel extends FlutterFlowModel<HomePageWidget> {
late MessageWellComponentModel messageWellComponentModel;
Future<void> _initVariable() async {
devUUID = StorageUtil().devUUID;
cliUUID = StorageUtil().cliUUID;
userUUID = StorageUtil().userUUID;
userName = StorageUtil().userName;
userEmail = StorageUtil().email;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
userName = (await StorageHelper.instance.get(SQLiteStorageKey.userName.value, Storage.SQLiteStorage)) ?? '';
userEmail = (await StorageHelper.instance.get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? '';
}
@override

View File

@ -9,7 +9,7 @@ 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/utils/storage_util.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart';
class HomePageWidget extends StatefulWidget {
@ -50,7 +50,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
@override
Widget build(BuildContext context) {
StorageUtil().context = context;
StorageHelper.instance.context = context;
return Scaffold(
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -3,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
late final String devUUID;
@ -35,9 +36,9 @@ class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
}
Future<void> init() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
Future answersRequest(

View File

@ -3,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class MessageHistoryPageModel extends FlutterFlowModel<MessageHistoryPageWidget> {
late final String devUUID;
@ -38,9 +39,9 @@ class MessageHistoryPageModel extends FlutterFlowModel<MessageHistoryPageWidget>
}
Future<void> init() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override

View File

@ -9,9 +9,10 @@ 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/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
import 'package:rxdart/rxdart.dart';
@ -62,7 +63,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
}
Future<void> initDatabase() async {
cliUUID = StorageUtil().cliUUID;
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override
@ -215,8 +216,6 @@ class _PackageOrderPage extends State<PackageOrderPage> {
}
PreferredSizeWidget _appBar(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
return AppBar(
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -4,9 +4,10 @@ import 'package:hub/components/templates_components/card_item_template_component
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/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
class PetsHistoryScreen extends StatefulWidget {
const PetsHistoryScreen({super.key, required this.model});
@ -231,10 +232,10 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
}
],
onTapCardItemAction: () async {
final cliUUID = StorageUtil().cliUUID;
final cliName = StorageUtil().cliName;
final devUUID = StorageUtil().devUUID;
final userUUID = StorageUtil().userUUID;
final devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
final cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
await showDialog(
useSafeArea: true,
context: context,

View File

@ -12,9 +12,10 @@ 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/utils/dialog_util.dart';
import 'package:hub/shared/utils/image_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
@ -101,10 +102,10 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
String? Function(BuildContext, String?)? textControllerObservationValidator;
Future<void> initAsync() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
petAmountRegister = StorageUtil().petAmountRegister.toString();
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
petAmountRegister = (await StorageHelper.instance.get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage)) ?? '';
safeSetState?.call();
}

View File

@ -5,11 +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/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.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:hub/shared/services/localization/localization_service.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:share_plus/share_plus.dart';
import '../../shared/utils/snackbar_util.dart';
@ -17,16 +16,28 @@ import '../../shared/utils/snackbar_util.dart';
class PreferencesPageModel with ChangeNotifier {
final unfocusNode = FocusNode();
PreferencesPageModel() {
initVariables();
}
Future<void> initVariables() async {
late bool isFingerprint = false;
late bool isPerson = false;
late bool isNotify = false;
late bool isAccess = false;
late bool isPanic = false;
Future<void> _initialize() async {
isFingerprint = await StorageHelper.instance.get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
isPerson = await StorageHelper.instance.get(SQLiteStorageKey.person.value, Storage.SQLiteStorage) == 'true';
isNotify = await StorageHelper.instance.get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true';
isAccess = await StorageHelper.instance.get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true';
isPanic = await StorageHelper.instance.get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true';
notifyListeners();
}
PreferencesPageModel() {
_initialize();
}
Future<void> enablePerson(BuildContext context) async {
final String userDevUUID = StorageUtil().userDevUUID;
final String userDevUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? '';
notifyListeners();
Share.share(
FFLocalizations.of(context).getVariableText(
@ -47,10 +58,11 @@ class PreferencesPageModel with ChangeNotifier {
);
onConfirm() async {
String content;
String value = StorageUtil().notify ? 'N' : 'S';
isNotify = await StorageHelper.instance.get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true';
String value = isNotify ? 'N' : 'S';
await PhpGroup.changeNotifica.call(notifica: value).then((value) async {
if (value.jsonBody['error'] == false) {
StorageUtil().notify = !StorageUtil().notify;
await StorageHelper.instance.set(SQLiteStorageKey.notify.value, isNotify ? 'false' : 'true',Storage.SQLiteStorage);
notifyListeners();
content = FFLocalizations.of(context).getVariableText(
enText: 'Notification changed successfully',
@ -80,15 +92,15 @@ class PreferencesPageModel with ChangeNotifier {
Future<void> toggleAccess(BuildContext context) async {
onChange(String key) async {
StorageUtil().accessPass = key;
await PhpGroup.changePass
.call(
newSenha: key,
)
.then((value) async {
await StorageHelper.instance.set(SecureStorageKey.accessPass.value, key, Storage.SecureStorage);
isAccess = await StorageHelper.instance.get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true';
await PhpGroup.changePass.call(newSenha: key).then((value) async {
final String content;
if (jsonDecode(value.jsonBody['error'].toString()) == false) {
if (!StorageUtil().access) StorageUtil().access = !StorageUtil().access;
if (!isAccess) {
await StorageHelper.instance.set(SQLiteStorageKey.access.value, isAccess ? 'false' : 'true', Storage.SQLiteStorage);
}
notifyListeners();
content = FFLocalizations.of(context).getVariableText(
enText: 'Access pass changed successfully',
@ -116,15 +128,16 @@ class PreferencesPageModel with ChangeNotifier {
Future<void> togglePanic(BuildContext context) async {
onChange(String key) async {
StorageUtil().panicPass = key;
await StorageHelper.instance.set(SecureStorageKey.panicPass.value, key, Storage.SecureStorage);
isPanic = await StorageHelper.instance.get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true';
await PhpGroup.changePanic
.call(
newSenhaPanico: StorageUtil().panicPass,
)
.call(newSenhaPanico: key)
.then((value) async {
final String content;
if (jsonDecode(value.jsonBody['error'].toString()) == false) {
if (!StorageUtil().panic) StorageUtil().panic = !StorageUtil().panic;
if (!isPanic) {
await StorageHelper.instance.set(SQLiteStorageKey.panic.value, isPanic ? 'false' : 'true', Storage.SQLiteStorage);
}
notifyListeners();
content = FFLocalizations.of(context).getVariableText(
enText: 'Panic password changed successfully',
@ -156,17 +169,21 @@ class PreferencesPageModel with ChangeNotifier {
ptText: 'Impressão digital alterada com sucesso',
);
isFingerprint = await StorageHelper.instance.get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
onChange(String? key) async {
StorageUtil().fingerprint = !StorageUtil().fingerprint;
if (!StorageUtil().fingerprint) StorageUtil().fingerprintPass = key ?? '';
if (StorageUtil().fingerprint) StorageUtil().fingerprintPass = '';
isFingerprint = !isFingerprint;
await StorageHelper.instance.set(SecureStorageKey.fingerprintPass.value, isFingerprint ? '' : key ?? '', Storage.SecureStorage);
isFingerprint = await StorageHelper.instance.get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
notifyListeners();
SnackBarUtil.showSnackBar(context, content);
}
StorageUtil().fingerprint ? onChange(null) : _showPassKey(context, onChange);
isFingerprint ? onChange(null) : _showPassKey(context, onChange);
}
Future<void> deleteAccount(BuildContext context) async {

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
@ -5,7 +7,8 @@ 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/preferences_settings_page/preferences_settings_model.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:provider/provider.dart';
class PreferencesPageWidget extends StatefulWidget {
@ -16,6 +19,7 @@ class PreferencesPageWidget extends StatefulWidget {
}
class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
@override
void initState() {
super.initState();
@ -101,7 +105,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 0:
icon = Icons.fingerprint;
onPressed = () => model.toggleFingerprint(context);
isEnabled = StorageUtil().fingerprint;
isEnabled = model.isFingerprint;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative a autenticação por impressão digital para login seguro.',
enText: 'Enable fingerprint authentication for secure login.',
@ -110,7 +114,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 1:
icon = Icons.person;
onPressed = () => model.enablePerson(context);
isEnabled = StorageUtil().person;
isEnabled = model.isPerson;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Compartilhe o código de identificação remota',
enText: 'Share the remote identification code',
@ -119,7 +123,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 2:
icon = Icons.notifications;
onPressed = () => model.toggleNotify(context);
isEnabled = StorageUtil().notify;
isEnabled = model.isNotify;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para receber sua notificação de acesso',
enText: 'Enable to receive your access notification',
@ -128,7 +132,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 3:
icon = Icons.lock;
onPressed = () => model.toggleAccess(context);
isEnabled = StorageUtil().access;
isEnabled = model.isAccess;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para inserir uma credencial de acesso para o QRCode',
enText: 'Enable to enter an access credential for the QRCode',
@ -137,7 +141,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 4:
icon = Icons.lock_clock_sharp;
onPressed = () => model.togglePanic(context);
isEnabled = StorageUtil().panic;
isEnabled = model.isPanic;
content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para inserir uma credencial de pânico para o QRCode',
enText: 'Enable to enter a panic credential for the QRCode',

View File

@ -4,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:qr_flutter/qr_flutter.dart';
class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
@ -28,8 +29,8 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
}
Future<void> initVariable() async {
isFingerprint = StorageUtil().fingerprint;
userDevUUID = StorageUtil().userDevUUID;
isFingerprint = await StorageHelper.instance.get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
userDevUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override
@ -79,7 +80,6 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
packet.add(check);
}
var bytes = packet.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join((' '));
return Uint8List.fromList(packet);
}

View File

@ -14,9 +14,10 @@ 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/utils/biometric_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
import 'package:qr_flutter/qr_flutter.dart';
@ -330,13 +331,13 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
Future<void> _showBiometricsAuth(BuildContext context) async {
BiometricHelper.checkBiometrics()
.then((value) => BiometricHelper.authenticateBiometric().then((value) {
safeSetState(() {
safeSetState(() async {
if (animationsMap['barcodeOnActionTriggerAnimation'] != null) {
animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop();
animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse();
}
_model.isAccess = !_model.isAccess;
_model.key = StorageUtil().fingerprintPass;
_model.key = (await StorageHelper.instance.get(SecureStorageKey.fingerprintPass.value, Storage.SecureStorage)) ?? '';
});
}))
.onError((error, StackTrace) {

View File

@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:share_plus/share_plus.dart';
class ReceptionPageModel with ChangeNotifier {
Future<void> getIdenfifier(BuildContext context) async {
final String userDevUUID = StorageUtil().userDevUUID;
final String userDevUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? '';
notifyListeners();
Share.share(

View File

@ -11,8 +11,9 @@ 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/reception_page/reception_page_model.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/storage_util.dart';
import 'package:provider/provider.dart';
class ReceptionPageWidget extends StatefulWidget {
@ -54,7 +55,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> with WidgetsB
@override
Widget build(BuildContext context) {
StorageUtil().context = context;
StorageHelper.instance.context = context;
return ChangeNotifierProvider(
create: (context) => ReceptionPageModel(),
child: Scaffold(
@ -157,7 +158,8 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> with WidgetsB
onPressed: () async {
PhpGroup.unregisterDevice();
StorageUtil.purge();
StorageHelper.instance.clearAll(Storage.SecureStorage);
setState(() {});
context.go(

View File

@ -5,7 +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/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart' as hub;
import 'package:hub/shared/helpers/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';
@ -21,12 +22,12 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
late WebViewController _controllerAll;
Future<Map<String, String>> initVariables() async {
final email = StorageUtil().email;
final name = StorageUtil().cliName;
final userUUID = StorageUtil().userUUID;
final devUUID = StorageUtil().devUUID;
final createdAt = StorageUtil().createdAt;
final clientId = StorageUtil().cliUUID;
final email = (await StorageHelper.instance.get(hub.SecureStorageKey.email.value, hub.Storage.SecureStorage)) ?? '';
final name = (await StorageHelper.instance.get(hub.SQLiteStorageKey.userName.value, hub.Storage.SQLiteStorage)) ?? '';
final devUUID = (await StorageHelper.instance.get(hub.SQLiteStorageKey.devUUID.value, hub.Storage.SQLiteStorage)) ?? '';
final userUUID = (await StorageHelper.instance.get(hub.SQLiteStorageKey.userUUID.value, hub.Storage.SQLiteStorage)) ?? '';
final clientId = (await StorageHelper.instance.get(hub.SQLiteStorageKey.clientUUID.value, hub.Storage.SQLiteStorage)) ?? '';
const createdAt = '0000-00-00 00:00:00';
final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId';

View File

@ -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/mixins/status_mixin.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:share_plus/share_plus.dart';
import '../../shared/utils/validator_util.dart';
@ -213,9 +214,9 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel<ScheduleComplete>
}
Future<void> _initVariables() async {
devUUID = StorageUtil().devUUID;
cliUUID = StorageUtil().cliUUID;
userUUID = StorageUtil().userUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override

View File

@ -5,10 +5,11 @@ 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/mixins/status_mixin.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
class VisitHistoryWidget extends ScheduleComplete {
@ -33,9 +34,9 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> with TickerProv
List<dynamic> _visitWrap = [];
Future<void> _initVariables() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
}
@override
@ -232,10 +233,10 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> with TickerProv
},
],
onTapCardItemAction: () async {
final cliUUID = StorageUtil().cliUUID;
final cliName = StorageUtil().cliName;
final devUUID = StorageUtil().devUUID;
final userUUID = StorageUtil().userUUID;
final devUUID = (await StorageHelper.instance.get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final userUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
final cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
await showDialog(
useSafeArea: true,

View File

@ -1,6 +1,6 @@
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/mixins/switcher_mixin.dart';
import '../../shared/utils/storage_util.dart';
import '/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -35,7 +35,7 @@ class _SignInPageWidgetState extends State<SignInPageWidget> {
@override
Widget build(BuildContext context) {
StorageUtil().context = context;
StorageHelper.instance.context = context;
return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode)

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/mixins/switcher_mixin.dart';
import '../../shared/utils/storage_util.dart';
import '/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -36,7 +36,7 @@ class _SignUpPageWidgetState extends State<SignUpPageWidget> {
@override
Widget build(BuildContext context) {
StorageUtil().context = context;
StorageHelper.instance.context = context;
return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode)

View File

@ -1,11 +1,8 @@
import 'dart:async';
import 'dart:developer';
import 'package:app_links/app_links.dart';
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/mixins/switcher_mixin.dart';
import 'package:hub/shared/utils/storage_util.dart';
import '/components/templates_components/welcome_template_component/welcome_template_component_widget.dart';
import '/flutter_flow/flutter_flow_theme.dart';
@ -34,13 +31,13 @@ class _WelcomePageWidgetState extends State<WelcomePageWidget> {
// On page load action.
SchedulerBinding.instance.addPostFrameCallback((_) async {
if (isAndroid == true) {
StorageUtil().deviceType = 'Android';
await StorageHelper.instance.set(SecureStorageKey.deviceType.value, 'Android', Storage.SecureStorage);
setState(() {});
} else if (isiOS == true) {
StorageUtil().deviceType = 'iOS';
await StorageHelper.instance.set(SecureStorageKey.deviceType.value, 'iOS', Storage.SecureStorage);
setState(() {});
} else {
StorageUtil().deviceType = 'Web';
await StorageHelper.instance.set(SecureStorageKey.deviceType.value, 'Web', Storage.SecureStorage);
setState(() {});
}
});
@ -55,7 +52,7 @@ class _WelcomePageWidgetState extends State<WelcomePageWidget> {
@override
Widget build(BuildContext context) {
StorageUtil().context = context;
StorageHelper.instance.context = context;
return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode)

View File

@ -0,0 +1,144 @@
abstract class BaseStorage {
Future<void> init();
Future<void> set(String key, String value);
Future<String?> get(String key);
Future<void> delete(String key);
Future<void> clearAll();
}
enum Storage {
SecureStorage,
SharedPreferences,
SQLiteStorage,
}
enum SharedPreferencesKey {
isFirstRun,
}
extension SharedPreferencesKeyExtension on SharedPreferencesKey {
String get value {
switch (this) {
case SharedPreferencesKey.isFirstRun:
return 'fre_isFirstRun';
default:
return '';
}
}
}
enum SecureStorageKey {
isLogged,
email,
password,
deviceType,
token,
accessPass,
panicPass,
fingerprintPass,
haveLocal,
deviceDescription,
}
extension SecureStorageKeyExtension on SecureStorageKey {
String get value {
switch (this) {
case SecureStorageKey.isLogged:
return 'fre_isLogged';
case SecureStorageKey.email:
return 'fre_email';
case SecureStorageKey.password:
return 'fre_passwd';
case SecureStorageKey.deviceType:
return 'fre_deviceType';
case SecureStorageKey.token:
return 'fre_token';
case SecureStorageKey.accessPass:
return 'fre_accessPass';
case SecureStorageKey.panicPass:
return 'fre_panicPass';
case SecureStorageKey.fingerprintPass:
return 'fre_fingerprintPass';
case SecureStorageKey.haveLocal:
return 'fre_have_local';
case SecureStorageKey.deviceDescription:
return 'fre_deviceDescription';
default:
return '';
}
}
}
enum SQLiteStorageKey {
devUUID,
userUUID,
userDevUUID,
status,
userName,
clientUUID,
ownerUUID,
clientName,
petAmount,
whatsapp,
provisional,
pets,
local,
notify,
fingerprint,
access,
panic,
person,
requestOSNotification,
}
extension SQLIteStorageKeyExtension on SQLiteStorageKey {
String get value {
switch (this) {
case SQLiteStorageKey.devUUID:
return 'fre_devUUID';
case SQLiteStorageKey.userUUID:
return 'fre_userUUID';
case SQLiteStorageKey.userDevUUID:
return 'fre_userDevUUID';
case SQLiteStorageKey.status:
return 'fre_status';
case SQLiteStorageKey.userName:
return 'fre_userName';
case SQLiteStorageKey.clientUUID:
return 'fre_cliUUID';
case SQLiteStorageKey.ownerUUID:
return 'fre_ownerUUID';
case SQLiteStorageKey.clientName:
return 'fre_cliName';
case SQLiteStorageKey.petAmount:
return 'fre_petAmountRegister';
case SQLiteStorageKey.whatsapp:
return 'fre_whatsapp';
case SQLiteStorageKey.provisional:
return 'fre_provisional';
case SQLiteStorageKey.pets:
return 'fre_pets';
case SQLiteStorageKey.local:
return 'fre_local';
case SQLiteStorageKey.notify:
return 'fre_notify';
case SQLiteStorageKey.fingerprint:
return 'fre_fingerprint';
case SQLiteStorageKey.access:
return 'fre_access';
case SQLiteStorageKey.panic:
return 'fre_panic';
case SQLiteStorageKey.person:
return 'fre_person';
case SQLiteStorageKey.requestOSNotification:
return 'fre_requestOSnotification';
default:
return '';
}
}
}

View File

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hub/shared/helpers/base_storage.dart';
class SecureStorage extends ChangeNotifier implements BaseStorage {
SecureStorage._();
static final SecureStorage instance = SecureStorage._();
late final FlutterSecureStorage _secureStorage;
@override
Future<void> init() async {
_secureStorage = const FlutterSecureStorage();
}
@override
Future<String?> get(String key) async {
return await _secureStorage.read(key: key);
}
@override
Future<void> set(String key, String value) async {
await _secureStorage.write(key: key, value: value);
notifyListeners();
}
@override
Future<void> delete(String key) async {
await _secureStorage.delete(key: key);
notifyListeners();
}
@override
Future<void> clearAll() async {
await _secureStorage.deleteAll();
notifyListeners();
}
}

View File

@ -1,110 +0,0 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hub/shared/utils/cache_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
class SecureStorageHelper extends ChangeNotifier implements Storage {
static final SecureStorageHelper _instance = SecureStorageHelper._internal();
final FlutterSecureStorage _secureStorage = const FlutterSecureStorage();
factory SecureStorageHelper() => _instance;
SecureStorageHelper._internal();
static SecureStorageHelper get instance => _instance;
Future<void> setAndCacheString(String key, String value, Function(String) cacheSetter) async {
log('SecureStorageHelper -> setAndCacheString value for key: $key to $value');
await _secureStorage.write(key: key, value: value);
CacheUtil.instance.set(key, value);
cacheSetter(value);
}
Future<void> setAndCacheBool(String key, bool value, Function(bool) cacheSetter) async {
log('SecureStorageHelper -> setAndCacheBool value for key: $key to $value');
await _secureStorage.write(key: key, value: value.toString());
CacheUtil.instance.set(key, value);
cacheSetter(value);
}
Future<void> setAndCacheObject(String key, String value, Function(String) cacheSetter) async {
log('SecureStorageHelper -> setAndCacheObject value for key: $key to $value');
await _secureStorage.write(key: key, value: value);
CacheUtil.instance.set(key, value);
cacheSetter(value);
}
Future<String?> getString(String key) async {
var value = CacheUtil.instance.get(key);
if (value == null) {
value = await _secureStorage.read(key: key);
CacheUtil.instance.set(key, value);
}
log('SecureStorageHelper -> getString $value for key: $key');
return value;
}
Future<bool?> getBool(String key) async {
var value = CacheUtil.instance.get(key);
if (value == null || value == 'null') {
value = await _secureStorage.read(key: key);
CacheUtil.instance.set(key, value);
log('SecureStorageHelper -> getBool $value for key: $key');
return value == 'true';
}
log('SecureStorageHelper -> getBool $value for key: $key');
return value == 'true' || value == true;
}
Future<BuildContext?> getObject(String key) async {
var value = CacheUtil.instance.get(key);
if (value == null) {
value = await _secureStorage.read(key: key);
CacheUtil.instance.set(key, value);
}
log('SecureStorageHelper -> getObject $value for key: $key');
return value as BuildContext?;
}
@override
Future<void> set(String key, dynamic value, Function(dynamic) cacheSetter) async {
if (value is String? || value is String) {
await setAndCacheString(key, value!, cacheSetter);
} else if (value is bool? || value is bool) {
await setAndCacheBool(key, value, cacheSetter);
} else if (value is BuildContext || value is BuildContext?) {
await setAndCacheObject(key, value.toString(), cacheSetter);
}
}
@override
Future<dynamic> get(String key) async {
log('SecureStorageHelper -> get value for key: $key');
var stringValue = await getString(key);
if (stringValue != null) return stringValue;
var boolValue = await getBool(key);
if (boolValue != null) return boolValue;
var objectValue = await getObject(key);
if (objectValue != null) return objectValue;
return null;
}
@override
Future<void> delete(String key) async {
log('SecureStorageHelper -> delete value for key: $key');
await _secureStorage.delete(key: key);
CacheUtil.instance.delete(key);
}
Future<void> purge() async {
log('SecureStorageHelper -> Purging secure storage');
await _secureStorage.deleteAll();
CacheUtil.instance.clear();
}
}

View File

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:shared_preferences/shared_preferences.dart';
class SharedPreferencesStorage extends ChangeNotifier implements BaseStorage {
SharedPreferencesStorage._();
static final SharedPreferencesStorage instance = SharedPreferencesStorage._();
late final SharedPreferences _prefs;
@override
Future<void> init() async {
_prefs = await SharedPreferences.getInstance();
}
@override
Future<String?> get(String key) async {
return _prefs.get(key).toString();
}
@override
Future<void> set(String key, String value) async {
await _prefs.setString(key, value);
notifyListeners();
}
@override
Future<void> delete(String key) async {
await _prefs.remove(key);
notifyListeners();
}
@override
Future<void> clearAll() async {
await _prefs.clear();
notifyListeners();
}
}

View File

@ -1,95 +0,0 @@
import 'dart:developer';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:hub/shared/utils/cache_util.dart';
class SharedPreferencesStorageHelper implements Storage {
static final SharedPreferencesStorageHelper _instance = SharedPreferencesStorageHelper._internal();
SharedPreferences? _prefs;
SharedPreferences? get prefs => _prefs;
set prefs(SharedPreferences? value) => _prefs = value;
factory SharedPreferencesStorageHelper() => _instance;
SharedPreferencesStorageHelper._internal();
static SharedPreferencesStorageHelper get instance => _instance;
Future<void> initialize() async => _prefs = await SharedPreferences.getInstance();
Future<void> _setAndCache<T>(
String key, T value, Function(T) cacheSetter, Future<void> Function(String, T) setFunc) async {
log('setAndCache value for key: $key to $value');
await setFunc(key, value);
CacheUtil.instance.set(key, value);
cacheSetter(value);
}
Future<void> _setAndCacheString(String key, String value, Function(String) cacheSetter) async {
log('setAndCacheString value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setString);
}
Future<void> _setAndCacheBool(String key, bool value, Function(bool) cacheSetter) async {
log('setAndCacheBool value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setBool);
}
Future<void> _setAndCacheInt(String key, int value, Function(int) cacheSetter) async {
log('setAndCacheInt value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setInt);
}
Future<void> _setAndCacheDouble(String key, double value, Function(double) cacheSetter) async {
log('setAndCacheDouble value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setDouble);
}
Future<void> _setAndCacheStringList(String key, List<String> value, Function(List<String>) cacheSetter) async {
log('setAndCacheStringList value for key: $key to $value');
await _setAndCache(key, value, cacheSetter, _prefs!.setStringList);
}
@override
Future<void> set(String key, dynamic value, Function(dynamic) cacheSetter) async {
if (value is bool) {
log('() => setAndCacheBool $key to $value');
await _prefs?.setBool(key, value);
} else if (value is String) {
await _prefs?.setString(key, value);
} else if (value is int) {
await _prefs?.setInt(key, value);
} else if (value is double) {
await _prefs?.setDouble(key, value);
} else if (value is List<String>) {
await _prefs?.setStringList(key, value);
}
CacheUtil.instance.set(key, value);
}
@override
Future<dynamic> get(String key) async {
log('Getting value for key: $key');
var value = CacheUtil.instance.get(key);
if (value == null) {
value = _prefs?.get(key);
CacheUtil.instance.set(key, value);
}
return value;
}
@override
Future<void> delete(String key) async {
log('Deleting value for key: $key');
await _prefs?.remove(key);
CacheUtil.instance.delete(key);
}
@override
Future<void> purge() async {
log('Purging shared preferences');
await _prefs?.clear();
CacheUtil.instance.clear();
}
}

View File

@ -0,0 +1,133 @@
import 'dart:developer';
import 'package:flutter/material.dart';
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 extends ChangeNotifier implements BaseStorage {
SQLiteStorage._();
final String _dbName = 'database.db';
final int _dbVersion = 1;
static final SQLiteStorage instance = SQLiteStorage._();
late final _database;
@override
Future<void> 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 {}
_onInitLocalVariables(Database database) async {
// TODO: Talvez precise colocar um transaction aqui como o
// database.batch() para melhorar a performance
for (var variable in _localVariables) {
var isConfig = await database.query('keychain', where: 'key = ?', whereArgs: [variable['key']]);
if (isConfig.isEmpty) {
await database.insert('keychain', variable);
}
}
}
String get _tableKeychain => '''
CREATE TABLE keychain (
key TEXT UNIQUE,
value TEXT,
type TEXT,
updateAt TEXT,
resolvedAt TEXT,
createdAt TEXT
);
''';
List<Map<String, dynamic>> 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<String?> 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<void> set(String key, String value) async {
var date = DateTime.now().toIso8601String();
await _database.insert(
'keychain',
{
'key': key,
'value': value,
'type': 'local',
'updateAt': date,
'resolvedAt': date,
'createdAt': date,
},
conflictAlgorithm: ConflictAlgorithm.replace
);
notifyListeners();
}
@override
Future<void> delete(String key) async {
var isConfig = await _database.query('keychain', where: 'key = ?', whereArgs: [key]);
if (isConfig.isNotEmpty) {
await _database.delete('keychain', where: 'key = ?', whereArgs: [key]);
}
notifyListeners();
}
@override
Future<void> clearAll() async {
await _database.delete('keychain');
notifyListeners();
}
}

View File

@ -1,275 +0,0 @@
import 'package:hub/shared/utils/cache_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:sqflite/sqflite.dart';
import 'dart:developer';
import 'package:path/path.dart';
class DatabaseConfig {
static const String dbName = 'database.db';
static const int dbVersion = 1;
static const String tableKeychain = 'keychain';
static const String columnKey = 'key';
static const String columnValue = 'value';
static const String columnType = 'type';
static const String columnUpdateAt = 'updateAt';
static const String columnResolvedAt = 'resolvedAt';
static const String columnCreatedAt = 'createdAt';
static const List<Map<String, dynamic>> initialData = [
{'key': 'devUUID', 'value': '', 'type': 'user'},
{'key': 'userUUID', 'value': '', 'type': 'user'},
{'key': 'userDevUUID', 'value': '', 'type': 'user'},
{'key': 'status', 'value': '', 'type': 'user'},
{'key': 'userName', 'value': '', 'type': 'user'},
{'key': 'cliUUID', 'value': '', 'type': 'local'},
{'key': 'ownerUUID', 'value': '', 'type': 'local'},
{'key': 'cliName', 'value': '', 'type': 'local'},
{'key': 'whatsapp', 'value': 'false', 'type': 'util'},
{'key': 'provisional', 'value': 'false', 'type': 'util'},
{'key': 'pets', 'value': 'false', 'type': 'util'},
{'key': 'local', 'value': 'false', 'type': 'util'},
{'key': 'notify', 'value': 'false', 'type': 'util'},
{'key': 'fingerprint', 'value': 'false', 'type': 'util'},
{'key': 'access', 'value': 'false', 'type': 'util'},
{'key': 'panic', 'value': 'false', 'type': 'util'},
{'key': 'person', 'value': 'false', 'type': 'util'},
{'key': 'requestOSnotification', 'value': 'false', 'type': 'util'},
{'key': 'petAmountRegister', 'value': '', 'type': 'local'},
];
}
class SQLiteStorageHelper implements Storage {
static final SQLiteStorageHelper _instance = SQLiteStorageHelper._internal();
static Database? _database;
static String? _databasePath;
factory SQLiteStorageHelper() => _instance;
SQLiteStorageHelper._internal();
static SQLiteStorageHelper get instance => _instance;
Future<Database> get database async {
log('Getting database instance');
if (_database != null) return _database!;
_database = await _initDatabase();
return _database!;
}
Future<String> _getDatabasePath() async {
log('Getting database path');
if (_databasePath != null) return _databasePath!;
final databasesPath = await getDatabasesPath();
_databasePath = join(databasesPath, DatabaseConfig.dbName);
log('Database path: $_databasePath');
return _databasePath!;
}
Future<Database> _initDatabase() async {
log('Initializing database');
final path = await _getDatabasePath();
return await openDatabase(
path,
version: DatabaseConfig.dbVersion,
onCreate: _onCreate,
onOpen: _onOpen,
onUpgrade: _onUpgrade,
onDowngrade: _onDowngrade,
onConfigure: _onConfigure,
).catchError((error) {
log('Error initializing database: $error');
throw error;
}).whenComplete(() async {
log('Database initialization complete');
await setupLocalVariables();
});
}
Future<void> _onCreate(Database db, int version) async {
log('Creating tables...');
await db.execute('''
CREATE TABLE ${DatabaseConfig.tableKeychain} (
${DatabaseConfig.columnKey} TEXT UNIQUE,
${DatabaseConfig.columnValue} TEXT,
${DatabaseConfig.columnType} TEXT,
${DatabaseConfig.columnUpdateAt} TEXT,
${DatabaseConfig.columnResolvedAt} TEXT,
${DatabaseConfig.columnCreatedAt} TEXT
);
''');
await _insertInitialData(db);
log('Tables created');
}
Future<void> _insertInitialData(Database db) async {
log('Inserting initial data');
final batch = db.batch();
for (var data in DatabaseConfig.initialData) {
batch.insert(DatabaseConfig.tableKeychain, data);
}
await batch.commit(noResult: true);
log('Initial data inserted');
}
Future<void> _onOpen(Database db) async {
log('Opening database');
await _checkExistingData(db);
}
Future<void> _onUpgrade(Database db, int oldVersion, int newVersion) async {
log('Upgrading database from version $oldVersion to $newVersion');
}
Future<void> _onDowngrade(Database db, int oldVersion, int newVersion) async {
log('Downgrading database from version $oldVersion to $newVersion');
}
Future<void> _onConfigure(Database db) async {
log('Configuring database');
}
Future<void> _checkExistingData(Database db) async {
log('Checking existing data');
try {
final maps = await db.query(DatabaseConfig.tableKeychain);
log('Existing data: $maps');
} catch (error) {
log('Error checking existing data: $error');
}
}
Future<void> setupLocalVariables() async {
log('Setting up local variables');
try {
await _database?.transaction((txn) async {
final keys = [
'devUUID',
'userUUID',
'userDevUUID',
'status',
'userName',
'cliUUID',
'ownerUUID',
'cliName',
'petAmountRegister',
'whatsapp',
'provisional',
'pets',
'local',
'notify',
'fingerprint',
'access',
'panic',
'person',
'requestOSnotification'
];
for (var key in keys) {
log('Fetching value for key: $key');
final result = await txn.query(
DatabaseConfig.tableKeychain,
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
log('Result for key $key: $result');
}
});
log('Local variables setup complete');
} catch (error) {
log('Error setting up local variables: $error');
}
}
Future<bool> getBoolean(String key) async {
log('Getting boolean value for key: $key');
final value = await get(key);
return value == 'true';
}
@override
Future<dynamic> get(String key) async {
log('Getting value for key: $key');
final cachedValue = CacheUtil().get(key);
if (cachedValue != null) {
log('Found cached value for key: $key');
return cachedValue;
}
try {
final db = await database;
final result = await db.query(
DatabaseConfig.tableKeychain,
columns: [DatabaseConfig.columnValue],
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
if (result.isNotEmpty) {
final value = result.first[DatabaseConfig.columnValue];
CacheUtil().set(key, value);
log('Value for key $key: $value');
return value;
}
log('No value found for key: $key');
return null;
} catch (error) {
log('Error getting value for key $key: $error');
return null;
}
}
@override
Future<int> set(String key, dynamic value, Function(dynamic) cacheSetter) async {
log('Setting value for key: $key to $value');
CacheUtil().set(key, value);
final db = await database;
final data = {
DatabaseConfig.columnKey: key,
DatabaseConfig.columnValue: value.toString(),
DatabaseConfig.columnUpdateAt: DateTime.now().toIso8601String(),
DatabaseConfig.columnCreatedAt: DateTime.now().toIso8601String(),
};
final result = await db.insert(
DatabaseConfig.tableKeychain,
data,
conflictAlgorithm: ConflictAlgorithm.replace,
);
log('Value $value set for key: $key with result: $result');
return result;
}
@override
Future<int> delete(String key) async {
log('Deleting value for key: $key');
final db = await database;
final result = await db.transaction((txn) async {
return await txn.delete(
DatabaseConfig.tableKeychain,
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
});
log('Value deleted for key: $key');
return result;
}
@override
Future<void> purge() async {
log('Purging SQLite storage');
await deleteDatabaseDB();
await database;
log('Database purged');
}
Future<void> deleteDatabaseDB() async {
log('Deleting database');
final path = await _getDatabasePath();
await deleteDatabase(path);
log('Database deleted');
_database = null;
}
}
class SqliteStorageDelegate {}

View File

@ -0,0 +1,81 @@
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 {
StorageHelper._();
late BuildContext? _context;
late bool _isRecovered = false;
static final StorageHelper instance = StorageHelper._();
BuildContext? get context => _context;
set context(BuildContext? context) => _context = context;
bool get isRecovered => _isRecovered;
set isRecovered(bool isRecovered) => _isRecovered = isRecovered;
Future<void> 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 == 'true') {
await SharedPreferencesStorage.instance.set(SharedPreferencesKey.isFirstRun.value, 'false');
await SecureStorage.instance.set(SecureStorageKey.isLogged.value, 'false');
}
}
Future<String?> 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<void> 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<void> 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<void> 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();
}
}
}

View File

@ -1,5 +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/utils/snackbar_util.dart';
import '../../../backend/api_requests/api_calls.dart';
@ -8,7 +10,6 @@ import '../../../flutter_flow/random_data_util.dart';
import '../../utils/device_util.dart';
import '../../utils/dialog_util.dart';
import '../../utils/log_util.dart';
import '../../utils/storage_util.dart';
class AuthenticationService {
static Future<void> login(BuildContext context) async {
@ -23,13 +24,14 @@ class AuthenticationService {
List<dynamic> locals = response.jsonBody['locais'] ?? [];
if (locals.isEmpty) {
StorageUtil().haveLocal = false;
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'false', Storage.SecureStorage);
context.go('/receptionPage');
} else {
StorageUtil().haveLocal = true;
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
context.go('/homePage');
}
StorageUtil().isLogged = true;
await StorageHelper.instance.set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage);
}
static Future signIn(
@ -41,13 +43,8 @@ class AuthenticationService {
try {
final ApiCallResponse? response;
final LoginCall callback = PhpGroup.loginCall;
StorageUtil().deviceDescription = randomString(
10,
10,
true,
false,
false,
);
String deviceDescription = randomString(10, 10, true, false, false);
await StorageHelper.instance.set(SecureStorageKey.deviceDescription.value, deviceDescription, Storage.SecureStorage);
final String? devUUID;
final String userUUID;
@ -62,9 +59,9 @@ class AuthenticationService {
devUUID = await DeviceUtil.getDevUUID();
if ((email != '') && (passwd != '')) {
StorageUtil().email = email;
StorageUtil().passwd = passwd;
StorageUtil().devUUID = devUUID!;
await StorageHelper.instance.set(SecureStorageKey.email.value, email, Storage.SecureStorage);
await StorageHelper.instance.set(SecureStorageKey.password.value, passwd, Storage.SecureStorage);
await StorageHelper.instance.set(SQLiteStorageKey.devUUID.value, devUUID!, Storage.SQLiteStorage);
response = await callback.call();
if (response.jsonBody['error'] == false) {
@ -73,10 +70,10 @@ class AuthenticationService {
userDevUUID = response.jsonBody['user']['dev_id'];
userName = response.jsonBody['user']['name'];
StorageUtil().userUUID = userUUID;
StorageUtil().userDevUUID = userDevUUID;
StorageUtil().status = status;
StorageUtil().userName = userName;
await StorageHelper.instance.set(SQLiteStorageKey.userUUID.value, userUUID, Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.userDevUUID.value, userDevUUID, Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.status.value, status, Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.userName.value, userName, Storage.SQLiteStorage);
await login(context);
} else {
@ -140,7 +137,7 @@ class AuthenticationService {
alignment: Alignment.bottomCenter,
),
};
await StorageUtil.purge();
await StorageHelper.instance.clearAll(Storage.SecureStorage);
context.go('/welcomePage', extra: extra);
}
@ -188,7 +185,7 @@ class AuthenticationService {
static Future<void> deleteAccount(BuildContext context) async {
String content;
try {
await PhpGroup.deleteAccount.call().then((value) {
await PhpGroup.deleteAccount.call().then((value) async {
final Map<String, dynamic> extra = <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
@ -201,7 +198,7 @@ class AuthenticationService {
enText: 'Account deleted successfully',
ptText: 'Conta deletada com sucesso',
);
StorageUtil.purge();
await StorageHelper.instance.clearAll(Storage.SecureStorage);
context.pop();
context.go('/welcomePage', extra: extra);
}

View File

@ -2,8 +2,9 @@ import 'dart:developer';
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/utils/dialog_util.dart';
import 'package:hub/shared/utils/storage_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';
@ -30,12 +31,12 @@ class LocalizationService {
final bool isEnable = !isEmpty && isActive;
if (isEnable) {
StorageUtil().haveLocal = true;
StorageUtil().isLogged = true;
await StorageHelper.instance.set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
await StorageHelper.instance.set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage);
await WidgetsBinding.instance.endOfFrame;
StorageUtil().cliUUID = '';
StorageUtil().ownerUUID = '';
StorageUtil().context?.go('/homePage');
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage);
StorageHelper.instance.context?.go('/homePage');
}
} catch (e, s) {
log(e.toString(), stackTrace: s);
@ -44,7 +45,6 @@ class LocalizationService {
static Future<bool> processLocals(BuildContext context) async {
try {
await StorageUtil().ensureInitialization();
final GetLocalsCall callback = PhpGroup.getLocalsCall;
final ApiCallResponse response = await callback.call();
final bool isError = response.jsonBody['error'];
@ -59,16 +59,16 @@ class LocalizationService {
_logLocalsStatus(locals);
final bool isActive = _isActive(locals);
final bool isInactived = _isInactived(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 = _isUnselected();
final bool isSelected = _isSelected(isInactived);
final bool isUnselected = await _isUnselected();
final bool isSelected = await _isSelected(isInactived);
final bool isUnavailable = isPending && isUnselected && isUnique;
final bool isAvailable = _isAvailable();
final bool isAvailable = await _isAvailable();
if (isDisabled) {
AuthenticationService.signOut(context);
@ -109,7 +109,6 @@ class LocalizationService {
static Future<bool> processData(BuildContext context) async {
try {
await StorageUtil().ensureInitialization();
final GetDadosCall callback = PhpGroup.getDadosCall;
var response = await callback.call();
final bool error = response.jsonBody['error'];
@ -119,7 +118,7 @@ class LocalizationService {
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
return false;
} else {
_updateStorageUtil(response.jsonBody);
await _updateStorageUtil(response.jsonBody);
return true;
}
} catch (e, s) {
@ -161,10 +160,10 @@ class LocalizationService {
ptText: 'Dispositivo desvinculado com sucesso',
);
await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) {
await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async {
if (value.jsonBody['error'] == false) {
StorageUtil().cliName = '';
StorageUtil().cliUUID = '';
await StorageHelper.instance.set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
context.pop();
context.go(
'/homePage',
@ -200,21 +199,19 @@ class LocalizationService {
static void _handleError(BuildContext context, String errorMsg) {
AuthenticationService.signOut(context);
DialogUtil.error(context, errorMsg);
LogUtil.requestAPIFailed('getLocals.php', '{devUUID: ${StorageUtil().devUUID}, cliUUID: ${StorageUtil().userUUID}}',
'Get Locals', errorMsg, StackTrace.current);
}
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
log('() => isUnavailable');
try {
StorageUtil().cliUUID = locals[0]['CLI_ID'];
StorageUtil().ownerUUID = locals[0]['CLU_OWNER_ID'];
StorageUtil().cliName = locals[0]['CLI_NOME'];
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, locals[0]['CLI_ID'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.clientName.value, locals[0]['CLI_NOME'], Storage.SQLiteStorage);
var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A');
if (response.jsonBody['error'] == true) {
StorageUtil().cliUUID = '';
StorageUtil().cliName = '';
StorageUtil().ownerUUID = '';
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage);
return false;
}
if (response.jsonBody['error'] == false) return await processData(context).then((value) => value);
@ -228,10 +225,10 @@ class LocalizationService {
static Future<bool> _handleEnabled(BuildContext context, dynamic local) async {
log('() => isEnabled');
StorageUtil().cliName = local['CLI_NOME'];
StorageUtil().userName = local['USU_NOME'];
StorageUtil().cliUUID = local['CLI_ID'];
StorageUtil().ownerUUID = local['CLU_OWNER_ID'];
await StorageHelper.instance.set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.userName.value, local['USU_NOME'], Storage.SQLiteStorage);
return await processData(context);
}
@ -246,32 +243,39 @@ class LocalizationService {
return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty;
}
static bool _isInactived(List<dynamic> locals) {
return locals.where((local) => local['CLI_ID'] != StorageUtil().cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty;
static Future<bool> _isInactived(List<dynamic> locals) async {
String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty;
}
static bool _isPending(List<dynamic> locals) {
return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty;
}
static bool _isUnselected() {
return StorageUtil().cliUUID.isEmpty && StorageUtil().cliName.isEmpty && StorageUtil().ownerUUID.isEmpty;
static Future<bool> _isUnselected() async {
String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
String cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
String ownerUUID = (await StorageHelper.instance.get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? '';
return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty;
}
static bool _isSelected(bool isInactived) {
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty && isInactived;
static Future<bool> _isSelected(bool isInactived) async {
String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
String cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived;
}
static bool _isAvailable() {
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty;
static Future<bool> _isAvailable() async {
String cliUUID = (await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
String cliName = (await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
return cliUUID.isNotEmpty && cliName.isNotEmpty;
}
static void _updateStorageUtil(Map<String, dynamic> jsonBody) {
StorageUtil().whatsapp = jsonBody['whatsapp'] ?? false;
StorageUtil().provisional = jsonBody['provisional'] ?? false;
StorageUtil().pets = jsonBody['pet'] ?? false;
StorageUtil().petAmountRegister =
jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString();
StorageUtil().userName = jsonBody['visitado']['VDO_NOME'];
static Future<void> _updateStorageUtil(Map<String, dynamic> jsonBody) async {
await StorageHelper.instance.set(SQLiteStorageKey.whatsapp.value, jsonBody['whatsapp'] ? 'true' : 'false', Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.provisional.value, jsonBody['provisional'] ? 'true' : 'false', Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.pets.value, jsonBody['pet'] ? 'true' : 'false', Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.petAmount.value, jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString(), Storage.SQLiteStorage);
await StorageHelper.instance.set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage);
}
}

View File

@ -1,34 +0,0 @@
class CacheUtil {
static final CacheUtil _instance = CacheUtil._internal();
static final Map<String, dynamic> _cache = {};
CacheUtil._internal();
factory CacheUtil() => _instance;
static CacheUtil get instance => _instance;
void set(String key, dynamic value) {
_cache[key] = value;
}
dynamic get(String key) {
return _cache[key];
}
bool containsKey(String key) {
return _cache.containsKey(key);
}
dynamic getOrElse(String key, dynamic fallback) {
return _cache.containsKey(key) ? _cache[key] : fallback;
}
void delete(String key) {
_cache.remove(key);
}
void clear() {
_cache.clear();
}
}

View File

@ -1,10 +1,11 @@
import 'package:hub/shared/utils/storage_util.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:share_plus/share_plus.dart';
class ShareUtil {
static Future<void> showShare(payload) async {
final cliName = StorageUtil().cliName;
final cliUUID = StorageUtil().cliUUID;
final cliName = await StorageHelper.instance.get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage);
final cliUUID = await StorageHelper.instance.get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage);
for (var i = 0; i < payload['convites'].length; i++) {
await Share.share('''

View File

@ -1,439 +0,0 @@
import 'dart:developer';
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/shared_preferences_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/cache_util.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart';
import 'package:shared_preferences/shared_preferences.dart';
enum StorageType { secureStorage, sharedPreferences, dbSQLite3 }
abstract class Storage {
Future<void> set(String key, dynamic value, Function(dynamic) cacheSetter);
Future<dynamic> get(String key);
Future<void> delete(String key);
Future<void> purge();
}
class StorageData {
final String key;
final dynamic value;
final StorageType type;
StorageData(this.key, this.value, this.type);
}
class StorageUtil {
static final StorageUtil _instance = StorageUtil._internal();
factory StorageUtil() {
return _instance;
}
StorageUtil._internal();
late final SQLiteStorageHelper _sqliteStorage;
late final SecureStorageHelper _secureStorage;
late final SharedPreferencesStorageHelper _sharedPreferences;
bool _initialized = true;
static Future<void> set(StorageData data) async {
try {
var currentValue = CacheUtil().get(data.key);
if (currentValue != null && currentValue == data.value) {
log('Value for key ${data.key} is already set to ${data.value}, skipping update.');
return;
}
switch (data.type) {
case StorageType.secureStorage:
await SecureStorageHelper().set(data.key, data.value, (v) {});
break;
case StorageType.sharedPreferences:
await SharedPreferencesStorageHelper().set(data.key, data.value, (v) {});
break;
case StorageType.dbSQLite3:
await SQLiteStorageHelper().set(data.key, data.value, (v) {});
break;
}
CacheUtil().set(data.key, data.value);
} catch (e) {
log('Error setting data: $e');
}
}
static Future<dynamic> get(StorageData data) async {
try {
var value = CacheUtil().get(data.key);
if (value == null) {
switch (data.type) {
case StorageType.secureStorage:
value = await SecureStorageHelper().get(data.key);
break;
case StorageType.sharedPreferences:
value = await SharedPreferencesStorageHelper().get(data.key);
break;
case StorageType.dbSQLite3:
value = await SQLiteStorageHelper().get(data.key);
break;
}
CacheUtil().set(data.key, value);
}
return value;
} catch (e) {
log('Error getting data: $e');
return null;
}
}
static Future<void> delete(StorageData data) async {
try {
CacheUtil().delete(data.key);
switch (data.type) {
case StorageType.secureStorage:
await SecureStorageHelper().delete(data.key);
break;
case StorageType.sharedPreferences:
await SharedPreferencesStorageHelper().delete(data.key);
break;
case StorageType.dbSQLite3:
await SQLiteStorageHelper().delete(data.key);
break;
}
} catch (e) {
log('Error deleting data: $e');
}
}
static Future<void> purge() async {
try {
await SecureStorageHelper().purge();
await SQLiteStorageHelper().purge();
// await SharedPreferencesStorageHelper().purge();
} catch (e) {
log('Error purging data: $e');
}
}
Future<bool> ensureInitialization() async {
try {
log('StorageUtil: Starting initialization');
if (!_initialized) return true;
await initSharedPreferences();
await initSecureStorage();
await initSQLiteStorage();
if (_initialized) _initialized = false;
if (_initialized) return true;
return false;
} catch (e, s) {
log('Error initializing storage: $e');
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'StorageUtil', e, s);
return false;
}
}
Future<void> initSharedPreferences() async {
try {
if (_initialized) _sharedPreferences = SharedPreferencesStorageHelper();
_sharedPreferences.prefs ??= await SharedPreferences.getInstance();
final bool milestone = _sharedPreferences.prefs?.getBool('fre_isFirstRun') ?? true;
if (milestone) {
isFirstRun = false;
await _sharedPreferences.prefs?.setBool('fre_isFirstRun', false);
isLogged = false;
final String message = '';
// _secureStorage.purge();
// _sqliteStorage.purge();
}
} catch (e, s) {
log('SharedPreferencesStorageHelper: Error during initialization');
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'SharedPreferencesStorageHelper', e, s);
}
}
Future<void> initSecureStorage() async {
log('SecureStorageHelper: Starting initialization');
try {
if (_initialized) _secureStorage = SecureStorageHelper();
_email = await _secureStorage.getString('fre_email');
_passwd = await _secureStorage.getString('fre_passwd');
_deviceType = await _secureStorage.getString('fre_deviceType');
_isLogged = await _secureStorage.getBool('fre_isLogged') ?? false;
_tokenAPNS = await _secureStorage.getString('fre_tokenAPNS');
_accessPass = await _secureStorage.getString('fre_accessPass');
_panicPass = await _secureStorage.getString('fre_panicPass');
_fingerprintPass = await _secureStorage.getString('fre_fingerprintPass');
_haveLocal = await _secureStorage.getBool('fre_have_local') ?? false;
_deviceDescription = await _secureStorage.getString('fre_deviceDescription');
} catch (e, s) {
log('SecureStorageHelper: Error during initialization: $e');
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'SecureStorageHelper', e, s);
}
log('SecureStorageHelper: Initialization complete');
}
Future<void> initSQLiteStorage() async {
log('SQLiteStorageHelper: Starting initialization');
try {
if (_initialized) _sqliteStorage = SQLiteStorageHelper();
await _sqliteStorage.database;
_devUUID = await _sqliteStorage.get('fre_devUUID') ?? '';
_userUUID = await _sqliteStorage.get('fre_userUUID') ?? '';
_userDevUUID = await _sqliteStorage.get('fre_userDevUUID') ?? '';
_status = await _sqliteStorage.get('fre_status') ?? '';
_userName = await _sqliteStorage.get('fre_userName') ?? '';
_cliUUID = await _sqliteStorage.get('fre_cliUUID') ?? '';
_ownerUUID = await _sqliteStorage.get('fre_ownerUUID') ?? '';
_cliName = await _sqliteStorage.get('fre_cliName') ?? '';
_petAmountRegister = await _sqliteStorage.get('fre_petAmountRegister') ?? '';
_whatsapp = await _sqliteStorage.getBoolean('fre_whatsapp');
_provisional = await _sqliteStorage.getBoolean('fre_provisional');
_pets = await _sqliteStorage.getBoolean('fre_pets');
_local = await _sqliteStorage.getBoolean('fre_local');
_notify = await _sqliteStorage.getBoolean('fre_notify');
_fingerprint = await _sqliteStorage.getBoolean('fre_fingerprint');
_access = await _sqliteStorage.getBoolean('fre_access');
_panic = await _sqliteStorage.getBoolean('fre_panic');
_person = await _sqliteStorage.getBoolean('fre_person');
_requestOSnotification = await _sqliteStorage.getBoolean('fre_requestOSnotification');
} catch (e, s) {
log('SQLiteStorageHelper: Error during initialization: $e');
LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'SQLiteStorageHelper', e, s);
}
log('SQLiteStorageHelper: Initialization complete');
}
bool _isRecovered = false;
bool get isRecovered => _isRecovered;
set isRecovered(bool value) => _isRecovered = value;
bool _isFirstRun = true;
bool get isFirstRun => _isFirstRun;
set isFirstRun(bool value) {
_isFirstRun = value;
_sharedPreferences.set('fre_isFirstRun', value, (v) => _isFirstRun = v);
}
String? _deviceDescription;
String get deviceDescription => _deviceDescription ?? '';
set deviceDescription(String value) {
_deviceDescription = value;
_secureStorage.set('fre_deviceDescription', value, (v) => _deviceDescription = v);
}
BuildContext? _context;
BuildContext? get context => _context;
set context(BuildContext? value) {
_context = value;
_secureStorage.set('fre_context', value.toString(), (v) => _context = value);
}
bool _haveLocal = false;
bool get haveLocal => _haveLocal;
set haveLocal(bool value) {
_haveLocal = value;
_secureStorage.set('fre_have_local', value ?? false, (v) => _haveLocal = value);
}
String? _fingerprintPass;
String get fingerprintPass => _fingerprintPass ?? '';
set fingerprintPass(String value) {
_fingerprintPass = value;
_secureStorage.set('fre_fingerprintPass', value, (v) => _fingerprintPass = v);
}
String? _accessPass;
String get accessPass => _accessPass ?? '';
set accessPass(String value) {
_accessPass = value;
_secureStorage.set('fre_accessPass', value, (v) => _accessPass = v);
}
String? _panicPass;
String get panicPass => _panicPass ?? '';
set panicPass(String value) {
_panicPass = value;
_secureStorage.set('fre_panicPass', value, (v) => _panicPass = v);
}
String? _tokenAPNS;
String? get tokenAPNS => _tokenAPNS;
set tokenAPNS(String? value) {
_tokenAPNS = value;
_secureStorage.set('fre_tokenAPNS', value ?? '', (v) => _tokenAPNS = v);
}
String? _email;
String get email => _email ?? '';
set email(String value) {
_email = value;
_secureStorage.set('fre_email', value, (v) => _email = v);
}
String? _passwd;
String get passwd => _passwd ?? '';
set passwd(String value) {
_passwd = value;
_secureStorage.set('fre_passwd', value, (v) => _passwd = v);
}
String? _deviceType;
String get deviceType => _deviceType ?? '';
set deviceType(String value) {
_deviceType = value;
_secureStorage.set('fre_deviceType', value, (v) => _deviceType = v);
}
bool _isLogged = false;
bool get isLogged => _isLogged;
set isLogged(bool value) {
_isLogged = value;
_secureStorage.set('fre_isLogged', value, (v) => _isLogged = v);
}
String? _token;
String get token => _token ?? '';
set token(String value) {
_token = value;
_secureStorage.set('fre_token', value, (v) => _token = v);
}
String _devUUID = '';
String get devUUID => _devUUID;
set devUUID(String value) {
_devUUID = value;
_sqliteStorage.set('fre_devUUID', value, (v) {});
}
String _userUUID = '';
String get userUUID => _userUUID;
set userUUID(String value) {
_userUUID = value;
_sqliteStorage.set('fre_userUUID', value, (v) {});
}
String _userDevUUID = '';
String get userDevUUID => _userDevUUID;
set userDevUUID(String value) {
_userDevUUID = value;
_sqliteStorage.set('fre_userDevUUID', value, (v) {});
}
String _status = '';
String get status => _status;
set status(String value) {
_status = value;
_sqliteStorage.set('fre_status', value, (v) {});
}
String _userName = '';
String get userName => _userName;
set userName(String value) {
_userName = value;
_sqliteStorage.set('fre_userName', value, (v) {});
}
String _cliUUID = '';
String get cliUUID => _cliUUID;
set cliUUID(String value) {
_cliUUID = value;
_sqliteStorage.set('fre_cliUUID', value, (v) {});
}
String _ownerUUID = '';
String get ownerUUID => _ownerUUID;
set ownerUUID(String value) {
_ownerUUID = value;
_sqliteStorage.set('fre_ownerUUID', value, (v) {});
}
String _cliName = '';
String get cliName => _cliName;
set cliName(String value) {
_cliName = value;
_sqliteStorage.set('fre_cliName', value, (v) {});
}
String _petAmountRegister = '';
String get petAmountRegister => _petAmountRegister;
set petAmountRegister(String value) {
_petAmountRegister = value;
_sqliteStorage.set('fre_petAmountRegister', value, (v) {});
}
bool _whatsapp = false;
bool get whatsapp => _whatsapp;
set whatsapp(bool value) {
_whatsapp = value;
_sqliteStorage.set('fre_whatsapp', value, (v) {});
}
bool _provisional = false;
bool get provisional => _provisional;
set provisional(bool value) {
_provisional = value;
_sqliteStorage.set('fre_provisional', value, (v) {});
}
bool _pets = false;
bool get pets => _pets;
set pets(bool value) {
_pets = value;
_sqliteStorage.set('fre_pets', value, (v) {});
}
bool _local = false;
bool get local => _local;
set local(bool value) {
_local = value;
_sqliteStorage.set('fre_local', value, (v) {});
}
bool _notify = false;
bool get notify => _notify;
set notify(bool value) {
_notify = value;
_sqliteStorage.set('fre_notify', value, (v) {});
}
bool _fingerprint = false;
bool get fingerprint => _fingerprint;
set fingerprint(bool value) {
_fingerprint = value;
_sqliteStorage.set('fre_fingerprint', value, (v) {});
}
bool _access = false;
bool get access => _access;
set access(bool value) {
_access = value;
_sqliteStorage.set('fre_access', value, (v) {});
}
bool _panic = false;
bool get panic => _panic;
set panic(bool value) {
_panic = value;
_sqliteStorage.set('fre_panic', value, (v) {});
}
bool _person = false;
bool get person => _person;
set person(bool value) {
_person = value;
_sqliteStorage.set('fre_person', value, (v) {});
}
bool _requestOSnotification = false;
bool get requestOSnotification => _requestOSnotification;
set requestOSnotification(bool value) {
_requestOSnotification = value;
_sqliteStorage.set('fre_requestOSnotification', value, (v) {});
}
String get createdAt => '0000-00-00 00:00:00';
}

View File

@ -12,7 +12,7 @@
// import 'package:crop_your_image/crop_your_image.dart';
// import 'package:google_fonts/google_fonts.dart';
// import '/backend/firebase_storage/storage.dart';
// import '/backend/firebase_storage/base_storage.dart';
// /////////////////