This commit is contained in:
J. A. Messias 2024-09-25 09:30:58 -03:00
parent d82617c7e1
commit 43f5839db0
61 changed files with 640 additions and 758 deletions

View File

@ -4,6 +4,7 @@ import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/utils/cache_util.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/validator_util.dart';
@ -61,8 +62,8 @@ class UnregisterDevice {
Future<ApiCallResponse> call() async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
return ApiManager.instance.makeApiCall(
callName: 'unregisterDevice',
@ -92,9 +93,9 @@ class DeletePet {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'excluirPet';
return ApiManager.instance.makeApiCall(
@ -137,9 +138,9 @@ class UpdatePet {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'atualizarPet';
return ApiManager.instance.makeApiCall(
@ -185,9 +186,9 @@ class GetPets {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'consultaPets';
return ApiManager.instance.makeApiCall(
@ -221,9 +222,9 @@ class GetPetPhoto {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'consultaFotoPet';
return ApiManager.instance.makeApiCall(
@ -264,9 +265,9 @@ class RegisterPet {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'cadastrarPet';
return ApiManager.instance.makeApiCall(
@ -311,9 +312,9 @@ class BuscaEnconcomendas {
String? adresseeType = '',
String? status = '',
}) async {
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'getEncomendas';
final baseUrl = PhpGroup.getBaseUrl();
@ -355,9 +356,9 @@ class CancelaVisita {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'cancelaVisita';
return ApiManager.instance.makeApiCall(
@ -389,8 +390,8 @@ class CancelaVisita {
class DeleteAccount {
Future<ApiCallResponse> call() async {
final devUUID = CacheUtil.get('devUUID');
final userUUID = CacheUtil.get('userUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final baseUrl = PhpGroup.getBaseUrl();
return ApiManager.instance.makeApiCall(
@ -421,9 +422,9 @@ class ChangePanic {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'updVisitado';
return ApiManager.instance.makeApiCall(
@ -457,9 +458,9 @@ class ChangePass {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'updVisitado';
return ApiManager.instance.makeApiCall(
@ -494,8 +495,8 @@ class RespondeVinculo {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
return ApiManager.instance.makeApiCall(
callName: 'respondeVinculo',
@ -527,9 +528,9 @@ class ChangeNotifica {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = CacheUtil.get('devUUID');
final userUUID = CacheUtil.get('userUUID');
final cliID = CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'updVisitado';
return ApiManager.instance.makeApiCall(
@ -561,9 +562,9 @@ class UpdToken {
Future<ApiCallResponse> call() async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final token = AppState().token;
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final token = SecureStorageHelper().token;
return ApiManager.instance.makeApiCall(
callName: 'updToken',
@ -590,12 +591,12 @@ class UpdToken {
class LoginCall {
Future<ApiCallResponse> call() async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = CacheUtil.get('devUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final email = AppState().email;
final password = AppState().passwd;
final type = AppState().deviceType;
final description = AppState().deviceDescription;
final email = SecureStorageHelper().email;
final password = SecureStorageHelper().passwd;
final type = SecureStorageHelper().deviceType;
final description = SecureStorageHelper().deviceDescription;
final token = FirebaseMessagingService.getToken();
return ApiManager.instance.makeApiCall(
@ -694,8 +695,8 @@ class GetLocalsCall {
Future<ApiCallResponse> call() async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
return ApiManager.instance.makeApiCall(
callName: 'getLocals',
@ -734,9 +735,9 @@ class PostScheduleVisitorCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'putVisitante';
return ApiManager.instance.makeApiCall(
@ -789,9 +790,9 @@ class PostScheduleVisitCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'putVisita';
return ApiManager.instance.makeApiCall(
@ -843,9 +844,9 @@ class GetScheduleVisitCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliUUID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
const atividade = 'getVisitas';
return ApiManager.instance.makeApiCall(
@ -1117,9 +1118,9 @@ class GetDadosCall {
Future<ApiCallResponse> call() async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliUUID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
const atividade = 'getDados';
return ApiManager.instance.makeApiCall(
@ -1360,9 +1361,9 @@ class GetVisitorByDocCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'getVisitante';
return ApiManager.instance.makeApiCall(
@ -1414,9 +1415,9 @@ class GetFotoVisitanteCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'getFotoVisitante';
return ApiManager.instance.makeApiCall(
@ -1453,9 +1454,9 @@ class PostProvVisitSchedulingCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'putAgendamentoProv';
return ApiManager.instance.makeApiCall(
@ -1502,9 +1503,9 @@ class GetVisitsCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'getVisitas';
return ApiManager.instance.makeApiCall(
@ -1765,9 +1766,9 @@ class DeleteVisitCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliID = SQLiteStorageHelper().cliUUID;
const atividade = 'cancelaVisita';
return ApiManager.instance.makeApiCall(
@ -1808,10 +1809,10 @@ class GetPessoasLocalCall {
Future<ApiCallResponse> call() async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final ownerUUID = await CacheUtil.get('ownerUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliUUID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final ownerUUID = SQLiteStorageHelper().ownerUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
return ApiManager.instance.makeApiCall(
callName: 'getPessoasLocal',
@ -1874,9 +1875,9 @@ class RespondeSolicitacaoCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliUUID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
const atividade = 'respondeSolicitacao';
return ApiManager.instance.makeApiCall(
@ -1924,9 +1925,9 @@ class GetAccessCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = await CacheUtil.get('devUUID');
final userUUID = await CacheUtil.get('userUUID');
final cliUUID = await CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
const atividade = 'getAcessos';
return ApiManager.instance.makeApiCall(
@ -2173,10 +2174,10 @@ class GetLiberationsCall {
final StreamController<ApiCallResponse> controller = StreamController();
Future.microtask(() async {
final devUUID = CacheUtil.get('devUUID');
final userUUID = CacheUtil.get('userUUID');
final cliUUID = CacheUtil.get('cliUUID');
const atividade = 'getLiberacoes';
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
const atividade = 'getSolicitacoes';
try {
final response = await ApiManager.instance.makeApiCall(
@ -2365,9 +2366,9 @@ class GetMessagesCall {
}) async {
final baseUrl = PhpGroup.getBaseUrl();
final devUUID = CacheUtil.get('devUUID');
final userUUID = CacheUtil.get('userUUID');
final cliUUID = CacheUtil.get('cliUUID');
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
const atividade = 'getMensagens';
return ApiManager.instance.makeApiCall(

View File

@ -1,5 +1,3 @@
// ignore_for_file: constant_identifier_names, depend_on_referenced_packages, prefer_final_fields
import 'dart:convert';
import 'dart:core';
import 'dart:developer';
@ -107,11 +105,8 @@ class ApiCallResponse {
final http.Response? response;
final http.StreamedResponse? streamedResponse;
final Object? exception;
// Whether we received a 2xx status (which generally marks success).
bool get succeeded => statusCode >= 200 && statusCode < 300;
String getHeader(String headerName) => headers[headerName] ?? '';
// Return the raw body from the response, or if this came from a cloud call
// and the body is not a string, then the json encoded body.
String get bodyText =>
response?.body ??
(jsonBody is String ? jsonBody as String : jsonEncode(jsonBody));
@ -126,7 +121,7 @@ class ApiCallResponse {
dynamic jsonBody;
try {
if (bodyType == BodyType.BLOB) {
jsonBody = response.bodyBytes; // Armazenar os bytes diretamente
jsonBody = response.bodyBytes;
} else {
final responseBody = decodeUtf8 && returnBody
? const Utf8Decoder().convert(response.bodyBytes)
@ -153,19 +148,13 @@ class ApiCallResponse {
class ApiManager {
ApiManager._();
// Cache that will ensure identical calls are not repeatedly made.
static Map<ApiCallOptions, ApiCallResponse> _apiCache = {};
static ApiManager? _instance;
static ApiManager get instance => _instance ??= ApiManager._();
// If your API calls need authentication, populate this field once
// the user has authenticated. Alter this as needed.
static String? _accessToken;
// You may want to call this if, for example, you make a change to the
// database and no longer want the cached result of a call that may
// have changed.
static void clearCache(String callName) => _apiCache.keys
.toSet()
.forEach((k) => k.callName == callName ? _apiCache.remove(k) : null);
@ -187,7 +176,7 @@ class ApiManager {
bool decodeUtf8,
bool isStreamingApi, {
http.Client? client,
BodyType? bodyType, // Adicionado para verificar o tipo de corpo
BodyType? bodyType,
}) async {
if (params.isNotEmpty) {
final specifier =
@ -213,7 +202,7 @@ class ApiManager {
final response =
await makeRequest(Uri.parse(apiUrl), headers: toStringMap(headers));
return ApiCallResponse.fromHttpResponse(
response, returnBody, decodeUtf8, bodyType); // Passar bodyType
response, returnBody, decodeUtf8, bodyType);
}
static Future<ApiCallResponse> requestWithBody(
@ -368,7 +357,6 @@ class ApiManager {
case null:
break;
}
// Set "Content-Type" header if it was previously unset.
if (contentType != null &&
!headers.keys.any((h) => h.toLowerCase() == 'content-type')) {
headers['Content-Type'] = contentType;
@ -428,7 +416,6 @@ class ApiManager {
cache: cache,
isStreamingApi: isStreamingApi,
);
// Modify for your specific needs if this differs from your API.
if (_accessToken != null) {
headers[HttpHeaders.authorizationHeader] = 'Bearer $_accessToken';
}
@ -436,8 +423,6 @@ class ApiManager {
apiUrl = 'https://$apiUrl';
}
// If we've already made this exact call before and caching is on,
// return the cached result.
if (cache && _apiCache.containsKey(callOptions)) {
return _apiCache[callOptions]!;
}
@ -504,7 +489,6 @@ class ApiManager {
break;
}
// If caching is on, cache the result (if present).
if (cache) {
_apiCache[callOptions] = result;
}

View File

@ -4,6 +4,7 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:hub/app_state.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/log_util.dart';
@ -64,7 +65,7 @@ class FirebaseMessagingService {
final String? deviceToken = await _firebaseMessaging.getToken();
if (deviceToken != null) {
AppState().token = deviceToken;
SecureStorageHelper().token = deviceToken;
final ApiCallResponse? response;
response = await PhpGroup.updToken.call();

View File

@ -13,6 +13,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_widgets.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:sqflite/sqflite.dart';
@ -20,10 +21,8 @@ import 'package:sqflite/sqflite.dart';
Future<void> onMessageReceived(
Map<String, dynamic> payload, String? extra, String? handleClick) async {
final localId = jsonDecode(payload['local']!)['CLI_ID'];
final SQLiteStorageHelper db = SQLiteStorageHelper();
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final cliUUID = SQLiteStorageHelper().cliUUID;
answersRequest(
{required BuildContext context,
required String? ref,
@ -50,7 +49,7 @@ Future<void> onMessageReceived(
switch (handleClick) {
case 'visit_request':
showDialog(
context: AppState().context!,
context: SecureStorageHelper().context!,
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (BuildContext context) {
@ -173,7 +172,7 @@ Future<void> onMessageReceived(
break;
case 'access':
showDialog(
context: AppState().context!,
context: SecureStorageHelper().context!,
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (BuildContext context) {
@ -232,7 +231,7 @@ Future<void> onMessageReceived(
break;
case 'mensagem':
showDialog(
context: AppState().context!,
context: SecureStorageHelper().context!,
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (BuildContext context) {
@ -255,8 +254,8 @@ Future<void> onMessageReceived(
break;
case 'enroll_cond':
AppState().haveLocal = true;
AppState().context!.go('/homePage');
SecureStorageHelper().haveLocal = true;
SecureStorageHelper().context!.go('/homePage');
break;
default:
break;
@ -292,14 +291,12 @@ class NotificationService {
await AwesomeNotifications()
.isNotificationAllowed()
.then((isAllowed) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final bool requestOSnotification = await db
.get(key: 'requestOSnotification', field: 'value')
.then((value) => value.toString() == 'true');
final bool requestOSnotification =
SQLiteStorageHelper().requestOSnotification;
if (!requestOSnotification) {
if (!isAllowed) {
await db.update('requestOSnotification', 'true', 'util');
SQLiteStorageHelper().requestOSnotification = true;
await AwesomeNotifications().requestPermissionToSendNotifications();
}
}

View File

@ -34,10 +34,7 @@ class _MenuButtonWidgetState extends State<MenuButtonWidget> {
hoverColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: () async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final cliUUID = SQLiteStorageHelper().cliUUID;
if (cliUUID.isEmpty) {
return DialogUtil.warningDefault(context);

View File

@ -4,6 +4,7 @@ import 'package:hub/components/molecular_components/order_filter_modal/order_fil
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
class OrderFilterModalWidget extends StatefulWidget {
final String defaultAdresseeType;
@ -25,24 +26,25 @@ class _OrderFilterModalWidgetState extends State<OrderFilterModalWidget> {
late Map<String, dynamic> selected;
final List<Map<String, String>> adresseeTypeOptions = [
{
'title': FFLocalizations.of(AppState().context!)
'title': FFLocalizations.of(SecureStorageHelper().context!)
.getVariableText(enText: 'Resident', ptText: 'Morador'),
'value': 'MOR'
},
{
'title': FFLocalizations.of(AppState().context!)
'title': FFLocalizations.of(SecureStorageHelper().context!)
.getVariableText(enText: 'Property', ptText: 'Propriedade'),
'value': 'PRO'
},
];
final List<Map<String, String>> statusOptions = [
{
'title': FFLocalizations.of(AppState().context!).getVariableText(
'title': FFLocalizations.of(SecureStorageHelper().context!)
.getVariableText(
ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'),
'value': 'notPickedUp'
},
{
'title': FFLocalizations.of(AppState().context!)
'title': FFLocalizations.of(SecureStorageHelper().context!)
.getVariableText(ptText: 'Retirado', enText: 'Picked Up'),
'value': 'pickedUp'
},

View File

@ -65,10 +65,6 @@ class _BottomArrowLinkedLocalsComponentWidgetState
Future<ApiCallResponse?> _fetchLocals() async {
try {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final devUUID = await db.get(key: 'devUUID', field: 'value');
final userUUID = await db.get(key: 'userUUID', field: 'value');
setState(() => _loading = true);
var response = await PhpGroup.getLocalsCall.call();
@ -84,9 +80,9 @@ class _BottomArrowLinkedLocalsComponentWidgetState
// Verifica se apenas um local e se o status é 'A'
if (locals.length == 1 && locals[0]['CLU_STATUS'] == 'A') {
final local = locals[0];
db.update('cliUUID', local['CLI_ID'], 'local');
db.update('cliName', local['CLI_NOME'], 'local');
db.update('ownerUUID', local['CLU_OWNER_ID'], 'local');
SQLiteStorageHelper().cliName = local['CLI_NOME'];
SQLiteStorageHelper().cliUUID = local['CLI_ID'];
SQLiteStorageHelper().ownerUUID = local['CLU_OWNER_ID'];
context.pop();
}
@ -173,12 +169,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState
labelsHashMap: _labelsHashMap(local),
statusHashMap: [_statusHashMap(local)],
onTapCardItemAction: () async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
if (local['CLU_STATUS'] == 'A') {
db.update('cliUUID', local['CLI_ID'], 'local');
db.update('cliName', local['CLI_NOME'], 'local');
db.update('ownerUUID', local['CLU_OWNER_ID'], 'local');
SQLiteStorageHelper().cliUUID = local['CLI_ID'];
SQLiteStorageHelper().cliName = local['CLI_NOME'];
SQLiteStorageHelper().ownerUUID = local['CLU_OWNER_ID'];
context.pop();
} else if (local['CLU_STATUS'] == 'B') {
@ -247,8 +241,6 @@ class _BottomArrowLinkedLocalsComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
double height = MediaQuery.sizeOf(context).height;
return Align(

View File

@ -1,4 +1,3 @@
import 'dart:ffi';
import 'dart:math';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
@ -11,7 +10,6 @@ import 'package:flutter/material.dart';
class LocalProfileComponentModel
extends FlutterFlowModel<LocalProfileComponentWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
String cliName = '';
String cliUUID = '';
VoidCallback? setStateCallback;
@ -22,12 +20,8 @@ class LocalProfileComponentModel
}
Future<void> getData() async {
cliName = await db
.get(key: 'cliName', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
cliName = SQLiteStorageHelper().cliName;
cliUUID = SQLiteStorageHelper().cliUUID;
setStateCallback?.call();
}

View File

@ -16,8 +16,6 @@ import 'local_profile_component_model.dart';
export 'local_profile_component_model.dart';
////
class LocalProfileComponentWidget extends StatefulWidget {
LocalProfileComponentWidget({Key? key}) : super(key: key);
@ -29,7 +27,6 @@ class LocalProfileComponentWidget extends StatefulWidget {
class _LocalProfileComponentWidgetState
extends State<LocalProfileComponentWidget> {
late LocalProfileComponentModel _model;
final SQLiteStorageHelper db = SQLiteStorageHelper();
@override
void setState(VoidCallback callback) {
@ -45,9 +42,7 @@ class _LocalProfileComponentWidgetState
_model.setStateCallback = () => safeSetState(() {});
() async {
_model.cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
_model.cliUUID = SQLiteStorageHelper().cliUUID;
if (_model.cliUUID.isEmpty) {
await processLocals();
@ -78,11 +73,11 @@ class _LocalProfileComponentWidgetState
final petAmountRegister = response.jsonBody['petAmountRegister'] ?? '0';
final name = response.jsonBody['visitado']['VDO_NOME'];
await db.update('whatsapp', whatsapp.toString(), 'local');
await db.update('provisional', provisional.toString(), 'local');
await db.update('pets', pets.toString(), 'local');
await db.update('petAmountRegister', petAmountRegister, 'local');
await db.update('name', name, 'local');
SQLiteStorageHelper().whatsapp = whatsapp;
SQLiteStorageHelper().provisional = provisional;
SQLiteStorageHelper().pets = pets;
SQLiteStorageHelper().petAmountRegister = petAmountRegister;
SQLiteStorageHelper().cliName = name;
safeSetState(() {});
return;
@ -100,9 +95,7 @@ class _LocalProfileComponentWidgetState
try {
final GetLocalsCall callback = PhpGroup.getLocalsCall;
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final cliUUID = SQLiteStorageHelper().cliUUID;
var response = await callback.call();
List<dynamic> locals = response.jsonBody['locais'] ?? [];
@ -146,8 +139,6 @@ class _LocalProfileComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Container(
decoration: const BoxDecoration(),
child: Align(

View File

@ -3,7 +3,9 @@ import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/extensions/dialog_extensions.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:sqflite/sqflite.dart';
import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
@ -70,11 +72,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future deliverySchedule(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final bool isProvisional = await db
.get(key: 'provisional', field: 'value')
.then((value) => value.toString() == 'true') as bool;
final bool isProvisional = SQLiteStorageHelper().provisional;
if (isProvisional == true) {
context.push(
@ -93,11 +91,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future provisionalSchedule(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final isProvisional = await db
.get(key: 'provisional', field: 'value')
.then((value) => value.toString() == 'true') as bool;
final isProvisional = SQLiteStorageHelper().provisional;
if (isProvisional == true) {
context.push(
'/provisionalSchedule',
@ -115,10 +109,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future fastPassAction(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
final isWpp = SQLiteStorageHelper().whatsapp;
if (isWpp) {
context.push(
'/fastPassPage',
@ -202,8 +193,6 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future<void> signOut(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
showAlertDialog(
context,
'Logout',
@ -212,7 +201,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
ptText: 'Tem certeza',
), () async {
PhpGroup.unregisterDevice.call();
AppState().deleteAll();
StorageManager.purge();
context.go(
'/welcomePage',
@ -224,7 +213,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
),
},
);
await db.purge();
await SQLiteStorageHelper().purge();
});
}
@ -242,10 +231,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future packageOrder(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
final isWpp = SQLiteStorageHelper().whatsapp;
if (isWpp) {
context.push(
@ -264,10 +250,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future reservation(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
final isWpp = SQLiteStorageHelper().whatsapp;
if (isWpp) {
context.push(
'/reservation',
@ -383,10 +366,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
}
Future petsAction(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
bool isPet = await db.get(key: 'pets', field: 'value').then((value) {
return value.toString() == 'true';
}) as bool;
bool isPet = SQLiteStorageHelper().pets;
if (isPet) {
context.push(
'/petsPage',

View File

@ -339,7 +339,6 @@ class MessageWellState {
class MessageWellNotifier extends StateNotifier<MessageWellState> {
var _totalPageNumber = 1;
int get totalPageNumber => _totalPageNumber;
final SQLiteStorageHelper db = SQLiteStorageHelper();
set totalPageNumber(int value) {
_totalPageNumber = value;

View File

@ -10,7 +10,6 @@ import 'package:intl/intl.dart';
class ScheduleVisitDetailModel
extends FlutterFlowModel<ScheduleVisitDetailWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -60,9 +59,9 @@ class ScheduleVisitDetailModel
}
Future<void> initDB() async {
devUUID = await db.get(key: 'devUUID', field: 'value');
userUUID = await db.get(key: 'userUUID', field: 'value');
cliUUID = await db.get(key: 'cliUUID', field: 'value');
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -94,7 +94,6 @@ class _ScheduleVisitDetailWidgetState extends State<ScheduleVisitDetailWidget> {
@override
Widget build(BuildContext context) {
context.watch<AppState>();
final visitorsData = widget.visitorJsonList!.toList().take(2).toList();
final visitorsDataItem = visitorsData[0];

View File

@ -6,7 +6,6 @@ import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
class UpArrowLinkedLocalsComponentModel
extends FlutterFlowModel<UpArrowLinkedLocalsComponentWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -18,18 +17,10 @@ class UpArrowLinkedLocalsComponentModel
}
Future<void> initDB() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
cliName = await db
.get(key: 'cliName', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
cliName = SQLiteStorageHelper().cliName;
}
@override

View File

@ -42,8 +42,6 @@ class _UpArrowLinkedLocalsComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Align(
alignment: const AlignmentDirectional(0.0, -1.0),
child: Container(

View File

@ -9,7 +9,6 @@ import 'access_notification_modal_template_component_widget.dart'
class AccessNotificationModalTemplateComponentModel
extends FlutterFlowModel<AccessNotificationModalTemplateComponentWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -33,15 +32,9 @@ class AccessNotificationModalTemplateComponentModel
}
Future<void> initDB() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -67,8 +67,6 @@ class _AccessNotificationModalTemplateComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
String labelTypeResident = FFLocalizations.of(context)
.getVariableText(enText: 'Resident', ptText: 'Morador');

View File

@ -208,8 +208,6 @@ class _CardItemTemplateComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return InkWell(
splashColor: Colors.transparent,
focusColor: Colors.transparent,

View File

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
@ -129,7 +130,7 @@ class _PassKeyTemplateWidgetState extends State<PassKeyTemplateWidget> {
child: Text(
FFLocalizations.of(context).getVariableText(
enText: 'INSERT PASSWORD',
ptText: AppState().accessPass != ''
ptText: SecureStorageHelper().accessPass != ''
? 'ALTERAR SENHA'
: 'ADICIONAR SENHA',
),
@ -316,9 +317,12 @@ class _PassKeyTemplateWidgetState extends State<PassKeyTemplateWidget> {
context.pop(true);
},
text: FFLocalizations.of(context).getVariableText(
ptText:
AppState().accessPass != '' ? 'Alterar' : 'Adicionar',
enText: AppState().accessPass != '' ? 'Change' : 'Add',
ptText: SecureStorageHelper().accessPass != ''
? 'Alterar'
: 'Adicionar',
enText: SecureStorageHelper().accessPass != ''
? 'Change'
: 'Add',
),
options: FFButtonOptions(
width: 270.0,

View File

@ -64,7 +64,6 @@ class _DetailsComponentWidgetState extends State<DetailsComponentWidget> {
@override
Widget build(BuildContext context) {
context.watch<AppState>();
// CachedNetworkImage.evictFromCache(widget.imagePath ?? '');
return Container(

View File

@ -9,7 +9,6 @@ import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
class LiberationHistoryItemDetailsTemplateComponentModel
extends FlutterFlowModel<
LiberationHistoryItemDetailsTemplateComponentWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -31,15 +30,9 @@ class LiberationHistoryItemDetailsTemplateComponentModel
void initState(BuildContext context) {}
Future<void> initDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -68,8 +68,6 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Align(
alignment: const AlignmentDirectional(0.0, 0.0),
child: Padding(

View File

@ -59,8 +59,6 @@ class _MessageNotificationModalTemplateComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Container(
width: MediaQuery.sizeOf(context).width,
height: MediaQuery.sizeOf(context).height,

View File

@ -7,7 +7,6 @@ import 'package:sqflite/sqflite.dart';
class ScheduleProvisionalVisitPageModel
extends FlutterFlowModel<ScheduleProvisionalVisitPageWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
String cliUUID = '';
String devUUID = '';
String userUUID = '';
@ -125,11 +124,11 @@ class ScheduleProvisionalVisitPageModel
}
Future<void> init() async {
cliUUID = await db.get(key: 'cliUUID', field: 'value');
devUUID = await db.get(key: 'devUUID', field: 'value');
userUUID = await db.get(key: 'userUUID', field: 'value');
cliName = await db.get(key: 'cliName', field: 'value');
ownerUUID = await db.get(key: 'ownerUUID', field: 'value');
cliUUID = SQLiteStorageHelper().cliUUID;
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliName = SQLiteStorageHelper().cliName;
ownerUUID = SQLiteStorageHelper().ownerUUID;
setState?.call();
}

View File

@ -42,8 +42,6 @@ class _ScheduleProvisionalVisitPageWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: SingleChildScrollView(

View File

@ -12,7 +12,6 @@ import 'regisiter_vistor_template_component_widget.dart';
class RegisiterVistorTemplateComponentModel
extends FlutterFlowModel<RegisiterVistorTemplateComponentWidget> {
Timer? _debounceTimer;
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -135,9 +134,9 @@ class RegisiterVistorTemplateComponentModel
}
Future<void> initializeDatabase() async {
devUUID = await db.get(key: 'devUUID', field: 'value');
userUUID = await db.get(key: 'userUUID', field: 'value');
cliUUID = await db.get(key: 'cliUUID', field: 'value');
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -121,7 +121,6 @@ class _RegisiterVistorTemplateComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Align(
alignment: const AlignmentDirectional(0.0, 1.0),
child: Container(

View File

@ -3,6 +3,7 @@ import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/flutter_flow/random_data_util.dart';
import 'package:hub/pages/home_page/home_page_model.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/device_util.dart';
import 'package:hub/shared/utils/dialog_util.dart';
@ -86,9 +87,8 @@ class SignInTemplateComponentModel
}) async {
try {
final ApiCallResponse? response;
final SQLiteStorageHelper db = SQLiteStorageHelper();
final LoginCall callback = PhpGroup.loginCall;
AppState().deviceDescription = randomString(
SecureStorageHelper().deviceDescription = randomString(
10,
10,
true,
@ -111,8 +111,8 @@ class SignInTemplateComponentModel
devUUID = await DeviceUtil.getDevUUID();
if ((email != '') && (passwd != '')) {
AppState().email = email;
AppState().passwd = passwd;
SecureStorageHelper().email = email;
SecureStorageHelper().passwd = passwd;
response = await callback.call();
if (response.jsonBody['error'] == false) {
@ -122,17 +122,17 @@ class SignInTemplateComponentModel
userDevUUID = response.jsonBody['user']['dev_id'];
userName = response.jsonBody['user']['name'];
db.update('devUUID', devUUID, 'user');
db.update('userUUID', userUUID, 'user');
db.update('userDevUUID', userDevUUID, 'user');
db.update('status', status, 'user');
db.update('userName', userName, 'user');
SQLiteStorageHelper().devUUID = devUUID!;
SQLiteStorageHelper().userUUID = userUUID;
SQLiteStorageHelper().userDevUUID = userDevUUID;
SQLiteStorageHelper().status = status;
SQLiteStorageHelper().userName = userName;
isLogged = true;
await checkLocals(context: context, model: model).then((value) {
AppState().haveLocal = value;
AppState().isLogged = isLogged;
AppState().update(() {});
SecureStorageHelper().haveLocal = value;
SecureStorageHelper().isLogged = isLogged;
SecureStorageHelper().update(() {});
toggleApp(context);
});
} else {
@ -154,7 +154,7 @@ class SignInTemplateComponentModel
}
Future toggleApp(BuildContext context) async {
final haveLocal = AppState().haveLocal;
final haveLocal = SecureStorageHelper().haveLocal;
if (haveLocal == true) {
context.go('/homePage');
} else if (haveLocal == false) {

View File

@ -4,6 +4,7 @@ import 'package:flutter_animate/flutter_animate.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart';
import 'package:hub/shared/components/atoms/atom_terms_of_use.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/utils/validator_util.dart';
import 'package:provider/provider.dart';
@ -124,8 +125,6 @@ class _SignUpTemplateComponentWidgetState
return false;
}
context.watch<AppState>();
return Row(
mainAxisSize: MainAxisSize.max,
children: [
@ -702,7 +701,8 @@ class _SignUpTemplateComponentWidgetState
.emailRegisterFormTextController
.text,
device:
AppState().deviceType,
SecureStorageHelper()
.deviceType,
);
shouldSetState = true;
if (_model.signUp == true) {

View File

@ -6,7 +6,6 @@ import 'view_visit_detail_widget.dart' show ViewVisitDetailWidget;
import 'package:flutter/material.dart';
class ViewVisitDetailModel extends FlutterFlowModel<ViewVisitDetailWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -37,15 +36,9 @@ class ViewVisitDetailModel extends FlutterFlowModel<ViewVisitDetailWidget> {
}
Future<void> initializeDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -121,8 +121,6 @@ class _ViewVisitDetailWidgetState extends State<ViewVisitDetailWidget> {
var filteredVisitorJsonList =
findVisitorById(widget.visitorJsonList, widget.visitIdStr) ?? 'null';
context.watch<AppState>();
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 200.0, 0.0, 0.0),
child: Container(

View File

@ -7,7 +7,6 @@ import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
class VisitorSearchModalTemplateComponentModel
extends FlutterFlowModel<VisitorSearchModalTemplateComponentWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -40,15 +39,9 @@ class VisitorSearchModalTemplateComponentModel
}
Future<void> initDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -59,8 +59,6 @@ class _VisitorSearchModalTemplateComponentWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0),
child: Container(

View File

@ -10,6 +10,7 @@ import 'package:hub/pages/pets_page/pets_page_widget.dart';
import 'package:hub/pages/provisional_schedule_page/provisional_schedule_widget.dart';
import 'package:hub/pages/reception_page/reception_page_widget.dart';
import 'package:hub/pages/reservation_page/reservation_page_widget.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:provider/provider.dart';
import '/backend/schema/structs/index.dart';
@ -72,8 +73,8 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter(
FFRoute(
name: '_initialize',
path: '/',
builder: (context, _) => AppState().isLogged
? AppState().haveLocal == true
builder: (context, _) => SecureStorageHelper().isLogged
? SecureStorageHelper().haveLocal == true
? const HomePageWidget()
: const ReceptionPageWidget()
: const WelcomePageWidget(),

View File

@ -26,18 +26,20 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
Future<void> initializeApp() async {
WidgetsFlutterBinding.ensureInitialized();
await SQLiteStorageHelper().database;
final sharedPreferencesHelper = SharedPreferencesStorageHelper();
SQLiteStorageHelper().deleteDatabaseDB();
final SharedPreferencesStorageHelper sharedPreferencesHelper =
SharedPreferencesStorageHelper();
final SecureStorageHelper secureStorageHelper = SecureStorageHelper();
await sharedPreferencesHelper.initialize();
await sharedPreferencesHelper.ensureInitialization();
await secureStorageHelper.ensureInitilization();
if (sharedPreferencesHelper.isFirstRun) {
// Execute actions for the first run
sharedPreferencesHelper.isFirstRun = false;
secureStorageHelper.deleteAll();
secureStorageHelper.purge();
}
final status = await AppTrackingTransparency.requestTrackingAuthorization();
await AppTrackingTransparency.requestTrackingAuthorization();
await Firebase.initializeApp();
await NotificationService.initialize();
@ -61,7 +63,7 @@ Future<void> initializeApp() async {
Future<void> foregroundHandleMessage(RemoteMessage message) async {
if (message.data['click_action'] == 'enroll_cond') {
SecureStorageHelper().set('haveLocal', 'true');
SecureStorageHelper().haveLocal = true;
SecureStorageHelper().context?.go('/homePage');
}
if (!Platform.isIOS) {
@ -123,6 +125,8 @@ class _AppState extends State<App> {
_backgroundHandleMessage(message);
}
});
// SecureStorageHelper().isLogged = false;
}
void setLocale(String language) {
@ -139,11 +143,7 @@ class _AppState extends State<App> {
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: const [],
// ChangeNotifierProvider(create: (_) => {AppState()}),
child: MaterialApp.router(
return MaterialApp.router(
title: 'FRE ACCESS HUB',
builder: (context, widget) => ResponsiveBreakpoints.builder(
child: BouncingScrollWrapper.builder(context, widget!),
@ -199,7 +199,6 @@ class _AppState extends State<App> {
),
themeMode: _themeMode,
routerConfig: _router,
),
);
}
}

View File

@ -7,7 +7,6 @@ import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -34,15 +33,9 @@ class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
}
Future<void> initDatabase() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -31,7 +31,6 @@ class _DeliveryScheduleState extends State<DeliverySchedule> {
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Scaffold(
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -5,6 +5,7 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:hub/app_state.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/webview_util.dart';
import 'package:url_launcher/url_launcher_string.dart';
@ -18,25 +19,14 @@ class FastPassPageWidget extends StatefulWidget {
class _FastPassPageWidgetState extends State<FastPassPageWidget> {
late InAppWebViewController _controllerIOS;
late WebViewController _controllerAll;
final SQLiteStorageHelper db = SQLiteStorageHelper();
Future<Map<String, String>> initVariables() async {
final email = AppState().email;
final name = await db
.get(key: 'userName', field: 'value')
.then((value) => value.toString());
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final createdAt = await db
.get(key: 'devUUID', field: 'createdAt')
.then((value) => value.toString());
final email = SecureStorageHelper().email;
final name = SQLiteStorageHelper().userName;
final userUUID = SQLiteStorageHelper().userUUID;
final devUUID = SQLiteStorageHelper().devUUID;
final cliUUID = SQLiteStorageHelper().cliUUID;
final createdAt = '0000-00-00 00:00:00';
final url = 'https://hub.freaccess.com.br/hub/fast-pass/$cliUUID';
final freUserData = "{\"name\": \"$name\", " +
"\"email\": \"$email\"," +

View File

@ -5,11 +5,11 @@ import 'package:hub/components/organism_components/menu_component/menu_component
import 'package:hub/components/organism_components/message_well_component/message_well_component_model.dart';
import 'package:hub/flutter_flow/flutter_flow_model.dart';
import 'package:hub/pages/home_page/home_page_widget.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
class HomePageModel extends FlutterFlowModel<HomePageWidget> {
bool isGrid = false;
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String cliUUID;
late final String userUUID;
@ -25,19 +25,11 @@ class HomePageModel extends FlutterFlowModel<HomePageWidget> {
late MessageWellComponentModel messageWellComponentModel;
Future<void> _initVariable() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
userName = await db
.get(key: 'userName', field: 'value')
.then((value) => value.toString());
userEmail = AppState().email;
devUUID = SQLiteStorageHelper().devUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
userUUID = SQLiteStorageHelper().userUUID;
userName = SQLiteStorageHelper().cliName;
userEmail = SecureStorageHelper().email;
}
@override

View File

@ -11,6 +11,7 @@ import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/pages/home_page/home_page_model.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart';
@ -25,7 +26,6 @@ class _HomePageWidgetState extends State<HomePageWidget> {
late HomePageModel _model;
final scaffoldKey = GlobalKey<ScaffoldState>();
late LocalProfileComponentWidget _localProfileComponentWidget;
final SQLiteStorageHelper db = SQLiteStorageHelper();
_HomePageWidgetState() {
_localProfileComponentWidget = LocalProfileComponentWidget();
@ -52,7 +52,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
@override
Widget build(BuildContext context) {
AppState().context = context;
SecureStorageHelper().context = context;
return GestureDetector(
onTap: () => _model.unfocusNode.canRequestFocus
? FocusScope.of(context).requestFocus(_model.unfocusNode)

View File

@ -8,7 +8,6 @@ import 'package:hub/pages/liberation_history/liberation_history_widget.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -39,15 +38,9 @@ class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
}
Future<void> init() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliName;
}
Future answersRequest(

View File

@ -90,7 +90,6 @@ class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Scaffold(
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -9,7 +9,6 @@ import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
class MessageHistoryPageModel
extends FlutterFlowModel<MessageHistoryPageWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -44,15 +43,9 @@ class MessageHistoryPageModel
}
Future<void> init() async {
devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -85,7 +85,6 @@ class _MessageHistoryPageWidgetState extends State<MessageHistoryPageWidget>
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Scaffold(
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -28,7 +28,6 @@ class _PackageOrderPage extends State<PackageOrderPage> {
final int _pageSize = 10;
bool _hasData = false;
bool _loading = false;
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String cliUUID;
late Future<void> _orderFuture;
@ -64,9 +63,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
}
Future<void> initDatabase() async {
cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override

View File

@ -41,8 +41,6 @@ class _PeopleOnThePropertyPageWidgetState
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Scaffold(
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -243,19 +243,10 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
}
],
onTapCardItemAction: () async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final cliUUID = await db
.get(key: 'cliUUID', field: 'value')
.then((value) => value.toString());
final cliName = await db
.get(key: 'cliName', field: 'value')
.then((value) => value.toString());
final devUUID = await db
.get(key: 'devUUID', field: 'value')
.then((value) => value.toString());
final userUUID = await db
.get(key: 'userUUID', field: 'value')
.then((value) => value.toString());
final cliUUID = SQLiteStorageHelper().cliUUID;
final cliName = SQLiteStorageHelper().cliName;
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
await showDialog(
useSafeArea: true,
context: context,

View File

@ -19,7 +19,6 @@ import 'package:hub/shared/utils/log_util.dart';
import 'package:hub/shared/utils/validator_util.dart';
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -103,18 +102,10 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
String? Function(BuildContext, String?)? textControllerObservationValidator;
Future<void> initAsync() async {
devUUID = await db.get(key: 'devUUID', field: 'value').then((value) {
return value.toString();
});
userUUID = await db.get(key: 'userUUID', field: 'value').then((value) {
return value.toString();
});
cliUUID = await db.get(key: 'cliUUID', field: 'value').then((value) {
return value.toString();
});
petAmountRegister = await db
.get(key: 'petAmountRegister', field: 'value')
.then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
petAmountRegister = SQLiteStorageHelper().petAmountRegister.toString();
safeSetState?.call();
}

View File

@ -6,13 +6,14 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:share_plus/share_plus.dart';
import 'package:sqflite/sqflite.dart';
class PreferencesPageModel with ChangeNotifier {
final unfocusNode = FocusNode();
final SQLiteStorageHelper db = SQLiteStorageHelper();
bool fingerprint = false;
bool person = false;
bool notify = false;
@ -24,7 +25,7 @@ class PreferencesPageModel with ChangeNotifier {
}
Future<void> enablePerson(BuildContext context) async {
final String userDevUUID = await db.get(key: 'userDevUUID', field: 'value');
final String userDevUUID = SQLiteStorageHelper().userDevUUID;
notifyListeners();
Share.share(
FFLocalizations.of(context).getVariableText(
@ -69,7 +70,7 @@ class PreferencesPageModel with ChangeNotifier {
Future<void> toggleAccess(BuildContext context) async {
onChange(String key) async {
AppState().accessPass = key;
SecureStorageHelper().accessPass = key;
await PhpGroup.changePass
.call(
newSenha: key,
@ -105,10 +106,10 @@ class PreferencesPageModel with ChangeNotifier {
Future<void> togglePanic(BuildContext context) async {
onChange(String key) async {
AppState().panicPass = key;
SecureStorageHelper().panicPass = key;
await PhpGroup.changePanic
.call(
newSenhaPanico: AppState().panicPass,
newSenhaPanico: SecureStorageHelper().panicPass,
)
.then((value) async {
final String content;
@ -146,8 +147,8 @@ class PreferencesPageModel with ChangeNotifier {
);
onChange(String? key) async {
if (!fingerprint) AppState().fingerprintPass = key ?? '';
if (fingerprint) AppState().deleteFingerprintPass();
if (!fingerprint) SecureStorageHelper().fingerprintPass = key ?? '';
if (fingerprint) SecureStorageHelper().delete('fingerprintPass');
fingerprint = await _toggleBoolInDb('fingerprint');
notifyListeners();
@ -177,7 +178,7 @@ class PreferencesPageModel with ChangeNotifier {
ptText: 'Conta deletada com sucesso',
);
AppState().deleteAll();
StorageManager.purge();
context.pop();
context.go(
@ -223,7 +224,7 @@ class PreferencesPageModel with ChangeNotifier {
ptText: 'Tem certeza que deseja sair?',
);
onConfirm() async {
AppState().deleteAll();
StorageManager.purge();
context.go(
'/welcomePage',
@ -259,9 +260,9 @@ class PreferencesPageModel with ChangeNotifier {
await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) {
if (value.jsonBody['error'] == false) {
db.clear('cliName');
db.clear('cliUUID');
db.clear('ownerUUID');
SQLiteStorageHelper().cliName = '';
SQLiteStorageHelper().cliUUID = '';
SQLiteStorageHelper().ownerUUID = '';
context.pop();
@ -310,14 +311,15 @@ class PreferencesPageModel with ChangeNotifier {
}
Future<bool> _getBoolFromDb(String key) async {
final value = await db.get(key: key, field: 'value');
final value = SQLiteStorageHelper().get(key);
return value.toString() == 'true';
}
Future<bool> _toggleBoolInDb(String key) async {
final currentValue = await _getBoolFromDb(key);
final newValue = !currentValue;
await db.update(key, newValue.toString(), 'util');
await SQLiteStorageHelper().set(key, newValue.toString());
return newValue;
}

View File

@ -7,6 +7,7 @@ import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/pages/preferences_settings_page/preferences_settings_model.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:provider/provider.dart';
class PreferencesPageWidget extends StatefulWidget {
@ -17,8 +18,6 @@ class PreferencesPageWidget extends StatefulWidget {
}
class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
@override
void initState() {
super.initState();
@ -240,7 +239,7 @@ class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
enText: 'Are you sure you want to logout?',
ptText: 'Tem certeza',
), () async {
AppState().deleteAll();
StorageManager.purge();
// setState(() {});
context.go(

View File

@ -31,7 +31,6 @@ class _ProvisionalScheduleState extends State<ProvisionalSchedule> {
@override
Widget build(BuildContext context) {
context.watch<AppState>();
return Scaffold(
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,

View File

@ -14,7 +14,6 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
String? key = null;
DateTime? time;
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final bool isFingerprint;
late final String userDevUUID;
@ -28,9 +27,8 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
}
Future<void> initVariable() async {
isFingerprint =
await db.get('fingerprint').then((value) => value.toString() == 'true');
userDevUUID = await db.get('userDevUUID').then((value) => value.toString());
isFingerprint = SQLiteStorageHelper().fingerprint;
userDevUUID = SQLiteStorageHelper().userDevUUID;
}
@override

View File

@ -6,9 +6,7 @@ import 'package:share_plus/share_plus.dart';
class ReceptionPageModel with ChangeNotifier {
Future<void> getIdenfifier(BuildContext context) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final String userDevUUID =
await db.get('userDevUUID').then((value) => value.toString());
final String userDevUUID = SQLiteStorageHelper().userDevUUID;
notifyListeners();
Share.share(

View File

@ -6,6 +6,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:hub/app_state.dart';
import 'package:hub/flutter_flow/internationalization.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
import 'package:hub/shared/helpers/secure_storage_helper.dart';
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
import 'package:hub/shared/utils/webview_util.dart';
import 'package:sqflite/sqflite.dart';
@ -18,26 +19,23 @@ class ReservationPageWidget extends StatefulWidget {
}
class _ReservationPageWidgetState extends State<ReservationPageWidget> {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late InAppWebViewController _controllerIOS;
late WebViewController _controllerAll;
Future<Map<String, String>> initVariables() async {
final email = await db.get('email').then((value) => value.toString());
final name = await db.get('userName').then((value) => value.toString());
final userUUID = await db.get('userUUID').then((value) => value.toString());
final devUUID = await db.get('devUUID').then((value) => value.toString());
final createdAt = await db
.getByField(key: 'devUUID', field: 'createdAt')
.then((value) => value.toString());
final clientId = await db.get('cliUUID').then((value) => value.toString());
final email = SecureStorageHelper().email;
final name = SQLiteStorageHelper().cliName;
final userUUID = SQLiteStorageHelper().userUUID;
final devUUID = SQLiteStorageHelper().devUUID;
final createdAt = SQLiteStorageHelper().createdAt;
final clientId = SQLiteStorageHelper().cliUUID;
final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId';
final freUserData = "{\"name\": \"$name\", " +
"\"email\": \"$email\"," +
"\"dev_id\": \"$devUUID\"," +
"\"created_at\": \"$createdAt\"," +
"\"created_at\": \"0000-00-00 00:00:00\"," +
"\"updated_at\": \"0000-00-00 00:00:00\"," +
"\"status\": \"A\" }";

View File

@ -1,5 +1,3 @@
import 'dart:ffi';
import 'package:hub/backend/api_requests/api_calls.dart';
import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
@ -26,7 +24,6 @@ class ScheduleCompleteVisitPageModel
late VoidCallback safeSetState;
late Function(Function) updateState;
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String cliUUID;
late final String userUUID;
@ -184,9 +181,9 @@ class ScheduleCompleteVisitPageModel
}
Future<void> _initVariables() async {
devUUID = await db.get('devUUID').then((value) => value.toString());
cliUUID = await db.get('cliUUID').then((value) => value.toString());
userUUID = await db.get('userUUID').then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
userUUID = SQLiteStorageHelper().userUUID;
}
@override

View File

@ -20,7 +20,6 @@ class VisitHistoryWidget extends ScheduleComplete {
class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
with TickerProviderStateMixin, Status {
final SQLiteStorageHelper db = SQLiteStorageHelper();
late final String devUUID;
late final String userUUID;
late final String cliUUID;
@ -35,9 +34,9 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
List<dynamic> _visitWrap = [];
Future<void> _initVariables() async {
devUUID = await db.get('devUUID').then((value) => value.toString());
userUUID = await db.get('userUUID').then((value) => value.toString());
cliUUID = await db.get('cliUUID').then((value) => value.toString());
devUUID = SQLiteStorageHelper().devUUID;
userUUID = SQLiteStorageHelper().userUUID;
cliUUID = SQLiteStorageHelper().cliUUID;
}
@override
@ -246,15 +245,11 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
},
],
onTapCardItemAction: () async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final cliUUID =
await db.get('cliUUID').then((value) => value.toString());
final cliName =
await db.get('cliName').then((value) => value.toString());
final devUUID =
await db.get('devUUID').then((value) => value.toString());
final userUUID =
await db.get('userUUID').then((value) => value.toString());
final cliUUID = SQLiteStorageHelper().cliUUID;
final cliName = SQLiteStorageHelper().cliName;
final devUUID = SQLiteStorageHelper().devUUID;
final userUUID = SQLiteStorageHelper().userUUID;
await showDialog(
useSafeArea: true,
context: context,

View File

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/shared/utils/storage_util.dart';
import 'package:synchronized/synchronized.dart';
@ -12,7 +13,91 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
SecureStorageHelper._internal();
Future<void> initializePersistedState() async {
String _deviceDescription = '';
String get deviceDescription => _deviceDescription;
set deviceDescription(String value) {
_setString('deviceDescription', value);
_deviceDescription = value;
}
BuildContext? _context;
BuildContext? get context => _context;
set context(BuildContext? value) {
_setString('ff_context', value.toString());
_context = value;
}
bool? _haveLocal;
bool? get haveLocal => _haveLocal;
set haveLocal(bool? value) {
_setBool('ff_have_local', value);
_haveLocal = value;
}
String _fingerprintPass = '';
String get fingerprintPass => _fingerprintPass;
set fingerprintPass(String value) {
_setString('fingerprintPass', value);
_fingerprintPass = value;
}
String _accessPass = '';
String get accessPass => _accessPass;
set accessPass(String value) {
_setString('accessPass', value);
_accessPass = value;
}
String _panicPass = '';
String get panicPass => _panicPass;
set panicPass(String value) {
_setString('panicPass', value);
_panicPass = value;
}
String? _tokenAPNS = '';
String? get tokenAPNS => _tokenAPNS;
set tokenAPNS(String? value) {
_setString('ff_tokenAPNS', value ?? '');
_tokenAPNS = value;
}
String _email = '';
String get email => _email;
set email(String value) {
_setString('ff_email', value);
_email = value;
}
String _passwd = '';
String get passwd => _passwd;
set passwd(String value) {
_setString('ff_passwd', value);
_passwd = value;
}
String _deviceType = '';
String get deviceType => _deviceType;
set deviceType(String value) {
_setString('ff_deviceType', value);
_deviceType = value;
}
bool _isLogged = false;
bool get isLogged => _isLogged;
set isLogged(bool value) {
_setBool('ff_isLogged', value);
_isLogged = value;
}
String _token = '';
String get token => _token;
set token(String value) {
_setString('ff_token', value);
_token = value;
}
Future<void> ensureInitilization() async {
await _safeInitAsync(() async {
_email = await _getString('ff_email');
_passwd = await _getString('ff_passwd');
@ -56,55 +141,6 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
notifyListeners();
}
String _deviceDescription = '';
String get deviceDescription => _deviceDescription;
set deviceDescription(String value) => _setString('deviceDescription', value);
BuildContext? _context;
BuildContext? get context => _context;
set context(BuildContext? value) =>
_setString('ff_context', value.toString());
bool? _haveLocal;
bool? get haveLocal => _haveLocal;
set haveLocal(bool? value) => _setBool('ff_have_local', value);
String _fingerprintPass = '';
String get fingerprintPass => _fingerprintPass;
set fingerprintPass(String value) => _setString('fingerprintPass', value);
String _accessPass = '';
String get accessPass => _accessPass;
set accessPass(String value) => _setString('accessPass', value);
String _panicPass = '';
String get panicPass => _panicPass;
set panicPass(String value) => _setString('panicPass', value);
String? _tokenAPNS = '';
String? get tokenAPNS => _tokenAPNS;
set tokenAPNS(String? value) => _setString('ff_tokenAPNS', value ?? '');
String _email = '';
String get email => _email;
set email(String value) => _setString('ff_email', value);
String _passwd = '';
String get passwd => _passwd;
set passwd(String value) => _setString('ff_passwd', value);
String _deviceType = '';
String get deviceType => _deviceType;
set deviceType(String value) => _setString('ff_deviceType', value);
bool _isLogged = false;
bool get isLogged => _isLogged;
set isLogged(bool value) => _setBool('ff_isLogged', value);
String _token = '';
String get token => _token;
set token(String value) => _setString('ff_token', value);
Future<void> _setString(String key, String value) async {
await _secureStorage.write(key: key, value: value);
}
@ -115,6 +151,7 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
Future<void> purge() async {
_secureStorage.deleteAll();
await ensureInitilization();
}
@override

View File

@ -13,7 +13,7 @@ class SharedPreferencesStorageHelper implements Storage {
SharedPreferencesStorageHelper._internal();
Future<void> initialize() async {
Future<void> ensureInitialization() async {
_prefs = await SharedPreferences.getInstance();
_isFirstRun = _prefs.getBool('first_run') ?? true;
}
@ -61,5 +61,6 @@ class SharedPreferencesStorageHelper implements Storage {
Future<void> purge() async {
await _prefs.clear();
await ensureInitialization();
}
}

View File

@ -1,3 +1,9 @@
import 'package:hub/shared/utils/cache_util.dart';
import 'package:sqflite/sqflite.dart';
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart';
@ -14,63 +20,8 @@ class DatabaseConfig {
static const String columnUpdateAt = 'updateAt';
static const String columnResolvedAt = 'resolvedAt';
static const String columnCreatedAt = 'createdAt';
}
class SQLiteStorageHelper {
static final SQLiteStorageHelper _instance = SQLiteStorageHelper._internal();
static Database? _database;
factory SQLiteStorageHelper() => _instance;
SQLiteStorageHelper._internal();
Future<Database> get database async {
if (_database != null) return _database!;
_database = await _initDatabase();
return _database!;
}
Future<Database> _initDatabase() async {
final path = await _getDatabasePath();
log('Database path: $path');
return await openDatabase(
path,
version: DatabaseConfig.dbVersion,
onCreate: _onCreate,
onOpen: _onOpen,
onUpgrade: _onUpgrade,
onDowngrade: _onDowngrade,
onConfigure: _onConfigure,
).catchError((error) {
throw error;
}).whenComplete(() => log('Database initialized'));
}
Future<String> _getDatabasePath() async {
final databasesPath = await getDatabasesPath();
final path = join(databasesPath, DatabaseConfig.dbName);
log('Database path: $path');
return path;
}
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 {
final initialData = [
static const List<Map<String, dynamic>> initialData = [
{'key': 'devUUID', 'value': '', 'type': 'user'},
{'key': 'userUUID', 'value': '', 'type': 'user'},
{'key': 'userDevUUID', 'value': '', 'type': 'user'},
@ -91,10 +42,69 @@ class SQLiteStorageHelper {
{'key': 'requestOSnotification', 'value': 'false', 'type': 'util'},
{'key': 'petAmountRegister', 'value': '', 'type': 'local'},
];
for (var data in initialData) {
await db.insert(DatabaseConfig.tableKeychain, data);
}
class SQLiteStorageHelper {
static final SQLiteStorageHelper _instance = SQLiteStorageHelper._internal();
static Database? _database;
static String? _databasePath;
factory SQLiteStorageHelper() => _instance;
SQLiteStorageHelper._internal();
Future<Database> get database async {
if (_database != null) return _database!;
_database = await _initDatabase();
return _database!;
}
Future<String> _getDatabasePath() async {
if (_databasePath != null) return _databasePath!;
final databasesPath = await getDatabasesPath();
_databasePath = join(databasesPath, DatabaseConfig.dbName);
log('Database path: $_databasePath');
return _databasePath!;
}
Future<Database> _initDatabase() async {
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 => 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 {
final batch = db.batch();
for (var data in DatabaseConfig.initialData) {
batch.insert(DatabaseConfig.tableKeychain, data);
}
await batch.commit(noResult: true);
}
Future<void> _onOpen(Database db) async {
@ -123,151 +133,184 @@ class SQLiteStorageHelper {
}
}
String _devUUID = '';
String _userUUID = '';
String _userDevUUID = '';
String _status = '';
String _userName = '';
String _cliUUID = '';
String _ownerUUID = '';
String _cliName = '';
String _petAmountRegister = '';
bool _whatsapp = false;
bool _provisional = false;
bool _pets = false;
bool _local = false;
bool _notify = false;
bool _fingerprint = false;
bool _access = false;
bool _panic = false;
bool _person = false;
bool _requestOSnotification = false;
String get createdAt => '0000-00-00 00:00:00';
String get devUUID => _devUUID;
String get userUUID => _userUUID;
String get userDevUUID => _userDevUUID;
String get status => _status;
String get userName => _userName;
String get cliUUID => _cliUUID;
String get ownerUUID => _ownerUUID;
String get cliName => _cliName;
String get petAmountRegister => _petAmountRegister;
bool get whatsapp => _whatsapp;
bool get provisional => _provisional;
bool get pets => _pets;
bool get local => _local;
bool get notify => _notify;
bool get fingerprint => _fingerprint;
bool get access => _access;
bool get panic => _panic;
bool get person => _person;
bool get requestOSnotification => _requestOSnotification;
set devUUID(String value) => set('devUUID', value);
set userUUID(String value) => set('userUUID', value);
set userDevUUID(String value) => set('userDevUUID', value);
set status(String value) => set('status', value);
set userName(String value) => set('userName', value);
set cliUUID(String value) => set('cliUUID', value);
set ownerUUID(String value) => set('ownerUUID', value);
set cliName(String value) => set('cliName', value);
set petAmountRegister(String value) => set('petAmountRegister', value);
set whatsapp(bool value) => set('whatsapp', value);
set provisional(bool value) => set('provisional', value);
set pets(bool value) => set('pets', value);
set local(bool value) => set('local', value);
set notify(bool value) => set('notify', value);
set fingerprint(bool value) => set('fingerprint', value);
set access(bool value) => set('access', value);
set panic(bool value) => set('panic', value);
set person(bool value) => set('person', value);
set requestOSnotification(bool value) => set('requestOSnotification', value);
Future<void> setupLocalVariables() async {
log('Setting up local variables...');
await _database?.transaction((txn) async {
final keys = [
'devUUID',
'userUUID',
'userDevUUID',
'status',
'userName',
'cliUUID',
'ownerUUID',
'cliName',
'whatsapp',
'provisional',
'pets',
'local',
'notify',
'fingerprint',
'access',
'panic',
'person',
'requestOSnotification'
];
final results = await Future.wait(keys.map((key) => get(key)));
_devUUID = results[0]?.toString() ?? '';
_userUUID = results[1]?.toString() ?? '';
_userDevUUID = results[2]?.toString() ?? '';
_status = results[3]?.toString() ?? '';
_userName = results[4]?.toString() ?? '';
_cliUUID = results[5]?.toString() ?? '';
_ownerUUID = results[6]?.toString() ?? '';
_cliName = results[7]?.toString() ?? '';
_whatsapp = results[8] == 'true';
_provisional = results[9] == 'true';
_pets = results[10] == 'true';
_local = results[11] == 'true';
_notify = results[12] == 'true';
_fingerprint = results[13] == 'true';
_access = results[14] == 'true';
_panic = results[15] == 'true';
_person = results[16] == 'true';
_requestOSnotification = results[17] == 'true';
});
}
Future<bool> getBoolean(String key) async {
final value = await get(key);
return value == 'true';
}
Future<dynamic> get(String key) async {
final cachedValue = CacheUtil.get(key);
if (cachedValue != null) {
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);
return value;
}
return null;
} catch (error) {
log('Error getting value for key $key: $error');
return null;
}
}
Future<int> set(String key, dynamic value) async {
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(),
};
return await db.insert(
DatabaseConfig.tableKeychain,
data,
conflictAlgorithm: ConflictAlgorithm.replace,
);
}
Future<int> delete(String key) async {
final db = await database;
return await db.transaction((txn) async {
return await txn.delete(
DatabaseConfig.tableKeychain,
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
});
}
Future<void> purge() async {
await deleteDatabaseDB();
await database;
log('Database purged');
}
Future<void> deleteDatabaseDB() async {
final path = await _getDatabasePath();
await deleteDatabase(path);
log('Database deleted');
_database = null;
}
Future<dynamic> getByField({String? key, String? field}) async {
try {
final db = await database;
List<Map<String, dynamic>> queryResult;
if (field != null && key != null) {
queryResult = await db.query(
DatabaseConfig.tableKeychain,
columns: [field],
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
} else if (field != null) {
queryResult = await db.query(
DatabaseConfig.tableKeychain,
columns: [field],
);
} else if (key != null) {
field = DatabaseConfig.columnValue;
queryResult = await db.query(
DatabaseConfig.tableKeychain,
columns: [field],
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
} else {
queryResult = await db.query(DatabaseConfig.tableKeychain);
}
log('Query result for key: $key, field: $field -> $queryResult');
if (queryResult.isNotEmpty) {
return queryResult.first[field];
} else {
return null;
}
} catch (error) {
log('Error getting: $error');
return null;
}
}
Future<dynamic> get(String? key) async {
try {
final db = await database;
List<Map<String, dynamic>> queryResult;
const String field = DatabaseConfig.columnValue;
if (key != null) {
queryResult = await db.query(
DatabaseConfig.tableKeychain,
columns: [field],
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
} else {
queryResult = await db.query(
DatabaseConfig.tableKeychain,
columns: [field],
);
}
log('Query result for key: $key, field: $field -> $queryResult');
if (queryResult.isNotEmpty) {
return queryResult.first[field];
} else {
return null;
}
} catch (error) {
log('Error getting: $error');
return null;
}
}
Future<int> insert(String key, dynamic value, String? type) async {
final db = await database;
final Map<String, dynamic> data = {
DatabaseConfig.columnKey: key,
DatabaseConfig.columnValue: value.toString(),
DatabaseConfig.columnType: type,
DatabaseConfig.columnUpdateAt: DateTime.now().toIso8601String(),
DatabaseConfig.columnResolvedAt: null,
DatabaseConfig.columnCreatedAt: DateTime.now().toIso8601String(),
};
log('Inserting: $data');
return await db.insert(DatabaseConfig.tableKeychain, data);
}
Future<int> set(String key, dynamic value) async {
final db = await database;
final Map<String, dynamic> data = {
DatabaseConfig.columnKey: key,
if (value != null) DatabaseConfig.columnValue: value.toString(),
// if (type != null) DatabaseConfig.columnType: type,
DatabaseConfig.columnUpdateAt: DateTime.now().toIso8601String(),
DatabaseConfig.columnResolvedAt: null,
DatabaseConfig.columnCreatedAt: DateTime.now().toIso8601String(),
};
log('Updating: $data');
return await db.update(
DatabaseConfig.tableKeychain,
data,
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
}
Future<int> clear(String key) async {
final db = await database;
log('Setting value of key: $key to empty string');
return await db.update(
DatabaseConfig.tableKeychain,
{DatabaseConfig.columnValue: ''},
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
}
Future<int> delete(String key) async {
final db = await database;
log('Deleting key: $key');
return await db.delete(
DatabaseConfig.tableKeychain,
where: '${DatabaseConfig.columnKey} = ?',
whereArgs: [key],
);
}
Future<void> purge() async {
await deleteDatabaseDB();
await database;
log('Purge');
}
}

View File

@ -1,5 +1,3 @@
class CacheManager {}
class CacheUtil {
static final Map<String, dynamic> _cache = {};

View File

@ -3,9 +3,8 @@ import 'package:share_plus/share_plus.dart';
class ShareUtil {
static Future<void> showShare(payload) async {
final SQLiteStorageHelper db = SQLiteStorageHelper();
final cliName = await db.get('cliName').then((value) => value.toString());
final cliUUID = await db.get('cliUUID').then((value) => value.toString());
final cliName = SQLiteStorageHelper().cliName;
final cliUUID = SQLiteStorageHelper().cliUUID;
for (var i = 0; i < payload['convites'].length; i++) {
await Share.share('''