diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 49d9cda7..a153be7c 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -22,7 +22,6 @@ import 'package:url_launcher/url_launcher.dart'; import '../shared/utils/log_util.dart'; Future openTermsOfUse(BuildContext context) async { - log('openTermsOfUse'); final Uri url = Uri.parse('https://freaccess.com.br/pp/'); if (!await launchUrl(url)) { throw Exception('Could not launch $url'); @@ -90,7 +89,6 @@ Future manageStatusColorAction( BuildContext context, { required String? visitStatusStr, }) async { - log('visitStatusStr: $visitStatusStr'); if (visitStatusStr == 'A') { return FlutterFlowTheme.of(context).success; } else if ((visitStatusStr == 'C') || @@ -322,41 +320,28 @@ Future toggleHomePage(BuildContext context) async { ); } -Future visitRequestComponentAction( - BuildContext context, { - required String? actionValue, - required String? refUUID, - required String? responseValue, - required String? vteUUID, -}) async { - ApiCallResponse? respondeSolicitacaoCall; +Future visitCancelAction(BuildContext context, + {required int? idDestino, + required int? idVisita, + required String? accessKey, + required String? email}) async { + ApiCallResponse? apiCallResponse; - respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call( + apiCallResponse = await PhpGroup.cancelaVisita.call( userUUID: FFAppState().userUUID, devUUID: FFAppState().devUUID, - cliUUID: FFAppState().cliUUID, - atividade: 'respondeSolicitacao', - referencia: refUUID, - tarefa: actionValue, - resposta: responseValue, - idVisitante: vteUUID, + cliID: FFAppState().cliUUID, + atividade: 'cancelaVisita', + idDestino: idDestino, + idVisita: idVisita, + AccessKey: accessKey, + UsuEmail: email, + DevDesc: '', ); - if (respondeSolicitacaoCall.statusCode == 200) { - log('jsonBody: ${respondeSolicitacaoCall.jsonBody}; actionValue: $actionValue; refUUID: $refUUID; responseValue: $responseValue; vteUUID: $vteUUID; status: ${respondeSolicitacaoCall.jsonBody['error']}'); - return !respondeSolicitacaoCall.jsonBody['error']; + if (apiCallResponse.statusCode == 200) { + return !apiCallResponse.jsonBody['error']; } else { - log('headers: ${respondeSolicitacaoCall.headers}'); - log('bodyText: ${respondeSolicitacaoCall.bodyText}'); - log('jsonBody: ${respondeSolicitacaoCall.jsonBody}'); - log('userUUID: ${FFAppState().userUUID}'); - log('devUUID: ${FFAppState().devUUID}'); - log('cliUUID: ${FFAppState().cliUUID}'); - log('atividade: respondeSolicitacao'); - log('referencia: $refUUID'); - log('tarefa: $actionValue'); - log('resposta: $responseValue'); - log('idVisitante: $vteUUID'); return false; } } @@ -402,7 +387,6 @@ Future checkLocals({ // Verificação rápida de erro para evitar processamento desnecessário. if (response.jsonBody['error']) { - log("checkLocals => Erro encontrado na resposta"); return false; } @@ -414,10 +398,8 @@ Future checkLocals({ // Log e retorno condicional baseado no resultado da busca. if (itemFound) { - log("checkLocals => Item encontrado com CLI_ID $uuid e CLU_STATUS A"); return true; } else { - log("checkLocals => Item não encontrado com CLI_ID $uuid e CLU_STATUS A"); // A chamada para showModalBottomSheet permanece, mas a atualização da UI é otimizada. await showModalBottomSheet( isScrollControlled: true, @@ -440,58 +422,50 @@ Future checkLocals({ } } +Future answersRequest(BuildContext context, String? ref, String? task, + String? response, String? id) async { + ApiCallResponse? respondeSolicitacaoCall; + + respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call( + userUUID: FFAppState().userUUID, + devUUID: FFAppState().devUUID, + cliUUID: FFAppState().cliUUID, + atividade: 'respondeSolicitacao', + referencia: ref, + tarefa: task, + resposta: response, + idVisitante: id, + ); + + if (respondeSolicitacaoCall.statusCode == 200) { + return !respondeSolicitacaoCall.jsonBody['error']; + } else { + return false; + } +} + Future changeStatusAction( BuildContext context, - String status, - String vawREF, - String msg, - String vteUUID, + int idDestino, + int idVisita, + String accessKey, + String email, ) async { - log('status: $status'); + Navigator.pop(context, true); - switch (status) { - case 'L': - Navigator.pop(context, true); - - bool? approveVisitRequest; - approveVisitRequest = await visitRequestComponentAction( - context, - actionValue: status, - refUUID: vawREF, - responseValue: msg, - vteUUID: vteUUID, - ); - if (!context.mounted) return; - if (approveVisitRequest == true) { - log('Aprovado'); - context.pop(); - } else { - log('Erro ao aprovar'); - context.pop(); - } - break; - case 'B': - Navigator.pop(context, true); - - bool? blockVisitRequest; - blockVisitRequest = await visitRequestComponentAction( - context, - actionValue: status, - refUUID: vawREF, - responseValue: msg, - vteUUID: vteUUID, - ); - if (!context.mounted) return; - if (blockVisitRequest == true) { - log('Bloqueado'); - return true; - } else { - log('Erro ao bloquear'); - return false; - } - break; - default: - break; + bool? blockVisitRequest; + blockVisitRequest = await visitCancelAction( + context, + accessKey: accessKey, + idDestino: idDestino, + idVisita: idVisita, + email: email, + ); + if (!context.mounted) return; + if (blockVisitRequest == true) { + return true; + } else { + return false; } } @@ -502,8 +476,6 @@ Uint8List assembleQRPacket(int direction, String identifier, String password) { String paddedBadge = identifier.padLeft(30, '0'); - log("Badge: $paddedBadge"); - for (var i = 0; i < paddedBadge.length; i += 2) { packet.add(int.parse(paddedBadge.substring(i, i + 2), radix: 16)); } @@ -545,8 +517,6 @@ Uint8List assembleQRPacket(int direction, String identifier, String password) { var bytes = packet.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join((' ')); - log("Pacote: $packet"); - log("Bytes: $bytes"); return Uint8List.fromList(packet); } @@ -582,7 +552,6 @@ Widget buildQrCode( required String pass, required int direction}) { try { - log("pass: $pass"); const Color backgroundColor = Colors.white; const Color foregroundColor = Colors.black; return QrImageView.withQr( @@ -784,3 +753,22 @@ Future accessQRCodeOptAction(BuildContext context) async { }, ); } + +enum status { active, unknown, canceled, finished, blocked, inactive } + +status? getStatus(dynamic data) { + switch (data) { + case 'A': + return status.active; + case 'F': + return status.finished; + case 'B': + return status.blocked; + case 'C': + return status.canceled; + case 'I': + return status.inactive; + default: + return status.unknown; + } +} diff --git a/lib/app_state.dart b/lib/app_state.dart index 115951d0..c3a91e95 100644 --- a/lib/app_state.dart +++ b/lib/app_state.dart @@ -20,7 +20,6 @@ class FFAppState extends ChangeNotifier { return await auth.canCheckBiometrics; } catch (e) { clearBiometricAuthentication(); - debugPrint('Error checking biometrics: $e'); return false; } } @@ -44,8 +43,6 @@ class FFAppState extends ChangeNotifier { // Salvar o estado de autenticação biométrica, se necessário } } catch (e) { - print(e); - debugPrint('Error authenticating: $e'); clearBiometricAuthentication(); return Future.error(e); } diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index d6009dae..1630cdd3 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -47,6 +47,53 @@ class PhpGroup { static ChangePass changePass = ChangePass(); static ChangePanic changePanic = ChangePanic(); static DeleteAccount deleteAccount = DeleteAccount(); + static CancelaVisita cancelaVisita = CancelaVisita(); +} + +class CancelaVisita { + Future call({ + String? devUUID = '', + String? userUUID = '', + String? cliID = '', + String? atividade = '', + int? idDestino, + int? idVisita, + String? AccessKey = '', + String? UsuEmail = '', + String? DevDesc = '', + }) async { + final baseUrl = PhpGroup.getBaseUrl(); + + return ApiManager.instance.makeApiCall( + callName: 'cancelaVisita', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + 'atividade': atividade, + 'cliID': cliID, + 'idVisita': idVisita, + 'AccessKey': AccessKey, + 'UsuEmail': UsuEmail, + 'DevDesc': DevDesc, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + alwaysAllowBody: false, + ); + } + + bool? error(dynamic response) => castToType(getJsonField( + response, + r'''$.error''', + )); } class DeleteAccount { @@ -2504,7 +2551,6 @@ String _serializeList(List? list) { return json.encode(list, toEncodable: _toEncodable); } catch (_) { if (kDebugMode) { - log("List serialization failed. Returning empty list."); } return '[]'; } @@ -2516,7 +2562,6 @@ String _serializeJson(dynamic jsonVar, [bool isList = false]) { return json.encode(jsonVar, toEncodable: _toEncodable); } catch (_) { if (kDebugMode) { - log("Json serialization failed. Returning empty json."); } return isList ? '[]' : '{}'; } diff --git a/lib/backend/push_notification/pushNotificationService.dart b/lib/backend/push_notification/pushNotificationService.dart index 411682e9..98f023ec 100644 --- a/lib/backend/push_notification/pushNotificationService.dart +++ b/lib/backend/push_notification/pushNotificationService.dart @@ -59,10 +59,7 @@ class PushNotificationService { sound: true, ); if (settings.authorizationStatus == AuthorizationStatus.authorized) { - log('User granted permission'); - } else { - log('User declined or has not accepted permission'); - } + } else {} } Map validJsonFromString(String? jsonString) { @@ -101,7 +98,6 @@ class PushNotificationService { // Passo 4: Decodificar o JSON corrigido return jsonDecode(correctedJson); } catch (e) { - log('Error decoding JSON: $e'); return {}; } } @@ -126,19 +122,14 @@ class PushNotificationService { _flutterLocalNotificationsPlugin.initialize( initializationSettings, onDidReceiveNotificationResponse: (NotificationResponse response) async { - log('Response payload:${response.payload}'); if (response.payload != null) { try { Map message = validJsonFromString(response.payload!); - log('Notification payload: $message'); var data = _notificationDetails; // Assuming getOnMessage() now returns the latest RemoteMessage - log('Extra: ${data.value}'); _handleNotificationClick(message, extra: data.value); - } catch (e) { - log('Error decoding notification payload: $e'); - } + } catch (e) {} } }, ); @@ -174,8 +165,6 @@ class PushNotificationService { void _listenToForegroundMessages(BuildContext context) { FirebaseMessaging.onMessage.listen((RemoteMessage message) { - log('Got a message whilst in the foreground!'); - log('Message data: ${message.toMap()}'); _onMessage.add(message); _notificationDetails.add(message.toMap()['notification']); _showNotification(message); @@ -188,32 +177,25 @@ class PushNotificationService { void _listenToNotificationClicks(BuildContext context) { FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { - log('Notification clicked!'); - _onMessage.add(message); - log('Extra: ${message.notification?.body}'); NotificationHandler().handleMessage(message.data, context); }); } void configureTokenRefresh() { - _firebaseMessaging.onTokenRefresh.listen(_handleTokenUpdate).onError((err) { - log("Error refreshing token: $err"); - }); + _firebaseMessaging.onTokenRefresh + .listen(_handleTokenUpdate) + .onError((err) {}); } Future _updateToken(String token) async { FFAppState().token = token; final ApiCallResponse? response = await _updateTokenOnServer(token); if (_isTokenUpdateSuccessful(response)) { - log('Token updated successfully on server. Token: $token'); - } else { - log('Error updating token on server'); - } + } else {} } Future _handleTokenUpdate(String newToken) async { - log('Token refreshed: $newToken'); await _updateToken(newToken); } @@ -226,11 +208,8 @@ class PushNotificationService { final String? deviceToken = await _firebaseMessaging.getToken(); if (deviceToken != null) { - log('Push Messaging token: $deviceToken'); await _updateToken(deviceToken); - } else { - log('Failed to get Firebase Messaging token'); - } + } else {} } Future _requestNotificationPermission() async { @@ -283,7 +262,6 @@ class PushNotificationService { var generalNotificationDetails = NotificationDetails(android: androidDetails, iOS: iOSDetails); - log('Showing notification: ${message.messageId.hashCode}'); await _flutterLocalNotificationsPlugin.show( // DateTime.now().millisecondsSinceEpoch % (1 << 31), math.Random().nextInt(1 << 30), @@ -299,32 +277,24 @@ class PushNotificationService { switch (payload.isNotEmpty) { case true: // Print the 'data' property - log('Notification payload: $payload'); - log('Extra: $extra'); // Handle the message data as needed NotificationHandler().handleMessage(payload, _context.value, extra: extra.isEmpty ? {} : extra); // Access the 'data' property of 'RemoteMessage' case false: - log('Notification payload is empty'); // Handle the message notification as needed break; } } static Future _firebaseMessagingBackgroundHandler( - RemoteMessage message) async { - log('Handling a background message: ${message.messageId}'); - } + RemoteMessage message) async {} } class NotificationHandler { void handleMessage(Map message, BuildContext context, {Map extra = const {}}) { - log('Notification Received!'); - message.forEach((key, value) { - log('$key: $value'); - }); + message.forEach((key, value) {}); switch (message['click_action']) { case 'visit_request': @@ -340,10 +310,8 @@ class NotificationHandler { _showMessageNotificationDialog(message, context, extra); break; case 'enroll_cond': - log('enroll_cond'); break; default: - log('Notification type not recognized'); } } @@ -363,10 +331,6 @@ class NotificationHandler { void _showAcessNotificationModal( Map message, BuildContext context) { - log('Showing access notification dialog'); - log('USR_TIPO: ${message['USR_TIPO']}'); - log('USR_ID: ${message['USR_ID']}'); - log('USR_DOCUMENTO: ${message['USR_DOCUMENTO']}'); showDialog( context: context, builder: (BuildContext context) { @@ -392,8 +356,6 @@ class NotificationHandler { void _showMessageNotificationDialog(Map message, BuildContext context, Map extra) { - log('Showing message notification dialog'); - log('Notification "message": $message'); showDialog( useSafeArea: true, barrierDismissible: true, @@ -432,7 +394,6 @@ class NotificationHandler { void _showVisitRequestDialog( Map message, BuildContext context) { - log('Showing visit request notification dialog'); showDialog( context: context, barrierDismissible: true, @@ -442,13 +403,6 @@ class NotificationHandler { return Dialog( backgroundColor: Colors.transparent, child: VisitRequestTemplateComponentWidget( - vteName: message['mensagem'] ?? 'Unknown', - vteReason: message['motivo'] ?? 'Unknown', - vteMsg: message['mensagem'] ?? 'Unknown', - vteDocument: message['documento'] ?? '', - vteUUID: message['idVisitante'].toString(), - vawRef: message['referencia'].toString(), - vawStatus: 'S', buttons: [ FlutterFlowIconButton( icon: const Icon(Icons.done), @@ -504,10 +458,10 @@ class NotificationHandler { ptText: 'Sim', ), onPressed: () async { - await changeStatusAction.call( + await answersRequest.call( context, - 'L', message['referencia'].toString(), + 'L', 'Mensagem', message['idVisitante'].toString(), ); @@ -588,10 +542,10 @@ class NotificationHandler { ptText: 'Sim', ), onPressed: () async { - await changeStatusAction.call( + await answersRequest.call( context, - 'B', message['referencia'].toString(), + 'B', 'Mensagem', message['idVisitante'].toString(), ); @@ -645,7 +599,7 @@ class NotificationHandler { ): FlutterFlowTheme.of(context).warning, }, ], - changeStatusAction: changeStatusAction, + // changeStatusAction: answersRequest, ), ); }, diff --git a/lib/backend/push_notification/tapNotifcationActivity.dart b/lib/backend/push_notification/tapNotifcationActivity.dart index 1ee22050..8b137891 100644 --- a/lib/backend/push_notification/tapNotifcationActivity.dart +++ b/lib/backend/push_notification/tapNotifcationActivity.dart @@ -1,90 +1 @@ -// import 'package:f_r_e_hub/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart'; -// import 'package:firebase_messaging/firebase_messaging.dart'; -// import 'package:flutter/material.dart'; -// import 'package:rxdart/rxdart.dart'; - - - -// class NotificationHandler { -// // Criar BehaviorSubjects para mensagens em primeiro plano e mensagens que abriram o app -// final BehaviorSubject _onMessage = -// BehaviorSubject(); -// final BehaviorSubject _onMessageOpenedApp = -// BehaviorSubject(); - -// // Inicializar listeners no construtor -// NotificationHandler() { -// initializeListeners(); -// } - -// void initializeListeners() async { -// // Listener para mensagens em primeiro plano -// // FirebaseMessaging.onMessage.listen((message) { -// // _onMessage.add(message); // Adicionar mensagem ao stream -// // }); - -// RemoteMessage? initialMessage = -// await FirebaseMessaging.instance.getInitialMessage(); - -// if (initialMessage != null) _onMessage.add(initialMessage); - -// // Listener para mensagens que abriram o app -// FirebaseMessaging.onMessageOpenedApp.listen((message) { -// _onMessageOpenedApp.add(message); // Adicionar mensagem ao stream -// }); -// } - -// void openedAppVisitRequestNotification( -// RemoteMessage message, BuildContext context) { -// log('openedAppVisitRequestNotification'); -// showDialog( -// context: context, -// builder: (BuildContext context) { -// return Dialog( -// backgroundColor: -// Colors.transparent, // Faz o fundo do Dialog ser transparente -// child: VisitRequestTemplateComponentWidget( -// name: message.data['nome'] ?? 'blabla', -// reason: message.data['motivo'] ?? 'blabla', -// message: message.data['mensagem'] ?? 'blabla', -// document: message.data['document']), -// ); -// }); -// } - -// // Método para tratar mensagens recebidas -// void handleMessage(RemoteMessage message, BuildContext context) { -// log('Notification Received!'); -// message.data.forEach((key, value) { -// log('$key: $value'); -// }); - -// switch (message.data['type']) { -// case 'visit_request': -// openedAppVisitRequestNotification(message, context); -// break; -// case '': -// break; -// default: -// log('Notification type not recognized'); -// } -// } - -// // Ouvir streams -// void listenToNotifications(BuildContext context) { -// _onMessage.listen((message) { -// handleMessage(message, context); -// }); - -// _onMessageOpenedApp.listen((message) { -// handleMessage(message, context); -// }); -// } - -// // Dispor streams -// void dispose() { -// _onMessage.close(); -// _onMessageOpenedApp.close(); -// } -// } diff --git a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart index b1ece369..c2bc0753 100644 --- a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart @@ -10,7 +10,6 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:provider/provider.dart'; - class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget { const BottomArrowLinkedLocalsComponentWidget({super.key}); @@ -100,9 +99,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState color: FlutterFlowTheme.of(context).primary, size: 24.0, ), - onPressed: () { - print('IconButton pressed ...'); - }, + onPressed: () {}, ), ), Expanded( @@ -180,8 +177,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState width: 50.0, height: double.infinity, decoration: const BoxDecoration(), - alignment: - const AlignmentDirectional(0.0, 0.0), + alignment: const AlignmentDirectional( + 0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: @@ -232,14 +229,15 @@ class _BottomArrowLinkedLocalsComponentWidgetState width: double.infinity, height: double.infinity, fit: BoxFit.fill, - alignment: - const Alignment(0.0, 0.0), + alignment: const Alignment( + 0.0, 0.0), ), ), ), Padding( - padding: const EdgeInsetsDirectional - .fromSTEB( + padding: + const EdgeInsetsDirectional + .fromSTEB( 0.0, 10.0, 0.0, 0.0), child: Text( getJsonField( @@ -290,4 +288,4 @@ class _BottomArrowLinkedLocalsComponentWidgetState ), ); } -} \ No newline at end of file +} diff --git a/lib/components/organism_components/message_well_component/message_well_component_widget.dart b/lib/components/organism_components/message_well_component/message_well_component_widget.dart index fb4632a9..f56b8c36 100644 --- a/lib/components/organism_components/message_well_component/message_well_component_widget.dart +++ b/lib/components/organism_components/message_well_component/message_well_component_widget.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'dart:collection'; import 'dart:developer'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -213,7 +212,7 @@ class _MessageWellComponentWidgetState children: [ Icon( message['MSG_DESTINO_TP'] == 'T' - ? EvaIcons.globe + ? Icons.language : message['MSG_DESTINO_TP'] == 'P' ? Icons.person : Icons.home, @@ -374,12 +373,8 @@ class MessageWellNotifier extends StateNotifier { // .toList(); // Provider.of(context, listen: false).setCounter(int.parse(response.jsonBody['total_pages'])); // totalPageNumber = int.parse(response.jsonBody['total_pages']); - } else { - log('Error fetching messages: ${response.statusCode}'); - } - } else { - log('No more messages to fetch ...'); - } + } else {} + } else {} } List getMessages() { diff --git a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart index d4df4084..9abfbefe 100644 --- a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart +++ b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart @@ -40,8 +40,6 @@ class ScheduleVisitDetailModel String convertDateFormat(String dateStr) { try { - log('Received date string: $dateStr'); - // Formato original DateFormat originalFormat = DateFormat('d/M/y H:mm:ss'); // Novo formato @@ -50,7 +48,6 @@ class ScheduleVisitDetailModel // Validate the input string format if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$') .hasMatch(dateStr)) { - log('Invalid date format: $dateStr'); return 'Invalid date format'; } @@ -59,11 +56,9 @@ class ScheduleVisitDetailModel // Converte DateTime para a nova string formatada String formattedDate = newFormat.format(dateTime); - log('Formatted date: $formattedDate'); return formattedDate; } catch (e) { // Handle the exception by returning an error message or a default value - log('Error parsing date: $e'); return 'Invalid date format'; } } diff --git a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart index fd8b4c48..1b503c1e 100644 --- a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart +++ b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart @@ -74,14 +74,6 @@ class _CardItemTemplateComponentWidgetState @override Widget build(BuildContext context) { context.watch(); - log('------------------------------'); - log('labelsHashMap: ${widget.labelsHashMap}'); - log('statusHashMap: ${widget.statusHashMap}'); - log('imageHashMap: ${widget.imageHashMap}'); - log('onTapCardItemAction: ${widget.onTapCardItemAction}'); - log('labelsLinkedHashMap: $labelsLinkedHashMap'); - log('statusLinkedHashMap: $statusLinkedHashMap'); - log('------------------------------'); return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, diff --git a/lib/components/templates_components/details_component/details_component_action.dart b/lib/components/templates_components/details_component/details_component_action.dart index bf7df5fe..fafb0916 100644 --- a/lib/components/templates_components/details_component/details_component_action.dart +++ b/lib/components/templates_components/details_component/details_component_action.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; +import 'package:hub/actions/actions.dart'; import 'package:hub/app_state.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; @@ -12,45 +13,12 @@ import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:rxdart/rxdart.dart'; import 'package:share_plus/share_plus.dart'; -enum status { active, unknown, canceled, finished, blocked, inactive } - -status? getStatus(dynamic data) { - debugPrint('getStatus: $data'); - switch (data) { - case 'A': - return status.active; - case 'F': - return status.finished; - case 'B': - return status.blocked; - case 'C': - return status.canceled; - case 'I': - return status.inactive; - default: - return status.unknown; - } -} - Widget buildDetails( dynamic visitaWrapItem, BuildContext context, - Future Function(BuildContext, String, String, String, String)? + Future Function(BuildContext, int, int, String, String)? changeStatusAction) { return VisitRequestTemplateComponentWidget( - vteName: 'Lorem Ipsus', - vteReason: 'Lorem Ipsus', - vawDate: 'Lorem Ipsus', - vawStatus: 'Lorem Ipsus', - vteMsg: 'Lorem Ipsus', - vteUUID: 'Lorem Ipsus', - cliUUID: FFAppState().cliUUID, - msgUUID: 'Lorem Ipsus', - vawDestino: 'Lorem Ipsus', - vawUUID: 'Lorem Ipsus', - vawName: 'Lorem Ipsus', - vawRef: 'Lorem Ipsus', - changeStatusAction: changeStatusAction, buttons: [ if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active) // REJECT ACTION @@ -109,13 +77,14 @@ Widget buildDetails( await changeStatusAction ?.call( context, - 'B', - visitaWrapItem['VAW_REF'] ?? '', - 'Mensagem', - visitaWrapItem['VTE_ID'] ?? '', + int.parse(visitaWrapItem['VAW_DESTINO']), + int.parse(visitaWrapItem['VAW_ID']), + visitaWrapItem['VAW_CHAVE'] ?? '', + visitaWrapItem['VTE_DOCUMENTO'] ?? '', ) .then((value) { Navigator.pop(context); + Navigator.pop(context); if (value == false) { showSnackbar( context, @@ -136,8 +105,6 @@ Widget buildDetails( ); } }).catchError((err, stack) { - debugPrint('Error: $err'); - debugPrint('Stack: $stack'); showSnackbar( context, FFLocalizations.of(context).getVariableText( diff --git a/lib/components/templates_components/details_component/details_component_widget.dart b/lib/components/templates_components/details_component/details_component_widget.dart index f6576993..bc8e40f1 100644 --- a/lib/components/templates_components/details_component/details_component_widget.dart +++ b/lib/components/templates_components/details_component/details_component_widget.dart @@ -14,20 +14,6 @@ import 'package:provider/provider.dart'; class VisitRequestTemplateComponentWidget extends StatefulWidget { const VisitRequestTemplateComponentWidget({ Key? key, - required this.vteName, - required this.vteReason, - required this.vteMsg, - this.vteDocument, - this.cliUUID, - this.vteUUID, - this.vawName, - this.msgUUID, - this.vawRef, - this.vawUUID, - this.vawDestino, - required this.vawStatus, - this.vawDate, - this.changeStatusAction, required this.labelsHashMap, required this.statusHashMap, required this.imageHashMap, @@ -41,27 +27,12 @@ class VisitRequestTemplateComponentWidget extends StatefulWidget { final Future Function()? onTapCardItemAction; final List buttons; - final String? vteName; - final String? vteReason; - final String? vteMsg; - final String? vteDocument; - final String? cliUUID; - final String? vteUUID; - final String? vawName; - final String? msgUUID; - final String? vawRef; - final String? vawUUID; - final String? vawDestino; - final String? vawStatus; - final String? vawDate; - - final Future Function( - BuildContext context, - String status, - String vawREF, - String msg, - String vteUUID, - )? changeStatusAction; + // final Future Function( + // BuildContext context, + // int idDestino, + // int idVisita, + // String AccessKey, + // )? changeStatusAction; @override State createState() => @@ -90,24 +61,6 @@ class _VisitRequestTemplateComponentWidgetState void initState() { super.initState(); _model = createModel(context, () => VisitRequestTemplateComponentModel()); - - _model.textController1 ??= TextEditingController(text: widget.vteName); - _model.textFieldFocusNode1 ??= FocusNode(); - - _model.textController2 ??= TextEditingController(text: widget.vteReason); - _model.textFieldFocusNode2 ??= FocusNode(); - - _model.textController3 ??= TextEditingController(text: widget.vteMsg); - _model.textFieldFocusNode3 ??= FocusNode(); - - _model.textController4 ??= TextEditingController(text: widget.vawDate); - _model.textFieldFocusNode4 ??= FocusNode(); - - _model.textController5 ??= TextEditingController(); - _model.textFieldFocusNode5 ??= FocusNode(); - - _model.textControllerStatus ??= - TextEditingController(text: widget.vawStatus); _model.textFieldFocusNodeStatus ??= FocusNode(); } @@ -120,21 +73,21 @@ class _VisitRequestTemplateComponentWidgetState @override Widget build(BuildContext context) { - log('VAW_STATUS: ${statusLinkedHashMap}'); context.watch(); - bool isLoaded = false; - final pending = FFLocalizations.of(context).getVariableText( - enText: 'Pending', - ptText: 'Pendente', - ); - final active = FFLocalizations.of(context).getVariableText( - enText: 'Ativo', - ptText: 'Ativo', - ); - final canceled = FFLocalizations.of(context).getVariableText( - enText: 'Canceled', - ptText: 'Cancelado', - ); + + // bool isLoaded = false; + // final pending = FFLocalizations.of(context).getVariableText( + // enText: 'Pending', + // ptText: 'Pendente', + // ); + // final active = FFLocalizations.of(context).getVariableText( + // enText: 'Ativo', + // ptText: 'Ativo', + // ); + // final canceled = FFLocalizations.of(context).getVariableText( + // enText: 'Canceled', + // ptText: 'Cancelado', + // ); return LayoutBuilder( builder: (context, constraints) { diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart index 192f8fc3..3c65d365 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart @@ -45,7 +45,6 @@ class RegisiterVistorTemplateComponentModel documento: document, ); - log('${response.jsonBody}'); if (response.jsonBody['visitante']['VTE_ID'] != '0' && response.jsonBody['error'] != 'false') { return true; diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart index f1cc977d..adaec865 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart @@ -69,7 +69,6 @@ class _RegisiterVistorTemplateComponentWidgetState } void _onTextChanged() { - log('changed'); setState(() {}); } @@ -94,7 +93,6 @@ class _RegisiterVistorTemplateComponentWidgetState return false; } - log("Visitante Já Cadastrado $_isVisitorRegistered"); if (_isVisitorRegistered) { return false; } diff --git a/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart b/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart index 949290cb..647a9541 100644 --- a/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart +++ b/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart @@ -63,7 +63,6 @@ List? findVisitorById(List? jsonList, String? id) { ); return foundItem != null ? [foundItem] : null; } catch (e) { - log("Error searching item: $e"); return null; } } @@ -874,7 +873,6 @@ class _ViewVisitDetailWidgetState extends State { size: 24.0, ), onPressed: () { - log('IconButton pressed ...'); // Implement share functionality here Share.share( 'Visita agendada para ${widget.visitStartDate} com término previsto para ${widget.visitEndDate}. Motivo: ${widget.visitReasonStr}. Nível de acesso: ${widget.visitLevelStr}. Observações: ${widget.visitObsStr}.', diff --git a/lib/custom_code/actions/get_dev_u_u_i_d.dart b/lib/custom_code/actions/get_dev_u_u_i_d.dart index e5df025d..3e70fa5d 100644 --- a/lib/custom_code/actions/get_dev_u_u_i_d.dart +++ b/lib/custom_code/actions/get_dev_u_u_i_d.dart @@ -1,5 +1,3 @@ - - import '/backend/schema/structs/index.dart'; import 'dart:developer'; import '/backend/schema/enums/enums.dart'; @@ -12,29 +10,14 @@ import 'package:flutter/material.dart'; import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; - - - Future getDevUUID() async { var deviceInfo = DeviceInfoPlugin(); if (Platform.isIOS) { // import 'dart:io' var iosDeviceInfo = await deviceInfo.iosInfo; - log('DeviceInfoPlugin => iosDeviceInfo.utsname.machine: ${iosDeviceInfo.utsname.machine}'); // e.g. "iPod7,1" - log('DeviceInfoPlugin => iosDeviceInfo.systemName: ${iosDeviceInfo.systemName}'); // e.g. "iOS" - log('DeviceInfoPlugin => iosDeviceInfo.systemVersion: ${iosDeviceInfo.systemVersion}'); // e.g. "13.3" - log('DeviceInfoPlugin => iosDeviceInfo.model: ${iosDeviceInfo.model}'); // e.g. "iPhone" - log('DeviceInfoPlugin => iosDeviceInfo.localizedModel: ${iosDeviceInfo.localizedModel}'); // e.g. "iPhone" - log('DeviceInfoPlugin => iosDeviceInfo.identifierForVendor: ${iosDeviceInfo.identifierForVendor}'); // e.g. "A8E9F7C8-4D1F-4D97-9C3B-3A3D0F0F3E9E" return iosDeviceInfo.identifierForVendor; // unique ID on iOS } else if (Platform.isAndroid) { var androidDeviceInfo = await deviceInfo.androidInfo; - // log('Running on ${androidDeviceInfo.androidId}'); // e.g. "A8E9F7C8-4D1F-4D97-9C3B-3A3D0F0F3E9E" - log('DeviceInfoPLugin => androidDeviceInfo.model: ${androidDeviceInfo.model}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.manufacturer: ${androidDeviceInfo.manufacturer}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.product: ${androidDeviceInfo.product}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.device: ${androidDeviceInfo.device}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.id: ${androidDeviceInfo.id}'); // e.g. "iPhone" return androidDeviceInfo.id; // unique ID on Android } } @@ -44,21 +27,9 @@ Future getSerialNumber() async { if (Platform.isIOS) { // import 'dart:io' var iosDeviceInfo = await deviceInfo.iosInfo; - log('DeviceInfoPlugin => iosDeviceInfo.utsname.machine: ${iosDeviceInfo.utsname.machine}'); // e.g. "iPod7,1" - log('DeviceInfoPlugin => iosDeviceInfo.systemName: ${iosDeviceInfo.systemName}'); // e.g. "iOS" - log('DeviceInfoPlugin => iosDeviceInfo.systemVersion: ${iosDeviceInfo.systemVersion}'); // e.g. "13.3" - log('DeviceInfoPlugin => iosDeviceInfo.model: ${iosDeviceInfo.model}'); // e.g. "iPhone" - log('DeviceInfoPlugin => iosDeviceInfo.localizedModel: ${iosDeviceInfo.localizedModel}'); // e.g. "iPhone" - log('DeviceInfoPlugin => iosDeviceInfo.identifierForVendor: ${iosDeviceInfo.identifierForVendor}'); // e.g. "A8E9F7C8-4D1F-4D97-9C3B-3A3D0F0F3E9E" return iosDeviceInfo.identifierForVendor; // unique ID on iOS } else if (Platform.isAndroid) { var androidDeviceInfo = await deviceInfo.androidInfo; - // log('Running on ${androidDeviceInfo.androidId}'); // e.g. "A8E9F7C8-4D1F-4D97-9C3B-3A3D0F0F3E9E" - log('DeviceInfoPLugin => androidDeviceInfo.model: ${androidDeviceInfo.model}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.manufacturer: ${androidDeviceInfo.manufacturer}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.product: ${androidDeviceInfo.product}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.device: ${androidDeviceInfo.device}'); // e.g. "iPhone" - log('DeviceInfoPLugin => androidDeviceInfo.id: ${androidDeviceInfo.id}'); // e.g. "iPhone" return androidDeviceInfo.serialNumber; // unique ID on Android + } } -} \ No newline at end of file diff --git a/lib/custom_code/widgets/image_cropper.dart b/lib/custom_code/widgets/image_cropper.dart index 90704f46..9b79b434 100644 --- a/lib/custom_code/widgets/image_cropper.dart +++ b/lib/custom_code/widgets/image_cropper.dart @@ -60,7 +60,6 @@ // final path = _getStoragePath(_firebasePathPrefix(), // widget.imageFile!.name!, false, 0); // uploadData(path, image).then((value) { -// log('image cropped'); // widget.callBackAction!.call(value!); // loading = false; // }); @@ -95,7 +94,6 @@ // setState(() { // loading = true; // }); -// log('Button pressed ...'); // _crop_controller.crop(); // //widget.loading = true; diff --git a/lib/flutter_flow/flutter_flow_util.dart b/lib/flutter_flow/flutter_flow_util.dart index b2c3e3fb..78192536 100644 --- a/lib/flutter_flow/flutter_flow_util.dart +++ b/lib/flutter_flow/flutter_flow_util.dart @@ -6,6 +6,8 @@ import 'package:flutter/services.dart'; import 'package:collection/collection.dart'; import 'package:from_css_color/from_css_color.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; import 'dart:math' show pow, pi, sin; import 'package:intl/intl.dart'; import 'package:json_path/json_path.dart'; @@ -547,6 +549,69 @@ void showSnackbar( ); } +void showAlertDialog( + BuildContext context, String title, String content, Future action) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + title: Text(title), + content: Text(content), + actions: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + FFButtonWidget( + onPressed: () => Navigator.pop(context), + options: FFButtonOptions( + width: MediaQuery.of(context).size.width * 0.3, + height: MediaQuery.of(context).size.height * 0.05, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + text: FFLocalizations.of(context).getVariableText( + enText: 'No', + ptText: 'Não', + ), + ), + FFButtonWidget( + onPressed: () async { + await action; + }, + options: FFButtonOptions( + width: MediaQuery.of(context).size.width * 0.3, + height: MediaQuery.of(context).size.height * 0.05, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + text: FFLocalizations.of(context).getVariableText( + enText: 'Yes', + ptText: 'Sim', + ), + ), + ], + ), + ], + ); + }); +} + extension FFStringExt on String { String maybeHandleOverflow({int? maxChars, String replacement = ''}) => maxChars != null && length > maxChars diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index 86f9ca21..68bfc993 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -76,19 +76,18 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter( FFRoute( name: 'homePage', path: '/homePage', - builder: (context, params) => params.isEmpty - ? const HomePageWidget() - : const HomePageWidget(), + builder: (context, params) => + params.isEmpty ? const HomePageWidget() : const HomePageWidget(), ), + // FFRoute( + // name: 'visitHistoryPage', + // path: '/visitHistoryPage', + // builder: (context, params) => const VisitHistoryPageWidget(), + // ), FFRoute( - name: 'visitHistoryPage', - path: '/visitHistoryPage', - builder: (context, params) => const VisitHistoryPageWidget(), - ), - FFRoute( - name: 'messageHistoryPage', - path: '/messageHistoryPage', - builder: (context, params) => const MessageHistoryPageWidget()), + name: 'messageHistoryPage', + path: '/messageHistoryPage', + builder: (context, params) => const MessageHistoryPageWidget()), FFRoute( name: 'registerVisitorPage', path: '/registerVisitorPage', @@ -99,7 +98,7 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter( path: '/scheduleCompleteVisitPage', builder: (context, params) => ScheduleCompleteVisitPageWidget( // get current datatime picker dd/mm/aaaa hh:mm:ss - // visitStartDateStr: DateTime.now().toString(), + // visitStartDateStr: DateTime.now().toString(), // post 1 day // visitEndDateStr: DateTime.now().add(const Duration(days: 1)).toString(), visitorStrList: params.getParam( @@ -148,9 +147,12 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter( path: '/fastPassPage', builder: (context, params) => /*const*/ FastPassPageWidget(), ), - FFRoute(name: 'preferencesSettings', path: '/preferencesSettings', builder: (context, params) => const PreferencesPageWidget( - key: Key('preferencesSettings'), - )), + FFRoute( + name: 'preferencesSettings', + path: '/preferencesSettings', + builder: (context, params) => const PreferencesPageWidget( + key: Key('preferencesSettings'), + )), FFRoute( name: 'peopleOnThePropertyPage', path: '/peopleOnThePropertyPage', @@ -397,4 +399,4 @@ extension GoRouterLocationExtension on GoRouter { : routerDelegate.currentConfiguration; return matchList.uri.toString(); } -} \ No newline at end of file +} diff --git a/lib/flutter_flow/nav/serialization_util.dart b/lib/flutter_flow/nav/serialization_util.dart index 887c8eec..349feee6 100644 --- a/lib/flutter_flow/nav/serialization_util.dart +++ b/lib/flutter_flow/nav/serialization_util.dart @@ -10,7 +10,6 @@ import '../../flutter_flow/lat_lng.dart'; import '../../flutter_flow/place.dart'; import '../../flutter_flow/uploaded_file.dart'; - /// SERIALIZATION HELPERS String dateTimeRangeToString(DateTimeRange dateTimeRange) { @@ -85,7 +84,6 @@ String? serializeParam( } return data; } catch (e) { - log('Error serializing parameter: $e'); return null; } } @@ -226,7 +224,6 @@ dynamic deserializeParam( return null; } } catch (e) { - log('Error deserializing parameter: $e'); return null; } -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index 642f9e0b..61119468 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -30,7 +30,6 @@ void main() async { Future initializeApp() async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError; - await FlutterFlowTheme.initialize(); await FFLocalizations.initialize(); final appState = FFAppState(); diff --git a/lib/pages/acess_history_page/acess_history_page_widget.dart b/lib/pages/acess_history_page/acess_history_page_widget.dart index 58976eb6..48a4ae87 100644 --- a/lib/pages/acess_history_page/acess_history_page_widget.dart +++ b/lib/pages/acess_history_page/acess_history_page_widget.dart @@ -19,9 +19,6 @@ import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/pages/acess_history_page/acess_history_page_model.dart'; import 'package:rxdart/rxdart.dart'; - - - @immutable class AcessHistoryPageWidget extends StatefulWidget { late Map opt = { @@ -58,16 +55,13 @@ class _AcessHistoryPageWidgetState extends State { _AcessHistoryPageWidgetState(Map opt) : selectedTypeSubject = BehaviorSubject.seeded(opt) { - selectedTypeSubject.listen((value) { - log("selectedTypeSubject changed: $value"); - }); + selectedTypeSubject.listen((value) {}); } @override void initState() { super.initState(); _model = createModel(context, () => AcessHistoryPageModel()); - log("initState called in _AcessHistoryPageWidgetState"); } @override @@ -134,7 +128,6 @@ class _AcessHistoryPageWidgetState extends State { } Widget _appBarFilterButtonAtomWidget(BuildContext context) { - log('selectedTypeSubject: ${selectedTypeSubject.value}'); return Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -156,7 +149,6 @@ class _AcessHistoryPageWidgetState extends State { ); if (selectedFilter != null) { - log('Selected Filter: $selectedFilter'); _updateAccessHistoryAction(selectedFilter); } }, @@ -178,14 +170,12 @@ class _AcessHistoryPageWidgetState extends State { }); if (needsUpdate) { selectedTypeSubject.add(updatedType); - log("updateAccessHistory called with newType: $newType"); safeSetState(() {}); } } } Stream fetchAccessHistoryService(String selectedType) { - log('Calling API with type: $selectedType'); switch (selectedType) { case 'E': return _model.accessHistory( @@ -247,14 +237,9 @@ class _AcessHistoryPageWidgetState extends State { Future> fetchCardListViewService( Map select) async { - log('Fetching access history'); final response = await fetchAccessHistoryService(select['personType']!).first; - log('Response: ${response.jsonBody}'); final List accessHistory = response.jsonBody['acessos'] ?? []; - log('Access History Before Filtering: $accessHistory'); - log( - 'Filtering for: Person Type - ${select['personType']}, Access Type - ${select['accessType']}, Search - ${select['search']}'); return accessHistory.where((item) { final personTypeMatches = select['personType'] == '.*' || @@ -266,20 +251,15 @@ class _AcessHistoryPageWidgetState extends State { .toString() .toLowerCase() .contains(select['search']!.toLowerCase()); - log('NOMES: ${item["PES_NOME"].toString().toLowerCase()}'); return personTypeMatches && accessTypeMatches && searchMatches; }).toList(); } Widget _cardListViewOrganismWidget(Map selected) { - log( - 'Selected types in Card: ${selected['personType']}, ${selected['accessType']}'); - log('_buildAccessHistoryList called'); return FutureBuilder>( future: fetchCardListViewService(selected), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { - log('Waiting for data'); return Center( child: SizedBox( width: 50.0, @@ -294,15 +274,12 @@ class _AcessHistoryPageWidgetState extends State { return Text('Error: ${snapshot.error}'); } else { final accessHistory = snapshot.data!; - log('Access History: $accessHistory'); return ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: accessHistory.length, itemBuilder: (context, index) { final accessHistoryItem = accessHistory[index]; - log( - 'Access History Item: ${accessHistoryItem['PES_TIPO']}'); return _accessHistoryCardMoleculeWidget( context, accessHistoryItem); }, @@ -314,7 +291,6 @@ class _AcessHistoryPageWidgetState extends State { Widget _accessHistoryCardMoleculeWidget( BuildContext context, dynamic accessHistoryItem) { - log('Access History Item: $accessHistoryItem'); return CardItemTemplateComponentWidget( imageHashMap: Map.from({ 'key': accessHistoryItem['PES_ID'] ?? '', @@ -327,230 +303,53 @@ class _AcessHistoryPageWidgetState extends State { }), statusHashMap: [ accessHistoryItem['PES_TIPO'] == 'O' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Morador', - enText: 'Resident', - ): FlutterFlowTheme.of(context).alternate2, - }) - : accessHistoryItem['PES_TIPO'] == 'E' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Visitante', - enText: 'Visitor', - ): FlutterFlowTheme.of(context).alternate2, - }) - : Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Desconhecido', - enText: 'Unknown', - ): FlutterFlowTheme.of(context).alternate2, - }), + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Morador', + enText: 'Resident', + ): FlutterFlowTheme.of(context).alternate2, + }) + : accessHistoryItem['PES_TIPO'] == 'E' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Visitante', + enText: 'Visitor', + ): FlutterFlowTheme.of(context).alternate2, + }) + : Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Desconhecido', + enText: 'Unknown', + ): FlutterFlowTheme.of(context).alternate2, + }), accessHistoryItem['ACE_TIPO'] == '0' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Entrada', - enText: 'Entrance', - ): FlutterFlowTheme.of(context).success, - }) - : accessHistoryItem['ACE_TIPO'] == '1' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Saída', - enText: 'Exit', - ): FlutterFlowTheme.of(context).error, - }) - : Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Desconhecido', - enText: 'Unknown', - ): FlutterFlowTheme.of(context).warning, - }) + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Entrada', + enText: 'Entrance', + ): FlutterFlowTheme.of(context).success, + }) + : accessHistoryItem['ACE_TIPO'] == '1' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Saída', + enText: 'Exit', + ): FlutterFlowTheme.of(context).error, + }) + : Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Desconhecido', + enText: 'Unknown', + ): FlutterFlowTheme.of(context).warning, + }) ], onTapCardItemAction: () async {}); } } -Widget _cardHeaderAtomWidget(BuildContext context, String urlImagem, - String tipoPessoa, Color corFundoTipo, accessHistoryItem) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: const EdgeInsets.all(10.0), - child: ClipRRect( - borderRadius: BorderRadius.circular(100.0), - child: Image.network( - urlImagem, - width: 60.0, - height: 60.0, - fit: BoxFit.cover, - ), - ), - ), - Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - getJsonField( - accessHistoryItem, - r'''$.PES_NOME''', - ).toString(), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - Container( - width: 100.0, - height: 25.0, - decoration: BoxDecoration( - color: (() { - // Extrai o valor de PES_TIPO, converte para String, remove espaços em branco e aspas - final pesTipo = - jsonToStr(getJsonField( - accessHistoryItem, - r'''$.PES_TIPO''', - )) - .trim() - .replaceAll('"', ''); // Remove aspas - - // Debug: Imprime o valor de PES_TIPO ajustado - log('PES_TIPO FOR COLORING: $pesTipo'); - - // Retorna a cor baseada na condição ajustada - return pesTipo == 'E' - ? FlutterFlowTheme.of(context).warning - : FlutterFlowTheme.of(context).primary; - })(), - borderRadius: BorderRadius.circular(24.0), - ), - child: Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: Text( - getJsonField( - accessHistoryItem, - r'''$.PES_TIPO''', - ).toString() == - 'E' - ? FFLocalizations.of(context).getText( - 'zok7lu4w', - ) - : FFLocalizations.of(context).getText( - 'oonqk812', - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).info, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - ), - ), - ], - ), - ] - .divide(const SizedBox(width: 20.0)) - .addToStart(const SizedBox(width: 5.0)) - .addToEnd(const SizedBox(width: 5.0)), - ); -} - -Widget _cardDetailsMoleculeWidget( - BuildContext context, dynamic accessHistoryItem) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - FFLocalizations.of(context).getText( - '2odgr6hg', - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - Text( - getJsonField( - accessHistoryItem, - r'''$.ACE_DATAHORA''', - ).toString(), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - ].addToStart(const SizedBox(width: 10.0)), - ), - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - FFLocalizations.of(context).getText( - 'zrde3fke', - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - Text( - getJsonField( - accessHistoryItem, - r'''$.ACI_DESCRICAO''', - ).toString(), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - ].addToStart(const SizedBox(width: 10.0)), - ), - ].divide(const SizedBox(height: 3.0)), - ), - ), - ] - .addToStart(const SizedBox(width: 5.0)) - .addToEnd(const SizedBox(width: 5.0)), - ); -} - String imageUrlAtomWidget(String document, String type) { return valueOrDefault( "https://freaccess.com.br/freaccess/getImage.php?&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=$document&tipo=$type", "https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg", ); -} \ No newline at end of file +} diff --git a/lib/pages/home_page/home_page_widget.dart b/lib/pages/home_page/home_page_widget.dart index 6cf9f539..ee4abbe3 100644 --- a/lib/pages/home_page/home_page_widget.dart +++ b/lib/pages/home_page/home_page_widget.dart @@ -298,9 +298,7 @@ class _HomePageWidgetState extends State { color: FlutterFlowTheme.of(context).info, size: 24.0, ), - onPressed: () { - log('IconButton pressed ...'); - }, + onPressed: () {}, ), ), ), @@ -545,7 +543,7 @@ class _HomePageWidgetState extends State { ), FFButtonWidget( onPressed: () async { - FFAppState().isLogged = false; + FFAppState().deleteAll(); setState(() {}); context.goNamed( diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index c13695f9..ef9bed94 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -330,7 +330,6 @@ Widget liberationHistoryItemCard( }) ], onTapCardItemAction: () async { - log('LiberationItem: $liberationHistoryItem'); showModalBottomSheet( isScrollControlled: true, isDismissible: true, @@ -339,20 +338,20 @@ Widget liberationHistoryItemCard( context: context, builder: (context) { return VisitRequestTemplateComponentWidget( - vteName: liberationHistoryItem['VTE_NOME'], - vteReason: liberationHistoryItem['NOT_MOTIVO'], - vawDate: liberationHistoryItem['NOT_STATUS'] == 'S' - ? liberationHistoryItem['NOT_DTENVIO'] - : liberationHistoryItem['NOT_DTRESPOSTA'], - vawStatus: liberationHistoryItem['NOT_STATUS'], - vteMsg: liberationHistoryItem['NOT_MSGENVIO'], - vteUUID: liberationHistoryItem['VTE_ID'], - cliUUID: FFAppState().cliUUID, - msgUUID: liberationHistoryItem['NOT_ID'], - vawDestino: liberationHistoryItem['NOT_DESTINO'], - vawUUID: liberationHistoryItem['NOT_ID'], - vawName: liberationHistoryItem['NOT_NOME'], - vawRef: liberationHistoryItem['NOT_ID'], + // vteName: liberationHistoryItem['VTE_NOME'], + // vteReason: liberationHistoryItem['NOT_MOTIVO'], + // vawDate: liberationHistoryItem['NOT_STATUS'] == 'S' + // ? liberationHistoryItem['NOT_DTENVIO'] + // : liberationHistoryItem['NOT_DTRESPOSTA'], + // vawStatus: liberationHistoryItem['NOT_STATUS'], + // vteMsg: liberationHistoryItem['NOT_MSGENVIO'], + // vteUUID: liberationHistoryItem['VTE_ID'], + // cliUUID: FFAppState().cliUUID, + // msgUUID: liberationHistoryItem['NOT_ID'], + // vawDestino: liberationHistoryItem['NOT_DESTINO'], + // vawUUID: liberationHistoryItem['NOT_ID'], + // vawName: liberationHistoryItem['NOT_NOME'], + // vawRef: liberationHistoryItem['NOT_ID'], labelsHashMap: Map.from({ 'Nome:': liberationHistoryItem['VTE_NOME'], 'Data:': liberationHistoryItem['NOT_DTENVIO'], @@ -418,13 +417,19 @@ Widget liberationHistoryItemCard( ptText: 'Sim', ), onPressed: () async { - await changeStatusAction.call( + Navigator.pop(context); + Navigator.pop(context); + await answersRequest + .call( context, - 'L', liberationHistoryItem['NOT_ID'].toString(), + 'L', 'Mensagem', liberationHistoryItem['VTE_ID'].toString(), - ); + ) + .then((value) { + log(value.toString()); + }); }, options: FFButtonOptions( width: 100, @@ -505,10 +510,10 @@ Widget liberationHistoryItemCard( ptText: 'Sim', ), onPressed: () async { - await changeStatusAction.call( + await answersRequest.call( context, - 'B', liberationHistoryItem['NOT_ID'].toString(), + 'B', 'Mensagem', liberationHistoryItem['VTE_ID'].toString(), ); @@ -562,7 +567,7 @@ Widget liberationHistoryItemCard( 'key': liberationHistoryItem['VTE_ID'], 'value': 'E', }), - changeStatusAction: changeStatusAction, + // changeStatusAction: answersRequest, // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], ); }, @@ -572,7 +577,6 @@ Widget liberationHistoryItemCard( _pushNotificationService.onMessageReceived.listen((received) { if (received.data['click_action'] == 'cancel_request') { - log('Aprovado'); _pushNotificationService.dispose(); snackbar(context, opt: true); context.pushReplacementNamed( diff --git a/lib/pages/message_history_page/message_history_page_widget.dart b/lib/pages/message_history_page/message_history_page_widget.dart index df268d4d..7c6d07dd 100644 --- a/lib/pages/message_history_page/message_history_page_widget.dart +++ b/lib/pages/message_history_page/message_history_page_widget.dart @@ -2,7 +2,6 @@ import 'dart:developer'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:hub/app_state.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; @@ -219,8 +218,6 @@ Widget buildListView( snapshot.data == null || !snapshot.hasData || snapshot.hasError) { - log('Error: ${snapshot.error.toString()}'); - // log('Error: ${snapshot.data!.jsonBody['mensagens']}'); return const Center( child: Text('Erro ao carregar mensagens'), ); @@ -273,7 +270,7 @@ Widget buildListItem(BuildContext context, dynamic jsonBody) { children: [ Icon( jsonBody['MSG_DESTINO_TP'] == 'T' - ? EvaIcons.globe + ? Icons.language : jsonBody['MSG_DESTINO_TP'] == 'P' ? Icons.person : Icons.home, diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 1a3ff528..7ed3cef2 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -520,7 +520,6 @@ class PreferencesPageModel with ChangeNotifier { } Future togglePass(BuildContext context) async { - debugPrint('pass: ${FFAppState().pass}'); // if (FFAppState().pass) { // FFAppState().pass = false; // FFAppState().deleteAccessPass(); @@ -538,7 +537,6 @@ class PreferencesPageModel with ChangeNotifier { toggleActionStatus: (key) async { FFAppState().accessPass = key; notifyListeners(); - debugPrint('key: $key'); await PhpGroup.changePass .call( userUUID: FFAppState().userUUID, @@ -549,7 +547,6 @@ class PreferencesPageModel with ChangeNotifier { ) .then((value) { // var error = jsonDecode(value.jsonBody['error'].toString()); - // log('${jsonDecode(value.jsonBody['error'].toString())}'); if (jsonDecode(value.jsonBody['error'].toString()) == false) { FFAppState().pass = true; ScaffoldMessenger.of(context).showSnackBar( diff --git a/lib/pages/qr_code_page/qr_code_page_widget.dart b/lib/pages/qr_code_page/qr_code_page_widget.dart index 7ddd315d..09e790d5 100644 --- a/lib/pages/qr_code_page/qr_code_page_widget.dart +++ b/lib/pages/qr_code_page/qr_code_page_widget.dart @@ -398,7 +398,6 @@ class _QrCodePageWidgetState extends State padding: MediaQuery.viewInsetsOf(context), child: QrCodePassKeyTemplateComponentWidget( toggleActionStatus: (key) async { - log('Key: $key'); safeSetState(() { if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { @@ -418,7 +417,6 @@ class _QrCodePageWidgetState extends State ); }, ).catchError((error) => safeSetState(() { - log('Error: $error'); _resetAnimationAndToggleAccess(); })); unawaited( diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart index 79647877..0ca53309 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart @@ -22,6 +22,7 @@ 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/schedule_complete_visit_page/schedule_complete_visit_page_model.dart'; +import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart'; import 'package:provider/provider.dart'; class ScheduleCompleteVisitPageWidget extends StatefulWidget { @@ -162,26 +163,6 @@ class _ScheduleCompleteVisitPageWidgetState } } -enum status { active, unknown, canceled, finished, blocked, inactive } - -status? getStatus(dynamic data) { - debugPrint('getStatus: $data'); - switch (data) { - case 'A': - return status.active; - case 'F': - return status.finished; - case 'B': - return status.blocked; - case 'C': - return status.canceled; - case 'I': - return status.inactive; - default: - return status.unknown; - } -} - PreferredSizeWidget appBarScheduleCompleteVisit(BuildContext context) { return AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, @@ -267,7 +248,16 @@ Widget bodyScheduleCompleteVisit( controller: _model.tabBarController, children: [ scheduleVisit(context, _model, setState, safeSetState), - visitHistory(context, _model, safeSetState), + wrapWithModel( + model: _model, + child: VisitHistoryWidget( + model: _model, + safeSetState: safeSetState, + ), + updateCallback: () { + setState(() {}); + }, + updateOnChange: true), ], ), ), @@ -863,40 +853,8 @@ Widget scheduleVisit( focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, - onTap: () async { - // await showModalBottomSheet( - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // enableDrag: false, - // context: context, - // builder: (context) { - // return GestureDetector( - // onTap: () => _model - // .unfocusNode.canRequestFocus - // ? FocusScope.of(context) - // .requestFocus(_model.unfocusNode) - // : FocusScope.of(context).unfocus(), - // child: Padding( - // padding: - // MediaQuery.viewInsetsOf(context), - // child: - // const VisitorDetailsModalTemplateComponentWidget( - // visitorImageURL: '', - // visitorEmail: '', - // visitorName: '', - // visitorPhone: '', - // visitorType: '', - // ), - // ), - // ); - // }, - // ).then((value) => safeSetState(() {})); - }, - onLongPress: () async { - // _model.removeFromVisitorJsonList( - // visitorListViewItem); - // setState(() {}); - }, + onTap: () async {}, + onLongPress: () async {}, child: Container( width: MediaQuery.of(context).size.width, height: 70.0, @@ -1460,16 +1418,6 @@ Widget scheduleVisit( ), hoverColor: FlutterFlowTheme.of(context).primaryBackground, - // thumbColor: WidgetStateColor.resolveWith( - // (states) { - // if (states.contains(WidgetState.disabled)) { - // return FlutterFlowTheme.of(context) - // .alternate; - // } - // return FlutterFlowTheme.of(context) - // .alternate; - // }, - // ), overlayColor: WidgetStateProperty.resolveWith( (states) { if (states.contains(WidgetState.disabled)) { @@ -1684,213 +1632,3 @@ Widget scheduleVisit( ), ); } - -Widget visitHistory( - BuildContext context, - ScheduleCompleteVisitPageModel _model, - Function safeSetState, -) { - return Container( - width: double.infinity, - height: 900.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primaryBackground, - ), - child: StreamBuilder( - stream: _model.visitHistory( - requestFn: () => PhpGroup.getVisitsCall.call( - devUUID: FFAppState().devUUID, - userUUID: FFAppState().userUUID, - cliID: FFAppState().cliUUID, - atividade: 'getVisitas', - pageSize: 100, - pageNumber: 1, - ), - ), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return Center( - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - FlutterFlowTheme.of(context).primary, - ), - )); - } else if (snapshot.hasError) { - log('Error: ${snapshot.error}'); - return Center(child: Text('Error: ${snapshot.error}')); - } else if (!snapshot.hasData || snapshot.data!.jsonBody == null) { - log('No data or jsonBody is null'); - return const Center(child: Text('No visits found')); - } - - final wrapGetVisitsResponse = snapshot.data!; - log('Response: ${wrapGetVisitsResponse.jsonBody}'); - - final visitaWrap = PhpGroup.getVisitsCall - .visitasList(wrapGetVisitsResponse.jsonBody) - ?.toList() ?? - []; - log('visitaWrap: $visitaWrap'); - return ListView.builder( - itemCount: visitaWrap.length, - shrinkWrap: true, - scrollDirection: Axis.vertical, - physics: const BouncingScrollPhysics(), - addAutomaticKeepAlives: true, - cacheExtent: 1000.0, - addRepaintBoundaries: true, - addSemanticIndexes: true, - itemBuilder: (context, index) { - final visitaWrapItem = visitaWrap[index]; - return CardItemTemplateComponentWidget( - imageHashMap: Map.from({ - 'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '', - 'value': 'E', - }), - labelsHashMap: Map.from({ - 'Nome:': visitaWrapItem['VTE_NOME'] ?? '', - 'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '', - 'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '', - }), - statusHashMap: [ - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.active) - Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active', - ): FlutterFlowTheme.of(context).warning, - }), - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.finished) - Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Finalizado', - enText: 'Finished', - ): FlutterFlowTheme.of(context).success, - }), - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.unknown) - Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Desconhecido', - enText: 'Unknown', - ): FlutterFlowTheme.of(context).alternate, - }), - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.canceled) - Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Cancelado', - enText: 'Canceled', - ): FlutterFlowTheme.of(context).error, - }), - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.blocked) - Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked', - ): FlutterFlowTheme.of(context).error, - }), - if (getStatus(visitaWrapItem['VAW_STATUS']) == - status.inactive) - Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Inactive', - enText: 'Inactive', - ): FlutterFlowTheme.of(context).error, - }), - ], - onTapCardItemAction: () async { - showModalBottomSheet( - isScrollControlled: true, - isDismissible: true, - backgroundColor: Colors.transparent, - useSafeArea: true, - context: context, - builder: (context) { - return buildDetails( - visitaWrapItem, - context, - changeStatusAction, - ); - }, - ).then((_) { - // PushNotificationManager _pushNotificationService = - // PushNotificationManager(); - // _pushNotificationService.onMessageReceived - // .listen((received) { - // if (received.data['click_action'] == - // 'cancel_request') { - // log('Aprovado'); - // _pushNotificationService.dispose(); - // snackbar(context, opt: true); - // context.pushReplacementNamed( - // 'liberationHistory', - // extra: { - // kTransitionInfoKey: const TransitionInfo( - // hasTransition: true, - // transitionType: PageTransitionType.scale, - // alignment: Alignment.bottomCenter, - // ), - // }, - // ); - // } - // }); - }); - // await showModalBottomSheet( - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // enableDrag: true, - // isDismissible: true, - // useSafeArea: true, - // context: context, - // builder: (context) { - // return GestureDetector( - // onTap: () => _model.unfocusNode.canRequestFocus - // ? FocusScope.of(context) - // .requestFocus(_model.unfocusNode) - // : FocusScope.of(context).unfocus(), - // child: VisitDetailsModalTemplateComponentWidget( - // visitStatusStr: visitaWrapItem['VAW_STATUS'], - // visitStartDateStr: - // visitaWrapItem['VAW_DTINICIO'], - // visitEndDateStr: visitaWrapItem['VAW_DTFIM'], - // visitReasonStr: - // visitaWrapItem['MOT_DESCRICAO'], - // visitLevelStr: - // visitaWrapItem['NAC_DESCRICAO'], - // visitTempStr: - // visitaWrapItem['VTE_UNICA'].toString(), - // visitObsStr: visitaWrapItem['VAW_OBS'], - // visitorImgPath: valueOrDefault( - // "https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField( - // visitaWrapItem, - // r'''$.VTE_DOCUMENTO''', - // ).toString()}&tipo=E", - // 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', - // ), - // visitorStrList: - // visitaWrapItem['VTE_DOCUMENTO'], - // visitIdStr: visitaWrapItem['VAW_ID'], - // visitStatusColor: - // visitaWrapItem['VAW_STATUS'] == 'A' - // ? FlutterFlowTheme.of(context).success - // : FlutterFlowTheme.of(context).error, - // visitorJsonList: - // PhpGroup.getVisitsCall.visitasList( - // wrapGetVisitsResponse.jsonBody, - // ), - // updateToggleIdx: () async {}, - // repeatVisitSchedule: () async {}, - // ), - // ); - // }, - // ).then((value) => safeSetState(() {})); - }); - }); - }, - ), - ); -} diff --git a/lib/pages/test_page/test_page.dart b/lib/pages/test_page/test_page.dart index c8e9cc15..b7a0e8db 100644 --- a/lib/pages/test_page/test_page.dart +++ b/lib/pages/test_page/test_page.dart @@ -53,7 +53,6 @@ // imageHashMap: imageKeyValue, // onTapCardItemAction: () async { // // Ação ao tocar no card -// log('Card tapped'); // }, // ); // }), diff --git a/lib/pages/visit_history_page/visit_history_page_model.dart b/lib/pages/visit_history_page/visit_history_page_model.dart index 2adb1620..8b137891 100644 --- a/lib/pages/visit_history_page/visit_history_page_model.dart +++ b/lib/pages/visit_history_page/visit_history_page_model.dart @@ -1,106 +1 @@ -import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_manager.dart'; -import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/flutter_flow/form_field_controller.dart'; -import 'package:hub/flutter_flow/request_manager.dart'; -import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart'; -class VisitHistoryPageModel extends FlutterFlowModel { - final _visitHistoryManager = StreamRequestManager(); - Stream visitHistory({ - String? uniqueQueryKey, - bool? overrideCache, - required Stream Function() requestFn, - }) => - _visitHistoryManager.performRequest( - uniqueQueryKey: uniqueQueryKey, - overrideCache: overrideCache, - requestFn: requestFn, - ); - void clearVisitHistoryCache() => _visitHistoryManager.clear(); - void clearVisitHistoryCacheKey(String? uniqueKey) => - _visitHistoryManager.clearRequest(uniqueKey); - - /// Local state fields for this page. - - List visitorJsonList = []; - void addToVisitorJsonList(dynamic item) => visitorJsonList.add(item); - void removeFromVisitorJsonList(dynamic item) => visitorJsonList.remove(item); - void removeAtIndexFromVisitorJsonList(int index) => - visitorJsonList.removeAt(index); - void insertAtIndexInVisitorJsonList(int index, dynamic item) => - visitorJsonList.insert(index, item); - void updateVisitorJsonListAtIndex(int index, Function(dynamic) updateFn) => - visitorJsonList[index] = updateFn(visitorJsonList[index]); - - String visitorStrList = '0'; - - /// State fields for stateful widgets in this page. - - final unfocusNode = FocusNode(); - // State field(s) for TabBar widget. - TabController? tabBarController; - int get tabBarCurrentIndex => - tabBarController != null ? tabBarController!.index : 0; - - // State field(s) for TextField widget. - FocusNode? textFieldFocusNode1; - TextEditingController? textController1; - String? Function(BuildContext, String?)? textController1Validator; - DateTime? datePicked1; - // State field(s) for TextField widget. - FocusNode? textFieldFocusNode2; - TextEditingController? textController2; - String? Function(BuildContext, String?)? textController2Validator; - DateTime? datePicked2; - // State field(s) for DropDown widget. - String? dropDownValue1; - FormFieldController? dropDownValueController1; - // State field(s) for DropDown widget. - String? dropDownValue2; - FormFieldController? dropDownValueController2; - // State field(s) for Switch widget. - bool? switchValue; - // State field(s) for TextField widget. - FocusNode? textFieldFocusNode3; - TextEditingController? textController3; - String? Function(BuildContext, String?)? textController3Validator; - - @override - void initState(BuildContext context) {} - - @override - void dispose() { - unfocusNode.dispose(); - tabBarController?.dispose(); - textFieldFocusNode1?.dispose(); - textController1?.dispose(); - - textFieldFocusNode2?.dispose(); - textController2?.dispose(); - - textFieldFocusNode3?.dispose(); - textController3?.dispose(); - - clearVisitHistoryCache(); - } - - /// Action blocks. - Future getVisitorsActionPage( - BuildContext context, { - List? visitorsJsonList, - }) async { - visitorJsonList = visitorsJsonList!.toList().cast(); - } - - Future toggleCurrentSelectionHeader( - BuildContext context, { - required bool? toggleIndexValue, - }) async { - if (toggleIndexValue == true) { - return true; - } - - return false; - } -} diff --git a/lib/pages/visit_history_page/visit_history_page_widget.dart b/lib/pages/visit_history_page/visit_history_page_widget.dart index 64bfc9c6..b688d554 100644 --- a/lib/pages/visit_history_page/visit_history_page_widget.dart +++ b/lib/pages/visit_history_page/visit_history_page_widget.dart @@ -1,753 +1,155 @@ -import 'dart:developer'; - -import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/scheduler.dart'; -import 'package:flutter_spinkit/flutter_spinkit.dart'; -import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/actions/actions.dart'; +import 'package:hub/app_state.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; - -import 'package:hub/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart'; -import 'package:hub/flutter_flow/custom_functions.dart'; -import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; +import 'package:hub/backend/api_requests/api_manager.dart'; +import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/components/templates_components/details_component/details_component_action.dart'; 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/visit_history_page/visit_history_page_model.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; +import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart'; import 'package:provider/provider.dart'; -class VisitHistoryPageWidget extends StatefulWidget { - const VisitHistoryPageWidget({ - super.key, - this.visitorStrList, - this.visitStartDateStr, - this.visitEndDateStr, - this.visitReasonStr, - this.visitLevelStr, - this.visitTempBol, - this.visitObsStr, - this.visitorJsonList, - }); +class VisitHistoryWidget extends StatelessWidget { + final ScheduleCompleteVisitPageModel _model; + final Function safeSetState; - final String? visitorStrList; - final String? visitStartDateStr; - final String? visitEndDateStr; - final String? visitReasonStr; - final String? visitLevelStr; - final bool? visitTempBol; - final String? visitObsStr; - final List? visitorJsonList; - - @override - State createState() => _VisitHistoryPageWidgetState(); -} - -class _VisitHistoryPageWidgetState extends State - with TickerProviderStateMixin { - late VisitHistoryPageModel _model; - int _visitHistoryLoadingIdx = 0; - final int _visitHistoryLoadingCount = 10; - List _visitHistoryList = []; - ScrollController _visitHistoryController = ScrollController(); - - final scaffoldKey = GlobalKey(); - - @override - void initState() { - super.initState(); - _model = createModel(context, () => VisitHistoryPageModel()); - - // On page load action. - SchedulerBinding.instance.addPostFrameCallback((_) async { - if ((widget.visitorStrList != null && widget.visitorStrList != '') && - ((widget.visitorJsonList != null && - (widget.visitorJsonList)!.isNotEmpty) != - null)) { - _model.visitorJsonList = widget.visitorJsonList! - .where((e) => - widget.visitorStrList == - getJsonField( - e, - r'''$.VTE_DOCUMENTO''', - ).toString().toString()) - .toList() - .toList() - .cast(); - _model.visitorStrList = widget.visitorStrList!; - setState(() {}); - } else { - return; - } - }); - - _model.tabBarController = TabController( - vsync: this, - length: 2, - initialIndex: 0, - )..addListener(() => setState(() {})); - _model.textController1 ??= TextEditingController(); - _model.textFieldFocusNode1 ??= FocusNode(); - - _model.textController2 ??= TextEditingController(); - _model.textFieldFocusNode2 ??= FocusNode(); - - _model.switchValue = true; - _model.textController3 ??= TextEditingController(); - _model.textFieldFocusNode3 ??= FocusNode(); - } - - void _loadMoreVisitHistory() async { - // Simulate fetching data from an API or database - Future> fetchVisitHistory(int start, int limit) async { - // Simulate network delay - await Future.delayed(Duration(seconds: 1)); - // Generate a list of visit history items - return List.generate(limit, (index) => "Item ${start + index}"); - } - - // Calculate the start index for the next batch of items to load - final int start = _visitHistoryLoadingIdx * _visitHistoryLoadingCount; - // Fetch the next batch of items - final List newItems = - await fetchVisitHistory(start, _visitHistoryLoadingCount); - - // If new items were fetched, add them to the list and update the index - if (newItems.isNotEmpty) { - _visitHistoryList.addAll(newItems); - _visitHistoryLoadingIdx++; - setState(() {}); - } - } - - void_scrollListener() { - if (_visitHistoryController.position.pixels == - _visitHistoryController.position.maxScrollExtent) { - _loadMoreVisitHistory(); - } - } - - @override - void dispose() { - _model.dispose(); - - super.dispose(); - } + const VisitHistoryWidget({ + Key? key, + required ScheduleCompleteVisitPageModel model, + required this.safeSetState, + }) : _model = model, + super(key: key); @override Widget build(BuildContext context) { - context.watch(); - - return GestureDetector( - onTap: () => _model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), - child: Scaffold( - key: scaffoldKey, - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - appBar: appBarScheduleCompleteVisit(context), - body: - bodyScheduleCompleteVisit(context, _model, setState, safeSetState), + return Container( + width: double.infinity, + height: 900.0, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primaryBackground, ), - ); - } -} - -PreferredSizeWidget appBarScheduleCompleteVisit(BuildContext context) { - return AppBar( - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - automaticallyImplyLeading: false, - leading: FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 30.0, - borderWidth: 1.0, - buttonSize: 60.0, - icon: Icon( - Icons.keyboard_arrow_left, - color: FlutterFlowTheme.of(context).primaryText, - size: 30.0, - ), - onPressed: () async { - context.pop(); - }, - ), - title: Text( - FFLocalizations.of(context).getText( - '61lcxdgm' /* Agendar Visita */, - ), - style: FlutterFlowTheme.of(context).headlineMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 15.0, - letterSpacing: 0.0, - fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - ), - ), - actions: const [], - centerTitle: true, - ); -} - -Widget bodyScheduleCompleteVisit(BuildContext context, - VisitHistoryPageModel _model, Function setState, Function safeSetState) { - return SafeArea( - top: true, - child: visitHistory(context, _model, safeSetState), - ); -} - -Widget visitHistory( - BuildContext context, - VisitHistoryPageModel _model, - Function safeSetState, -) { - return Container( - width: double.infinity, - height: 900.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primaryBackground, - ), - child: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 20.0, - borderWidth: 1.0, - buttonSize: 40.0, - icon: Icon( - Icons.settings_sharp, - color: FlutterFlowTheme.of(context).primary, - size: 24.0, - ), - onPressed: () { - log('IconButton pressed ...'); - }, - ), - ], - ), - StreamBuilder( - stream: _model.visitHistory( + child: Consumer( + builder: (context, model, _) { + return StreamBuilder( + stream: model.visitHistory( requestFn: () => PhpGroup.getVisitsCall.call( devUUID: FFAppState().devUUID, userUUID: FFAppState().userUUID, cliID: FFAppState().cliUUID, atividade: 'getVisitas', + pageSize: 100, + pageNumber: 1, ), ), builder: (context, snapshot) { - // Customize what your widget looks like when it's loading. - if (!snapshot.hasData) { + if (snapshot.connectionState == ConnectionState.waiting) { return Center( - child: SizedBox( - width: 50.0, - height: 50.0, - child: SpinKitCircle( - color: FlutterFlowTheme.of(context).primary, - size: 50.0, + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + FlutterFlowTheme.of(context).primary, ), ), ); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data!.jsonBody == null) { + return const Center(child: Text('No visits found')); } final wrapGetVisitsResponse = snapshot.data!; - return Builder( - builder: (context) { - final visitaWrap = PhpGroup.getVisitsCall - .visitasList( - wrapGetVisitsResponse.jsonBody, - ) - ?.toList() ?? - []; - return ListView.builder( - itemCount: visitaWrap.length, - shrinkWrap: true, - scrollDirection: Axis.vertical, - physics: const BouncingScrollPhysics(), - addAutomaticKeepAlives: true, - cacheExtent: 1000.0, - addRepaintBoundaries: true, - addSemanticIndexes: true, - itemBuilder: (context, index) { - final visitaWrapItem = visitaWrap[index]; - // visitaWrap.length, (visitaWrapIndex) { - - return InkWell( - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onTap: () async { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, - useSafeArea: true, - context: context, - builder: (context) { - return GestureDetector( - onTap: () => - _model.unfocusNode.canRequestFocus - ? FocusScope.of(context) - .requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), - child: Padding( - padding: MediaQuery.viewInsetsOf(context), - child: - VisitDetailsModalTemplateComponentWidget( - visitStatusStr: getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - ).toString(), - visitStartDateStr: getJsonField( - visitaWrapItem, - r'''$.VAW_DTINICIO''', - ).toString(), - visitEndDateStr: getJsonField( - visitaWrapItem, - r'''$.VAW_DTFIM''', - ).toString(), - visitReasonStr: getJsonField( - visitaWrapItem, - r'''$.MOT_DESCRICAO''', - ).toString(), - visitLevelStr: getJsonField( - visitaWrapItem, - r'''$.NAC_DESCRICAO''', - ).toString(), - visitTempStr: getJsonField( - visitaWrapItem, - r'''$.VTE_UNICA''', - ).toString(), - visitObsStr: getJsonField( - visitaWrapItem, - r'''$.VAW_OBS''', - ).toString(), - visitorImgPath: valueOrDefault( - "https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField( - visitaWrapItem, - r'''$.VTE_DOCUMENTO''', - ).toString()}&tipo=E", - 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', - ), - visitorStrList: getJsonField( - visitaWrapItem, - r'''$.VTE_DOCUMENTO''', - ).toString(), - visitIdStr: getJsonField( - visitaWrapItem, - r'''$.VAW_ID''', - ).toString(), - visitStatusColor: getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - ).toString() == - 'A' - ? FlutterFlowTheme.of(context).success - : FlutterFlowTheme.of(context).error, - visitorJsonList: - PhpGroup.getVisitsCall.visitasList( - wrapGetVisitsResponse.jsonBody, - ), - updateToggleIdx: () async {}, - repeatVisitSchedule: () async {}, - ), - ), - ); - }, - ).then((value) => safeSetState(() {})); - }, - child: Card( - clipBehavior: Clip.antiAliasWithSaveLayer, - color: FlutterFlowTheme.of(context) - .secondaryBackground, - elevation: 5.0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - ), - child: Container( - width: 350.0, - height: 115.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context) - .secondaryBackground, - ), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Container( - width: 100.0, - height: 100.0, - decoration: const BoxDecoration(), - child: Column( - mainAxisSize: MainAxisSize.max, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - children: [ - Text( - FFLocalizations.of(context) - .getText( - 'i46frqyi' /* Visitante: */, - ), - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - fontWeight: - FontWeight.bold, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), - ), - Align( - alignment: - const AlignmentDirectional( - -1.0, -1.0), - child: Text( - getJsonField( - visitaWrapItem, - r'''$.VTE_NOME''', - ).toString(), - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), - ), - ), - ].addToStart( - const SizedBox(width: 10.0)), - ), - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - FFLocalizations.of(context) - .getText( - '73b1kj59' /* Início em: */, - ), - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - fontWeight: - FontWeight.bold, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), - ), - Text( - getJsonField( - visitaWrapItem, - r'''$.VAW_DTINICIO''', - ).toString(), - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), - ), - ].addToStart( - const SizedBox(width: 10.0)), - ), - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Text( - FFLocalizations.of(context) - .getText( - 'klzzrfbn' /* Fim em: */, - ), - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - fontWeight: - FontWeight.bold, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), - ), - Text( - getJsonField( - visitaWrapItem, - r'''$.VAW_DTFIM''', - ).toString(), - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - fontSize: 12.5, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), - ), - ].addToStart( - const SizedBox(width: 10.0)), - ), - Align( - alignment: - const AlignmentDirectional( - -1.0, 0.0), - child: Padding( - padding: - const EdgeInsetsDirectional - .fromSTEB( - 10.0, 0.0, 0.0, 0.0), - child: Container( - width: 200.0, - height: 27.0, - decoration: BoxDecoration( - color: valueOrDefault( - () { - if (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"A\"') { - return FlutterFlowTheme - .of(context) - .success; - } else if ((jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"C\"') || - (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"F\"') || - (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"B\"') || - (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"I\"')) { - return FlutterFlowTheme - .of(context) - .error; - } else if (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"I\"') { - return FlutterFlowTheme - .of(context) - .warning; - } else { - return FlutterFlowTheme - .of(context) - .primary; - } - }(), - FlutterFlowTheme.of(context) - .primary, - ), - borderRadius: - BorderRadius.circular( - 5.0), - ), - child: Align( - alignment: - const AlignmentDirectional( - 0.0, 0.0), - child: Text( - () { - if (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"A\"') { - return FFLocalizations - .of(context) - .getVariableText( - ptText: 'Ativo', - enText: 'Active', - ); - } else if ((jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"F\"') || - (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"C\"') || - (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"B\"') || - (jsonToStr( - getJsonField( - visitaWrapItem, - r'''$.VAW_STATUS''', - )) == - '\"I\"')) { - return FFLocalizations - .of(context) - .getVariableText( - ptText: 'Cancelado', - enText: 'Canceled', - ); - } else { - return FFLocalizations - .of(context) - .getVariableText( - ptText: 'Pendente', - enText: 'Pending', - ); - } - }(), - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - color: FlutterFlowTheme - .of(context) - .info, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), - ), - ), - ), - ), - ), - ].divide(const SizedBox(height: 3.0)), - ), - ), - ), - ClipRRect( - borderRadius: BorderRadius.circular(0.0), - child: CachedNetworkImage( - fadeInDuration: - const Duration(milliseconds: 500), - fadeOutDuration: - const Duration(milliseconds: 500), - imageUrl: valueOrDefault( - 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField( - visitaWrapItem, - r'''$.VTE_DOCUMENTO''', - ).toString()}&tipo=E', - 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', - ), - fit: BoxFit.cover, - ), - ), - ], - ), - ), - ), - ); - }); + final visitaWrap = PhpGroup.getVisitsCall + .visitasList(wrapGetVisitsResponse.jsonBody) + ?.toList() ?? + []; + return ListView.builder( + itemCount: visitaWrap.length, + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + itemBuilder: (context, index) { + final visitaWrapItem = visitaWrap[index]; + return CardItemTemplateComponentWidget( + imageHashMap: { + 'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '', + 'value': 'E', + }, + labelsHashMap: { + 'Nome:': visitaWrapItem['VTE_NOME'] ?? '', + 'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '', + 'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '', + }, + statusHashMap: [ + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.active) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).warning, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.finished) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Finalizado', + enText: 'Finished', + ): FlutterFlowTheme.of(context).success, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.unknown) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Desconhecido', + enText: 'Unknown', + ): FlutterFlowTheme.of(context).alternate, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.canceled) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Cancelado', + enText: 'Canceled', + ): FlutterFlowTheme.of(context).error, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.blocked) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Bloqueado', + enText: 'Blocked', + ): FlutterFlowTheme.of(context).error, + }, + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.inactive) + { + FFLocalizations.of(context).getVariableText( + ptText: 'Inactive', + enText: 'Inactive', + ): FlutterFlowTheme.of(context).error, + }, + ], + onTapCardItemAction: () async { + showModalBottomSheet( + isScrollControlled: true, + isDismissible: true, + backgroundColor: Colors.transparent, + useSafeArea: true, + context: context, + builder: (context) { + return buildDetails( + visitaWrapItem, + context, + changeStatusAction, + ); + }, + ); + }, + ); }, ); }, - ) - ], + ); + }, ), - ), - ); + ); + } } diff --git a/pubspec.lock b/pubspec.lock index d60bd97b..db941ddb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -233,14 +233,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.5" - eva_icons_flutter: - dependency: "direct main" - description: - name: eva_icons_flutter - sha256: "6d48a10b93590ab83eb092bee5adacdeb14f3d83f527a4b9e4092c363d56e2a8" - url: "https://pub.dev" - source: hosted - version: "3.1.0" fake_async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 828e33cd..95aa0238 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,7 +49,6 @@ dependencies: flutter_plugin_android_lifecycle: 2.0.20 share_plus: ^9.0.0 flutter_secure_storage: 9.2.2 - eva_icons_flutter: ^3.1.0 flutter_secure_storage_linux: 1.2.1 flutter_secure_storage_macos: 3.1.2 flutter_secure_storage_platform_interface: 1.1.2