This commit is contained in:
J. A. Messias 2024-11-06 14:08:33 -03:00
commit 3f674541ad
66 changed files with 1494 additions and 1541 deletions

View File

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

View File

@ -3,7 +3,8 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:hub/flutter_flow/random_data_util.dart'; import 'package:hub/flutter_flow/random_data_util.dart';
import 'package:hub/main.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'; import 'package:integration_test/integration_test.dart';
late WidgetTester widget; late WidgetTester widget;
@ -13,7 +14,8 @@ void main() {
group('Initialization', () { group('Initialization', () {
group('Navigation', () { group('Navigation', () {
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); setUpAll(() async => await initializeApp().then(
(_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
testWidgets('Test Welcome', (WidgetTester tester) async { testWidgets('Test Welcome', (WidgetTester tester) async {
widget = tester; widget = tester;
await _testWelcome(); await _testWelcome();
@ -24,14 +26,16 @@ void main() {
}); });
group('Authentication', () { group('Authentication', () {
group('Sign in', () { group('Sign in', () {
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); setUpAll(() async => await initializeApp().then(
(_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
testWidgets('Test Sign In', (WidgetTester tester) async { testWidgets('Test Sign In', (WidgetTester tester) async {
widget = tester; widget = tester;
await _testSignIn(); await _testSignIn();
}); });
}); });
group('Sign up', () { group('Sign up', () {
setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); setUpAll(() async => await initializeApp().then(
(_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage)));
testWidgets('Test Sign Up', (WidgetTester tester) async { testWidgets('Test Sign Up', (WidgetTester tester) async {
widget = tester; widget = tester;
await _testSignUp(); await _testSignUp();

View File

@ -3,7 +3,8 @@ import 'dart:convert';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:hub/backend/notifications/firebase_messaging_service.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 'package:hub/shared/utils/validator_util.dart';
import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_util.dart';
@ -60,9 +61,12 @@ class PhpGroup {
class GetOpenedVisits { class GetOpenedVisits {
Future<ApiCallResponse> call(final String page) async { Future<ApiCallResponse> call(final String page) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getOpenedVisits'; const String atividade = 'getOpenedVisits';
const String pageSize = '10'; const String pageSize = '10';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -92,9 +96,12 @@ class GetOpenedVisits {
class GetResidentsByProperty { class GetResidentsByProperty {
Future<ApiCallResponse> call(final String page) async { Future<ApiCallResponse> call(final String page) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getResidentsByProperty'; const String atividade = 'getResidentsByProperty';
const String pageSize = '10'; const String pageSize = '10';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -123,9 +130,12 @@ class GetResidentsByProperty {
class GetVehiclesByProperty { class GetVehiclesByProperty {
Future<ApiCallResponse> call(final String page) async { Future<ApiCallResponse> call(final String page) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getVehiclesByProperty'; const String atividade = 'getVehiclesByProperty';
const String pageSize = '10'; const String pageSize = '10';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -154,8 +164,10 @@ class GetVehiclesByProperty {
class UnregisterDevice { class UnregisterDevice {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
callName: 'unregisterDevice', callName: 'unregisterDevice',
@ -182,9 +194,12 @@ class UnregisterDevice {
class DeletePet { class DeletePet {
Future<ApiCallResponse> call({final int? petID = 0}) async { Future<ApiCallResponse> call({final int? petID = 0}) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'excluirPet'; const String atividade = 'excluirPet';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -227,9 +242,9 @@ class UpdatePet {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = StorageUtil().userUUID; final String userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String cliID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'atualizarPet'; const String atividade = 'atualizarPet';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -273,9 +288,12 @@ class GetPets {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'consultaPets'; const String atividade = 'consultaPets';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -307,9 +325,12 @@ class GetPetPhoto {
Future<ApiCallResponse> call({final int? petId}) async { Future<ApiCallResponse> call({final int? petId}) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'consultaFotoPet'; const String atividade = 'consultaFotoPet';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -350,9 +371,12 @@ class RegisterPet {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'cadastrarPet'; const String atividade = 'cadastrarPet';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -395,9 +419,12 @@ class BuscaEnconcomendas {
final String? adresseeType, final String? adresseeType,
final String? status, final String? status,
}) async { }) async {
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getEncomendas'; const String atividade = 'getEncomendas';
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
@ -439,9 +466,12 @@ class CancelaVisita {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'cancelaVisita'; const String atividade = 'cancelaVisita';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -473,8 +503,10 @@ class CancelaVisita {
class DeleteAccount { class DeleteAccount {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -505,9 +537,12 @@ class ChangePanic {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'updVisitado'; const String atividade = 'updVisitado';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -541,9 +576,12 @@ class ChangePass {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'updVisitado'; const String atividade = 'updVisitado';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -577,9 +615,12 @@ class RespondeVinculo {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
callName: 'respondeVinculo', callName: 'respondeVinculo',
@ -611,9 +652,12 @@ class ChangeNotifica {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'updVisitado'; const String atividade = 'updVisitado';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -645,10 +689,14 @@ class UpdateIDE {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
final String newIde = StorageUtil().userDevUUID; (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
final String newIde =
(await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'updVisitado'; const String atividade = 'updVisitado';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -661,7 +709,7 @@ class UpdateIDE {
params: { params: {
'devUUID': devUUID, 'devUUID': devUUID,
'userUUID': userUUID, 'userUUID': userUUID,
'cliID': cliID, 'cliID': cliUUID,
'atividade': atividade, 'atividade': atividade,
'newIde': newIde, 'newIde': newIde,
}, },
@ -680,9 +728,11 @@ class UpdToken {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String token = StorageUtil().token; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String token = (await StorageHelper().get(SecureStorageKey.token.value, Storage.SecureStorage)) ?? '';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
callName: 'updToken', callName: 'updToken',
@ -709,11 +759,15 @@ class UpdToken {
class LoginCall { class LoginCall {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String email = StorageUtil().email; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String password = StorageUtil().passwd; final String email = (await StorageHelper().get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? '';
final String type = StorageUtil().deviceType; final String password =
final String description = StorageUtil().deviceDescription; (await StorageHelper().get(SecureStorageKey.password.value, Storage.SecureStorage)) ?? '';
final String type =
(await StorageHelper().get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? '';
final String description =
(await StorageHelper().get(SecureStorageKey.deviceDescription.value, Storage.SecureStorage)) ?? '';
final String token = await FirebaseMessagingService.getToken(); final String token = await FirebaseMessagingService.getToken();
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -788,9 +842,12 @@ class ChangePasswordCall {
required final String psswd, required final String psswd,
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
callName: 'changePassword', callName: 'changePassword',
@ -849,8 +906,8 @@ class GetLocalsCall {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? '';
final String userUUID = StorageUtil().userUUID; final String userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? '';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
callName: 'getLocals', callName: 'getLocals',
@ -889,9 +946,12 @@ class PostScheduleVisitorCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'putVisitante'; const String atividade = 'putVisitante';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -944,9 +1004,12 @@ class PostScheduleVisitCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'putVisita'; const String atividade = 'putVisita';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -998,9 +1061,12 @@ class GetScheduleVisitCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getVisitas'; const String atividade = 'getVisitas';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -1272,9 +1338,12 @@ class GetDadosCall {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getDados'; const String atividade = 'getDados';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -1505,9 +1574,12 @@ class GetVisitorByDocCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getVisitante'; const String atividade = 'getVisitante';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -1559,9 +1631,12 @@ class GetFotoVisitanteCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getFotoVisitante'; const String atividade = 'getFotoVisitante';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -1598,9 +1673,12 @@ class PostProvVisitSchedulingCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'putAgendamentoProv'; const String atividade = 'putAgendamentoProv';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -1647,9 +1725,12 @@ class GetVisitsCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getVisitas'; const String atividade = 'getVisitas';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -1910,9 +1991,12 @@ class DeleteVisitCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'cancelaVisita'; const String atividade = 'cancelaVisita';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -1953,10 +2037,14 @@ class GetPessoasLocalCall {
Future<ApiCallResponse> call() async { Future<ApiCallResponse> call() async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String ownerUUID = StorageUtil().ownerUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID = StorageUtil().userUUID; final String ownerUUID =
final String cliUUID = StorageUtil().cliUUID; (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? '';
final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
callName: 'getPessoasLocal', callName: 'getPessoasLocal',
@ -2019,9 +2107,12 @@ class RespondeSolicitacaoCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'respondeSolicitacao'; const String atividade = 'respondeSolicitacao';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -2069,9 +2160,12 @@ class GetAccessCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getAcessos'; const String atividade = 'getAcessos';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(
@ -2318,9 +2412,12 @@ class GetLiberationsCall {
final StreamController<ApiCallResponse> controller = StreamController(); final StreamController<ApiCallResponse> controller = StreamController();
Future.microtask(() async { Future.microtask(() async {
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getSolicitacoes'; const String atividade = 'getSolicitacoes';
try { try {
@ -2510,9 +2607,12 @@ class GetMessagesCall {
}) async { }) async {
final String baseUrl = PhpGroup.getBaseUrl(); final String baseUrl = PhpGroup.getBaseUrl();
final String devUUID = StorageUtil().devUUID; final String devUUID =
final String userUUID = StorageUtil().userUUID; (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID = StorageUtil().cliUUID; final String userUUID =
(await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final String cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
const String atividade = 'getMensagens'; const String atividade = 'getMensagens';
return ApiManager.instance.makeApiCall( return ApiManager.instance.makeApiCall(

View File

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

View File

@ -2,8 +2,9 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; import 'package:hub/components/molecular_components/menu_item/menu_item.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/shared/extensions/dialog_extensions.dart';
import 'package:hub/shared/services/localization/localization_service.dart'; import '../../../shared/extensions/dialog_extensions.dart';
import '../../../shared/services/localization/localization_service.dart';
class MenuButtonWidget extends MenuEntry { class MenuButtonWidget extends MenuEntry {
const MenuButtonWidget({ const MenuButtonWidget({

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_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
// ignore: unused_import // ignore: unused_import
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/utils/storage_util.dart';
class OrderFilterModalWidget extends StatefulWidget { class OrderFilterModalWidget extends StatefulWidget {
final String defaultAdresseeType; final String defaultAdresseeType;
@ -28,22 +27,25 @@ class _OrderFilterModalWidgetState extends State<OrderFilterModalWidget> {
late Map<String, dynamic> selected; late Map<String, dynamic> selected;
final List<Map<String, String>> adresseeTypeOptions = [ final List<Map<String, String>> adresseeTypeOptions = [
{ {
'title': FFLocalizations.of(StorageUtil().context!).getVariableText(enText: 'Resident', ptText: 'Morador'), 'title':
FFLocalizations.of(StorageHelper().context!).getVariableText(enText: 'Resident', ptText: 'Morador'),
'value': 'MOR' 'value': 'MOR'
}, },
{ {
'title': FFLocalizations.of(StorageUtil().context!).getVariableText(enText: 'Property', ptText: 'Propriedade'), 'title': FFLocalizations.of(StorageHelper().context!)
.getVariableText(enText: 'Property', ptText: 'Propriedade'),
'value': 'PRO' 'value': 'PRO'
}, },
]; ];
final List<Map<String, String>> statusOptions = [ final List<Map<String, String>> statusOptions = [
{ {
'title': FFLocalizations.of(StorageUtil().context!) 'title': FFLocalizations.of(StorageHelper().context!)
.getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'), .getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'),
'value': 'notPickedUp' 'value': 'notPickedUp'
}, },
{ {
'title': FFLocalizations.of(StorageUtil().context!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'), 'title':
FFLocalizations.of(StorageHelper().context!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'),
'value': 'pickedUp' '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/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/flutter_flow_util.dart';
import 'package:hub/flutter_flow/nav/nav.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/dialog_util.dart';
import 'package:hub/shared/utils/log_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 '../../../shared/services/authentication/authentication_service.dart';
import '/backend/api_requests/api_calls.dart'; import '/backend/api_requests/api_calls.dart';
@ -94,9 +95,11 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
} }
if (isEnabled) { if (isEnabled) {
final local = locals[0]; final local = locals[0];
StorageUtil().cliName = local['CLI_NOME'];
StorageUtil().cliUUID = local['CLI_ID']; await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage);
StorageUtil().ownerUUID = local['CLU_OWNER_ID']; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage);
await StorageHelper()
.set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
context.pop(); context.pop();
return response; return response;
@ -123,13 +126,11 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
static void _handleError(BuildContext context, String errorMsg) { static void _handleError(BuildContext context, String errorMsg) {
AuthenticationService.signOut(context); AuthenticationService.signOut(context);
DialogUtil.error(context, errorMsg); 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 { Future<dynamic> _fetchResponseLink(String status, String cliID) async {
try { try {
StorageUtil().cliUUID = cliID; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, cliID, Storage.SQLiteStorage);
var response = await PhpGroup.resopndeVinculo.call(tarefa: status); var response = await PhpGroup.resopndeVinculo.call(tarefa: status);
if (response.jsonBody['error'] == false) { if (response.jsonBody['error'] == false) {
@ -139,7 +140,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
.getVariableText(ptText: "Vínculo Ativado com Sucesso", enText: "Link Activated Successfully") .getVariableText(ptText: "Vínculo Ativado com Sucesso", enText: "Link Activated Successfully")
}; };
} else { } else {
StorageUtil().cliUUID = ''; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
return response.jsonBody; return response.jsonBody;
} }
} catch (e, s) { } catch (e, s) {
@ -187,9 +188,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
statusHashMap: [_statusHashMap(local)], statusHashMap: [_statusHashMap(local)],
onTapCardItemAction: () async { onTapCardItemAction: () async {
if (local['CLU_STATUS'] == 'A') { if (local['CLU_STATUS'] == 'A') {
StorageUtil().cliUUID = local['CLI_ID']; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage);
StorageUtil().cliName = local['CLI_NOME']; await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage);
StorageUtil().ownerUUID = local['CLU_OWNER_ID']; await StorageHelper()
.set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
context.pop(); context.pop();
} else if (local['CLU_STATUS'] == 'B') { } 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 '/flutter_flow/flutter_flow_util.dart';
import 'local_profile_component_widget.dart' show LocalProfileComponentWidget; import 'local_profile_component_widget.dart' show LocalProfileComponentWidget;
@ -17,8 +18,9 @@ class LocalProfileComponentModel extends FlutterFlowModel<LocalProfileComponentW
} }
Future<void> getData() async { Future<void> getData() async {
cliName = StorageUtil().cliName; cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
;
setStateCallback?.call(); setStateCallback?.call();
} }

View File

@ -10,10 +10,16 @@ import 'package:hub/components/organism_components/menu_staggered_view_component
import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/extensions/dialog_extensions.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/services/authentication/authentication_service.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.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';
import 'menu_component_widget.dart' show MenuComponentWidget;
class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> { class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
final MenuView style; final MenuView style;
final MenuItem item; final MenuItem item;
@ -76,7 +82,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}); });
if (options.contains(MenuOption.WorkersOnTheProperty)) if (options.contains(MenuOption.WorkersOnTheProperty))
addMenuEntry(Icons.engineering_outlined, 'Schedule Providers', 'Agendar Prestadores', () async { addMenuEntry(Icons.engineering_outlined, 'Schedule Providers', 'Agendar Prestadores', () async {
if (StorageUtil().provisional) if (await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true')
await open(context, '/provisionalSchedule'); await open(context, '/provisionalSchedule');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -84,7 +90,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}); });
if (options.contains(MenuOption.DeliverySchedule)) if (options.contains(MenuOption.DeliverySchedule))
addMenuEntry(Icons.sports_motorsports_outlined, 'Schedule Deliveries', 'Agendar Entregas', () async { addMenuEntry(Icons.sports_motorsports_outlined, 'Schedule Deliveries', 'Agendar Entregas', () async {
if (StorageUtil().provisional) if (await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true')
await open(context, '/deliverySchedule'); await open(context, '/deliverySchedule');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -92,7 +98,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}); });
if (options.contains(MenuOption.FastPassSchedule)) if (options.contains(MenuOption.FastPassSchedule))
addMenuEntry(Icons.attach_email_outlined, 'Invite Visitor', 'Convidar Visitante', () async { addMenuEntry(Icons.attach_email_outlined, 'Invite Visitor', 'Convidar Visitante', () async {
if (StorageUtil().whatsapp) if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true')
await open(context, '/fastPassPage'); await open(context, '/fastPassPage');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -107,7 +113,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
/// ABOUT THE PROPERTY /// ABOUT THE PROPERTY
if (options.contains(MenuOption.AboutProperty)) if (options.contains(MenuOption.AboutProperty))
addMenuEntry(Icons.home, 'About Property', 'Sobre a Propriedade', () async { addMenuEntry(Icons.home, 'About Property', 'Sobre a Propriedade', () async {
if (StorageUtil().whatsapp) if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true')
await open(context, '/aboutProperty'); await open(context, '/aboutProperty');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -115,7 +121,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}); });
if (options.contains(MenuOption.PetsOnTheProperty)) if (options.contains(MenuOption.PetsOnTheProperty))
addMenuEntry(Icons.pets, 'My Pets', 'Meus Pets', () async { addMenuEntry(Icons.pets, 'My Pets', 'Meus Pets', () async {
if (StorageUtil().pets) if (await StorageHelper().get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == 'true')
await open(context, '/petsOnThePropertyPage'); await open(context, '/petsOnThePropertyPage');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -138,7 +144,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}); });
if (options.contains(MenuOption.PackagesOnTheProperty)) if (options.contains(MenuOption.PackagesOnTheProperty))
addMenuEntry(Icons.inventory_2_outlined, 'My Orders', 'Minhas Encomendas', () async { addMenuEntry(Icons.inventory_2_outlined, 'My Orders', 'Minhas Encomendas', () async {
if (StorageUtil().whatsapp) if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true')
await open(context, '/packageOrder'); await open(context, '/packageOrder');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -148,7 +154,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
/// ABOUT THE RESIDENTS /// ABOUT THE RESIDENTS
if (options.contains(MenuOption.PetsRegister)) if (options.contains(MenuOption.PetsRegister))
addMenuEntry(Icons.pets, 'Pets Register', 'Cadastrar Pet', () async { addMenuEntry(Icons.pets, 'Pets Register', 'Cadastrar Pet', () async {
if (StorageUtil().pets) if (await StorageHelper().get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == 'true')
await open(context, '/petsPage'); await open(context, '/petsPage');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -156,7 +162,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}); });
if (options.contains(MenuOption.ReservationsOnTheLocal)) if (options.contains(MenuOption.ReservationsOnTheLocal))
addMenuEntry(Icons.event_available, 'Reservations', 'Reservas', () async { addMenuEntry(Icons.event_available, 'Reservations', 'Reservas', () async {
if (StorageUtil().whatsapp) if (await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true')
await open(context, '/reservation'); await open(context, '/reservation');
else else
DialogUnavailable.unavailableFeature(context); DialogUnavailable.unavailableFeature(context);
@ -224,7 +230,62 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
showAlertDialog(context, title, content, () async => await AuthenticationService.signOut(context)); showAlertDialog(context, title, content, () async => await AuthenticationService.signOut(context));
} }
/// LEGACY FEATURES Future openDeliverySchedule(BuildContext context) async {
final bool isProvisional =
await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true';
if (isProvisional == true) {
context.push(
'/deliverySchedule',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
} else {
DialogUnavailable.unavailableFeature(context);
}
}
Future openProvisionalSchedule(BuildContext context) async {
final isProvisional =
await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == 'true';
if (isProvisional == true) {
context.push(
'/provisionalSchedule',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
} else {
DialogUnavailable.unavailableFeature(context);
}
}
Future openFastPassSchedule(BuildContext context) async {
final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true';
if (isWpp) {
context.push(
'/fastPassPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
} else {
DialogUnavailable.unavailableFeature(context);
}
}
Future showSchedules(BuildContext context) async { Future showSchedules(BuildContext context) async {
final routesListStr = <String>[ final routesListStr = <String>[
'scheduleProvisionalVisitPage', 'scheduleProvisionalVisitPage',
@ -265,6 +326,95 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
); );
} }
Future openVisitorsRegister(BuildContext context) async {
context.push(
'/registerVisitorPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}
Future openPoepleOnTheProperty(BuildContext context) async {
context.push(
'/peopleOnThePropertyPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}
Future<void> Logout(BuildContext context) async {
final String title = FFLocalizations.of(context).getVariableText(
ptText: 'Sair',
enText: 'Logout',
);
final String content = FFLocalizations.of(context).getVariableText(
ptText: 'Tem certeza que deseja sair?',
enText: 'Are you sure you want to logout?',
);
showAlertDialog(context, title, content, () async => await AuthenticationService.signOut(context));
}
Future openPreferencesSettings(BuildContext context) async {
context.push(
'/preferencesSettings',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}
Future openMyOrders(BuildContext context) async {
final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true';
;
if (isWpp) {
context.push(
'/packageOrder',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
} else {
DialogUnavailable.unavailableFeature(context);
}
}
Future openReservations(BuildContext context) async {
final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == 'true';
;
if (isWpp) {
context.push(
'/reservation',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
} else {
DialogUnavailable.unavailableFeature(context);
}
}
Future showHistories(BuildContext context) async { Future showHistories(BuildContext context) async {
await showAdaptiveDialog( await showAdaptiveDialog(
// isScrollControlled: true, // isScrollControlled: true,
@ -310,4 +460,75 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}, },
); );
} }
Future openLiberationsHistory(BuildContext context) async {
context.push(
'/liberationHistory',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}
Future openAccessHistory(BuildContext context) async {
context.push(
'/acessHistoryPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}
Future openVisitsHistory(BuildContext context) async {
context.push(
'/scheduleCompleteVisitPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}
Future openMessagesHistory(BuildContext context) async {
context.push(
'/messageHistoryPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
}
Future openPetsRegister(BuildContext context) async {
bool isPet = await StorageHelper().get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == 'true';
;
if (isPet) {
context.push(
'/petsPage',
extra: <String, dynamic>{
kTransitionInfoKey: const TransitionInfo(
hasTransition: true,
transitionType: PageTransitionType.scale,
alignment: Alignment.bottomCenter,
),
},
);
} else {
DialogUnavailable.unavailableFeature(context);
}
}
} }

View File

@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
import 'package:hub/backend/api_requests/api_manager.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/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_model.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 // 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'; import 'package:intl/intl.dart';
class ScheduleVisitDetailModel extends FlutterFlowModel<ScheduleVisitDetailWidget> { class ScheduleVisitDetailModel extends FlutterFlowModel<ScheduleVisitDetailWidget> {
@ -56,9 +56,9 @@ class ScheduleVisitDetailModel extends FlutterFlowModel<ScheduleVisitDetailWidge
} }
Future<void> initDB() async { Future<void> initDB() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
} }
@override @override

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,8 @@ import 'package:flutter/material.dart';
import 'package:hub/backend/api_requests/api_manager.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/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_util.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> { class ScheduleProvisionalVisitPageModel extends FlutterFlowModel<ScheduleProvisionalVisitPageWidget> {
String cliUUID = ''; String cliUUID = '';
@ -137,11 +138,12 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel<ScheduleProvisi
} }
Future<void> init() async { Future<void> init() async {
cliUUID = StorageUtil().cliUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
devUUID = StorageUtil().devUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
cliName = StorageUtil().cliName; ;
ownerUUID = StorageUtil().ownerUUID; cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
ownerUUID = (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? '';
setState?.call(); setState?.call();
} }
} }

View File

@ -1,5 +1,3 @@
import 'dart:developer';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:easy_debounce/easy_debounce.dart'; import 'package:easy_debounce/easy_debounce.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -582,7 +580,9 @@ class _ScheduleProvisionalVisitPageWidgetState extends State<ScheduleProvisional
: () async { : () async {
try { try {
model.provVisitSchedule = await PhpGroup.postProvVisitSchedulingCall.call( model.provVisitSchedule = await PhpGroup.postProvVisitSchedulingCall.call(
data: DateFormat('dd/MM/yyyy HH:mm:ss').format(DateFormat('dd/MM/yyyy HH:mm:ss').parse(model.dateTimeTextController.text).add(const Duration(hours: 3))), data: DateFormat('dd/MM/yyyy HH:mm:ss').format(DateFormat('dd/MM/yyyy HH:mm:ss')
.parse(model.dateTimeTextController.text)
.add(const Duration(hours: 3))),
motivo: model.notesTextController.text, motivo: model.notesTextController.text,
nome: model.personNameTextController.text, nome: model.personNameTextController.text,
proID: model.ownerUUID, proID: model.ownerUUID,
@ -612,7 +612,8 @@ class _ScheduleProvisionalVisitPageWidgetState extends State<ScheduleProvisional
setState(() {}); setState(() {});
} catch (e, s) { } catch (e, s) {
DialogUtil.errorDefault(context); DialogUtil.errorDefault(context);
LogUtil.requestAPIFailed("processRequest.php", "", "Cadastrar Visita Provisória", e, s); LogUtil.requestAPIFailed(
"processRequest.php", "", "Cadastrar Visita Provisória", e, s);
} }
}, },
showLoadingIndicator: true, showLoadingIndicator: true,

View File

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

View File

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

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; 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 '/backend/api_requests/api_calls.dart';
import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_util.dart';
@ -36,9 +37,10 @@ class ViewVisitDetailModel extends FlutterFlowModel<ViewVisitDetailWidget> {
} }
Future<void> initializeDatabase() async { Future<void> initializeDatabase() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
;
} }
@override @override

View File

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

View File

@ -353,12 +353,12 @@ class _VisitorSearchModalTemplateComponentWidgetState extends State<VisitorSearc
if (PhpGroup.getVisitorByDocCall.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != '0' && if (PhpGroup.getVisitorByDocCall.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != '0' &&
PhpGroup.getVisitorByDocCall.error((_model.getVisitorByDoc?.jsonBody ?? '')) == false && PhpGroup.getVisitorByDocCall.error((_model.getVisitorByDoc?.jsonBody ?? '')) == false &&
PhpGroup.getVisitorByDocCall.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != null) { PhpGroup.getVisitorByDocCall.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != null) {
String newDoc = _model.textController.text; String newDoc = _model.textController.text.replaceFirst(RegExp(r'^0+'), '');
bool existDoc = _model.docs.contains(newDoc); bool existDoc = _model.docs.contains(newDoc);
if (existDoc == false) { if (existDoc == false) {
_model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante((_model.getVisitorByDoc?.jsonBody ?? ''))); _model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante((_model.getVisitorByDoc?.jsonBody ?? '')));
safeSetState(() {}); safeSetState(() {});
_model.addToDocs(_model.textController.text); _model.addToDocs(_model.textController.text.replaceFirst(RegExp(r'^0+'), ''));
safeSetState(() {}); safeSetState(() {});
} else if (existDoc == true) { } else if (existDoc == true) {
ToastUtil.showToast( ToastUtil.showToast(

View File

@ -29,9 +29,9 @@ import 'package:hub/pages/sign_up_page/sign_up_page_widget.dart';
import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart';
import 'package:hub/pages/visits_on_the_property/visits_on_the_property_screen.dart'; import 'package:hub/pages/visits_on_the_property/visits_on_the_property_screen.dart';
import 'package:hub/pages/welcome_page/welcome_page_widget.dart'; import 'package:hub/pages/welcome_page/welcome_page_widget.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
export 'package:go_router/go_router.dart'; export 'package:go_router/go_router.dart';
@ -54,11 +54,6 @@ class AppStateNotifier extends ChangeNotifier {
} }
GoRouter createRouter(AppStateNotifier appStateNotifier) { 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;
return GoRouter( return GoRouter(
initialLocation: '/', initialLocation: '/',
@ -76,16 +71,38 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) {
name: '_initialize', name: '_initialize',
path: '/', path: '/',
builder: (context, _) { builder: (context, _) {
try { return FutureBuilder<Widget>(
return isLogged && haveDevUUID && haveUserUUID future: () async {
? haveLocal == true final bool isLogged =
? const HomePageWidget() await StorageHelper().get(SecureStorageKey.isLogged.value, Storage.SecureStorage) == 'true';
: const ReceptionPageWidget() final bool haveLocal =
: const WelcomePageWidget(); await StorageHelper().get(SecureStorageKey.haveLocal.value, Storage.SecureStorage) == 'true';
} catch (e) { final bool haveUserUUID =
DialogUtil.error(context, e.toString()); (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage))
?.isNotEmpty ??
false;
final bool haveDevUUID =
(await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage))
?.isNotEmpty ??
false;
if (isLogged && haveDevUUID && haveUserUUID) {
return haveLocal ? const HomePageWidget() : const ReceptionPageWidget();
} else {
return const WelcomePageWidget(); return const WelcomePageWidget();
} }
}(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError) {
DialogUtil.error(context, snapshot.error.toString());
return const WelcomePageWidget();
} else {
return snapshot.data!;
}
},
);
}, },
), ),
FFRoute( FFRoute(

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/internationalization.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/forgot_password_page/forgot_password_screen.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/services/localization/localization_service.dart';
import 'package:hub/shared/utils/device_util.dart'; import 'package:hub/shared/utils/device_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:responsive_framework/responsive_framework.dart'; import 'package:responsive_framework/responsive_framework.dart';
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
@ -35,16 +35,15 @@ void main() async {
Future<void> initializeApp() async { Future<void> initializeApp() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await _initializeTracking(); await _initializeTracking();
await _initializeStorageHelpers(); await StorageHelper().init();
await _initializeFirebase(); await _initializeFirebase();
await _initializeNotificationService(); await _initializeNotificationService();
_initializeUrlStrategy(); _initializeUrlStrategy();
_initializeSystemSettings(); _initializeSystemSettings();
await _initializeFlutterFlow(); await _initializeFlutterFlow();
} }
Future<void> _initializeStorageHelpers() async {
await StorageUtil().ensureInitialization();
}
Future<void> _initializeTracking() async { Future<void> _initializeTracking() async {
await AppTrackingTransparency.requestTrackingAuthorization(); await AppTrackingTransparency.requestTrackingAuthorization();
} }
@ -78,9 +77,10 @@ Future<void> _initializeFlutterFlow() async {
} }
Future<void> _foregroundHandlerMessage(RemoteMessage message) async { Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') { if (message.data['click_action'] == 'enroll_cond') {
StorageUtil().haveLocal = true; await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
StorageUtil().context?.go('/homePage'); StorageHelper().context?.go('/homePage');
} }
if (!Platform.isIOS) { if (!Platform.isIOS) {
NotificationService.show( NotificationService.show(
title: message.notification!.title!, title: message.notification!.title!,
@ -90,9 +90,8 @@ Future<void> _foregroundHandlerMessage(RemoteMessage message) async {
} }
Future<void> _backgroundHandlerMessage(RemoteMessage message) async { Future<void> _backgroundHandlerMessage(RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') { if (message.data['click_action'] == 'enroll_cond') {
log('backgroundHandlerMessage'); await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
StorageUtil().haveLocal = true; StorageHelper().context?.go('/homePage');
StorageUtil().context?.go('/homePage');
} }
} }
@ -175,23 +174,21 @@ class _AppState extends State<App> with WidgetsBindingObserver {
Future<void> initDeepLinks() async { Future<void> initDeepLinks() async {
_appLinks = AppLinks(); _appLinks = AppLinks();
_linkSubscription = _appLinks.uriLinkStream.listen((uri) { _linkSubscription = _appLinks.uriLinkStream.listen((uri) {
final bool isRecovered = StorageUtil().isRecovered; final bool isRecovered = StorageHelper().isRecovered;
if (!isRecovered) openAppLink(uri); if (!isRecovered) openAppLink(uri);
}); });
} }
void openAppLink(Uri uri) { void openAppLink(Uri uri) {
final bool isRecovered = StorageUtil().isRecovered; final bool isRecovered = StorageHelper().isRecovered;
log('isRecovered: $isRecovered'); log('isRecovered: $isRecovered');
if (isRecovered) return; if (isRecovered) return;
StorageUtil().isRecovered = true; StorageHelper().isRecovered = true;
final String email = uri.queryParameters['email'] ?? ''; final String email = uri.queryParameters['email'] ?? '';
final String token = uri.queryParameters['token'] ?? ''; final String token = uri.queryParameters['token'] ?? '';
final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty; final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty;
if (isNotEmpty) { if (isNotEmpty) {
final BuildContext context = StorageUtil().context!; final BuildContext context = StorageHelper().context!;
final MediaQueryData mediaQuery = MediaQuery.of(context);
final double height = mediaQuery.size.height * 0.6;
final FlutterFlowTheme theme = FlutterFlowTheme.of(context); final FlutterFlowTheme theme = FlutterFlowTheme.of(context);
final Widget screen = ForgotPasswordScreen(email: email, token: token); final Widget screen = ForgotPasswordScreen(email: email, token: token);
builder(context) => screen; builder(context) => screen;
@ -205,7 +202,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
useSafeArea: true, useSafeArea: true,
enableDrag: true, enableDrag: true,
// isDismissible: true, // isDismissible: true,
).whenComplete(() => StorageUtil().isRecovered = false); ).whenComplete(() => StorageHelper().isRecovered = false);
} }
} }
@ -218,18 +215,18 @@ class _AppState extends State<App> with WidgetsBindingObserver {
} }
FirebaseMessaging.onMessage.listen(_foregroundHandlerMessage); FirebaseMessaging.onMessage.listen(_foregroundHandlerMessage);
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') { if (message.data['click_action'] == 'enroll_cond') {
StorageUtil().haveLocal = true; await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
log('onMessageOpenedApp'); log('onMessageOpenedApp');
} else { } else {
onMessageReceived(message.data, message.notification!.body, message.data['click_action']); onMessageReceived(message.data, message.notification!.body, message.data['click_action']);
} }
}); });
FirebaseMessaging.instance.getInitialMessage().then((message) { FirebaseMessaging.instance.getInitialMessage().then((message) async {
if (message != null) { if (message != null) {
if (message.data['click_action'] == 'enroll_cond') { if (message.data['click_action'] == 'enroll_cond') {
StorageUtil().haveLocal = true; await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
log('getInitialMessage'); log('getInitialMessage');
} }
} }
@ -274,8 +271,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
@override @override
void didChangeAppLifecycleState(AppLifecycleState state) async { void didChangeAppLifecycleState(AppLifecycleState state) async {
bool initialize = await StorageUtil().ensureInitialization(); await LocalizationService.processLocals(context);
if (initialize) await LocalizationService.processLocals(context);
} }
@override @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/flutter_flow_model.dart';
import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/flutter_flow/request_manager.dart';
import 'package:hub/pages/acess_history_page/acess_history_page_widget.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> { class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
late final String devUUID; late final String devUUID;
@ -32,9 +33,9 @@ class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
} }
Future<void> initDatabase() async { Future<void> initDatabase() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
} }
@override @override

View File

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

View File

@ -3,9 +3,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart'; import 'package:flutter_animate/flutter_animate.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:hub/flutter_flow/nav/nav.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_animations.dart';
import '../../flutter_flow/flutter_flow_icon_button.dart'; import '../../flutter_flow/flutter_flow_icon_button.dart';
import '../../flutter_flow/flutter_flow_model.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/flutter_flow_widgets.dart';
import '../../flutter_flow/internationalization.dart'; import '../../flutter_flow/internationalization.dart';
import '../../shared/services/authentication/authentication_service.dart'; import '../../shared/services/authentication/authentication_service.dart';
import '../../shared/utils/validator_util.dart';
import 'forgot_password_model.dart'; import 'forgot_password_model.dart';
class ForgotPasswordScreen extends StatefulWidget { class ForgotPasswordScreen extends StatefulWidget {
@ -112,7 +110,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> with Ticker
), ),
onPressed: () async { onPressed: () async {
context.pop(); context.pop();
StorageUtil().isRecovered = false; StorageHelper().isRecovered = false;
}, },
), ),
title: Text( title: Text(

View File

@ -6,9 +6,13 @@ 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/components/organism_components/message_well_component/message_well_component_model.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/pages/home_page/home_page_widget.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> { class HomePageModel extends FlutterFlowModel<HomePageWidget> {
HomePageModel({required this.safeSetState});
late final VoidCallback safeSetState;
bool isGrid = false; bool isGrid = false;
late final String devUUID; late final String devUUID;
late final String cliUUID; late final String cliUUID;
@ -26,11 +30,12 @@ class HomePageModel extends FlutterFlowModel<HomePageWidget> {
late MessageWellComponentModel messageWellComponentModel; late MessageWellComponentModel messageWellComponentModel;
Future<void> _initVariable() async { Future<void> _initVariable() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
userName = StorageUtil().userName; userName = (await StorageHelper().get(SQLiteStorageKey.userName.value, Storage.SQLiteStorage)) ?? '';
userEmail = StorageUtil().email; userEmail = (await StorageHelper().get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? '';
safeSetState.call();
} }
@override @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_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/home_page/home_page_model.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'; import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart';
class HomePageWidget extends StatefulWidget { class HomePageWidget extends StatefulWidget {
@ -39,8 +39,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
void initState() { void initState() {
super.initState(); super.initState();
_model = createModel(context, () => HomePageModel()); _model = createModel(context, () => HomePageModel(safeSetState: () => safeSetState((){})));
_model.updateOnChange = true;
FirebaseMessagingService().updateDeviceToken(); FirebaseMessagingService().updateDeviceToken();
@ -50,7 +49,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
StorageUtil().context = context; StorageHelper().context = context;
return Scaffold( return Scaffold(
key: scaffoldKey, key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground, 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/flutter_flow_model.dart';
import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/flutter_flow/request_manager.dart';
import 'package:hub/pages/liberation_history/liberation_history_widget.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> { class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
late final String devUUID; late final String devUUID;
@ -35,9 +36,9 @@ class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
} }
Future<void> init() async { Future<void> init() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
} }
Future answersRequest( 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/flutter_flow_model.dart';
import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/flutter_flow/request_manager.dart';
import 'package:hub/pages/message_history_page/message_history_page_widget.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> { class MessageHistoryPageModel extends FlutterFlowModel<MessageHistoryPageWidget> {
late final String devUUID; late final String devUUID;
@ -38,9 +39,9 @@ class MessageHistoryPageModel extends FlutterFlowModel<MessageHistoryPageWidget>
} }
Future<void> init() async { Future<void> init() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
} }
@override @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_icon_button.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_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/dialog_util.dart';
import 'package:hub/shared/utils/log_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:hub/shared/utils/validator_util.dart';
import 'package:rxdart/rxdart.dart'; import 'package:rxdart/rxdart.dart';
@ -62,7 +63,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
} }
Future<void> initDatabase() async { Future<void> initDatabase() async {
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
} }
@override @override
@ -215,9 +216,6 @@ class _PackageOrderPage extends State<PackageOrderPage> {
} }
PreferredSizeWidget _appBar(BuildContext context) { PreferredSizeWidget _appBar(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
return AppBar( return AppBar(
backgroundColor: FlutterFlowTheme.of(context).primaryBackground, backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
automaticallyImplyLeading: false, automaticallyImplyLeading: false,

View File

@ -1,12 +1,29 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/pages/people_on_the_property_page/people_on_the_property_page_widget.dart'; import 'package:hub/pages/people_on_the_property_page/people_on_the_property_page_widget.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/storage_helper.dart';
class PeopleOnThePropertyPageModel extends FlutterFlowModel<PeopleOnThePropertyPage> { class PeopleOnThePropertyPageModel extends FlutterFlowModel<PeopleOnThePropertyPage> {
PeopleOnThePropertyPageModel({this.onRefresh});
late final VoidCallback? onRefresh;
final unfocusNode = FocusNode(); final unfocusNode = FocusNode();
late final String devUUID;
late final String cliUUID;
@override @override
void initState(BuildContext context) {} void initState(BuildContext context) {
initVariables();
}
void initVariables() async {
devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
onRefresh?.call();
}
@override @override
void dispose() { void dispose() {

View File

@ -8,7 +8,6 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/people_on_the_property_page/people_on_the_property_page_model.dart'; import 'package:hub/pages/people_on_the_property_page/people_on_the_property_page_model.dart';
import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart'; import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
class PeopleOnThePropertyPage extends StatefulWidget { class PeopleOnThePropertyPage extends StatefulWidget {
const PeopleOnThePropertyPage({super.key}); const PeopleOnThePropertyPage({super.key});
@ -24,6 +23,9 @@ class _PeopleOnThePropertyPageState extends State<PeopleOnThePropertyPage> with
bool _hasData = false; bool _hasData = false;
bool _loading = false; bool _loading = false;
int count = 0; int count = 0;
late final PeopleOnThePropertyPageModel model; late final PeopleOnThePropertyPageModel model;
late Future<void> _petsFuture; late Future<void> _petsFuture;
@ -32,7 +34,8 @@ class _PeopleOnThePropertyPageState extends State<PeopleOnThePropertyPage> with
@override @override
void initState() { void initState() {
super.initState(); super.initState();
model = createModel(context, () => PeopleOnThePropertyPageModel()); model = createModel(context, () => PeopleOnThePropertyPageModel(onRefresh: () => safeSetState(() {})));
_petsFuture = _fetchVisits(); _petsFuture = _fetchVisits();
_scrollController = ScrollController() _scrollController = ScrollController()
@ -208,7 +211,7 @@ class _PeopleOnThePropertyPageState extends State<PeopleOnThePropertyPage> with
Widget _item(BuildContext context, dynamic uItem) { Widget _item(BuildContext context, dynamic uItem) {
return CardItemTemplateComponentWidget( return CardItemTemplateComponentWidget(
imagePath: imagePath:
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${StorageUtil().devUUID}&cliID=${StorageUtil().cliUUID}&atividade=getFoto&Documento=${uItem['documento']}&tipo=Z', 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${model.devUUID}&cliID=${model.cliUUID}&atividade=getFoto&Documento=${uItem['documento']}&tipo=Z',
labelsHashMap: { labelsHashMap: {
'${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['nome'] ?? '', '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['nome'] ?? '',
//statusweb //statusweb

View File

@ -8,17 +8,16 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/pets_page/pets_page_model.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/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart'; import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
class PetsHistoryScreen extends StatefulWidget { class PetsHistoryScreen extends StatefulWidget {
const PetsHistoryScreen({super.key, this.model}); const PetsHistoryScreen({super.key, this.model});
final PetsPageModel? model; final PetsPageModel? model;
@override @override _PetsHistoryScreenState createState() => _PetsHistoryScreenState();
_PetsHistoryScreenState createState() => _PetsHistoryScreenState();
} }
class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProviderStateMixin { class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProviderStateMixin {
@ -38,8 +37,10 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
void initState() { void initState() {
super.initState(); super.initState();
model = widget.model ?? createModel(context, () => PetsPageModel()); model = widget.model ?? createModel(context, () => PetsPageModel());
model.petAmountRegister = '0';
_petsFuture = _fetchVisits(); _petsFuture = _fetchVisits();
_scrollController = ScrollController() _scrollController = ScrollController()
..addListener(() { ..addListener(() {
if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) {
@ -273,10 +274,13 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen> with TickerProvid
} }
], ],
onTapCardItemAction: () async { onTapCardItemAction: () async {
final cliUUID = StorageUtil().cliUUID; final devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final cliName = StorageUtil().cliName; final userUUID =
final devUUID = StorageUtil().devUUID; (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final userUUID = StorageUtil().userUUID; final cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
final cliName =
(await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
await showDialog( await showDialog(
useSafeArea: true, useSafeArea: true,
context: context, 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/form_field_controller.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/pets_page/pets_page_widget.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/dialog_util.dart';
import 'package:hub/shared/utils/image_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'; import 'package:hub/shared/utils/validator_util.dart';
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> { class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
@ -26,7 +27,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
late final String devUUID; late final String devUUID;
late final String userUUID; late final String userUUID;
late final String cliUUID; late final String cliUUID;
late final String petAmountRegister; late String petAmountRegister;
dynamic item; dynamic item;
late final TabController tabBarController; late final TabController tabBarController;
@ -105,6 +106,15 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
TextEditingController? textControllerObservation; TextEditingController? textControllerObservation;
String? Function(BuildContext, String?)? textControllerObservationValidator; String? Function(BuildContext, String?)? textControllerObservationValidator;
Future<void> initAsync() async {
devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
petAmountRegister = (await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage)) ?? '';
safeSetState?.call();
}
@override @override
void initState(BuildContext context) { void initState(BuildContext context) {
resetInstance(); resetInstance();
@ -164,14 +174,6 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
dropDownValueController2?.dispose(); dropDownValueController2?.dispose();
} }
Future<void> initAsync() async {
devUUID = StorageUtil().devUUID;
userUUID = StorageUtil().userUUID;
cliUUID = StorageUtil().cliUUID;
petAmountRegister = StorageUtil().petAmountRegister.toString();
safeSetState?.call();
}
void setEditForm() { void setEditForm() {
log('item: $item'); log('item: $item');

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/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/flutter_flow_util.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart'; import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart'; import 'package:hub/shared/helpers/storage_helper.dart';
import 'package:hub/shared/services/authentication/authentication_service.dart'; import 'package:hub/shared/services/authentication/authentication_service.dart';
import 'package:hub/shared/services/localization/localization_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 'package:share_plus/share_plus.dart';
import '../../shared/utils/snackbar_util.dart'; import '../../shared/utils/snackbar_util.dart';
@ -17,16 +16,29 @@ import '../../shared/utils/snackbar_util.dart';
class PreferencesPageModel with ChangeNotifier { class PreferencesPageModel with ChangeNotifier {
final unfocusNode = FocusNode(); final unfocusNode = FocusNode();
PreferencesPageModel() { late bool isFingerprint = false;
initVariables(); late bool isPerson = false;
} late bool isNotify = false;
late bool isAccess = false;
late bool isPanic = false;
Future<void> initVariables() async { Future<void> _initialize() async {
isFingerprint =
await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
isPerson = await StorageHelper().get(SQLiteStorageKey.person.value, Storage.SQLiteStorage) == 'true';
isNotify = await StorageHelper().get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true';
isAccess = await StorageHelper().get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true';
isPanic = await StorageHelper().get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true';
notifyListeners(); notifyListeners();
} }
PreferencesPageModel() {
_initialize();
}
Future<void> enablePerson(BuildContext context) async { Future<void> enablePerson(BuildContext context) async {
final String userDevUUID = StorageUtil().userDevUUID; final String userDevUUID =
(await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? '';
notifyListeners(); notifyListeners();
Share.share( Share.share(
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
@ -45,17 +57,21 @@ class PreferencesPageModel with ChangeNotifier {
enText: 'Are you sure you want to change your notification?', enText: 'Are you sure you want to change your notification?',
ptText: 'Tem certeza que deseja alterar sua notificação?', ptText: 'Tem certeza que deseja alterar sua notificação?',
); );
onConfirm() async { onConfirm() async {
String content; String content;
String value = StorageUtil().notify ? 'N' : 'S'; String value = !isNotify ? 'N' : 'S';
await PhpGroup.changeNotifica.call(notifica: value).then((value) async { await PhpGroup.changeNotifica
.call(notifica: value)
.then((value) async {
if (value.jsonBody['error'] == false) { if (value.jsonBody['error'] == false) {
StorageUtil().notify = !StorageUtil().notify; await StorageHelper()
notifyListeners(); .set(SQLiteStorageKey.notify.value, isNotify ? 'false' : 'true', Storage.SQLiteStorage);
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
enText: 'Notification changed successfully', enText: 'Notification changed successfully',
ptText: 'Notificação alterada com sucesso', ptText: 'Notificação alterada com sucesso',
); );
notifyListeners();
SnackBarUtil.showSnackBar(context, content); SnackBarUtil.showSnackBar(context, content);
} else { } else {
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
@ -64,14 +80,18 @@ class PreferencesPageModel with ChangeNotifier {
); );
SnackBarUtil.showSnackBar(context, content, isError: true); SnackBarUtil.showSnackBar(context, content, isError: true);
} }
}).catchError((e, s) { })
.catchError((e, s) {
log('toggleNotify', error: e, stackTrace: s); log('toggleNotify', error: e, stackTrace: s);
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
enText: 'Error changing notification', enText: 'Error changing notification',
ptText: 'Erro ao alterar notificação', ptText: 'Erro ao alterar notificação',
); );
SnackBarUtil.showSnackBar(context, content, isError: true); SnackBarUtil.showSnackBar(context, content, isError: true);
}).whenComplete(() => notifyListeners()); })
.then((_) async => isNotify =
await StorageHelper().get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true')
.whenComplete(() => notifyListeners());
context.pop(); context.pop();
} }
@ -119,15 +139,14 @@ class PreferencesPageModel with ChangeNotifier {
Future<void> toggleAccess(BuildContext context) async { Future<void> toggleAccess(BuildContext context) async {
onChange(String key) async { onChange(String key) async {
StorageUtil().accessPass = key; await StorageHelper().set(SecureStorageKey.accessPass.value, key, Storage.SecureStorage);
await PhpGroup.changePass await PhpGroup.changePass
.call( .call(newSenha: key)
newSenha: key,
)
.then((value) async { .then((value) async {
final String content; final String content;
if (jsonDecode(value.jsonBody['error'].toString()) == false) { if (jsonDecode(value.jsonBody['error'].toString()) == false) {
if (!StorageUtil().access) StorageUtil().access = !StorageUtil().access; await StorageHelper()
.set(SQLiteStorageKey.access.value, isAccess ? 'false' : 'true', Storage.SQLiteStorage);
notifyListeners(); notifyListeners();
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
enText: 'Access pass changed successfully', enText: 'Access pass changed successfully',
@ -141,13 +160,17 @@ class PreferencesPageModel with ChangeNotifier {
); );
SnackBarUtil.showSnackBar(context, content, isError: true); SnackBarUtil.showSnackBar(context, content, isError: true);
} }
}).catchError((e, s) { })
.catchError((e, s) {
final String content = FFLocalizations.of(context).getVariableText( final String content = FFLocalizations.of(context).getVariableText(
ptText: 'Erro ao alterar senha de acesso', ptText: 'Erro ao alterar senha de acesso',
enText: 'Error changing access pass', enText: 'Error changing access pass',
); );
SnackBarUtil.showSnackBar(context, content, isError: true); SnackBarUtil.showSnackBar(context, content, isError: true);
}).whenComplete(() => notifyListeners()); })
.then((_) async => isAccess =
await StorageHelper().get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true')
.whenComplete(() => notifyListeners());
} }
_showPassKey(context, onChange); _showPassKey(context, onChange);
@ -155,15 +178,14 @@ class PreferencesPageModel with ChangeNotifier {
Future<void> togglePanic(BuildContext context) async { Future<void> togglePanic(BuildContext context) async {
onChange(String key) async { onChange(String key) async {
StorageUtil().panicPass = key; await StorageHelper().set(SecureStorageKey.panicPass.value, key, Storage.SecureStorage);
await PhpGroup.changePanic await PhpGroup.changePanic
.call( .call(newSenhaPanico: key)
newSenhaPanico: StorageUtil().panicPass,
)
.then((value) async { .then((value) async {
final String content; final String content;
if (jsonDecode(value.jsonBody['error'].toString()) == false) { if (jsonDecode(value.jsonBody['error'].toString()) == false) {
if (!StorageUtil().panic) StorageUtil().panic = !StorageUtil().panic; await StorageHelper()
.set(SQLiteStorageKey.panic.value, isPanic ? 'false' : 'true', Storage.SQLiteStorage);
notifyListeners(); notifyListeners();
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
enText: 'Panic password changed successfully', enText: 'Panic password changed successfully',
@ -177,13 +199,17 @@ class PreferencesPageModel with ChangeNotifier {
); );
SnackBarUtil.showSnackBar(context, content, isError: true); SnackBarUtil.showSnackBar(context, content, isError: true);
} }
}).catchError((e, s) { })
.catchError((e, s) {
final String content = FFLocalizations.of(context).getVariableText( final String content = FFLocalizations.of(context).getVariableText(
ptText: 'Erro ao alterar senha de pânico', ptText: 'Erro ao alterar senha de pânico',
enText: 'Error changing panic password', enText: 'Error changing panic password',
); );
SnackBarUtil.showSnackBar(context, content, isError: true); SnackBarUtil.showSnackBar(context, content, isError: true);
}).whenComplete(() => notifyListeners()); })
.then((_) async =>
isPanic = await StorageHelper().get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true')
.whenComplete(() => notifyListeners());
} }
_showPassKey(context, onChange); _showPassKey(context, onChange);
@ -196,16 +222,17 @@ class PreferencesPageModel with ChangeNotifier {
); );
onChange(String? key) async { onChange(String? key) async {
StorageUtil().fingerprint = !StorageUtil().fingerprint; isFingerprint = !isFingerprint;
if (!StorageUtil().fingerprint) StorageUtil().fingerprintPass = key ?? ''; await StorageHelper().set(SecureStorageKey.fingerprintPass.value, key ?? '', Storage.SecureStorage);
if (StorageUtil().fingerprint) StorageUtil().fingerprintPass = ''; await StorageHelper()
.set(SQLiteStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false', Storage.SQLiteStorage);
notifyListeners(); notifyListeners();
SnackBarUtil.showSnackBar(context, content); SnackBarUtil.showSnackBar(context, content);
isFingerprint =
await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
} }
StorageUtil().fingerprint ? onChange(null) : _showPassKey(context, onChange); isFingerprint ? onChange(null) : _showPassKey(context, onChange);
} }
Future<void> deleteAccount(BuildContext context) async { Future<void> deleteAccount(BuildContext context) async {

View File

@ -5,7 +5,7 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/preferences_settings_page/preferences_settings_model.dart'; import 'package:hub/pages/preferences_settings_page/preferences_settings_model.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class PreferencesPageWidget extends StatefulWidget { class PreferencesPageWidget extends StatefulWidget {
@ -101,7 +101,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 0: case 0:
icon = Icons.fingerprint; icon = Icons.fingerprint;
onPressed = () => model.toggleFingerprint(context); onPressed = () => model.toggleFingerprint(context);
isEnabled = StorageUtil().fingerprint; isEnabled = model.isFingerprint;
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative a autenticação por impressão digital para login seguro.', ptText: 'Ative a autenticação por impressão digital para login seguro.',
enText: 'Enable fingerprint authentication for secure login.', enText: 'Enable fingerprint authentication for secure login.',
@ -110,7 +110,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 1: case 1:
icon = Icons.person; icon = Icons.person;
onPressed = () => model.enablePerson(context); onPressed = () => model.enablePerson(context);
isEnabled = StorageUtil().person; isEnabled = model.isPerson;
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
ptText: 'Compartilhe o código de identificação remota', ptText: 'Compartilhe o código de identificação remota',
enText: 'Share the remote identification code', enText: 'Share the remote identification code',
@ -128,7 +128,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 3: case 3:
icon = Icons.notifications; icon = Icons.notifications;
onPressed = () => model.toggleNotify(context); onPressed = () => model.toggleNotify(context);
isEnabled = StorageUtil().notify; isEnabled = model.isNotify;
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para receber sua notificação de acesso', ptText: 'Ative para receber sua notificação de acesso',
enText: 'Enable to receive your access notification', enText: 'Enable to receive your access notification',
@ -137,7 +137,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 4: case 4:
icon = Icons.lock; icon = Icons.lock;
onPressed = () => model.toggleAccess(context); onPressed = () => model.toggleAccess(context);
isEnabled = StorageUtil().access; isEnabled = model.isAccess;
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para inserir uma credencial de acesso para o QRCode', ptText: 'Ative para inserir uma credencial de acesso para o QRCode',
enText: 'Enable to enter an access credential for the QRCode', enText: 'Enable to enter an access credential for the QRCode',
@ -146,7 +146,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
case 5: case 5:
icon = Icons.lock_clock_sharp; icon = Icons.lock_clock_sharp;
onPressed = () => model.togglePanic(context); onPressed = () => model.togglePanic(context);
isEnabled = StorageUtil().panic; isEnabled = model.isPanic;
content = FFLocalizations.of(context).getVariableText( content = FFLocalizations.of(context).getVariableText(
ptText: 'Ative para inserir uma credencial de pânico para o QRCode', ptText: 'Ative para inserir uma credencial de pânico para o QRCode',
enText: 'Enable to enter a panic credential for the QRCode', enText: 'Enable to enter a panic credential for the QRCode',
@ -190,10 +190,10 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
switch (index) { switch (index) {
case 3: case 4:
model.toggleAccess(context); model.toggleAccess(context);
break; break;
case 4: case 5:
model.togglePanic(context); model.togglePanic(context);
break; break;
default: default:

View File

@ -4,19 +4,20 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/flutter_flow_model.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/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'; import 'package:qr_flutter/qr_flutter.dart';
class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> { class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
/// Local state fields for this page. /// Local state fields for this page.
bool isAccess = false;
String? key; String? key;
DateTime? time; DateTime? time;
bool isAccess = false;
late final bool isFingerprint; late final bool isFingerprint;
late final String userDevUUID; late final String userDevUUID;
late final VoidCallback? safeSetState;
/// State fields for stateful widgets in this page. /// State fields for stateful widgets in this page.
@ -28,8 +29,10 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
} }
Future<void> initVariable() async { Future<void> initVariable() async {
isFingerprint = StorageUtil().fingerprint; isFingerprint =
userDevUUID = StorageUtil().userDevUUID; await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
userDevUUID = await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage) ?? '';
safeSetState?.call();
} }
@override @override
@ -79,8 +82,6 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
packet.add(check); packet.add(check);
} }
var bytes = packet.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join((' '));
return Uint8List.fromList(packet); return Uint8List.fromList(packet);
} }

View File

@ -1,4 +1,7 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:async'; import 'dart:async';
import 'dart:developer';
import 'package:barcode_widget/barcode_widget.dart'; import 'package:barcode_widget/barcode_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -14,9 +17,10 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/qr_code_page/qr_code_page_model.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/biometric_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:percent_indicator/circular_percent_indicator.dart'; import 'package:percent_indicator/circular_percent_indicator.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
@ -39,8 +43,8 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
void initState() { void initState() {
super.initState(); super.initState();
_model = createModel(context, () => QrCodePageModel()); _model = createModel(context, () => QrCodePageModel());
_model.safeSetState = () => safeSetState(() {});
// On page load action.
SchedulerBinding.instance.addPostFrameCallback((_) async { SchedulerBinding.instance.addPostFrameCallback((_) async {
if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { if (animationsMap['barcodeOnActionTriggerAnimation'] != null) {
animationsMap['barcodeOnActionTriggerAnimation']!.controller.fling(); animationsMap['barcodeOnActionTriggerAnimation']!.controller.fling();
@ -67,14 +71,6 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
animationsMap.values.where((anim) => anim.trigger == AnimationTrigger.onActionTrigger || !anim.applyInitialState), animationsMap.values.where((anim) => anim.trigger == AnimationTrigger.onActionTrigger || !anim.applyInitialState),
this, this,
); );
// // Adicionando um ouvinte de status à animação para reiniciá-la após a conclusão
// animationsMap['barcodeOnActionTriggerAnimation']?.controller.addStatusListener((status) {
// if (status == AnimationStatus.completed) {
// animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset();
// animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward();
// }
// });
} }
@override @override
@ -130,10 +126,8 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
alignment: const AlignmentDirectional(0.0, 0.0), alignment: const AlignmentDirectional(0.0, 0.0),
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
safeSetState(() async {
_resetAnimationAndToggleAccess(); _resetAnimationAndToggleAccess();
}); log('isFingerprint: ${_model.isFingerprint}');
_model.isFingerprint ? await _showBiometricsAuth(context) : await _showQrCodeBottomSheet(context); _model.isFingerprint ? await _showBiometricsAuth(context) : await _showQrCodeBottomSheet(context);
}, },
child: _model.buildQrCode( child: _model.buildQrCode(
@ -187,6 +181,7 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
alignment: const AlignmentDirectional(0.0, 0.0), alignment: const AlignmentDirectional(0.0, 0.0),
child: FFButtonWidget( child: FFButtonWidget(
onPressed: () async { onPressed: () async {
log('isFingerprint: ${_model.isFingerprint}');
_model.isFingerprint _model.isFingerprint
? await _showBiometricsAuth(context) ? await _showBiometricsAuth(context)
: await _showQrCodeBottomSheet(context); : await _showQrCodeBottomSheet(context);
@ -261,7 +256,6 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
FFLocalizations.of(context).getVariableText( FFLocalizations.of(context).getVariableText(
ptText: 'Expirando QR code em', ptText: 'Expirando QR code em',
enText: 'Expiring QR code in', enText: 'Expiring QR code in',
// 'wkjkxd2e' /* Trocando QR code em */,
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: FlutterFlowTheme.of(context).bodyMedium.override( style: FlutterFlowTheme.of(context).bodyMedium.override(
@ -328,19 +322,22 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
} }
Future<void> _showBiometricsAuth(BuildContext context) async { Future<void> _showBiometricsAuth(BuildContext context) async {
BiometricHelper.checkBiometrics() await BiometricHelper.checkBiometrics()
.then((value) => BiometricHelper.authenticateBiometric().then((value) { .then((value) async => await BiometricHelper.authenticateBiometric().then((value) async {
final key =
await StorageHelper().get(SecureStorageKey.fingerprintPass.value, Storage.SecureStorage) ?? '';
safeSetState(() { safeSetState(() {
if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { if (animationsMap['barcodeOnActionTriggerAnimation'] != null) {
animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop(); animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop();
animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse(); animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse();
} }
_model.isAccess = !_model.isAccess; _model.isAccess = !_model.isAccess;
_model.key = StorageUtil().fingerprintPass; _model.key = key;
}); });
})) }))
.onError((error, StackTrace) { .onError((error, stackTrace) {
_showQrCodeBottomSheet(context); log('Error', error: error, stackTrace: stackTrace);
if (mounted) _showQrCodeBottomSheet(context);
}); });
} }
@ -372,26 +369,19 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
), ),
); );
}, },
).catchError((error) => safeSetState(() { ).catchError((error) => safeSetState(() => _resetAnimationAndToggleAccess()));
_resetAnimationAndToggleAccess();
}));
unawaited( unawaited(
() async { () async {
await _model.qrCodeEncoder( await _model.qrCodeEncoder(context, key: _model.key);
context, safeSetState(() {});
key: _model.key,
);
setState(() {});
}(), }(),
); );
} }
void _resetAnimationAndToggleAccess() { void _resetAnimationAndToggleAccess() {
safeSetState(() { safeSetState(() {
// Reinicia a animação
animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset(); animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset();
animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward(); animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward();
// Alterna o estado de acesso
_model.isAccess = !_model.isAccess; _model.isAccess = !_model.isAccess;
_model.key = null; _model.key = null;
}); });
@ -416,9 +406,7 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
}, },
), ),
title: Text( title: Text(
FFLocalizations.of(context).getText( FFLocalizations.of(context).getText('ku7jqe53'),
'ku7jqe53' /* QR Code de Acesso */,
),
style: FlutterFlowTheme.of(context).headlineMedium.override( style: FlutterFlowTheme.of(context).headlineMedium.override(
fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily,
color: FlutterFlowTheme.of(context).primaryText, color: FlutterFlowTheme.of(context).primaryText,

View File

@ -1,11 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/internationalization.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'; import 'package:share_plus/share_plus.dart';
class ReceptionPageModel with ChangeNotifier { class ReceptionPageModel with ChangeNotifier {
Future<void> getIdenfifier(BuildContext context) async { Future<void> getIdenfifier(BuildContext context) async {
final String userDevUUID = StorageUtil().userDevUUID; final String userDevUUID =
(await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? '';
notifyListeners(); notifyListeners();
Share.share( Share.share(

View File

@ -11,9 +11,10 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/reception_page/reception_page_model.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/authentication/authentication_service.dart'; import 'package:hub/shared/services/authentication/authentication_service.dart';
import 'package:hub/shared/services/localization/localization_service.dart'; import 'package:hub/shared/services/localization/localization_service.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class ReceptionPageWidget extends StatefulWidget { class ReceptionPageWidget extends StatefulWidget {
@ -55,7 +56,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> with WidgetsB
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
StorageUtil().context = context; StorageHelper().context = context;
return ChangeNotifierProvider( return ChangeNotifierProvider(
create: (context) => ReceptionPageModel(), create: (context) => ReceptionPageModel(),
child: Scaffold( child: Scaffold(

View File

@ -5,7 +5,8 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/flutter_flow/nav/nav.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:hub/shared/utils/webview_util.dart';
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
import 'package:webview_flutter/webview_flutter.dart'; import 'package:webview_flutter/webview_flutter.dart';
@ -21,12 +22,16 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
late WebViewController _controllerAll; late WebViewController _controllerAll;
Future<Map<String, String>> initVariables() async { Future<Map<String, String>> initVariables() async {
final email = StorageUtil().email; final email = (await StorageHelper().get(hub.SecureStorageKey.email.value, hub.Storage.SecureStorage)) ?? '';
final name = StorageUtil().cliName; final name =
final userUUID = StorageUtil().userUUID; (await StorageHelper().get(hub.SQLiteStorageKey.userName.value, hub.Storage.SQLiteStorage)) ?? '';
final devUUID = StorageUtil().devUUID; final devUUID =
final createdAt = StorageUtil().createdAt; (await StorageHelper().get(hub.SQLiteStorageKey.devUUID.value, hub.Storage.SQLiteStorage)) ?? '';
final clientId = StorageUtil().cliUUID; final userUUID =
(await StorageHelper().get(hub.SQLiteStorageKey.userUUID.value, hub.Storage.SQLiteStorage)) ?? '';
final clientId =
(await StorageHelper().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'; final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId';

View File

@ -8,14 +8,17 @@ import 'package:hub/flutter_flow/form_field_controller.dart';
import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/flutter_flow/request_manager.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/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/mixins/status_mixin.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
import '../../shared/utils/validator_util.dart'; import '../../shared/utils/validator_util.dart';
class ScheduleCompleteVisitPageModel extends FlutterFlowModel<ScheduleComplete> { class ScheduleCompleteVisitPageModel extends FlutterFlowModel<ScheduleComplete> {
late VoidCallback safeSetState; ScheduleCompleteVisitPageModel({ this.safeSetState});
late VoidCallback? safeSetState;
late Function(Function) updateState; late Function(Function) updateState;
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>(); final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
late final String devUUID; late final String devUUID;
@ -213,9 +216,9 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel<ScheduleComplete>
} }
Future<void> _initVariables() async { Future<void> _initVariables() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
} }
@override @override
@ -369,7 +372,7 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel<ScheduleComplete>
void switchTab(int index) { void switchTab(int index) {
tabBarController?.animateTo(index); tabBarController?.animateTo(index);
safeSetState.call(); safeSetState?.call();
} }
void setFormField() { void setFormField() {

View File

@ -24,17 +24,13 @@ import 'package:hub/shared/utils/share_util.dart';
class ScheduleComplete extends StatefulWidget { class ScheduleComplete extends StatefulWidget {
const ScheduleComplete({super.key}); const ScheduleComplete({super.key});
@override @override State<StatefulWidget> createState() => throw UnimplementedError();
State<StatefulWidget> createState() {
throw UnimplementedError();
}
} }
class ScheduleCompleteVisitPageWidget extends ScheduleComplete { class ScheduleCompleteVisitPageWidget extends ScheduleComplete {
const ScheduleCompleteVisitPageWidget({super.key}); const ScheduleCompleteVisitPageWidget({super.key});
@override @override State<ScheduleCompleteVisitPageWidget> createState() => _ScheduleCompleteVisitPageWidgetState();
State<ScheduleCompleteVisitPageWidget> createState() => _ScheduleCompleteVisitPageWidgetState();
} }
class _ScheduleCompleteVisitPageWidgetState extends State<ScheduleCompleteVisitPageWidget> class _ScheduleCompleteVisitPageWidgetState extends State<ScheduleCompleteVisitPageWidget>
@ -47,11 +43,9 @@ class _ScheduleCompleteVisitPageWidgetState extends State<ScheduleCompleteVisitP
final scaffoldKey = GlobalKey<ScaffoldState>(); final scaffoldKey = GlobalKey<ScaffoldState>();
@override @override void initState() {
void initState() {
super.initState(); super.initState();
_model = createModel(context, () => ScheduleCompleteVisitPageModel()); _model = createModel(context, () => ScheduleCompleteVisitPageModel(safeSetState: () => safeSetState((){})));
_model.safeSetState = () => safeSetState(() {});
_model.updateState = (Function fn) => safeSetState(fn()); _model.updateState = (Function fn) => safeSetState(fn());
_model.tabBarController = TabController( _model.tabBarController = TabController(
@ -99,8 +93,7 @@ class _ScheduleCompleteVisitPageWidgetState extends State<ScheduleCompleteVisitP
super.dispose(); super.dispose();
} }
@override @override Widget build(BuildContext context) {
Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode) ? FocusScope.of(context).requestFocus(_model.unfocusNode)

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/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_model.dart';
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.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/mixins/status_mixin.dart';
import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_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:hub/shared/utils/validator_util.dart';
class VisitHistoryWidget extends ScheduleComplete { class VisitHistoryWidget extends ScheduleComplete {
@ -33,16 +34,17 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> with TickerProv
List<dynamic> _visitWrap = []; List<dynamic> _visitWrap = [];
Future<void> _initVariables() async { Future<void> _initVariables() async {
devUUID = StorageUtil().devUUID; devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
userUUID = StorageUtil().userUUID; userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = StorageUtil().cliUUID; cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
safeSetState(() {});
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_model = createModel(context, () => ScheduleCompleteVisitPageModel()); _model = createModel(context, () => ScheduleCompleteVisitPageModel(safeSetState: () => safeSetState(() {})));
_initVariables(); _initVariables();
_visitFuture = _fetchVisits(); _visitFuture = _fetchVisits();
@ -232,10 +234,13 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget> with TickerProv
}, },
], ],
onTapCardItemAction: () async { onTapCardItemAction: () async {
final cliUUID = StorageUtil().cliUUID; final devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
final cliName = StorageUtil().cliName; final userUUID =
final devUUID = StorageUtil().devUUID; (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? '';
final userUUID = StorageUtil().userUUID; final cliUUID =
(await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
final cliName =
(await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
await showDialog( await showDialog(
useSafeArea: true, 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 '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 '/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_theme.dart';
import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_util.dart';
@ -35,7 +35,7 @@ class _SignInPageWidgetState extends State<SignInPageWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
StorageUtil().context = context; StorageHelper().context = context;
return GestureDetector( return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode) ? FocusScope.of(context).requestFocus(_model.unfocusNode)

View File

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

View File

@ -1,11 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart';
import 'package:hub/shared/utils/storage_util.dart';
class VehicleModel extends FlutterFlowModel<VehicleOnTheProperty> { class VehicleModel extends FlutterFlowModel<VehicleOnTheProperty> {
static VehicleModel? _instance = VehicleModel._internal(); static VehicleModel? _instance = VehicleModel._internal();

View File

@ -5,16 +5,23 @@ import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.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 VisitsModel extends FlutterFlowModel<VehicleOnTheProperty> { class VisitsModel extends FlutterFlowModel<VehicleOnTheProperty> {
static VisitsModel? _instance = VisitsModel._internal(); static VisitsModel? _instance;
VisitsModel._internal(); VisitsModel._internal({this.onRefresh});
factory VisitsModel() => _instance ?? VisitsModel._internal(); factory VisitsModel({VoidCallback? onRefresh}) => _instance ??= VisitsModel._internal(onRefresh: onRefresh);
static void resetInstance() => _instance = null; static void resetInstance() => _instance = null;
late final VoidCallback? onRefresh;
late final String devUUID;
late final String cliUUID;
dynamic item; dynamic item;
@override @override
void initState(BuildContext context) { void initState(BuildContext context) {
resetInstance(); resetInstance();
@ -25,7 +32,11 @@ class VisitsModel extends FlutterFlowModel<VehicleOnTheProperty> {
@override @override
void dispose() {} void dispose() {}
Future<void> initAsync() async {} Future<void> initAsync() async {
devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? '';
cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
onRefresh?.call();
}
Widget buildVisitDetails({ Widget buildVisitDetails({
required dynamic item, required dynamic item,
@ -65,7 +76,7 @@ class VisitsModel extends FlutterFlowModel<VehicleOnTheProperty> {
), ),
}), }),
imagePath: imagePath:
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${StorageUtil().devUUID}&cliID=${StorageUtil().cliUUID}&atividade=getFoto&Documento=${item['VDO_DOCUMENTO']}&tipo=E', 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&cliID=${cliUUID}&atividade=getFoto&Documento=${item['VDO_DOCUMENTO']}&tipo=E',
statusHashMap: [ statusHashMap: [
if (item['VTA_NOME'] != null) if (item['VTA_NOME'] != null)
Map<String, Color>.from( Map<String, Color>.from(

View File

@ -8,7 +8,6 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/visits_on_the_property/model.dart'; import 'package:hub/pages/visits_on_the_property/model.dart';
import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/dialog_util.dart';
import 'package:hub/shared/utils/log_util.dart'; import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
class VisitsOnTheProperty extends StatefulWidget { class VisitsOnTheProperty extends StatefulWidget {
const VisitsOnTheProperty({super.key}); const VisitsOnTheProperty({super.key});
@ -32,7 +31,7 @@ class _VisitsOnThePropertyState extends State<VisitsOnTheProperty> with TickerPr
@override @override
void initState() { void initState() {
super.initState(); super.initState();
model = createModel(context, () => VisitsModel()); model = createModel(context, () => VisitsModel(onRefresh: () => safeSetState((){})));
_visitsFuture = _fetchVisits(); _visitsFuture = _fetchVisits();
_scrollController = ScrollController() _scrollController = ScrollController()
@ -208,7 +207,7 @@ class _VisitsOnThePropertyState extends State<VisitsOnTheProperty> with TickerPr
Widget _item(BuildContext context, dynamic uItem) { Widget _item(BuildContext context, dynamic uItem) {
return CardItemTemplateComponentWidget( return CardItemTemplateComponentWidget(
imagePath: imagePath:
'https://freaccess.com.br/freaccess/getImage.php?devUUID=${StorageUtil().devUUID}&cliID=${StorageUtil().cliUUID}&atividade=getFoto&Documento=${uItem['VDO_DOCUMENTO']}&tipo=E', 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${model.devUUID}&cliID=${model.cliUUID}&atividade=getFoto&Documento=${uItem['VDO_DOCUMENTO']}&tipo=E',
labelsHashMap: { labelsHashMap: {
'${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['VTA_NOME'] ?? '', '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['VTA_NOME'] ?? '',
'${FFLocalizations.of(context).getVariableText(ptText: "Validade", enText: "Valids")}:': '${FFLocalizations.of(context).getVariableText(ptText: "Validade", enText: "Valids")}:':

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

View File

@ -0,0 +1,143 @@
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,39 @@
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,39 @@
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,128 @@
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,270 +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();
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,82 @@
import 'package:flutter/cupertino.dart';
import 'package:hub/shared/helpers/base_storage.dart';
import 'package:hub/shared/helpers/secure_storage.dart';
import 'package:hub/shared/helpers/shared_preferences_storage.dart';
import 'package:hub/shared/helpers/sqlite_storage.dart';
class StorageHelper {
static final StorageHelper _instance = StorageHelper._internal();
factory StorageHelper() => _instance;
StorageHelper._internal();
late BuildContext? _context;
late bool _isRecovered = false;
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:flutter/material.dart';
import 'package:hub/flutter_flow/nav/nav.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 'package:hub/shared/utils/snackbar_util.dart';
import '../../../backend/api_requests/api_calls.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/device_util.dart';
import '../../utils/dialog_util.dart'; import '../../utils/dialog_util.dart';
import '../../utils/log_util.dart'; import '../../utils/log_util.dart';
import '../../utils/storage_util.dart';
class AuthenticationService { class AuthenticationService {
static Future<void> login(BuildContext context) async { static Future<void> login(BuildContext context) async {
@ -23,13 +24,14 @@ class AuthenticationService {
List<dynamic> locals = response.jsonBody['locais'] ?? []; List<dynamic> locals = response.jsonBody['locais'] ?? [];
if (locals.isEmpty) { if (locals.isEmpty) {
StorageUtil().haveLocal = false; await StorageHelper().set(SecureStorageKey.haveLocal.value, 'false', Storage.SecureStorage);
context.go('/receptionPage'); context.go('/receptionPage');
} else { } else {
StorageUtil().haveLocal = true; await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
context.go('/homePage'); context.go('/homePage');
} }
StorageUtil().isLogged = true;
await StorageHelper().set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage);
} }
static Future signIn( static Future signIn(
@ -41,13 +43,9 @@ class AuthenticationService {
try { try {
final ApiCallResponse? response; final ApiCallResponse? response;
final LoginCall callback = PhpGroup.loginCall; final LoginCall callback = PhpGroup.loginCall;
StorageUtil().deviceDescription = randomString( String deviceDescription = randomString(10, 10, true, false, false);
10, await StorageHelper()
10, .set(SecureStorageKey.deviceDescription.value, deviceDescription, Storage.SecureStorage);
true,
false,
false,
);
final String? devUUID; final String? devUUID;
final String userUUID; final String userUUID;
@ -62,9 +60,9 @@ class AuthenticationService {
devUUID = await DeviceUtil.getDevUUID(); devUUID = await DeviceUtil.getDevUUID();
if ((email != '') && (passwd != '')) { if ((email != '') && (passwd != '')) {
StorageUtil().email = email; await StorageHelper().set(SecureStorageKey.email.value, email, Storage.SecureStorage);
StorageUtil().passwd = passwd; await StorageHelper().set(SecureStorageKey.password.value, passwd, Storage.SecureStorage);
StorageUtil().devUUID = devUUID!; await StorageHelper().set(SQLiteStorageKey.devUUID.value, devUUID!, Storage.SQLiteStorage);
response = await callback.call(); response = await callback.call();
if (response.jsonBody['error'] == false) { if (response.jsonBody['error'] == false) {
@ -73,10 +71,10 @@ class AuthenticationService {
userDevUUID = response.jsonBody['user']['dev_id']; userDevUUID = response.jsonBody['user']['dev_id'];
userName = response.jsonBody['user']['name']; userName = response.jsonBody['user']['name'];
StorageUtil().userUUID = userUUID; await StorageHelper().set(SQLiteStorageKey.userUUID.value, userUUID, Storage.SQLiteStorage);
StorageUtil().userDevUUID = userDevUUID; await StorageHelper().set(SQLiteStorageKey.userDevUUID.value, userDevUUID, Storage.SQLiteStorage);
StorageUtil().status = status; await StorageHelper().set(SQLiteStorageKey.status.value, status, Storage.SQLiteStorage);
StorageUtil().userName = userName; await StorageHelper().set(SQLiteStorageKey.userName.value, userName, Storage.SQLiteStorage);
await login(context); await login(context);
} else { } else {
@ -134,8 +132,6 @@ class AuthenticationService {
static Future<void> signOut(BuildContext context) async { static Future<void> signOut(BuildContext context) async {
await PhpGroup.unregisterDevice.call(); await PhpGroup.unregisterDevice.call();
await StorageUtil().purge();
await StorageUtil().ensureInitialization();
final Map<String, dynamic> extra = <String, dynamic>{ final Map<String, dynamic> extra = <String, dynamic>{
kTransitionInfoKey: const TransitionInfo( kTransitionInfoKey: const TransitionInfo(
hasTransition: true, hasTransition: true,
@ -143,6 +139,8 @@ class AuthenticationService {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
), ),
}; };
await StorageHelper().clearAll(Storage.SecureStorage);
await StorageHelper().clearAll(Storage.SQLiteStorage);
context.go('/welcomePage', extra: extra); context.go('/welcomePage', extra: extra);
} }
@ -190,7 +188,7 @@ class AuthenticationService {
static Future<void> deleteAccount(BuildContext context) async { static Future<void> deleteAccount(BuildContext context) async {
String content; String content;
try { try {
await PhpGroup.deleteAccount.call().then((value) { await PhpGroup.deleteAccount.call().then((value) async {
final Map<String, dynamic> extra = <String, dynamic>{ final Map<String, dynamic> extra = <String, dynamic>{
kTransitionInfoKey: const TransitionInfo( kTransitionInfoKey: const TransitionInfo(
hasTransition: true, hasTransition: true,
@ -203,7 +201,7 @@ class AuthenticationService {
enText: 'Account deleted successfully', enText: 'Account deleted successfully',
ptText: 'Conta deletada com sucesso', ptText: 'Conta deletada com sucesso',
); );
StorageUtil().purge(); await StorageHelper().clearAll(Storage.SecureStorage);
context.pop(); context.pop();
context.go('/welcomePage', extra: extra); context.go('/welcomePage', extra: extra);
} }

View File

@ -1,9 +1,12 @@
// ignore_for_file: curly_braces_in_flow_control_structures
import 'dart:developer'; import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/nav/nav.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/dialog_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import '../../../backend/api_requests/api_calls.dart'; import '../../../backend/api_requests/api_calls.dart';
import '../../../components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; import '../../../components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
@ -30,12 +33,12 @@ class LocalizationService {
final bool isEnable = !isEmpty && isActive; final bool isEnable = !isEmpty && isActive;
if (isEnable) { if (isEnable) {
StorageUtil().haveLocal = true; await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage);
StorageUtil().isLogged = true; await StorageHelper().set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage);
await WidgetsBinding.instance.endOfFrame; await WidgetsBinding.instance.endOfFrame;
StorageUtil().cliUUID = ''; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
StorageUtil().ownerUUID = ''; await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage);
StorageUtil().context?.go('/homePage'); StorageHelper().context?.go('/homePage');
} }
} catch (e, s) { } catch (e, s) {
log(e.toString(), stackTrace: s); log(e.toString(), stackTrace: s);
@ -44,7 +47,6 @@ class LocalizationService {
static Future<bool> processLocals(BuildContext context) async { static Future<bool> processLocals(BuildContext context) async {
try { try {
await StorageUtil().ensureInitialization();
final GetLocalsCall callback = PhpGroup.getLocalsCall; final GetLocalsCall callback = PhpGroup.getLocalsCall;
final ApiCallResponse response = await callback.call(); final ApiCallResponse response = await callback.call();
final bool isError = response.jsonBody['error']; final bool isError = response.jsonBody['error'];
@ -59,16 +61,16 @@ class LocalizationService {
_logLocalsStatus(locals); _logLocalsStatus(locals);
final bool isActive = _isActive(locals); final bool isActive = _isActive(locals);
final bool isInactived = _isInactived(locals); final bool isInactived = await _isInactived(locals);
final bool isPending = _isPending(locals); final bool isPending = _isPending(locals);
final bool isUnique = locals.length == 1; final bool isUnique = locals.length == 1;
final bool isBlocked = locals.where((local) => local['CLU_STATUS'] == 'B').isNotEmpty; final bool isBlocked = locals.where((local) => local['CLU_STATUS'] == 'B').isNotEmpty;
final bool isEnabled = isUnique && isActive; final bool isEnabled = isUnique && isActive;
final bool isDisabled = isUnique && isBlocked; final bool isDisabled = isUnique && isBlocked;
final bool isUnselected = _isUnselected(); final bool isUnselected = await _isUnselected();
final bool isSelected = _isSelected(isInactived); final bool isSelected = await _isSelected(isInactived);
final bool isUnavailable = isPending && isUnselected && isUnique; final bool isUnavailable = isPending && isUnselected && isUnique;
final bool isAvailable = _isAvailable(); final bool isAvailable = await _isAvailable();
if (isDisabled) { if (isDisabled) {
AuthenticationService.signOut(context); AuthenticationService.signOut(context);
@ -109,7 +111,6 @@ class LocalizationService {
static Future<bool> processData(BuildContext context) async { static Future<bool> processData(BuildContext context) async {
try { try {
await StorageUtil().ensureInitialization();
final GetDadosCall callback = PhpGroup.getDadosCall; final GetDadosCall callback = PhpGroup.getDadosCall;
var response = await callback.call(); var response = await callback.call();
final bool error = response.jsonBody['error']; final bool error = response.jsonBody['error'];
@ -119,7 +120,7 @@ class LocalizationService {
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context)); DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
return false; return false;
} else { } else {
_updateStorageUtil(response.jsonBody); await _updateStorageUtil(response.jsonBody);
return true; return true;
} }
} catch (e, s) { } catch (e, s) {
@ -161,10 +162,10 @@ class LocalizationService {
ptText: 'Dispositivo desvinculado com sucesso', 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) { if (value.jsonBody['error'] == false) {
StorageUtil().cliName = ''; await StorageHelper().set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage);
StorageUtil().cliUUID = ''; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
context.pop(); context.pop();
context.go( context.go(
'/homePage', '/homePage',
@ -198,27 +199,40 @@ class LocalizationService {
} }
static void _handleError(BuildContext context, String errorMsg) async { static void _handleError(BuildContext context, String errorMsg) async {
await StorageUtil().ensureInitialization(); final String devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? '';
final bool isNotAuthenticated = StorageUtil().userUUID.isEmpty && StorageUtil().devUUID.isEmpty; final String userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? '';
final bool isLinked = errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty;
final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario');
log('() => isLinked: $errorMsg'); log('() => isLinked: $errorMsg');
if (isNotAuthenticated || isLinked) AuthenticationService.signOut(context); if (isAuthenticated && isDevLinked) await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context));
DialogUtil.error(context, errorMsg); if (isAuthenticated && !isDevLinked) {
LogUtil.requestAPIFailed('getLocals.php', '{devUUID: ${StorageUtil().devUUID}, cliUUID: ${StorageUtil().userUUID}}', errorMsg = FFLocalizations.of(context).getVariableText(
'Get Locals', errorMsg, StackTrace.current); ptText: 'Não foi possível vincular o dispositivo, tente novamente',
enText: 'Unable to link device, try again',
);
await DialogUtil.warning(context, errorMsg);
}
if (!isAuthenticated) {
errorMsg = FFLocalizations.of(context).getVariableText(
ptText: 'Erro ao obter credenciais de autenticação',
enText: 'Error getting authentication credentials',
);
await DialogUtil.error(context, errorMsg);
// await DialogUtil.error(context, errorMsg).whenComplete(() async => await AuthenticationService.signOut(context));
}
} }
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async { static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
log('() => isUnavailable'); log('() => isUnavailable');
try { try {
StorageUtil().cliUUID = locals[0]['CLI_ID']; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, locals[0]['CLI_ID'], Storage.SQLiteStorage);
StorageUtil().ownerUUID = locals[0]['CLU_OWNER_ID']; await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID'], Storage.SQLiteStorage);
StorageUtil().cliName = locals[0]['CLI_NOME']; await StorageHelper().set(SQLiteStorageKey.clientName.value, locals[0]['CLI_NOME'], Storage.SQLiteStorage);
var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A');
if (response.jsonBody['error'] == true) { if (response.jsonBody['error'] == true) {
StorageUtil().cliUUID = ''; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
StorageUtil().cliName = ''; await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage);
StorageUtil().ownerUUID = ''; await StorageHelper().set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage);
return false; return false;
} }
if (response.jsonBody['error'] == false) return await processData(context).then((value) => value); if (response.jsonBody['error'] == false) return await processData(context).then((value) => value);
@ -232,10 +246,10 @@ class LocalizationService {
static Future<bool> _handleEnabled(BuildContext context, dynamic local) async { static Future<bool> _handleEnabled(BuildContext context, dynamic local) async {
log('() => isEnabled'); log('() => isEnabled');
StorageUtil().cliName = local['CLI_NOME']; await StorageHelper().set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage);
StorageUtil().userName = local['USU_NOME']; await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
StorageUtil().cliUUID = local['CLI_ID']; await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage);
StorageUtil().ownerUUID = local['CLU_OWNER_ID']; await StorageHelper().set(SQLiteStorageKey.userName.value, local['USU_NOME'], Storage.SQLiteStorage);
return await processData(context); return await processData(context);
} }
@ -250,32 +264,50 @@ class LocalizationService {
return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty; return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty;
} }
static bool _isInactived(List<dynamic> locals) { static Future<bool> _isInactived(List<dynamic> locals) async {
return locals.where((local) => local['CLI_ID'] != StorageUtil().cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty;
} }
static bool _isPending(List<dynamic> locals) { static bool _isPending(List<dynamic> locals) {
return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty; return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty;
} }
static bool _isUnselected() { static Future<bool> _isUnselected() async {
return StorageUtil().cliUUID.isEmpty && StorageUtil().cliName.isEmpty && StorageUtil().ownerUUID.isEmpty; String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
String ownerUUID =
(await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? '';
return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty;
} }
static bool _isSelected(bool isInactived) { static Future<bool> _isSelected(bool isInactived) async {
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty && isInactived; String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived;
} }
static bool _isAvailable() { static Future<bool> _isAvailable() async {
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty; String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
return cliUUID.isNotEmpty && cliName.isNotEmpty;
} }
static void _updateStorageUtil(Map<String, dynamic> jsonBody) { static Future<void> _updateStorageUtil(Map<String, dynamic> jsonBody) async {
StorageUtil().whatsapp = jsonBody['whatsapp'] ?? false; await StorageHelper().set(SQLiteStorageKey.whatsapp.value,
StorageUtil().provisional = jsonBody['provisional'] ?? false; jsonBody['whatsapp'] != null && jsonBody['whatsapp'] ? 'true' : 'false', Storage.SQLiteStorage);
StorageUtil().pets = jsonBody['pet'] ?? false; await StorageHelper().set(SQLiteStorageKey.provisional.value,
StorageUtil().petAmountRegister = jsonBody['provisional'] != null && jsonBody['provisional'] ? 'true' : 'false', Storage.SQLiteStorage);
jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString(); await StorageHelper().set(SQLiteStorageKey.pets.value,
StorageUtil().userName = jsonBody['visitado']['VDO_NOME']; jsonBody['pet'] != null && jsonBody['pet'] ? 'true' : 'false', Storage.SQLiteStorage);
await StorageHelper().set(
SQLiteStorageKey.petAmount.value,
jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty
? '0'
: jsonBody['petAmountRegister'].toString(),
Storage.SQLiteStorage
);
await StorageHelper()
.set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage);
} }
} }

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'; import 'package:share_plus/share_plus.dart';
class ShareUtil { class ShareUtil {
static Future<void> showShare(payload) async { static Future<void> showShare(payload) async {
final cliName = StorageUtil().cliName; final cliName = await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage);
final cliUUID = StorageUtil().cliUUID; final cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage);
for (var i = 0; i < payload['convites'].length; i++) { for (var i = 0; i < payload['convites'].length; i++) {
await Share.share(''' await Share.share('''

View File

@ -1,442 +0,0 @@
import 'dart:developer';
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/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 SQLiteStorageHelper _sqliteStorage;
late SecureStorageHelper _secureStorage;
late 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');
}
}
Future<void> purge() async {
try {
await SecureStorageHelper().purge();
await SQLiteStorageHelper().purge();
_initialized = true;
// await SharedPreferencesStorageHelper().purge();
} catch (e) {
log('Error purging data: $e');
}
}
Future<bool> ensureInitialization() async {
try {
log('StorageUtil: Starting initialization');
if (!_initialized) return true;
if (_initialized) await SharedPreferencesStorageHelper().initialize();
if (_initialized) _secureStorage = SecureStorageHelper();
if (_initialized) _sharedPreferences = SharedPreferencesStorageHelper();
if (_initialized) _sqliteStorage = SQLiteStorageHelper();
await initSecureStorage();
await initSharedPreferences();
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:crop_your_image/crop_your_image.dart';
// import 'package:google_fonts/google_fonts.dart'; // import 'package:google_fonts/google_fonts.dart';
// import '/backend/firebase_storage/storage.dart'; // import '/backend/firebase_storage/base_storage.dart';
// ///////////////// // /////////////////