WIP
This commit is contained in:
parent
25c316ef79
commit
2d88a0b355
|
@ -56,9 +56,10 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
enText: 'Are you sure you want to change your notification?',
|
||||
ptText: 'Tem certeza que deseja alterar sua notificação?',
|
||||
);
|
||||
|
||||
|
||||
onConfirm() async {
|
||||
String content;
|
||||
isNotify = await StorageHelper.instance.get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true';
|
||||
String value = !isNotify ? 'N' : 'S';
|
||||
await PhpGroup.changeNotifica.call(notifica: value).then((value) async {
|
||||
if (value.jsonBody['error'] == false) {
|
||||
|
@ -83,7 +84,9 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
ptText: 'Erro ao alterar notificação',
|
||||
);
|
||||
SnackBarUtil.showSnackBar(context, content, isError: true);
|
||||
}).whenComplete(() => notifyListeners());
|
||||
})
|
||||
.then((_) async => isNotify = await StorageHelper.instance.get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true')
|
||||
.whenComplete(() => notifyListeners());
|
||||
context.pop();
|
||||
}
|
||||
|
||||
|
@ -93,8 +96,6 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
Future<void> toggleAccess(BuildContext context) async {
|
||||
onChange(String key) async {
|
||||
await StorageHelper.instance.set(SecureStorageKey.accessPass.value, key, Storage.SecureStorage);
|
||||
isAccess = await StorageHelper.instance.get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true';
|
||||
|
||||
await PhpGroup.changePass.call(newSenha: key).then((value) async {
|
||||
final String content;
|
||||
if (jsonDecode(value.jsonBody['error'].toString()) == false) {
|
||||
|
@ -118,7 +119,9 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
enText: 'Error changing access pass',
|
||||
);
|
||||
SnackBarUtil.showSnackBar(context, content, isError: true);
|
||||
}).whenComplete(() => notifyListeners());
|
||||
})
|
||||
.then((_) async => isAccess = await StorageHelper.instance.get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true')
|
||||
.whenComplete(() => notifyListeners());
|
||||
}
|
||||
|
||||
_showPassKey(context, onChange);
|
||||
|
@ -127,7 +130,6 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
Future<void> togglePanic(BuildContext context) async {
|
||||
onChange(String key) async {
|
||||
await StorageHelper.instance.set(SecureStorageKey.panicPass.value, key, Storage.SecureStorage);
|
||||
isPanic = await StorageHelper.instance.get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true';
|
||||
await PhpGroup.changePanic
|
||||
.call(newSenhaPanico: key)
|
||||
.then((value) async {
|
||||
|
@ -153,7 +155,9 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
enText: 'Error changing panic password',
|
||||
);
|
||||
SnackBarUtil.showSnackBar(context, content, isError: true);
|
||||
}).whenComplete(() => notifyListeners());
|
||||
})
|
||||
.then((_) async => isPanic = await StorageHelper.instance.get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true')
|
||||
.whenComplete(() => notifyListeners());
|
||||
}
|
||||
|
||||
_showPassKey(context, onChange);
|
||||
|
@ -165,7 +169,6 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
ptText: 'Impressão digital alterada com sucesso',
|
||||
);
|
||||
|
||||
isFingerprint = await StorageHelper.instance.get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
|
||||
|
||||
onChange(String? key) async {
|
||||
isFingerprint = !isFingerprint;
|
||||
|
@ -173,6 +176,8 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
await StorageHelper.instance.set(SQLiteStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false', Storage.SQLiteStorage);
|
||||
notifyListeners();
|
||||
SnackBarUtil.showSnackBar(context, content);
|
||||
isFingerprint = await StorageHelper.instance.get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
|
||||
|
||||
}
|
||||
|
||||
isFingerprint ? onChange(null) : _showPassKey(context, onChange);
|
||||
|
@ -244,4 +249,7 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
SnackBarUtil.showSnackBar(context, content, isError: true);
|
||||
}).whenComplete(() => notifyListeners());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
@ -7,8 +6,7 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
|||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/pages/preferences_settings_page/preferences_settings_model.dart';
|
||||
import 'package:hub/shared/helpers/base_storage.dart';
|
||||
import 'package:hub/shared/helpers/storage_helper.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PreferencesPageWidget extends StatefulWidget {
|
||||
|
|
|
@ -11,13 +11,15 @@ import 'package:qr_flutter/qr_flutter.dart';
|
|||
class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
|
||||
/// Local state fields for this page.
|
||||
|
||||
bool isAccess = false;
|
||||
|
||||
|
||||
String? key;
|
||||
|
||||
DateTime? time;
|
||||
bool isAccess = false;
|
||||
late final bool isFingerprint;
|
||||
late final String userDevUUID;
|
||||
late final VoidCallback? safeSetState;
|
||||
|
||||
/// State fields for stateful widgets in this page.
|
||||
|
||||
|
@ -30,7 +32,8 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
|
|||
|
||||
Future<void> initVariable() async {
|
||||
isFingerprint = await StorageHelper.instance.get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true';
|
||||
userDevUUID = (await StorageHelper.instance.get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||
userDevUUID = await StorageHelper.instance.get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage) ?? '';
|
||||
safeSetState?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:barcode_widget/barcode_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -40,8 +43,8 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
void initState() {
|
||||
super.initState();
|
||||
_model = createModel(context, () => QrCodePageModel());
|
||||
_model.safeSetState = () => safeSetState(() {});
|
||||
|
||||
// On page load action.
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) async {
|
||||
if (animationsMap['barcodeOnActionTriggerAnimation'] != null) {
|
||||
animationsMap['barcodeOnActionTriggerAnimation']!.controller.fling();
|
||||
|
@ -69,13 +72,6 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
this,
|
||||
);
|
||||
|
||||
// // Adicionando um ouvinte de status à animação para reiniciá-la após a conclusão
|
||||
// animationsMap['barcodeOnActionTriggerAnimation']?.controller.addStatusListener((status) {
|
||||
// if (status == AnimationStatus.completed) {
|
||||
// animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset();
|
||||
// animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -131,10 +127,8 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
safeSetState(() async {
|
||||
_resetAnimationAndToggleAccess();
|
||||
});
|
||||
|
||||
log('isFingerprint: ${_model.isFingerprint}');
|
||||
_model.isFingerprint ? await _showBiometricsAuth(context) : await _showQrCodeBottomSheet(context);
|
||||
},
|
||||
child: _model.buildQrCode(
|
||||
|
@ -188,6 +182,7 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||
child: FFButtonWidget(
|
||||
onPressed: () async {
|
||||
log('isFingerprint: ${_model.isFingerprint}');
|
||||
_model.isFingerprint
|
||||
? await _showBiometricsAuth(context)
|
||||
: await _showQrCodeBottomSheet(context);
|
||||
|
@ -262,7 +257,6 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Expirando QR code em',
|
||||
enText: 'Expiring QR code in',
|
||||
// 'wkjkxd2e' /* Trocando QR code em */,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
|
@ -329,19 +323,21 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
}
|
||||
|
||||
Future<void> _showBiometricsAuth(BuildContext context) async {
|
||||
BiometricHelper.checkBiometrics()
|
||||
.then((value) => BiometricHelper.authenticateBiometric().then((value) {
|
||||
safeSetState(() async {
|
||||
await BiometricHelper.checkBiometrics()
|
||||
.then((value) async => await BiometricHelper.authenticateBiometric().then((value) async {
|
||||
final key = await StorageHelper.instance.get(SecureStorageKey.fingerprintPass.value, Storage.SecureStorage) ?? '';
|
||||
safeSetState(() {
|
||||
if (animationsMap['barcodeOnActionTriggerAnimation'] != null) {
|
||||
animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop();
|
||||
animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse();
|
||||
}
|
||||
_model.isAccess = !_model.isAccess;
|
||||
_model.key = (await StorageHelper.instance.get(SecureStorageKey.fingerprintPass.value, Storage.SecureStorage)) ?? '';
|
||||
_model.key = key;
|
||||
});
|
||||
}))
|
||||
.onError((error, StackTrace) {
|
||||
_showQrCodeBottomSheet(context);
|
||||
.onError((error, stackTrace) {
|
||||
log('Error', error: error, stackTrace: stackTrace);
|
||||
if (mounted) _showQrCodeBottomSheet(context);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -373,26 +369,19 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
),
|
||||
);
|
||||
},
|
||||
).catchError((error) => safeSetState(() {
|
||||
_resetAnimationAndToggleAccess();
|
||||
}));
|
||||
).catchError((error) => safeSetState(() => _resetAnimationAndToggleAccess()));
|
||||
unawaited(
|
||||
() async {
|
||||
await _model.qrCodeEncoder(
|
||||
context,
|
||||
key: _model.key,
|
||||
);
|
||||
setState(() {});
|
||||
await _model.qrCodeEncoder(context, key: _model.key);
|
||||
safeSetState(() {});
|
||||
}(),
|
||||
);
|
||||
}
|
||||
|
||||
void _resetAnimationAndToggleAccess() {
|
||||
safeSetState(() {
|
||||
// Reinicia a animação
|
||||
animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset();
|
||||
animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward();
|
||||
// Alterna o estado de acesso
|
||||
_model.isAccess = !_model.isAccess;
|
||||
_model.key = null;
|
||||
});
|
||||
|
@ -417,9 +406,7 @@ class _QrCodePageWidgetState extends State<QrCodePageWidget> with TickerProvider
|
|||
},
|
||||
),
|
||||
title: Text(
|
||||
FFLocalizations.of(context).getText(
|
||||
'ku7jqe53' /* QR Code de Acesso */,
|
||||
),
|
||||
FFLocalizations.of(context).getText('ku7jqe53'),
|
||||
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
||||
fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily,
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
|
|
Loading…
Reference in New Issue