Refactor QR code generation and error handling
This commit is contained in:
parent
ff43303205
commit
f22a3b615b
|
@ -43,13 +43,16 @@ class FFAppState extends ChangeNotifier {
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
_isBiometricAuthenticated = true;
|
_isBiometricAuthenticated = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
return Future.value();
|
||||||
// Salvar o estado de autenticação biométrica, se necessário
|
// Salvar o estado de autenticação biométrica, se necessário
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
debugPrint('Error authenticating: $e');
|
debugPrint('Error authenticating: $e');
|
||||||
clearBiometricAuthentication();
|
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
|
// Função para limpar o estado de autenticação biométrica
|
||||||
|
@ -145,6 +148,9 @@ class FFAppState extends ChangeNotifier {
|
||||||
await _safeInitAsync(() async {
|
await _safeInitAsync(() async {
|
||||||
_panicPass = await secureStorage.getString('panicPass') ?? _panicPass;
|
_panicPass = await secureStorage.getString('panicPass') ?? _panicPass;
|
||||||
});
|
});
|
||||||
|
await _safeInitAsync(() async {
|
||||||
|
_fingerprintPass = await secureStorage.getString('fingerprintPass') ?? _fingerprintPass;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +161,17 @@ class FFAppState extends ChangeNotifier {
|
||||||
|
|
||||||
late FlutterSecureStorage secureStorage;
|
late FlutterSecureStorage secureStorage;
|
||||||
|
|
||||||
|
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 _accessPass = '';
|
||||||
String get accessPass => _accessPass;
|
String get accessPass => _accessPass;
|
||||||
set accessPass(String value) {
|
set accessPass(String value) {
|
||||||
|
|
|
@ -125,8 +125,8 @@ class _PassKeyTemplateWidgetState
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
|
padding: const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
enText: FFAppState().accessPass != '' ? 'CHANGE PASSWORD' : 'INSERT PASSWORD',
|
enText: 'INSERT PASSWORD',
|
||||||
ptText: FFAppState().accessPass != '' ? 'ALTERAR SENHA' : 'ADICIONAR SENHA',
|
ptText: 'ADICIONAR SENHA',
|
||||||
),
|
),
|
||||||
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
||||||
fontFamily: 'Outfit',
|
fontFamily: 'Outfit',
|
||||||
|
@ -161,249 +161,134 @@ class _PassKeyTemplateWidgetState
|
||||||
autovalidateMode: AutovalidateMode.always,
|
autovalidateMode: AutovalidateMode.always,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
if (FFAppState().accessPass.isNotEmpty)
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 16.0, 0.0),
|
padding: const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 16.0, 0.0),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: _model.keyTextFieldTextController1,
|
controller: _model.keyTextFieldTextController1,
|
||||||
|
focusNode: _model.keyTextFieldFocusNode1,
|
||||||
focusNode: _model.keyTextFieldFocusNode1,
|
onChanged: (_) => EasyDebounce.debounce(
|
||||||
onChanged: (_) => EasyDebounce.debounce(
|
'_model.keyTextFieldTextController',
|
||||||
'_model.keyTextFieldTextController',
|
const Duration(milliseconds: 2000),
|
||||||
const Duration(milliseconds: 2000),
|
() {
|
||||||
() => setState(() {}),
|
if (mounted) setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
autofillHints: const [AutofillHints.password],
|
||||||
|
textCapitalization: TextCapitalization.none,
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
|
obscureText: !_model.keyTextFieldVisibility1,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
labelText: FFLocalizations.of(context).getVariableText(
|
||||||
|
ptText: 'Senha',
|
||||||
|
enText: 'Password',
|
||||||
),
|
),
|
||||||
autofillHints: const [AutofillHints.password],
|
labelStyle: FlutterFlowTheme.of(context)
|
||||||
textCapitalization: TextCapitalization.none,
|
.labelMedium
|
||||||
textInputAction: TextInputAction.done,
|
.override(
|
||||||
obscureText: !_model.keyTextFieldVisibility1,
|
fontFamily: 'Plus Jakarta Sans',
|
||||||
decoration: InputDecoration(
|
color: FlutterFlowTheme.of(context).primary,
|
||||||
isDense: true,
|
fontSize: 14.0,
|
||||||
labelText: FFLocalizations.of(context).getVariableText(
|
letterSpacing: 0.0,
|
||||||
ptText: 'Senha Antiga',
|
fontWeight: FontWeight.w500,
|
||||||
enText: 'Old Password',
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
),
|
.containsKey('Plus Jakarta Sans'),
|
||||||
labelStyle:
|
|
||||||
FlutterFlowTheme.of(context).labelMedium.override(
|
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
|
||||||
color: FlutterFlowTheme.of(context).primary,
|
|
||||||
fontSize: 14.0,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
|
||||||
.containsKey('Plus Jakarta Sans'),
|
|
||||||
),
|
|
||||||
hintText: FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: 'Digite a sua senha antiga.....',
|
|
||||||
enText: 'Enter your old password.....',
|
|
||||||
),
|
|
||||||
hintStyle:
|
|
||||||
FlutterFlowTheme.of(context).labelMedium.override(
|
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
|
||||||
fontSize: 14.0,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
|
||||||
.containsKey('Plus Jakarta Sans'),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).accent3,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
errorBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).error,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
focusedErrorBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).error,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
filled: true,
|
|
||||||
fillColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
||||||
contentPadding: const EdgeInsetsDirectional.fromSTEB(
|
|
||||||
24.0, 24.0, 20.0, 24.0),
|
|
||||||
suffixIcon: InkWell(
|
|
||||||
onTap: () => setState(
|
|
||||||
() => _model.keyTextFieldVisibility1 =
|
|
||||||
!_model.keyTextFieldVisibility1,
|
|
||||||
),
|
|
||||||
focusNode: FocusNode(skipTraversal: true),
|
|
||||||
child: Icon(
|
|
||||||
_model.keyTextFieldVisibility1
|
|
||||||
? Icons.visibility_outlined
|
|
||||||
: Icons.visibility_off_outlined,
|
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
|
||||||
size: 22.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
hintText: FFLocalizations.of(context).getVariableText(
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
ptText: 'Digite a sua senha.....',
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
enText: 'Enter your password.....',
|
||||||
fontSize: 14.0,
|
),
|
||||||
letterSpacing: 0.0,
|
hintStyle: FlutterFlowTheme.of(context)
|
||||||
fontWeight: FontWeight.w500,
|
.labelMedium
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
.override(
|
||||||
.containsKey('Plus Jakarta Sans'),
|
fontFamily: 'Plus Jakarta Sans',
|
||||||
),
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
maxLength: 4,
|
fontSize: 14.0,
|
||||||
maxLengthEnforcement: MaxLengthEnforcement.none,
|
letterSpacing: 0.0,
|
||||||
buildCounter: (context,
|
fontWeight: FontWeight.w500,
|
||||||
{required currentLength,
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
required isFocused,
|
.containsKey('Plus Jakarta Sans'),
|
||||||
maxLength}) =>
|
),
|
||||||
null,
|
enabledBorder: OutlineInputBorder(
|
||||||
keyboardType: TextInputType.number,
|
borderSide: BorderSide(
|
||||||
cursorColor: FlutterFlowTheme.of(context).primary,
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
validator: _model.keyTextFieldTextControllerValidator1
|
width: 2.0,
|
||||||
.asValidator(context),
|
),
|
||||||
inputFormatters: [
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
FilteringTextInputFormatter.allow(RegExp('[0-9]'))
|
),
|
||||||
],
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).accent3,
|
||||||
|
width: 2.0,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
),
|
||||||
|
errorBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).error,
|
||||||
|
width: 2.0,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
),
|
||||||
|
focusedErrorBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).error,
|
||||||
|
width: 2.0,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
),
|
||||||
|
filled: true,
|
||||||
|
fillColor:
|
||||||
|
FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
24.0, 24.0, 20.0, 24.0),
|
||||||
|
suffixIcon: InkWell(
|
||||||
|
onTap: () => setState(
|
||||||
|
() => _model.keyTextFieldVisibility1 =
|
||||||
|
!_model.keyTextFieldVisibility1,
|
||||||
|
),
|
||||||
|
focusNode: FocusNode(skipTraversal: true),
|
||||||
|
child: Icon(
|
||||||
|
_model.keyTextFieldVisibility1
|
||||||
|
? Icons.visibility_outlined
|
||||||
|
: Icons.visibility_off_outlined,
|
||||||
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
|
size: 22.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||||
|
fontFamily: 'Plus Jakarta Sans',
|
||||||
|
color: FlutterFlowTheme.of(context).primaryText,
|
||||||
|
fontSize: 14.0,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey('Plus Jakarta Sans'),
|
||||||
|
),
|
||||||
|
maxLength: 4,
|
||||||
|
maxLengthEnforcement: MaxLengthEnforcement.enforced,
|
||||||
|
buildCounter: (context,
|
||||||
|
{required currentLength,
|
||||||
|
required isFocused,
|
||||||
|
maxLength}) =>
|
||||||
|
null,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
cursorColor: FlutterFlowTheme.of(context).primary,
|
||||||
|
validator: _model.keyTextFieldTextControllerValidator1
|
||||||
|
.asValidator(context),
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 16.0, 0.0),
|
|
||||||
child: SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: TextFormField(
|
|
||||||
controller: _model.keyTextFieldTextController2,
|
|
||||||
|
|
||||||
focusNode: _model.keyTextFieldFocusNode2,
|
|
||||||
onChanged: (_) => EasyDebounce.debounce(
|
|
||||||
'_model.keyTextFieldTextController',
|
|
||||||
const Duration(milliseconds: 2000),
|
|
||||||
() => setState(() {}),
|
|
||||||
),
|
|
||||||
autofillHints: const [AutofillHints.password],
|
|
||||||
textCapitalization: TextCapitalization.none,
|
|
||||||
textInputAction: TextInputAction.done,
|
|
||||||
obscureText: !_model.keyTextFieldVisibility2,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
isDense: true,
|
|
||||||
labelText: FFLocalizations.of(context).getVariableText(
|
|
||||||
ptText: FFAppState().accessPass != '' ? 'Nova Senha' : 'Senha',
|
|
||||||
enText: FFAppState().accessPass != '' ? 'New Password' : 'Password',
|
|
||||||
),
|
|
||||||
labelStyle:
|
|
||||||
FlutterFlowTheme.of(context).labelMedium.override(
|
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
|
||||||
color: FlutterFlowTheme.of(context).primary,
|
|
||||||
fontSize: 14.0,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
|
||||||
.containsKey('Plus Jakarta Sans'),
|
|
||||||
),
|
|
||||||
hintText: FFLocalizations.of(context).getVariableText(
|
|
||||||
enText: FFAppState().accessPass != null ? 'Enter your new password.....' : 'Enter your password.....',
|
|
||||||
ptText: FFAppState().accessPass != null ? 'Digite a sua nova senha.....' : 'Digite a sua senha.....',
|
|
||||||
),
|
|
||||||
hintStyle:
|
|
||||||
FlutterFlowTheme.of(context).labelMedium.override(
|
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
|
||||||
fontSize: 14.0,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
|
||||||
.containsKey('Plus Jakarta Sans'),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).accent3,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
errorBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).error,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
focusedErrorBorder: OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).error,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
filled: true,
|
|
||||||
fillColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
||||||
contentPadding: const EdgeInsetsDirectional.fromSTEB(
|
|
||||||
24.0, 24.0, 20.0, 24.0),
|
|
||||||
suffixIcon: InkWell(
|
|
||||||
onTap: () => setState(
|
|
||||||
() => _model.keyTextFieldVisibility1 =
|
|
||||||
!_model.keyTextFieldVisibility1,
|
|
||||||
),
|
|
||||||
focusNode: FocusNode(skipTraversal: true),
|
|
||||||
child: Icon(
|
|
||||||
_model.keyTextFieldVisibility1
|
|
||||||
? Icons.visibility_outlined
|
|
||||||
: Icons.visibility_off_outlined,
|
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
|
||||||
size: 22.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
||||||
fontFamily: 'Plus Jakarta Sans',
|
|
||||||
color: FlutterFlowTheme.of(context).primaryText,
|
|
||||||
fontSize: 14.0,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
|
||||||
.containsKey('Plus Jakarta Sans'),
|
|
||||||
),
|
|
||||||
maxLength: 4,
|
|
||||||
maxLengthEnforcement: MaxLengthEnforcement.none,
|
|
||||||
buildCounter: (context,
|
|
||||||
{required currentLength,
|
|
||||||
required isFocused,
|
|
||||||
maxLength}) =>
|
|
||||||
null,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
cursorColor: FlutterFlowTheme.of(context).primary,
|
|
||||||
validator: _model.keyTextFieldTextControllerValidator2
|
|
||||||
.asValidator(context),
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.allow(RegExp('[0-9]'))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: const AlignmentDirectional(0.0, 0.0),
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
|
@ -418,7 +303,7 @@ class _PassKeyTemplateWidgetState
|
||||||
await widget.toggleActionStatus?.call(
|
await widget.toggleActionStatus?.call(
|
||||||
_model.keyTextFieldTextController1.text.isEmpty ? _model.keyTextFieldTextController2.text : _model.keyTextFieldTextController1.text,
|
_model.keyTextFieldTextController1.text.isEmpty ? _model.keyTextFieldTextController2.text : _model.keyTextFieldTextController1.text,
|
||||||
);
|
);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context, true);
|
||||||
},
|
},
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: FFAppState().accessPass != '' ? 'Alterar' : 'Adicionar',
|
ptText: FFAppState().accessPass != '' ? 'Alterar' : 'Adicionar',
|
||||||
|
|
|
@ -1,21 +1,52 @@
|
||||||
|
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:f_r_e_hub/backend/api_requests/api_calls.dart';
|
import 'package:f_r_e_hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:f_r_e_hub/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart';
|
import 'package:f_r_e_hub/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart';
|
||||||
import 'package:f_r_e_hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:f_r_e_hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:f_r_e_hub/flutter_flow/flutter_flow_util.dart';
|
import 'package:f_r_e_hub/flutter_flow/flutter_flow_util.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
|
||||||
|
|
||||||
class PreferencesPageModel with ChangeNotifier {
|
class PreferencesPageModel with ChangeNotifier {
|
||||||
final unfocusNode = FocusNode();
|
final unfocusNode = FocusNode();
|
||||||
|
|
||||||
final LocalAuthentication auth = LocalAuthentication();
|
|
||||||
|
|
||||||
|
Future<void> toggleFingerprint(BuildContext context) async {
|
||||||
|
|
||||||
Future<void> toggleFingerprint() async {
|
// FFAppState().checkBiometrics()
|
||||||
|
// .then((value) => FFAppState().authenticateBiometric()
|
||||||
|
// .then( (value) {
|
||||||
|
// FFAppState().fingerprint = !FFAppState().fingerprint;
|
||||||
|
|
||||||
FFAppState().checkBiometrics().then((value) => FFAppState().authenticateBiometric().then( (value) => FFAppState().fingerprint = !FFAppState().fingerprint).whenComplete(() => notifyListeners()));
|
// })
|
||||||
|
// .whenComplete(() => notifyListeners()));
|
||||||
|
|
||||||
|
if(FFAppState().fingerprint) {
|
||||||
|
FFAppState().fingerprint = false;
|
||||||
|
FFAppState().deleteFingerprintPass();
|
||||||
|
notifyListeners();
|
||||||
|
} else {
|
||||||
|
await showModalBottomSheet(
|
||||||
|
isScrollControlled: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
useSafeArea: true,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return Padding(
|
||||||
|
padding:
|
||||||
|
MediaQuery.viewInsetsOf(context),
|
||||||
|
child:
|
||||||
|
PassKeyTemplateWidget(
|
||||||
|
toggleActionStatus: (key) async {
|
||||||
|
log(key);
|
||||||
|
FFAppState().fingerprintPass = key;
|
||||||
|
FFAppState().fingerprint = true;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).whenComplete(() => notifyListeners());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +105,12 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
|
|
||||||
|
|
||||||
Future<void> togglePass(BuildContext context) async {
|
Future<void> togglePass(BuildContext context) async {
|
||||||
FFAppState().pass = true;
|
debugPrint('pass: ${FFAppState().pass}');
|
||||||
notifyListeners();
|
if(FFAppState().pass) {
|
||||||
|
FFAppState().pass = false;
|
||||||
|
FFAppState().deleteAccessPass();
|
||||||
|
notifyListeners();
|
||||||
|
} else {
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
|
@ -91,20 +126,35 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
FFAppState().accessPass = key;
|
FFAppState().accessPass = key;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
debugPrint('key: $key');
|
debugPrint('key: $key');
|
||||||
// PhpGroup.changePass.call(
|
await PhpGroup.changePass.call(
|
||||||
// userUUID: FFAppState().userUUID,
|
userUUID: FFAppState().userUUID,
|
||||||
// devUUID: FFAppState().devUUID,
|
devUUID: FFAppState().devUUID,
|
||||||
// cliID: FFAppState().cliUUID,
|
cliID: FFAppState().cliUUID,
|
||||||
// atividade: 'updVisitado',
|
atividade: 'updVisitado',
|
||||||
// newSenha: FFAppState().accessPass,
|
newSenha: FFAppState().accessPass,
|
||||||
// );
|
)
|
||||||
|
.then((value) {
|
||||||
|
FFAppState().pass = true;
|
||||||
|
var error = jsonDecode(value.jsonBody['error'].toString());
|
||||||
|
log('${jsonDecode(value.jsonBody['error'].toString())}');
|
||||||
|
if(jsonDecode(value.jsonBody['error'].toString()) == false) {
|
||||||
|
FFAppState().pass = true;
|
||||||
|
} else {
|
||||||
|
FFAppState().pass = false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.onError((error, StackTrace) {
|
||||||
|
FFAppState().pass = false;
|
||||||
|
log(error.toString());
|
||||||
|
log(StackTrace.toString());
|
||||||
|
})
|
||||||
|
.whenComplete(() => notifyListeners());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
FFAppState().pass = false;
|
}
|
||||||
notifyListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -94,7 +94,7 @@ class PreferencesPageWidget extends StatelessWidget {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
icon = Icons.fingerprint;
|
icon = Icons.fingerprint;
|
||||||
onPressed = model.toggleFingerprint; // Desabilita se fingerprint for false
|
onPressed = () => model.toggleFingerprint(context); // Desabilita se fingerprint for false
|
||||||
isEnabled = FFAppState().fingerprint;
|
isEnabled = FFAppState().fingerprint;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
@ -8,7 +8,7 @@ class QrCodePageModel extends FlutterFlowModel<QrCodePageWidget> {
|
||||||
|
|
||||||
bool isAccess = false;
|
bool isAccess = false;
|
||||||
|
|
||||||
String? key;
|
String? key = null;
|
||||||
|
|
||||||
DateTime? time;
|
DateTime? time;
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ void dispose() {
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
if (_model.isAccess == true)
|
if (_model.isAccess == true && _model.key != null)
|
||||||
Text(
|
Text(
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Use esse QR Code para acesso',
|
ptText: 'Use esse QR Code para acesso',
|
||||||
|
@ -143,7 +143,7 @@ void dispose() {
|
||||||
),
|
),
|
||||||
Stack(
|
Stack(
|
||||||
children: [
|
children: [
|
||||||
if (_model.isAccess == true)
|
if (_model.isAccess == true && _model.key != null)
|
||||||
Align(
|
Align(
|
||||||
alignment: const AlignmentDirectional(0.0, 0.0),
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
@ -161,7 +161,7 @@ void dispose() {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if(_model.isAccess == false)
|
if(_model.isAccess == false && _model.key == null)
|
||||||
Align(
|
Align(
|
||||||
alignment: const AlignmentDirectional(0, 0),
|
alignment: const AlignmentDirectional(0, 0),
|
||||||
child: BarcodeWidget(
|
child: BarcodeWidget(
|
||||||
|
@ -180,7 +180,7 @@ void dispose() {
|
||||||
animationsMap['barcodeOnActionTriggerAnimation']!,
|
animationsMap['barcodeOnActionTriggerAnimation']!,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_model.isAccess == false)
|
if (_model.isAccess == false && _model.key == null)
|
||||||
Align(
|
Align(
|
||||||
alignment: const AlignmentDirectional(0.0, 0.0),
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
@ -203,8 +203,10 @@ void dispose() {
|
||||||
alignment: const AlignmentDirectional(0.0, 0.0),
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
child: FFButtonWidget(
|
child: FFButtonWidget(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await _showQrCodeBottomSheet(context);
|
await _showQrCodeBottomSheet(context).then((value) => _toggleQrCodeAccess()).onError((error, stackTrace) => safeSetState((){
|
||||||
_toggleQrCodeAccess();
|
_resetAnimationAndToggleAccess();
|
||||||
|
}));
|
||||||
|
|
||||||
},
|
},
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
text: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Gerar QR Code',
|
ptText: 'Gerar QR Code',
|
||||||
|
@ -243,7 +245,7 @@ void dispose() {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (_model.isAccess == true)
|
if (_model.isAccess == true && _model.key != null)
|
||||||
Container(
|
Container(
|
||||||
width: 300.0,
|
width: 300.0,
|
||||||
decoration: const BoxDecoration(),
|
decoration: const BoxDecoration(),
|
||||||
|
@ -265,7 +267,7 @@ void dispose() {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_model.isAccess == true)
|
if (_model.isAccess == true && _model.key != null)
|
||||||
Container(
|
Container(
|
||||||
width: 250.0,
|
width: 250.0,
|
||||||
height: 80.0,
|
height: 80.0,
|
||||||
|
@ -367,7 +369,11 @@ void dispose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _showQrCodeBottomSheet(BuildContext context) async {
|
Future<void> _showQrCodeBottomSheet(BuildContext context) async {
|
||||||
await showModalBottomSheet(
|
if(FFAppState().fingerprint) {
|
||||||
|
FFAppState().checkBiometrics().then((value) => FFAppState().authenticateBiometric().then( (value) => safeSetState(() {_model.key = FFAppState().accessPass;}) )).catchError((error) => safeSetState((){_resetAnimationAndToggleAccess();}));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
await showModalBottomSheet(
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
|
@ -393,6 +399,9 @@ void dispose() {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).then((value) => safeSetState(() {}));
|
).then((value) => safeSetState(() {}));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unawaited(
|
unawaited(
|
||||||
() async {
|
() async {
|
||||||
|
@ -412,6 +421,7 @@ void dispose() {
|
||||||
animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward();
|
animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward();
|
||||||
// Alterna o estado de acesso
|
// Alterna o estado de acesso
|
||||||
_model.isAccess = !_model.isAccess;
|
_model.isAccess = !_model.isAccess;
|
||||||
|
_model.key = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue