add
This commit is contained in:
parent
babff7b301
commit
80d428b766
|
@ -1,373 +1 @@
|
|||
// import 'dart:ffi';
|
||||
|
||||
import 'package:csv/csv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
|
||||
class AppState extends ChangeNotifier {
|
||||
// Adiciona a variável para controle de autenticação biométrica
|
||||
bool _isBiometricAuthenticated = false;
|
||||
bool get isBiometricAuthenticated => _isBiometricAuthenticated;
|
||||
|
||||
// Instância do LocalAuthentication
|
||||
final LocalAuthentication auth = LocalAuthentication();
|
||||
|
||||
// Verifica suporte biométrico
|
||||
Future<bool> checkBiometrics() async {
|
||||
try {
|
||||
return await auth.canCheckBiometrics;
|
||||
} catch (e) {
|
||||
clearBiometricAuthentication();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Solicita autenticação biométrica
|
||||
Future<void> authenticateBiometric() async {
|
||||
bool authenticated = false;
|
||||
try {
|
||||
authenticated = await auth.authenticate(
|
||||
localizedReason: 'Scan your fingerprint to authenticate',
|
||||
options: const AuthenticationOptions(
|
||||
biometricOnly: true,
|
||||
stickyAuth: true,
|
||||
useErrorDialogs: true,
|
||||
sensitiveTransaction: true,
|
||||
));
|
||||
if (authenticated) {
|
||||
_isBiometricAuthenticated = true;
|
||||
notifyListeners();
|
||||
return Future.value();
|
||||
// Salvar o estado de autenticação biométrica, se necessário
|
||||
}
|
||||
} catch (e) {
|
||||
clearBiometricAuthentication();
|
||||
return Future.error(e);
|
||||
}
|
||||
return Future.error(
|
||||
''); // Add this line to ensure a value is always returned
|
||||
}
|
||||
|
||||
// Função para limpar o estado de autenticação biométrica
|
||||
void clearBiometricAuthentication() {
|
||||
_isBiometricAuthenticated = false;
|
||||
notifyListeners();
|
||||
// Limpar a informação salva, se necessário
|
||||
}
|
||||
|
||||
static AppState _instance = AppState._internal();
|
||||
|
||||
factory AppState() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
AppState._internal();
|
||||
|
||||
static void reset() {
|
||||
_instance = AppState._internal();
|
||||
}
|
||||
|
||||
Future initializePersistedState() async {
|
||||
secureStorage = const FlutterSecureStorage();
|
||||
|
||||
await _safeInitAsync(() async {
|
||||
_email = await secureStorage.getString('ff_email') ?? _email;
|
||||
});
|
||||
await _safeInitAsync(() async {
|
||||
_passwd = await secureStorage.getString('ff_passwd') ?? _passwd;
|
||||
});
|
||||
await _safeInitAsync(() async {
|
||||
_deviceType =
|
||||
await secureStorage.getString('ff_deviceType') ?? _deviceType;
|
||||
});
|
||||
await _safeInitAsync(() async {
|
||||
_isLogged = await secureStorage.getBool('ff_isLogged') ?? _isLogged;
|
||||
});
|
||||
|
||||
await _safeInitAsync(() async {
|
||||
_tokenAPNS = await secureStorage.getString('ff_tokenAPNS') ?? _tokenAPNS;
|
||||
});
|
||||
|
||||
await _safeInitAsync(() async {
|
||||
_accessPass = await secureStorage.getString('accessPass') ?? _accessPass;
|
||||
});
|
||||
await _safeInitAsync(() async {
|
||||
_panicPass = await secureStorage.getString('panicPass') ?? _panicPass;
|
||||
});
|
||||
await _safeInitAsync(() async {
|
||||
_fingerprintPass =
|
||||
await secureStorage.getString('fingerprintPass') ?? _fingerprintPass;
|
||||
});
|
||||
await _safeInitAsync(() async {
|
||||
_context = await secureStorage.getObject('ff_context') ?? _context;
|
||||
});
|
||||
|
||||
await _safeInitAsync(() async {
|
||||
_haveLocal = await secureStorage.getBool('ff_have_local') ?? _haveLocal;
|
||||
});
|
||||
|
||||
await _safeInitAsync(() async {
|
||||
_deviceDescription = await secureStorage.getString('deviceDescription') ??
|
||||
_deviceDescription;
|
||||
});
|
||||
await loadFirstRun();
|
||||
}
|
||||
|
||||
bool _firstRun = true;
|
||||
bool get firstRun => _firstRun;
|
||||
|
||||
Future<void> loadFirstRun() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_firstRun = prefs.getBool('first_run') ?? true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> setFirstRun(bool value) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_firstRun = value;
|
||||
await prefs.setBool('first_run', value);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> deleteFirstRun() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_firstRun = true;
|
||||
await prefs.remove('first_run');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void update(VoidCallback callback) {
|
||||
callback();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
late FlutterSecureStorage secureStorage;
|
||||
|
||||
String _deviceDescription = '';
|
||||
String get deviceDescription => _deviceDescription;
|
||||
set deviceDescription(String value) {
|
||||
_deviceDescription = value;
|
||||
secureStorage.setString('deviceDescription', value);
|
||||
}
|
||||
|
||||
void deleteDeviceDescription() {
|
||||
secureStorage.delete(key: 'deviceDescription');
|
||||
}
|
||||
|
||||
BuildContext? _context;
|
||||
BuildContext? get context => _context;
|
||||
set context(BuildContext? value) {
|
||||
_context = value;
|
||||
secureStorage.setString('ff_context', value.toString());
|
||||
}
|
||||
|
||||
void deleteContext() {
|
||||
secureStorage.delete(key: 'ff_context');
|
||||
}
|
||||
|
||||
bool? _haveLocal = null;
|
||||
bool? get haveLocal => _haveLocal;
|
||||
set haveLocal(bool? value) {
|
||||
_haveLocal = value;
|
||||
secureStorage.setBool('ff_have_local', value);
|
||||
}
|
||||
|
||||
void deleteHaveLocal() {
|
||||
secureStorage.delete(key: 'ff_have_local');
|
||||
}
|
||||
|
||||
String _fingerprintPass = '';
|
||||
String get fingerprintPass => _fingerprintPass;
|
||||
set fingerprintPass(String value) {
|
||||
_fingerprintPass = value;
|
||||
secureStorage.setString('fingerprintPass', value);
|
||||
}
|
||||
|
||||
void deleteFingerprintPass() {
|
||||
secureStorage.delete(key: 'fingerprintPass');
|
||||
}
|
||||
|
||||
String _accessPass = '';
|
||||
String get accessPass => _accessPass;
|
||||
set accessPass(String value) {
|
||||
_accessPass = value;
|
||||
secureStorage.setString('accessPass', value);
|
||||
}
|
||||
|
||||
void deleteAccessPass() {
|
||||
secureStorage.delete(key: 'accessPass');
|
||||
}
|
||||
|
||||
String _panicPass = '';
|
||||
String get panicPass => _panicPass;
|
||||
set panicPass(String value) {
|
||||
_panicPass = value;
|
||||
secureStorage.setString('panicPass', value);
|
||||
}
|
||||
|
||||
void deletePanicPass() {
|
||||
secureStorage.delete(key: 'panicPass');
|
||||
}
|
||||
|
||||
String? _tokenAPNS = '';
|
||||
String? get tokenAPNS => _tokenAPNS;
|
||||
|
||||
set tokenAPNS(String? value) {
|
||||
_tokenAPNS = value;
|
||||
if (value != null) {
|
||||
secureStorage.setString('ff_tokenAPNS', value);
|
||||
} else {
|
||||
secureStorage.delete(key: 'ff_tokenAPNS');
|
||||
}
|
||||
}
|
||||
|
||||
void deleteTokenAPNS() {
|
||||
secureStorage.delete(key: 'ff_tokenAPNS');
|
||||
AppState().tokenAPNS = '';
|
||||
}
|
||||
|
||||
String _email = '';
|
||||
String get email => _email;
|
||||
set email(String value) {
|
||||
_email = value;
|
||||
secureStorage.setString('ff_email', value);
|
||||
}
|
||||
|
||||
void deleteEmail() {
|
||||
secureStorage.delete(key: 'ff_email');
|
||||
AppState().email = '';
|
||||
}
|
||||
|
||||
String _passwd = '';
|
||||
String get passwd => _passwd;
|
||||
set passwd(String value) {
|
||||
_passwd = value;
|
||||
secureStorage.setString('ff_passwd', value);
|
||||
}
|
||||
|
||||
void deletePasswd() {
|
||||
secureStorage.delete(key: 'ff_passwd');
|
||||
AppState().passwd = '';
|
||||
}
|
||||
|
||||
String _deviceType = '';
|
||||
String get deviceType => _deviceType;
|
||||
set deviceType(String value) {
|
||||
_deviceType = value;
|
||||
secureStorage.setString('ff_deviceType', value);
|
||||
}
|
||||
|
||||
void deleteDevice() {
|
||||
secureStorage.delete(key: 'ff_deviceType');
|
||||
AppState().deviceType = '';
|
||||
}
|
||||
|
||||
bool _isLogged = false;
|
||||
bool get isLogged => _isLogged;
|
||||
set isLogged(bool value) {
|
||||
_isLogged = value;
|
||||
secureStorage.setBool('ff_isLogged', value);
|
||||
}
|
||||
|
||||
void deleteIsLogged() {
|
||||
secureStorage.delete(key: 'ff_isLogged');
|
||||
}
|
||||
|
||||
String _token = '';
|
||||
String get token => _token;
|
||||
set token(String value) {
|
||||
_token = value;
|
||||
secureStorage.setString('ff_token', value);
|
||||
}
|
||||
|
||||
void deleteToken() {
|
||||
secureStorage.delete(key: 'ff_token');
|
||||
AppState().token = '';
|
||||
}
|
||||
|
||||
void deleteAll() {
|
||||
AppState().deleteAccessPass();
|
||||
AppState().deleteDevice();
|
||||
AppState().deleteEmail();
|
||||
AppState().deleteFingerprintPass();
|
||||
AppState().deleteIsLogged();
|
||||
AppState().deletePasswd();
|
||||
AppState().deletePanicPass();
|
||||
AppState().deleteToken();
|
||||
AppState().deleteTokenAPNS();
|
||||
AppState().deleteContext();
|
||||
secureStorage.deleteAll();
|
||||
|
||||
AppState().isLogged = false;
|
||||
AppState().setFirstRun(false);
|
||||
|
||||
AppState().update(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void _safeInit(Function() initializeField) {
|
||||
try {
|
||||
initializeField();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future _safeInitAsync(Function() initializeField) async {
|
||||
try {
|
||||
await initializeField();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
extension FlutterSecureStorageExtensions on FlutterSecureStorage {
|
||||
static final _lock = Lock();
|
||||
|
||||
Future<void> writeSync({required String key, String? value}) async =>
|
||||
await _lock.synchronized(() async {
|
||||
await write(key: key, value: value);
|
||||
});
|
||||
|
||||
void remove(String key) => delete(key: key);
|
||||
|
||||
Future<String?> getString(String key) async => await read(key: key);
|
||||
Future<void> setString(String key, String value) async =>
|
||||
await writeSync(key: key, value: value);
|
||||
|
||||
Future<bool?> getBool(String key) async => (await read(key: key)) == 'true';
|
||||
Future<void> setBool(String key, bool? value) async =>
|
||||
await writeSync(key: key, value: value.toString());
|
||||
|
||||
Future<int?> getInt(String key) async =>
|
||||
int.tryParse(await read(key: key) ?? '');
|
||||
Future<void> setInt(String key, int value) async =>
|
||||
await writeSync(key: key, value: value.toString());
|
||||
|
||||
Future<double?> getDouble(String key) async =>
|
||||
double.tryParse(await read(key: key) ?? '');
|
||||
Future<void> setDouble(String key, double value) async =>
|
||||
await writeSync(key: key, value: value.toString());
|
||||
|
||||
Future<BuildContext?> getObject(String key) async {
|
||||
final value = await read(key: key);
|
||||
if (value == null || value.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return value as BuildContext;
|
||||
}
|
||||
|
||||
Future<List<String>?> getStringList(String key) async =>
|
||||
await read(key: key).then((result) {
|
||||
if (result == null || result.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return const CsvToListConverter()
|
||||
.convert(result)
|
||||
.first
|
||||
.map((e) => e.toString())
|
||||
.toList();
|
||||
});
|
||||
Future<void> setStringList(String key, List<String> value) async =>
|
||||
await writeSync(
|
||||
key: key, value: const ListToCsvConverter().convert([value]));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ import 'dart:developer';
|
|||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
||||
import 'package:hub/shared/helpers/db_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';
|
||||
|
||||
import '/flutter_flow/flutter_flow_util.dart';
|
||||
|
@ -59,13 +60,9 @@ class PhpGroup {
|
|||
class UnregisterDevice {
|
||||
Future<ApiCallResponse> call() async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'unregisterDevice',
|
||||
|
@ -94,16 +91,10 @@ class DeletePet {
|
|||
int? petID = 0,
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'excluirPet';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -145,16 +136,10 @@ class UpdatePet {
|
|||
String? notes = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'atualizarPet';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -199,16 +184,10 @@ class GetPets {
|
|||
int? pageSize = 0,
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'consultaPets';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -241,16 +220,10 @@ class GetPetPhoto {
|
|||
int? petId = 0,
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'consultaFotoPet';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -290,16 +263,10 @@ class RegisterPet {
|
|||
String? notes = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'cadastrarPet';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -344,16 +311,9 @@ class BuscaEnconcomendas {
|
|||
String? adresseeType = '',
|
||||
String? status = '',
|
||||
}) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'getEncomendas';
|
||||
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
|
@ -394,17 +354,11 @@ class CancelaVisita {
|
|||
String? DevDesc = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'cancelaVisita';
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'cancelaVisita',
|
||||
|
@ -435,13 +389,9 @@ class CancelaVisita {
|
|||
|
||||
class DeleteAccount {
|
||||
Future<ApiCallResponse> call() async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 devUUID = CacheUtil.get('devUUID');
|
||||
final userUUID = CacheUtil.get('userUUID');
|
||||
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'deleteAccount',
|
||||
|
@ -470,17 +420,10 @@ class ChangePanic {
|
|||
String? newSenhaPanico = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'updVisitado';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -513,16 +456,10 @@ class ChangePass {
|
|||
String? newSenha = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'updVisitado';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -556,13 +493,9 @@ class RespondeVinculo {
|
|||
String? cliID = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'respondeVinculo',
|
||||
|
@ -593,16 +526,10 @@ class ChangeNotifica {
|
|||
String? notifica = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = CacheUtil.get('devUUID');
|
||||
final userUUID = CacheUtil.get('userUUID');
|
||||
final cliID = CacheUtil.get('cliUUID');
|
||||
const atividade = 'updVisitado';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -633,13 +560,9 @@ class ChangeNotifica {
|
|||
class UpdToken {
|
||||
Future<ApiCallResponse> call() async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final token = AppState().token;
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -667,10 +590,8 @@ class UpdToken {
|
|||
class LoginCall {
|
||||
Future<ApiCallResponse> call() async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final devUUID = await db
|
||||
.get(key: 'devUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final devUUID = CacheUtil.get('devUUID');
|
||||
|
||||
final email = AppState().email;
|
||||
final password = AppState().passwd;
|
||||
final type = AppState().deviceType;
|
||||
|
@ -772,13 +693,9 @@ class ForgotPasswordCall {
|
|||
class GetLocalsCall {
|
||||
Future<ApiCallResponse> call() async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'getLocals',
|
||||
|
@ -816,16 +733,10 @@ class PostScheduleVisitorCall {
|
|||
String? foto = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'putVisitante';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -877,16 +788,10 @@ class PostScheduleVisitCall {
|
|||
String? obs = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'putVisita';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -937,16 +842,10 @@ class GetScheduleVisitCall {
|
|||
String? chaveBusca = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliUUID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'getVisitas';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -1217,16 +1116,10 @@ class GetScheduleVisitCall {
|
|||
class GetDadosCall {
|
||||
Future<ApiCallResponse> call() async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliUUID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'getDados';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -1466,16 +1359,10 @@ class GetVisitorByDocCall {
|
|||
String? documento = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'getVisitante';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -1526,16 +1413,10 @@ class GetFotoVisitanteCall {
|
|||
String? tipo = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'getFotoVisitante';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -1571,16 +1452,10 @@ class PostProvVisitSchedulingCall {
|
|||
String? proID = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'putAgendamentoProv';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -1626,16 +1501,10 @@ class GetVisitsCall {
|
|||
int? pageNumber,
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'getVisitas';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -1895,16 +1764,10 @@ class DeleteVisitCall {
|
|||
String? idVisita = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 cliID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'cancelaVisita';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -1944,19 +1807,11 @@ class DeleteVisitCall {
|
|||
class GetPessoasLocalCall {
|
||||
Future<ApiCallResponse> call() async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final devUUID = await db
|
||||
.get(key: 'devUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final ownerUUID = await db
|
||||
.get(key: 'ownerUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final userUUID = await db
|
||||
.get(key: 'userUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final cliUUID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final ownerUUID = await CacheUtil.get('ownerUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliUUID = await CacheUtil.get('cliUUID');
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'getPessoasLocal',
|
||||
|
@ -2018,16 +1873,10 @@ class RespondeSolicitacaoCall {
|
|||
String? idVisitante = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliUUID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'respondeSolicitacao';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -2074,16 +1923,10 @@ class GetAccessCall {
|
|||
String? pesTipo = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = await CacheUtil.get('devUUID');
|
||||
final userUUID = await CacheUtil.get('userUUID');
|
||||
final cliUUID = await CacheUtil.get('cliUUID');
|
||||
const atividade = 'getAcessos';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
@ -2328,19 +2171,13 @@ class GetLiberationsCall {
|
|||
Stream<ApiCallResponse> call() {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final StreamController<ApiCallResponse> controller = StreamController();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
|
||||
Future.microtask(() async {
|
||||
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 = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
const atividade = 'getSolicitacoes';
|
||||
final devUUID = CacheUtil.get('devUUID');
|
||||
final userUUID = CacheUtil.get('userUUID');
|
||||
final cliUUID = CacheUtil.get('cliUUID');
|
||||
const atividade = 'getLiberacoes';
|
||||
|
||||
try {
|
||||
final response = await ApiManager.instance.makeApiCall(
|
||||
callName: 'getLiberations',
|
||||
|
@ -2527,16 +2364,10 @@ class GetMessagesCall {
|
|||
String? tipoDestino = '',
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
||||
final devUUID = CacheUtil.get('devUUID');
|
||||
final userUUID = CacheUtil.get('userUUID');
|
||||
final cliUUID = CacheUtil.get('cliUUID');
|
||||
const atividade = 'getMensagens';
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
|
|
|
@ -4,7 +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/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
|
||||
import 'notification_service.dart';
|
||||
|
|
|
@ -13,14 +13,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/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
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 DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final cliUUID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
@ -292,7 +292,7 @@ class NotificationService {
|
|||
await AwesomeNotifications()
|
||||
.isNotificationAllowed()
|
||||
.then((isAllowed) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final bool requestOSnotification = await db
|
||||
.get(key: 'requestOSnotification', field: 'value')
|
||||
.then((value) => value.toString() == 'true');
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/components/molecular_components/menu_item/menu_item.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
|
||||
import '../../../app_state.dart';
|
||||
|
@ -34,7 +34,7 @@ class _MenuButtonWidgetState extends State<MenuButtonWidget> {
|
|||
hoverColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
onTap: () async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final cliUUID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:hub/components/organism_components/bottom_arrow_linked_locals_co
|
|||
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
@ -65,7 +65,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
|||
|
||||
Future<ApiCallResponse?> _fetchLocals() async {
|
||||
try {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final devUUID = await db.get(key: 'devUUID', field: 'value');
|
||||
final userUUID = await db.get(key: 'userUUID', field: 'value');
|
||||
|
||||
|
@ -173,7 +173,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState
|
|||
labelsHashMap: _labelsHashMap(local),
|
||||
statusHashMap: [_statusHashMap(local)],
|
||||
onTapCardItemAction: () async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
if (local['CLU_STATUS'] == 'A') {
|
||||
db.update('cliUUID', local['CLI_ID'], 'local');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:ffi';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
import '/flutter_flow/flutter_flow_util.dart';
|
||||
import 'local_profile_component_widget.dart' show LocalProfileComponentWidget;
|
||||
|
@ -11,7 +11,7 @@ import 'package:flutter/material.dart';
|
|||
|
||||
class LocalProfileComponentModel
|
||||
extends FlutterFlowModel<LocalProfileComponentWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
String cliName = '';
|
||||
String cliUUID = '';
|
||||
VoidCallback? setStateCallback;
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
@ -29,7 +29,7 @@ class LocalProfileComponentWidget extends StatefulWidget {
|
|||
class _LocalProfileComponentWidgetState
|
||||
extends State<LocalProfileComponentWidget> {
|
||||
late LocalProfileComponentModel _model;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
|
|
|
@ -3,7 +3,7 @@ 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/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
|
||||
|
@ -70,7 +70,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future deliverySchedule(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
final bool isProvisional = await db
|
||||
.get(key: 'provisional', field: 'value')
|
||||
|
@ -93,7 +93,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future provisionalSchedule(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
final isProvisional = await db
|
||||
.get(key: 'provisional', field: 'value')
|
||||
|
@ -115,7 +115,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future fastPassAction(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
|
||||
return value.toString() == 'true';
|
||||
}) as bool;
|
||||
|
@ -202,7 +202,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future<void> signOut(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
showAlertDialog(
|
||||
context,
|
||||
|
@ -242,7 +242,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future packageOrder(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
|
||||
return value.toString() == 'true';
|
||||
}) as bool;
|
||||
|
@ -264,7 +264,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future reservation(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final isWpp = await db.get(key: 'whatsapp', field: 'value').then((value) {
|
||||
return value.toString() == 'true';
|
||||
}) as bool;
|
||||
|
@ -383,7 +383,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
|
|||
}
|
||||
|
||||
Future petsAction(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
bool isPet = await db.get(key: 'pets', field: 'value').then((value) {
|
||||
return value.toString() == 'true';
|
||||
}) as bool;
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:hub/backend/schema/enums/enums.dart';
|
|||
import 'package:hub/components/atomic_components/menu_button_item/menu_button_item_widget.dart';
|
||||
import 'package:hub/components/atomic_components/menu_card_item/menu_card_item.dart';
|
||||
import 'package:hub/components/molecular_components/menu_item/menu_item.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart';
|
||||
import '/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart';
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
|
||||
|
@ -339,7 +339,7 @@ class MessageWellState {
|
|||
class MessageWellNotifier extends StateNotifier<MessageWellState> {
|
||||
var _totalPageNumber = 1;
|
||||
int get totalPageNumber => _totalPageNumber;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
set totalPageNumber(int value) {
|
||||
_totalPageNumber = value;
|
||||
|
|
|
@ -5,12 +5,12 @@ import 'package:hub/backend/api_requests/api_manager.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class ScheduleVisitDetailModel
|
||||
extends FlutterFlowModel<ScheduleVisitDetailWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -2,11 +2,11 @@ import 'package:hub/components/organism_components/up_arrow_linked_locals_compon
|
|||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
class UpArrowLinkedLocalsComponentModel
|
||||
extends FlutterFlowModel<UpArrowLinkedLocalsComponentWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
import '/backend/api_requests/api_calls.dart';
|
||||
import '/flutter_flow/flutter_flow_util.dart';
|
||||
|
@ -9,7 +9,7 @@ import 'access_notification_modal_template_component_widget.dart'
|
|||
|
||||
class AccessNotificationModalTemplateComponentModel
|
||||
extends FlutterFlowModel<AccessNotificationModalTemplateComponentWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -4,12 +4,12 @@ import 'package:hub/backend/api_requests/api_calls.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/nav/nav.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
class LiberationHistoryItemDetailsTemplateComponentModel
|
||||
extends FlutterFlowModel<
|
||||
LiberationHistoryItemDetailsTemplateComponentWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -2,12 +2,12 @@ import 'package:flutter/material.dart';
|
|||
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||
import 'package:hub/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
class ScheduleProvisionalVisitPageModel
|
||||
extends FlutterFlowModel<ScheduleProvisionalVisitPageWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
String cliUUID = '';
|
||||
String devUUID = '';
|
||||
String userUUID = '';
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
||||
import '/backend/api_requests/api_calls.dart';
|
||||
|
@ -12,7 +12,7 @@ import 'regisiter_vistor_template_component_widget.dart';
|
|||
class RegisiterVistorTemplateComponentModel
|
||||
extends FlutterFlowModel<RegisiterVistorTemplateComponentWidget> {
|
||||
Timer? _debounceTimer;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -3,7 +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/db_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';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
|
@ -86,7 +86,7 @@ class SignInTemplateComponentModel
|
|||
}) async {
|
||||
try {
|
||||
final ApiCallResponse? response;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final LoginCall callback = PhpGroup.loginCall;
|
||||
AppState().deviceDescription = randomString(
|
||||
10,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
import '/backend/api_requests/api_calls.dart';
|
||||
import '/flutter_flow/flutter_flow_util.dart';
|
||||
|
@ -6,7 +6,7 @@ import 'view_visit_detail_widget.dart' show ViewVisitDetailWidget;
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ViewVisitDetailModel extends FlutterFlowModel<ViewVisitDetailWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -3,11 +3,11 @@ import 'package:hub/components/templates_components/visitor_search_modal_templat
|
|||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
class VisitorSearchModalTemplateComponentModel
|
||||
extends FlutterFlowModel<VisitorSearchModalTemplateComponentWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -15,7 +15,9 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
|||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.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:provider/provider.dart';
|
||||
import 'package:responsive_framework/responsive_framework.dart';
|
||||
|
||||
|
@ -23,17 +25,20 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
|||
|
||||
Future<void> initializeApp() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await DatabaseHelper().database;
|
||||
await SQLiteStorageHelper().database;
|
||||
final sharedPreferencesHelper = SharedPreferencesStorageHelper();
|
||||
final SecureStorageHelper secureStorageHelper = SecureStorageHelper();
|
||||
|
||||
await sharedPreferencesHelper.initialize();
|
||||
|
||||
if (sharedPreferencesHelper.isFirstRun) {
|
||||
// Execute actions for the first run
|
||||
sharedPreferencesHelper.isFirstRun = false;
|
||||
secureStorageHelper.deleteAll();
|
||||
}
|
||||
|
||||
final status = await AppTrackingTransparency.requestTrackingAuthorization();
|
||||
|
||||
final appState = AppState();
|
||||
await appState.initializePersistedState();
|
||||
|
||||
if (AppState().firstRun == true) {
|
||||
AppState().deleteAll();
|
||||
}
|
||||
|
||||
await Firebase.initializeApp();
|
||||
await NotificationService.initialize();
|
||||
|
||||
|
@ -56,8 +61,8 @@ Future<void> initializeApp() async {
|
|||
|
||||
Future<void> foregroundHandleMessage(RemoteMessage message) async {
|
||||
if (message.data['click_action'] == 'enroll_cond') {
|
||||
AppState().haveLocal = true;
|
||||
AppState().context!.go('/homePage');
|
||||
SecureStorageHelper().set('haveLocal', 'true');
|
||||
SecureStorageHelper().context?.go('/homePage');
|
||||
}
|
||||
if (!Platform.isIOS) {
|
||||
NotificationService.show(
|
||||
|
@ -69,8 +74,8 @@ Future<void> foregroundHandleMessage(RemoteMessage message) async {
|
|||
|
||||
Future<void> _backgroundHandleMessage(RemoteMessage message) async {
|
||||
if (message.data['click_action'] == 'enroll_cond') {
|
||||
AppState().haveLocal = true;
|
||||
AppState().context!.go('/homePage');
|
||||
SecureStorageHelper().set('haveLocal', 'true');
|
||||
SecureStorageHelper().context?.go('/homePage');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,9 +140,9 @@ class _AppState extends State<App> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => AppState()),
|
||||
],
|
||||
providers: const [],
|
||||
// ChangeNotifierProvider(create: (_) => {AppState()}),
|
||||
|
||||
child: MaterialApp.router(
|
||||
title: 'FRE ACCESS HUB',
|
||||
builder: (context, widget) => ResponsiveBreakpoints.builder(
|
||||
|
|
|
@ -4,10 +4,10 @@ import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_
|
|||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
import 'package:hub/flutter_flow/request_manager.dart';
|
||||
import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
class AcessHistoryPageModel extends FlutterFlowModel<AccessHistoryScreen> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -5,7 +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/db_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';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
@ -18,7 +18,7 @@ class FastPassPageWidget extends StatefulWidget {
|
|||
class _FastPassPageWidgetState extends State<FastPassPageWidget> {
|
||||
late InAppWebViewController _controllerIOS;
|
||||
late WebViewController _controllerAll;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
Future<Map<String, String>> initVariables() async {
|
||||
final email = AppState().email;
|
||||
|
|
|
@ -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/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
class HomePageModel extends FlutterFlowModel<HomePageWidget> {
|
||||
bool isGrid = false;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String cliUUID;
|
||||
late final String userUUID;
|
||||
|
|
|
@ -11,7 +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/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart';
|
||||
|
||||
class HomePageWidget extends StatefulWidget {
|
||||
|
@ -25,7 +25,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
|
|||
late HomePageModel _model;
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
late LocalProfileComponentWidget _localProfileComponentWidget;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
_HomePageWidgetState() {
|
||||
_localProfileComponentWidget = LocalProfileComponentWidget();
|
||||
|
|
|
@ -5,10 +5,10 @@ import 'package:hub/flutter_flow/request_manager.dart';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/pages/liberation_history/liberation_history_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
class LiberationHistoryModel extends FlutterFlowModel<LiberationHistoryWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -5,11 +5,11 @@ import 'package:hub/flutter_flow/request_manager.dart';
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/pages/message_history_page/message_history_page_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
|
||||
class MessageHistoryPageModel
|
||||
extends FlutterFlowModel<MessageHistoryPageWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'package:hub/components/templates_components/details_component/details_co
|
|||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
@ -28,7 +28,7 @@ class _PackageOrderPage extends State<PackageOrderPage> {
|
|||
final int _pageSize = 10;
|
||||
bool _hasData = false;
|
||||
bool _loading = false;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String cliUUID;
|
||||
|
||||
late Future<void> _orderFuture;
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
|||
import 'package:hub/pages/liberation_history/liberation_history_model.dart';
|
||||
import 'package:hub/pages/pets_page/pets_page_model.dart';
|
||||
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
@ -243,7 +243,7 @@ class _PetsHistoryScreenState extends State<PetsHistoryScreen>
|
|||
}
|
||||
],
|
||||
onTapCardItemAction: () async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final cliUUID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
|
|
@ -12,14 +12,14 @@ import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
|||
import 'package:hub/flutter_flow/form_field_controller.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/pages/pets_page/pets_page_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/image_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
||||
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
|
|
@ -6,13 +6,13 @@ 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/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
class PreferencesPageModel with ChangeNotifier {
|
||||
final unfocusNode = FocusNode();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
bool fingerprint = false;
|
||||
bool person = false;
|
||||
bool notify = false;
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
|||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/pages/preferences_settings_page/preferences_settings_model.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PreferencesPageWidget extends StatefulWidget {
|
||||
|
@ -17,7 +17,7 @@ class PreferencesPageWidget extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _PreferencesPageWidgetState extends State<PreferencesPageWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:typed_data';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
import 'package:hub/pages/qr_code_page/qr_code_page_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
|
||||
class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
|
||||
|
@ -14,7 +14,7 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
|
|||
String? key = null;
|
||||
|
||||
DateTime? time;
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final bool isFingerprint;
|
||||
late final String userDevUUID;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
|||
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/pages/qr_code_page/qr_code_page_model.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:percent_indicator/circular_percent_indicator.dart';
|
||||
// import 'package:percent_indicator/percent_indicator.dart';
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/app_state.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
class ReceptionPageModel with ChangeNotifier {
|
||||
Future<void> getIdenfifier(BuildContext context) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final String userDevUUID = await db
|
||||
.get(key: 'userDevUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
|
|
|
@ -5,7 +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/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/utils/webview_util.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
@ -17,7 +17,7 @@ class ReservationPageWidget extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _ReservationPageWidgetState extends State<ReservationPageWidget> {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late InAppWebViewController _controllerIOS;
|
||||
late WebViewController _controllerAll;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import 'package:hub/flutter_flow/request_manager.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
|
||||
import 'package:hub/pages/schedule_complete_visit_page/visit_history_page_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/mixins/status_mixin.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
@ -26,7 +26,7 @@ class ScheduleCompleteVisitPageModel
|
|||
late VoidCallback safeSetState;
|
||||
late Function(Function) updateState;
|
||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String cliUUID;
|
||||
late final String userUUID;
|
||||
|
|
|
@ -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/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
|
||||
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart';
|
||||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:hub/shared/mixins/status_mixin.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
|
@ -20,7 +20,7 @@ class VisitHistoryWidget extends ScheduleComplete {
|
|||
|
||||
class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
|
||||
with TickerProviderStateMixin, Status {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
late final String devUUID;
|
||||
late final String userUUID;
|
||||
late final String cliUUID;
|
||||
|
@ -35,15 +35,9 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
|
|||
List<dynamic> _visitWrap = [];
|
||||
|
||||
Future<void> _initVariables() 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 = 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());
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -252,19 +246,15 @@ class _VisitHistoryWidgetState extends State<VisitHistoryWidget>
|
|||
},
|
||||
],
|
||||
onTapCardItemAction: () async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
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 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());
|
||||
await showDialog(
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:hub/shared/helpers/secure_storage_helper.dart';
|
||||
import 'package:hub/shared/mixins/switcher_mixin.dart';
|
||||
|
||||
import '/components/templates_components/welcome_template_component/welcome_template_component_widget.dart';
|
||||
|
@ -29,13 +30,13 @@ class _WelcomePageWidgetState extends State<WelcomePageWidget> {
|
|||
// On page load action.
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||
if (isAndroid == true) {
|
||||
AppState().deviceType = 'Android';
|
||||
SecureStorageHelper().deviceType = 'Android';
|
||||
setState(() {});
|
||||
} else if (isiOS == true) {
|
||||
AppState().deviceType = 'iOS';
|
||||
SecureStorageHelper().deviceType = 'iOS';
|
||||
setState(() {});
|
||||
} else {
|
||||
AppState().deviceType = 'Web';
|
||||
SecureStorageHelper().deviceType = 'Web';
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
|
@ -50,8 +51,6 @@ class _WelcomePageWidgetState extends State<WelcomePageWidget> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
context.watch<AppState>();
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => _model.unfocusNode.canRequestFocus
|
||||
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import 'package:csv/csv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
|
||||
extension FlutterSecureStorageExtensions on FlutterSecureStorage {
|
||||
static final _lock = Lock();
|
||||
|
||||
Future<void> writeSync({required String key, String? value}) async =>
|
||||
await _lock.synchronized(() async {
|
||||
await write(key: key, value: value);
|
||||
});
|
||||
|
||||
void remove(String key) => delete(key: key);
|
||||
|
||||
Future<String?> getString(String key) async => await read(key: key);
|
||||
Future<void> setString(String key, String value) async =>
|
||||
await writeSync(key: key, value: value);
|
||||
|
||||
Future<bool?> getBool(String key) async => (await read(key: key)) == 'true';
|
||||
Future<void> setBool(String key, bool? value) async =>
|
||||
await writeSync(key: key, value: value.toString());
|
||||
|
||||
Future<int?> getInt(String key) async =>
|
||||
int.tryParse(await read(key: key) ?? '');
|
||||
Future<void> setInt(String key, int value) async =>
|
||||
await writeSync(key: key, value: value.toString());
|
||||
|
||||
Future<double?> getDouble(String key) async =>
|
||||
double.tryParse(await read(key: key) ?? '');
|
||||
Future<void> setDouble(String key, double value) async =>
|
||||
await writeSync(key: key, value: value.toString());
|
||||
|
||||
Future<BuildContext?> getObject(String key) async {
|
||||
final value = await read(key: key);
|
||||
if (value == null || value.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return value as BuildContext;
|
||||
}
|
||||
|
||||
Future<List<String>?> getStringList(String key) async =>
|
||||
await read(key: key).then((result) {
|
||||
if (result == null || result.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return const CsvToListConverter()
|
||||
.convert(result)
|
||||
.first
|
||||
.map((e) => e.toString())
|
||||
.toList();
|
||||
});
|
||||
Future<void> setStringList(String key, List<String> value) async =>
|
||||
await writeSync(
|
||||
key: key, value: const ListToCsvConverter().convert([value]));
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:hub/shared/utils/storage_util.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
|
||||
class SecureStorageHelper extends ChangeNotifier implements Storage {
|
||||
static final SecureStorageHelper _instance = SecureStorageHelper._internal();
|
||||
final FlutterSecureStorage _secureStorage = const FlutterSecureStorage();
|
||||
static final _lock = Lock();
|
||||
|
||||
factory SecureStorageHelper() => _instance;
|
||||
|
||||
SecureStorageHelper._internal();
|
||||
|
||||
Future<void> initializePersistedState() async {
|
||||
await _safeInitAsync(() async {
|
||||
_email = await _getString('ff_email');
|
||||
_passwd = await _getString('ff_passwd');
|
||||
_deviceType = await _getString('ff_deviceType');
|
||||
_isLogged = await _getBool('ff_isLogged');
|
||||
_tokenAPNS = await _getString('ff_tokenAPNS');
|
||||
_accessPass = await _getString('accessPass');
|
||||
_panicPass = await _getString('panicPass');
|
||||
_fingerprintPass = await _getString('fingerprintPass');
|
||||
_context = await _getObject('ff_context');
|
||||
_haveLocal = await _getBool('ff_have_local');
|
||||
_deviceDescription = await _getString('deviceDescription');
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _safeInitAsync(Future<void> Function() initFunction) async {
|
||||
await _lock.synchronized(() async {
|
||||
try {
|
||||
await initFunction();
|
||||
} catch (e) {
|
||||
// Log or handle the error
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<String> _getString(String key) async {
|
||||
return await _secureStorage.read(key: key) ?? '';
|
||||
}
|
||||
|
||||
Future<bool> _getBool(String key) async {
|
||||
return (await _secureStorage.read(key: key))?.toLowerCase() == 'true';
|
||||
}
|
||||
|
||||
Future<dynamic> _getObject(String key) async {
|
||||
// Implement your object retrieval logic here
|
||||
return null;
|
||||
}
|
||||
|
||||
void update(VoidCallback callback) {
|
||||
callback();
|
||||
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);
|
||||
}
|
||||
|
||||
Future<void> _setBool(String key, bool? value) async {
|
||||
await _secureStorage.write(key: key, value: value.toString());
|
||||
}
|
||||
|
||||
void deleteAll() {
|
||||
_secureStorage.deleteAll();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> set(String key, dynamic value) async {
|
||||
if (value is String) {
|
||||
await _setString(key, value);
|
||||
} else if (value is bool) {
|
||||
await _setBool(key, value);
|
||||
} else if (value is int || value is double) {
|
||||
await _setString(key, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> get(String key) async {
|
||||
return await _secureStorage.read(key: key);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> delete(String key) async {
|
||||
await _secureStorage.delete(key: key);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
import 'package:hub/shared/utils/storage_util.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SharedPreferencesStorageHelper implements Storage {
|
||||
late SharedPreferences _prefs;
|
||||
|
||||
static final SharedPreferencesStorageHelper _instance =
|
||||
SharedPreferencesStorageHelper._internal();
|
||||
|
||||
factory SharedPreferencesStorageHelper() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
SharedPreferencesStorageHelper._internal();
|
||||
|
||||
Future<void> initialize() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
_isFirstRun = _prefs.getBool('first_run') ?? true;
|
||||
}
|
||||
|
||||
bool _isFirstRun = true;
|
||||
bool get isFirstRun => _isFirstRun;
|
||||
set isFirstRun(bool value) {
|
||||
_isFirstRun = value;
|
||||
set('first_run', value);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> set(String key, dynamic value) async {
|
||||
if (value is bool) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<dynamic> get(String key) async {
|
||||
try {
|
||||
return _prefs.get(key);
|
||||
} catch (e) {
|
||||
// Log or handle the error
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> delete(String key) async {
|
||||
try {
|
||||
await _prefs.remove(key);
|
||||
} catch (e) {
|
||||
// Log or handle the error
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,13 +16,13 @@ class DatabaseConfig {
|
|||
static const String columnCreatedAt = 'createdAt';
|
||||
}
|
||||
|
||||
class DatabaseHelper {
|
||||
static final DatabaseHelper _instance = DatabaseHelper._internal();
|
||||
class SQLiteStorageHelper {
|
||||
static final SQLiteStorageHelper _instance = SQLiteStorageHelper._internal();
|
||||
static Database? _database;
|
||||
|
||||
factory DatabaseHelper() => _instance;
|
||||
factory SQLiteStorageHelper() => _instance;
|
||||
|
||||
DatabaseHelper._internal();
|
||||
SQLiteStorageHelper._internal();
|
||||
|
||||
Future<Database> get database async {
|
||||
if (_database != null) return _database!;
|
||||
|
@ -130,7 +130,7 @@ class DatabaseHelper {
|
|||
_database = null;
|
||||
}
|
||||
|
||||
Future<dynamic> get({String? key, String? field}) async {
|
||||
Future<dynamic> getByField({String? key, String? field}) async {
|
||||
try {
|
||||
final db = await database;
|
||||
List<Map<String, dynamic>> queryResult;
|
||||
|
@ -172,6 +172,39 @@ class DatabaseHelper {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -188,13 +221,13 @@ class DatabaseHelper {
|
|||
return await db.insert(DatabaseConfig.tableKeychain, data);
|
||||
}
|
||||
|
||||
Future<int> update(String key, dynamic value, String? type) async {
|
||||
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,
|
||||
// if (type != null) DatabaseConfig.columnType: type,
|
||||
DatabaseConfig.columnUpdateAt: DateTime.now().toIso8601String(),
|
||||
DatabaseConfig.columnResolvedAt: null,
|
||||
DatabaseConfig.columnCreatedAt: DateTime.now().toIso8601String(),
|
|
@ -0,0 +1,32 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
|
||||
class BiometricHelper {
|
||||
final LocalAuthentication auth = LocalAuthentication();
|
||||
|
||||
Future<bool> checkBiometrics() async {
|
||||
try {
|
||||
return await auth.canCheckBiometrics;
|
||||
} catch (e) {
|
||||
// Log or handle the error
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> authenticateBiometric() async {
|
||||
try {
|
||||
return await auth.authenticate(
|
||||
localizedReason: 'Scan your fingerprint to authenticate',
|
||||
options: const AuthenticationOptions(
|
||||
biometricOnly: true,
|
||||
stickyAuth: true,
|
||||
useErrorDialogs: true,
|
||||
sensitiveTransaction: true,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
// Log or handle the error
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
class CacheManager {}
|
||||
|
||||
class CacheUtil {
|
||||
static final Map<String, dynamic> _cache = {};
|
||||
|
||||
static void set(String key, dynamic value) {
|
||||
_cache[key] = value;
|
||||
}
|
||||
|
||||
static dynamic get(String key) {
|
||||
return _cache[key];
|
||||
}
|
||||
|
||||
static void delete(String key) {
|
||||
_cache.remove(key);
|
||||
}
|
||||
|
||||
static void clear() {
|
||||
_cache.clear();
|
||||
}
|
||||
}
|
|
@ -1,15 +1,11 @@
|
|||
import 'package:hub/shared/helpers/db_helper.dart';
|
||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
class ShareUtil {
|
||||
static Future<void> showShare(payload) async {
|
||||
final DatabaseHelper db = DatabaseHelper();
|
||||
final cliName = await db
|
||||
.get(key: 'cliName', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final cliUUID = await db
|
||||
.get(key: 'cliUUID', field: 'value')
|
||||
.then((value) => value.toString());
|
||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||
final cliName = await db.get('cliName').then((value) => value.toString());
|
||||
final cliUUID = await db.get('cliUUID').then((value) => value.toString());
|
||||
|
||||
for (var i = 0; i < payload['convites'].length; i++) {
|
||||
await Share.share('''
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
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';
|
||||
|
||||
abstract class Storage {
|
||||
Future<void> set(String key, dynamic value);
|
||||
Future<dynamic> get(String key);
|
||||
Future<void> delete(String key);
|
||||
}
|
||||
|
||||
class StorageData {
|
||||
final String key;
|
||||
final dynamic value;
|
||||
final StorageType type;
|
||||
|
||||
StorageData(this.key, this.value, this.type);
|
||||
}
|
||||
|
||||
enum StorageType { SecureStorage, SharedPreferences, SQLite3 }
|
||||
|
||||
class StorageManager {
|
||||
final SecureStorageHelper _secureStorage = SecureStorageHelper();
|
||||
final SharedPreferencesStorageHelper _sharedPreferences =
|
||||
SharedPreferencesStorageHelper();
|
||||
final SQLiteStorageHelper _sqliteStorage = SQLiteStorageHelper();
|
||||
|
||||
Future<void> set(StorageData data) async {
|
||||
switch (data.type) {
|
||||
case StorageType.SecureStorage:
|
||||
CacheUtil.set(data.key, data.value);
|
||||
await _secureStorage.set(data.key, data.value);
|
||||
break;
|
||||
case StorageType.SharedPreferences:
|
||||
await _sharedPreferences.set(data.key, data.value);
|
||||
break;
|
||||
case StorageType.SQLite3:
|
||||
await _sqliteStorage.set(data.key, data.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Future<dynamic> get(StorageData data) async {
|
||||
var value = CacheUtil.get(data.key);
|
||||
if (value == null) {
|
||||
switch (data.type) {
|
||||
case StorageType.SecureStorage:
|
||||
value = await _secureStorage.get(data.key);
|
||||
break;
|
||||
case StorageType.SharedPreferences:
|
||||
value = await _sharedPreferences.get(data.key);
|
||||
break;
|
||||
case StorageType.SQLite3:
|
||||
value = await _sqliteStorage.get(data.key);
|
||||
break;
|
||||
}
|
||||
CacheUtil.set(data.key, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
Future<void> delete(StorageData data) async {
|
||||
switch (data.type) {
|
||||
case StorageType.SecureStorage:
|
||||
CacheUtil.delete(data.key);
|
||||
await _secureStorage.delete(data.key);
|
||||
break;
|
||||
case StorageType.SharedPreferences:
|
||||
await _sharedPreferences.delete(data.key);
|
||||
break;
|
||||
case StorageType.SQLite3:
|
||||
await _sqliteStorage.delete(data.key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StorageUtil {}
|
Loading…
Reference in New Issue