diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index a6a8b9ad..d6002cc2 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -40,6 +40,7 @@ class PhpGroup { static GetLiberationsCall getLiberationsCall = GetLiberationsCall(); static GetMessagesCall getMessagesCall = GetMessagesCall(); static ChangeNotifica changeNotifica = ChangeNotifica(); + static UpdateIDE updateIDE = UpdateIDE(); static RespondeVinculo resopndeVinculo = RespondeVinculo(); static ChangePass changePass = ChangePass(); static ChangePanic changePanic = ChangePanic(); @@ -581,6 +582,41 @@ class ChangeNotifica { } } +class UpdateIDE { + Future call() async { + final String baseUrl = PhpGroup.getBaseUrl(); + + final String devUUID = StorageUtil().devUUID; + final String userUUID = StorageUtil().userUUID; + final String cliID = StorageUtil().cliUUID; + final String newIde = StorageUtil().userDevUUID; + const String atividade = 'updVisitado'; + + return ApiManager.instance.makeApiCall( + callName: 'changeNotifica', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliID, + 'atividade': atividade, + 'newIde': newIde, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); + } +} + class UpdToken { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart index c24edbfa..837ba3e9 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + 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'; @@ -35,15 +37,11 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel 80) { - return FFLocalizations.of(context).getText( - 'l0b0zr50', - ); + return FFLocalizations.of(context).getText('l0b0zr50'); } return null; @@ -54,31 +52,26 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel 80) { return false; @@ -115,7 +121,7 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel( - getJsonField( - visitorItem, - r'''$.VTE_NOME''', - )?.toString(), + getJsonField(visitorItem, r'''$.VTE_NOME''')?.toString(), 'NOT FOUND', ), style: FlutterFlowTheme.of(context).bodyLarge.override( @@ -286,11 +258,8 @@ class _VisitorSearchModalTemplateComponentWidgetState extends State 0 - ? () async { - await addVisitor(context); - - safeSetState(() {}); - } - : () async { - await sendVisitors(context); - }, + ? () async => await addVisitor(context).whenComplete(safeSetState(() {})) + : () async => await sendVisitors(context), text: MediaQuery.of(context).viewInsets.bottom > 0 ? FFLocalizations.of(context).getVariableText( enText: 'Add', @@ -357,23 +318,17 @@ class _VisitorSearchModalTemplateComponentWidgetState extends State sendVisitors(BuildContext context) async { - await widget.getVisitors?.call( - _model.visitors, - ); + await widget.getVisitors?.call(_model.visitors); log('() => docs: ${_model.docs}'); await widget.getDocs?.call(_model.docs); context.pop(); @@ -394,22 +347,16 @@ class _VisitorSearchModalTemplateComponentWidgetState extends State safeSetState(() { diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 44eca848..98a7c8a5 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -98,6 +98,45 @@ class PreferencesPageModel with ChangeNotifier { showAlertDialog(context, title, content, onConfirm); } + Future toggleIdentification(BuildContext context) async { + final String title = FFLocalizations.of(context).getVariableText( + ptText: 'Atualizar Identificador de Acesso', + enText: 'Update Access Identifier', + ); + final String content = FFLocalizations.of(context).getVariableText( + ptText: 'Tem certeza que deseja habilitar seu dispositivo para acesso?', + enText: 'Are you sure you want to enable your device for access?', + ); + onConfirm() async { + String content; + await PhpGroup.updateIDE.call().then((value) async { + if (value.jsonBody['error'] == false) { + notifyListeners(); + content = FFLocalizations.of(context).getVariableText( + ptText: 'Atualização do identificador de acesso realizada com sucesso', + enText: 'Access identifier updated successfully', + ); + SnackBarUtil.showSnackBar(context, content); + } else { + content = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao atualizar identificador de acesso', + enText: 'Error updating access identifier', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + } + }).catchError((e, s) { + content = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao atualizar identificador de acesso', + enText: 'Error updating access identifier', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + }).whenComplete(() => notifyListeners()); + context.pop(); + } + + showAlertDialog(context, title, content, onConfirm); + } + Future toggleAccess(BuildContext context) async { onChange(String key) async { await StorageHelper.instance.set(SecureStorageKey.accessPass.value, key, Storage.SecureStorage); diff --git a/lib/pages/preferences_settings_page/preferences_settings_widget.dart b/lib/pages/preferences_settings_page/preferences_settings_widget.dart index 88a978a5..1249f1d0 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_widget.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_widget.dart @@ -75,7 +75,7 @@ class _PreferencesPageWidgetState extends State { Expanded( flex: 2, child: ListView.builder( - itemCount: 7, // Assuming 7 items for simplicity + itemCount: 8, padding: const EdgeInsets.symmetric(horizontal: 20.0), physics: const AlwaysScrollableScrollPhysics(), itemBuilder: (BuildContext context, int index) { @@ -117,6 +117,15 @@ class _PreferencesPageWidgetState extends State { ); break; case 2: + icon = Icons.info; + onPressed = () => model.toggleIdentification(context); + isEnabled = false; + content = FFLocalizations.of(context).getVariableText( + ptText: 'Atualize suas informações de identificação de acesso.', + enText: 'Update your access identification information.', + ); + break; + case 3: icon = Icons.notifications; onPressed = () => model.toggleNotify(context); isEnabled = model.isNotify; @@ -125,7 +134,7 @@ class _PreferencesPageWidgetState extends State { enText: 'Enable to receive your access notification', ); break; - case 3: + case 4: icon = Icons.lock; onPressed = () => model.toggleAccess(context); isEnabled = model.isAccess; @@ -134,7 +143,7 @@ class _PreferencesPageWidgetState extends State { enText: 'Enable to enter an access credential for the QRCode', ); break; - case 4: + case 5: icon = Icons.lock_clock_sharp; onPressed = () => model.togglePanic(context); isEnabled = model.isPanic; @@ -143,7 +152,7 @@ class _PreferencesPageWidgetState extends State { enText: 'Enable to enter a panic credential for the QRCode', ); break; - case 5: + case 6: icon = Icons.landscape; onPressed = () { model.localUnlink(context); @@ -154,7 +163,7 @@ class _PreferencesPageWidgetState extends State { enText: 'Enable to unlink from the selected location', ); break; - case 6: + case 7: icon = Icons.delete; onPressed = () => model.deleteAccount(context); isEnabled = false; @@ -163,7 +172,7 @@ class _PreferencesPageWidgetState extends State { enText: 'Delete your account and all associated data permanently.', ); break; - case 7: + case 8: icon = Icons.logout; onPressed = () => model.logout(context); isEnabled = false;