WIP
This commit is contained in:
parent
80d428b766
commit
d82617c7e1
|
@ -28,12 +28,9 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initVariable() async {
|
Future<void> initVariable() async {
|
||||||
isFingerprint = await db
|
isFingerprint =
|
||||||
.get(key: 'fingerprint', field: 'value')
|
await db.get('fingerprint').then((value) => value.toString() == 'true');
|
||||||
.then((value) => value.toString() == 'true');
|
userDevUUID = await db.get('userDevUUID').then((value) => value.toString());
|
||||||
userDevUUID = await db
|
|
||||||
.get(key: 'userDevUUID', field: 'value')
|
|
||||||
.then((value) => value.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -15,7 +15,9 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/pages/qr_code_page/qr_code_page_model.dart';
|
import 'package:hub/pages/qr_code_page/qr_code_page_model.dart';
|
||||||
|
import 'package:hub/shared/helpers/secure_storage_helper.dart';
|
||||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||||
|
import 'package:hub/shared/utils/biometric_util.dart';
|
||||||
import 'package:percent_indicator/circular_percent_indicator.dart';
|
import 'package:percent_indicator/circular_percent_indicator.dart';
|
||||||
// import 'package:percent_indicator/percent_indicator.dart';
|
// import 'package:percent_indicator/percent_indicator.dart';
|
||||||
|
|
||||||
|
@ -358,9 +360,8 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget>
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _showBiometricsAuth(BuildContext context) async {
|
Future<void> _showBiometricsAuth(BuildContext context) async {
|
||||||
AppState()
|
BiometricHelper.checkBiometrics()
|
||||||
.checkBiometrics()
|
.then((value) => BiometricHelper.authenticateBiometric().then((value) {
|
||||||
.then((value) => AppState().authenticateBiometric().then((value) {
|
|
||||||
safeSetState(() {
|
safeSetState(() {
|
||||||
if (animationsMap['barcodeOnActionTriggerAnimation'] != null) {
|
if (animationsMap['barcodeOnActionTriggerAnimation'] != null) {
|
||||||
animationsMap['barcodeOnActionTriggerAnimation']!
|
animationsMap['barcodeOnActionTriggerAnimation']!
|
||||||
|
@ -371,7 +372,7 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget>
|
||||||
.reverse();
|
.reverse();
|
||||||
}
|
}
|
||||||
_model.isAccess = !_model.isAccess;
|
_model.isAccess = !_model.isAccess;
|
||||||
_model.key = AppState().fingerprintPass;
|
_model.key = SecureStorageHelper().fingerprintPass;
|
||||||
});
|
});
|
||||||
}))
|
}))
|
||||||
.onError((error, StackTrace) {
|
.onError((error, StackTrace) {
|
||||||
|
|
|
@ -7,9 +7,8 @@ import 'package:share_plus/share_plus.dart';
|
||||||
class ReceptionPageModel with ChangeNotifier {
|
class ReceptionPageModel with ChangeNotifier {
|
||||||
Future<void> getIdenfifier(BuildContext context) async {
|
Future<void> getIdenfifier(BuildContext context) async {
|
||||||
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
final SQLiteStorageHelper db = SQLiteStorageHelper();
|
||||||
final String userDevUUID = await db
|
final String userDevUUID =
|
||||||
.get(key: 'userDevUUID', field: 'value')
|
await db.get('userDevUUID').then((value) => value.toString());
|
||||||
.then((value) => value.toString());
|
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
Share.share(
|
Share.share(
|
||||||
|
|
|
@ -8,6 +8,9 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/pages/reception_page/reception_page_model.dart';
|
import 'package:hub/pages/reception_page/reception_page_model.dart';
|
||||||
|
import 'package:hub/shared/helpers/secure_storage_helper.dart';
|
||||||
|
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||||
|
import 'package:hub/shared/utils/storage_util.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ReceptionPageWidget extends StatefulWidget {
|
class ReceptionPageWidget extends StatefulWidget {
|
||||||
|
@ -26,7 +29,7 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
AppState().context = context;
|
SecureStorageHelper().context = context;
|
||||||
return ChangeNotifierProvider(
|
return ChangeNotifierProvider(
|
||||||
create: (context) => ReceptionPageModel(),
|
create: (context) => ReceptionPageModel(),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
@ -151,7 +154,8 @@ class _ReceptionPageWidgetState extends State<ReceptionPageWidget> {
|
||||||
child: FFButtonWidget(
|
child: FFButtonWidget(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
PhpGroup.unregisterDevice();
|
PhpGroup.unregisterDevice();
|
||||||
AppState().deleteAll();
|
|
||||||
|
StorageManager.purge();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
context.go(
|
context.go(
|
||||||
|
|
|
@ -39,7 +39,6 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
context.watch<AppState>();
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
import 'package:hub/app_state.dart';
|
import 'package:hub/app_state.dart';
|
||||||
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
import 'package:hub/shared/helpers/sqlite_storage_helper.dart';
|
||||||
import 'package:hub/shared/utils/webview_util.dart';
|
import 'package:hub/shared/utils/webview_util.dart';
|
||||||
|
@ -22,24 +23,14 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
|
||||||
late WebViewController _controllerAll;
|
late WebViewController _controllerAll;
|
||||||
|
|
||||||
Future<Map<String, String>> initVariables() async {
|
Future<Map<String, String>> initVariables() async {
|
||||||
final email = await db
|
final email = await db.get('email').then((value) => value.toString());
|
||||||
.get(key: 'email', field: 'value')
|
final name = await db.get('userName').then((value) => value.toString());
|
||||||
.then((value) => value.toString());
|
final userUUID = await db.get('userUUID').then((value) => value.toString());
|
||||||
final name = await db
|
final devUUID = await db.get('devUUID').then((value) => value.toString());
|
||||||
.get(key: 'userName', field: 'value')
|
|
||||||
.then((value) => value.toString());
|
|
||||||
final userUUID = await db
|
|
||||||
.get(key: 'userUUID', field: 'value')
|
|
||||||
.then((value) => value.toString());
|
|
||||||
final devUUID = await db
|
|
||||||
.get(key: 'devUUID', field: 'value')
|
|
||||||
.then((value) => value.toString());
|
|
||||||
final createdAt = await db
|
final createdAt = await db
|
||||||
.get(key: 'devUUID', field: 'createdAt')
|
.getByField(key: 'devUUID', field: 'createdAt')
|
||||||
.then((value) => value.toString());
|
|
||||||
final clientId = await db
|
|
||||||
.get(key: 'cliUUID', field: 'value')
|
|
||||||
.then((value) => value.toString());
|
.then((value) => value.toString());
|
||||||
|
final clientId = await db.get('cliUUID').then((value) => value.toString());
|
||||||
|
|
||||||
final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId';
|
final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId';
|
||||||
|
|
||||||
|
@ -71,8 +62,12 @@ class _ReservationPageWidgetState extends State<ReservationPageWidget> {
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
return Center(child: CircularProgressIndicator());
|
return Center(child: CircularProgressIndicator());
|
||||||
} else if (snapshot.hasError) {
|
} else if (snapshot.hasError ||
|
||||||
return Center(child: Text('Error: ${snapshot.error}'));
|
snapshot.hasData == false ||
|
||||||
|
snapshot.data!.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Text(FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Unexpected error', ptText: 'Erro inesperado')));
|
||||||
} else if (snapshot.hasData) {
|
} else if (snapshot.hasData) {
|
||||||
final data = snapshot.data!;
|
final data = snapshot.data!;
|
||||||
final url = data['url']!;
|
final url = data['url']!;
|
||||||
|
|
|
@ -184,15 +184,9 @@ class ScheduleCompleteVisitPageModel
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initVariables() async {
|
Future<void> _initVariables() async {
|
||||||
devUUID = await db
|
devUUID = await db.get('devUUID').then((value) => value.toString());
|
||||||
.get(key: 'devUUID', field: 'value')
|
cliUUID = await db.get('cliUUID').then((value) => value.toString());
|
||||||
.then((value) => value.toString());
|
userUUID = await db.get('userUUID').then((value) => value.toString());
|
||||||
cliUUID = await db
|
|
||||||
.get(key: 'cliUUID', field: 'value')
|
|
||||||
.then((value) => value.toString());
|
|
||||||
userUUID = await db
|
|
||||||
.get(key: 'userUUID', field: 'value')
|
|
||||||
.then((value) => value.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -109,8 +109,6 @@ class _ScheduleCompleteVisitPageWidgetState
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
context.watch<AppState>();
|
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => _model.unfocusNode.canRequestFocus
|
onTap: () => _model.unfocusNode.canRequestFocus
|
||||||
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
||||||
|
|
|
@ -113,7 +113,7 @@ class SecureStorageHelper extends ChangeNotifier implements Storage {
|
||||||
await _secureStorage.write(key: key, value: value.toString());
|
await _secureStorage.write(key: key, value: value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteAll() {
|
Future<void> purge() async {
|
||||||
_secureStorage.deleteAll();
|
_secureStorage.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,4 +58,8 @@ class SharedPreferencesStorageHelper implements Storage {
|
||||||
// Log or handle the error
|
// Log or handle the error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> purge() async {
|
||||||
|
await _prefs.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
|
|
||||||
class BiometricHelper {
|
class BiometricHelper {
|
||||||
final LocalAuthentication auth = LocalAuthentication();
|
static final LocalAuthentication auth = LocalAuthentication();
|
||||||
|
|
||||||
Future<bool> checkBiometrics() async {
|
static Future<bool> checkBiometrics() async {
|
||||||
try {
|
try {
|
||||||
return await auth.canCheckBiometrics;
|
return await auth.canCheckBiometrics;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -13,7 +13,7 @@ class BiometricHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> authenticateBiometric() async {
|
static Future<bool> authenticateBiometric() async {
|
||||||
try {
|
try {
|
||||||
return await auth.authenticate(
|
return await auth.authenticate(
|
||||||
localizedReason: 'Scan your fingerprint to authenticate',
|
localizedReason: 'Scan your fingerprint to authenticate',
|
||||||
|
|
|
@ -20,12 +20,12 @@ class StorageData {
|
||||||
enum StorageType { SecureStorage, SharedPreferences, SQLite3 }
|
enum StorageType { SecureStorage, SharedPreferences, SQLite3 }
|
||||||
|
|
||||||
class StorageManager {
|
class StorageManager {
|
||||||
final SecureStorageHelper _secureStorage = SecureStorageHelper();
|
static final SecureStorageHelper _secureStorage = SecureStorageHelper();
|
||||||
final SharedPreferencesStorageHelper _sharedPreferences =
|
static final SharedPreferencesStorageHelper _sharedPreferences =
|
||||||
SharedPreferencesStorageHelper();
|
SharedPreferencesStorageHelper();
|
||||||
final SQLiteStorageHelper _sqliteStorage = SQLiteStorageHelper();
|
static final SQLiteStorageHelper _sqliteStorage = SQLiteStorageHelper();
|
||||||
|
|
||||||
Future<void> set(StorageData data) async {
|
static Future<void> set(StorageData data) async {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case StorageType.SecureStorage:
|
case StorageType.SecureStorage:
|
||||||
CacheUtil.set(data.key, data.value);
|
CacheUtil.set(data.key, data.value);
|
||||||
|
@ -40,7 +40,7 @@ class StorageManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> get(StorageData data) async {
|
static Future<dynamic> get(StorageData data) async {
|
||||||
var value = CacheUtil.get(data.key);
|
var value = CacheUtil.get(data.key);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
|
@ -59,7 +59,7 @@ class StorageManager {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> delete(StorageData data) async {
|
static Future<void> delete(StorageData data) async {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case StorageType.SecureStorage:
|
case StorageType.SecureStorage:
|
||||||
CacheUtil.delete(data.key);
|
CacheUtil.delete(data.key);
|
||||||
|
@ -73,6 +73,13 @@ class StorageManager {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> purge() async {
|
||||||
|
// CacheUtil.purge();
|
||||||
|
await _secureStorage.purge();
|
||||||
|
await _sharedPreferences.purge();
|
||||||
|
await _sqliteStorage.purge();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StorageUtil {}
|
class StorageUtil {}
|
||||||
|
|
Loading…
Reference in New Issue