diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index 2a8838ec..b198f4d3 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -11,7 +11,6 @@ export 'api_manager.dart' show ApiCallResponse; const _kPrivateApiFunctionName = 'ffPrivateApiCall'; - /// Start PHP Group Code class PhpGroup { @@ -46,6 +45,81 @@ class PhpGroup { static ChangeNotifica changeNotifica = ChangeNotifica(); static RespondeVinculo resopndeVinculo = RespondeVinculo(); static ChangePass changePass = ChangePass(); + static ChangePanic changePanic = ChangePanic(); + static DeleteAccount deleteAccount = DeleteAccount(); +} + +class DeleteAccount { + Future call({ + String? devUUID = '', + String? userUUID = '', + }) async { + final baseUrl = PhpGroup.getBaseUrl(); + return ApiManager.instance.makeApiCall( + callName: 'deleteAccount', + apiUrl: '$baseUrl/deleteAccount.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); + } + + bool? error(dynamic response) => castToType(getJsonField( + response, + r'''$.error''', + )); +} + +class ChangePanic { + Future call({ + String? devUUID = '', + String? userUUID = '', + String? cliID = '', + String? atividade = '', + String? newSenhaPanico = '', + }) async { + final baseUrl = PhpGroup.getBaseUrl(); + + return ApiManager.instance.makeApiCall( + callName: 'changePass', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliID, + 'atividade': atividade, + 'newSenhaPanico': newSenhaPanico, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); + } + + bool? error(dynamic response) => castToType(getJsonField( + response, + r'''$.error''', + )); } class ChangePass { @@ -95,31 +169,30 @@ class RespondeVinculo { String? cliID = '', String? tarefa = '', }) async { - final baseUrl = PhpGroup.getBaseUrl(); + final baseUrl = PhpGroup.getBaseUrl(); - return ApiManager.instance.makeApiCall( - callName: 'respondeVinculo', - apiUrl: '$baseUrl/processRequest.php', - callType: ApiCallType.POST, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - params: { - 'devUUID': devUUID, - 'userUUID': userUUID, - 'cliID': cliID, - 'tarefa': tarefa, - }, - bodyType: BodyType.X_WWW_FORM_URL_ENCODED, - returnBody: true, - encodeBodyUtf8: false, - decodeUtf8: false, - cache: false, - isStreamingApi: false, - alwaysAllowBody: false, - ); + return ApiManager.instance.makeApiCall( + callName: 'respondeVinculo', + apiUrl: '$baseUrl/responderVinculo.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliID, + 'tarefa': tarefa, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); } - } class ChangeNotifica { @@ -160,7 +233,7 @@ class ChangeNotifica { response, r'''$.error''', )); -} +} class UpdToken { Future call({ @@ -2433,4 +2506,4 @@ String _serializeJson(dynamic jsonVar, [bool isList = false]) { } return isList ? '[]' : '{}'; } -} \ No newline at end of file +} diff --git a/lib/backend/push_notification/pushNotificationService.dart b/lib/backend/push_notification/pushNotificationService.dart index 883a9338..a9224dc3 100644 --- a/lib/backend/push_notification/pushNotificationService.dart +++ b/lib/backend/push_notification/pushNotificationService.dart @@ -4,8 +4,6 @@ import 'dart:developer'; import 'dart:io'; import 'dart:math' as math; - - import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -17,11 +15,12 @@ import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart'; import 'package:hub/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart'; import 'package:hub/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; import 'package:rxdart/rxdart.dart'; // - class PushNotificationService { final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin = @@ -104,8 +103,6 @@ class PushNotificationService { } } - - void _initializeLocalNotifications( BehaviorSubject context) async { while (context.valueOrNull == null) { @@ -132,9 +129,10 @@ class PushNotificationService { 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); + 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'); } @@ -191,7 +189,8 @@ class PushNotificationService { _onMessage.add(message); log('Extra: ${message.notification?.body}'); - NotificationHandler().handleMessage(message.data, context); }); + NotificationHandler().handleMessage(message.data, context); + }); } void configureTokenRefresh() { @@ -292,14 +291,16 @@ class PushNotificationService { ); } - _handleNotificationClick(Map payload, {Map extra = const {}}) { + _handleNotificationClick(Map payload, + {Map extra = const {}}) { 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); + NotificationHandler().handleMessage(payload, _context.value, + extra: extra.isEmpty ? {} : extra); // Access the 'data' property of 'RemoteMessage' case false: log('Notification payload is empty'); @@ -315,7 +316,8 @@ class PushNotificationService { } class NotificationHandler { - void handleMessage(Map message, BuildContext context, {Map extra = const {}}) { + void handleMessage(Map message, BuildContext context, + {Map extra = const {}}) { log('Notification Received!'); message.forEach((key, value) { log('$key: $value'); @@ -331,8 +333,8 @@ class NotificationHandler { case 'access': _showAcessNotificationModal(message, context); break; - case 'mensagem': - _showMessageNotificationDialog(message, context, extra); + case 'mensagem': + _showMessageNotificationDialog(message, context, extra); break; case 'enroll_cond': log('enroll_cond'); @@ -385,8 +387,8 @@ class NotificationHandler { ); } - void _showMessageNotificationDialog( - Map message, BuildContext context, Map extra) { + void _showMessageNotificationDialog(Map message, + BuildContext context, Map extra) { log('Showing message notification dialog'); log('Notification "message": $message'); showDialog( @@ -398,20 +400,24 @@ class NotificationHandler { child: MessageNotificationModalTemplateComponentWidget( id: message['local']['CLI_ID'].toString(), from: message['remetente'].toString(), - to: message['destinatario'].toString() == 'O' ? 'Morador' : 'Visitante', - message: extra['body'].toString().isEmpty ? 'Unknown' : extra['body'].toString(), + to: message['destinatario'].toString() == 'O' + ? 'Morador' + : 'Visitante', + message: extra['body'].toString().isEmpty + ? 'Unknown' + : extra['body'].toString(), ), ); }, ); } - void _showVisitRequestDialog( Map message, BuildContext context) { log('Showing visit request notification dialog'); showDialog( context: context, + barrierDismissible: true, builder: (BuildContext context) { _getIdBasedOnUserType(message); return Dialog( @@ -424,6 +430,22 @@ class NotificationHandler { vteUUID: message['idVisitante'].toString(), vawRef: message['referencia'].toString(), vawStatus: 'S', + labelsHashMap: Map.from({ + 'key': message['documento'], + 'value': 'E', + }), + imageHashMap: Map.from({ + 'key': message['documento'], + 'value': 'E', + }), + statusHashMap: [ + { + FFLocalizations.of(context).getVariableText( + enText: 'Pending', + ptText: 'Pendente', + ): FlutterFlowTheme.of(context).primary, + }, + ], changeStatusAction: changeStatusAction, ), ); @@ -448,6 +470,4 @@ class PushNotificationManager { void dispose() { _onMessageReceivedController.close(); } - - -} \ No newline at end of file +} diff --git a/lib/components/molecular_components/throw_exception/throw_exception_widget.dart b/lib/components/molecular_components/throw_exception/throw_exception_widget.dart index 9f037c96..27187afb 100644 --- a/lib/components/molecular_components/throw_exception/throw_exception_widget.dart +++ b/lib/components/molecular_components/throw_exception/throw_exception_widget.dart @@ -93,7 +93,6 @@ class _ThrowExceptionWidgetState extends State case EnumThrowException.success: return FFLocalizations.of(context) .getVariableText(ptText: "Sucesso ;)", enText: "Success ;)"); - ; } } 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 a1e4cfc6..fd8b4c48 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 @@ -12,8 +12,6 @@ export 'card_item_template_component_model.dart'; /// - - class CardItemTemplateComponentWidget extends StatefulWidget { const CardItemTemplateComponentWidget({ super.key, @@ -25,7 +23,7 @@ class CardItemTemplateComponentWidget extends StatefulWidget { final Map? labelsHashMap; final List?> statusHashMap; - final Map imageHashMap; + final Map imageHashMap; final Future Function()? onTapCardItemAction; @override @@ -40,7 +38,9 @@ class _CardItemTemplateComponentWidgetState LinkedHashMap.from(widget.labelsHashMap ?? {}); List> get statusLinkedHashMap => - widget.statusHashMap.map((map) => LinkedHashMap.from(map ?? {})).toList(); + widget.statusHashMap + .map((map) => LinkedHashMap.from(map ?? {})) + .toList(); @override void setState(VoidCallback callback) { @@ -74,9 +74,14 @@ 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, @@ -89,7 +94,7 @@ class _CardItemTemplateComponentWidgetState padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), child: Card( clipBehavior: Clip.antiAliasWithSaveLayer, - color: FlutterFlowTheme.of(context).secondaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, elevation: 5.0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), @@ -98,7 +103,7 @@ class _CardItemTemplateComponentWidgetState width: 350.0, height: 115.0, decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).secondaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, ), child: Row( mainAxisSize: MainAxisSize.max, @@ -106,27 +111,27 @@ class _CardItemTemplateComponentWidgetState children: [ Expanded( child: Container( - width: 100.0, - height: 100.0, + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, decoration: const BoxDecoration(), - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: labelsLinkedHashMap.length, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (context, index) { - String key = - labelsLinkedHashMap.keys.elementAt(index); - String value = labelsLinkedHashMap[key]!; - return Padding( - padding: const EdgeInsets.only(bottom: 5.0), - child: Padding( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: labelsLinkedHashMap.length, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + String key = + labelsLinkedHashMap.keys.elementAt(index); + String value = labelsLinkedHashMap[key]!; + return Padding( padding: - const EdgeInsets.fromLTRB(20, 0, 0, 0), + const EdgeInsets.fromLTRB(20, 0, 0, 5), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: @@ -157,68 +162,80 @@ class _CardItemTemplateComponentWidgetState const SizedBox( width: 5.0), // Espaçamento entre o label e o valor - Text( - value, - 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), - ), + Flexible( + child: Text( + value, + overflow: TextOverflow.ellipsis, + 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), + ), + ), ), ], ), - ), - ); - }, + ); + }, + ), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: statusLinkedHashMap.expand((linkedHashMap) { - return linkedHashMap.entries.map((MapEntry item) { - return Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 1.0, vertical: 3.0), - child: Container( - width: 100.0, - height: 27.0, - decoration: BoxDecoration( - color: item.value, // Usa a cor do item atual - borderRadius: BorderRadius.circular(5.0), - ), - child: Align( - alignment: Alignment.center, - child: Text( - item.key, // Usa a chave do item atual como texto - style: TextStyle( - color: FlutterFlowTheme.of(context).info, // Ajuste conforme necessário + Row( + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: + statusLinkedHashMap.expand((linkedHashMap) { + return linkedHashMap.entries + .map((MapEntry item) { + return Container( + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 1.0, vertical: 3.0), + child: Container( + width: 100.0, + height: 27.0, + decoration: BoxDecoration( + color: item + .value, // Usa a cor do item atual + borderRadius: + BorderRadius.circular(5.0), + ), + child: Align( + alignment: Alignment.center, + child: Text( + item.key, // Usa a chave do item atual como texto + style: TextStyle( + color: FlutterFlowTheme.of( + context) + .info, // Ajuste conforme necessário + ), ), ), ), ), - ), - ], - ), - ); - }).toList(); - }).toList(), - ), - ]), + ], + ), + ); + }).toList(); + }).toList(), + ), + ]), + ), ), ), Padding( @@ -226,18 +243,19 @@ class _CardItemTemplateComponentWidgetState 10.0, 10.0, 10.0, 10.0), child: ClipRRect( borderRadius: BorderRadius.circular(22.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=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', - 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', - 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', + child: AspectRatio( + aspectRatio: + 1.0, // Define a proporção desejada (1:1 neste caso) + child: CachedNetworkImage( + fadeInDuration: const Duration(milliseconds: 500), + fadeOutDuration: const Duration(milliseconds: 500), + imageUrl: + 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', + fit: BoxFit.cover, ), - fit: BoxFit.cover, ), ), - ), + ) ], ), ), @@ -245,4 +263,4 @@ class _CardItemTemplateComponentWidgetState ), ); } -} \ No newline at end of file +} 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 0b82c87a..949290cb 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 @@ -131,10 +131,10 @@ class _ViewVisitDetailWidgetState extends State { context.watch(); return Padding( - padding: const EdgeInsetsDirectional.fromSTEB(0.0, 35.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 200.0, 0.0, 0.0), child: Container( - width: double.infinity, - height: double.infinity, + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height, decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primaryBackground, borderRadius: const BorderRadius.only( @@ -264,6 +264,10 @@ class _ViewVisitDetailWidgetState extends State { focusNode: _model.textFieldFocusNode1, autofocus: false, obscureText: false, + showCursor: false, + enabled: false, + cursorColor: FlutterFlowTheme.of(context).primary, + readOnly: true, decoration: InputDecoration( labelText: FFLocalizations.of(context).getText( '9yu35pzg' /* Encerramento da Visita */, @@ -348,6 +352,10 @@ class _ViewVisitDetailWidgetState extends State { focusNode: _model.textFieldFocusNode2, autofocus: false, obscureText: false, + showCursor: false, + enabled: false, + cursorColor: FlutterFlowTheme.of(context).primary, + readOnly: true, decoration: InputDecoration( labelText: FFLocalizations.of(context).getText( 'aj6scczp' /* Início */, @@ -436,6 +444,10 @@ class _ViewVisitDetailWidgetState extends State { focusNode: _model.textFieldFocusNode3, autofocus: false, obscureText: false, + showCursor: false, + enabled: false, + cursorColor: FlutterFlowTheme.of(context).primary, + readOnly: true, decoration: InputDecoration( labelText: FFLocalizations.of(context).getText( 'rvi5z7wg' /* Término */, @@ -534,6 +546,10 @@ class _ViewVisitDetailWidgetState extends State { focusNode: _model.textFieldFocusNode4, autofocus: false, obscureText: false, + showCursor: false, + enabled: false, + cursorColor: FlutterFlowTheme.of(context).primary, + readOnly: true, decoration: InputDecoration( labelText: FFLocalizations.of(context).getText( 'yxilg7ek' /* Motivo da Visita */, @@ -622,6 +638,10 @@ class _ViewVisitDetailWidgetState extends State { focusNode: _model.textFieldFocusNode5, autofocus: false, obscureText: false, + showCursor: false, + enabled: false, + cursorColor: FlutterFlowTheme.of(context).primary, + readOnly: true, decoration: InputDecoration( labelText: FFLocalizations.of(context).getText( 'dgr3pk3a' /* Nível de Acesso */, @@ -714,6 +734,10 @@ class _ViewVisitDetailWidgetState extends State { focusNode: _model.textFieldFocusNode6, autofocus: false, obscureText: false, + showCursor: false, + enabled: false, + cursorColor: FlutterFlowTheme.of(context).primary, + readOnly: true, decoration: InputDecoration( labelText: FFLocalizations.of(context).getText( 'lppn9rxa' /* Observações da Visita */, @@ -785,178 +809,153 @@ class _ViewVisitDetailWidgetState extends State { ], ), ), - Align( - alignment: const AlignmentDirectional(0.0, 1.0), - child: Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(0.0, 6.0, 0.0, 0.0), - child: Container( - width: double.infinity, - height: 35.0, - decoration: BoxDecoration( - color: widget.visitStatusColor, - borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(0.0), - bottomRight: Radius.circular(0.0), - topLeft: Radius.circular(0.0), - topRight: Radius.circular(0.0), - ), - ), - child: Builder( - builder: (context) { - if (widget.visitStatusStr == 'A') { - return Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - FlutterFlowIconButton( - borderRadius: 20.0, - borderWidth: 1.0, - buttonSize: 40.0, - icon: Icon( - Icons.block_sharp, - color: FlutterFlowTheme.of(context) - .primaryBackground, - size: 24.0, - ), - onPressed: () async { - _model.deleteVisit = - await PhpGroup.deleteVisitCall.call( - devUUID: FFAppState().devUUID, - userUUID: FFAppState().userUUID, - cliID: FFAppState().cliUUID, - atividade: 'cancelaVisita', - idVisita: widget.visitIdStr, - ); + Builder( + builder: (context) { + if (widget.visitStatusStr == 'A') { + return Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + FlutterFlowIconButton( + borderRadius: 20.0, + borderWidth: 1.0, + buttonSize: 40.0, + // fillColor: widget.visitStatusColor, + icon: Icon( + Icons.block_sharp, + color: FlutterFlowTheme.of(context).error, + size: 24.0, + ), + onPressed: () async { + _model.deleteVisit = + await PhpGroup.deleteVisitCall.call( + devUUID: FFAppState().devUUID, + userUUID: FFAppState().userUUID, + cliID: FFAppState().cliUUID, + atividade: 'cancelaVisita', + idVisita: widget.visitIdStr, + ); - if (PhpGroup.deleteVisitCall.error( - (_model.deleteVisit?.jsonBody ?? ''), - ) == - false) { - Navigator.pop(context); - } else { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, - context: context, - builder: (context) { - return Padding( - padding: - MediaQuery.viewInsetsOf(context), - child: ThrowExceptionWidget( - msg: PhpGroup.deleteVisitCall.msg( - (_model.deleteVisit?.jsonBody ?? - ''), - )!, - ), - ); - }, - ).then((value) => safeSetState(() {})); - } - - setState(() {}); - }, - ), - FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 20.0, - borderWidth: 1.0, - buttonSize: 40.0, - icon: Icon( - Icons.share, - color: FlutterFlowTheme.of(context) - .primaryBackground, - 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}.', - ); - }, - ), - ], - ); - } else if ((widget.visitStatusStr == 'C') || - (widget.visitStatusStr == 'F') || - (widget.visitStatusStr == 'B') || - (widget.visitStatusStr == 'I')) { - return InkWell( - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onTap: () async { + if (PhpGroup.deleteVisitCall.error( + (_model.deleteVisit?.jsonBody ?? ''), + ) == + false) { Navigator.pop(context); - - context.pushNamed( - 'scheduleCompleteVisitPage', - queryParameters: { - 'visitStartDateStr': serializeParam( - dateTimeFormat( - 'd/M/y H:mm:ss', - getCurrentTimestamp, - locale: FFLocalizations.of(context) - .languageCode, + } else { + await showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + enableDrag: false, + context: context, + builder: (context) { + return Padding( + padding: MediaQuery.viewInsetsOf(context), + child: ThrowExceptionWidget( + msg: PhpGroup.deleteVisitCall.msg( + (_model.deleteVisit?.jsonBody ?? ''), + )!, ), - ParamType.String, - ), - 'visitEndDateStr': serializeParam( - '', - ParamType.String, - ), - 'visitReasonStr': serializeParam( - widget.visitReasonStr, - ParamType.String, - ), - 'visitLevelStr': serializeParam( - widget.visitLevelStr, - ParamType.String, - ), - 'visitTempBol': serializeParam( - widget.visitTempStr == 'Sim' ? true : false, - ParamType.bool, - ), - 'visitObsStr': serializeParam( - widget.visitObsStr, - ParamType.String, - ), - 'visitorStrList': serializeParam( - widget.visitorStrList, - ParamType.String, - ), - 'visitorJsonList': serializeParam( - filteredVisitorJsonList, - ParamType.JSON, - isList: true, - ), - }.withoutNulls, - ); - }, - child: Icon( - Icons.repeat, - color: FlutterFlowTheme.of(context).secondaryText, - size: 24.0, + ); + }, + ).then((value) => safeSetState(() {})); + } + + setState(() {}); + }, + ), + FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 20.0, + borderWidth: 1.0, + buttonSize: 40.0, + icon: Icon( + Icons.share, + color: FlutterFlowTheme.of(context).accent1, + 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}.', + ); + }, + ), + ], + ); + } else if ((widget.visitStatusStr == 'C') || + (widget.visitStatusStr == 'F') || + (widget.visitStatusStr == 'B') || + (widget.visitStatusStr == 'I')) { + return InkWell( + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: () async { + Navigator.pop(context); + + context.pushNamed( + 'scheduleCompleteVisitPage', + queryParameters: { + 'visitStartDateStr': serializeParam( + dateTimeFormat( + 'd/M/y H:mm:ss', + getCurrentTimestamp, + locale: FFLocalizations.of(context).languageCode, + ), + ParamType.String, ), - ); - } else { - return Container( - width: 100.0, - height: 100.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context) - .secondaryBackground, + 'visitEndDateStr': serializeParam( + '', + ParamType.String, ), - ); - } + 'visitReasonStr': serializeParam( + widget.visitReasonStr, + ParamType.String, + ), + 'visitLevelStr': serializeParam( + widget.visitLevelStr, + ParamType.String, + ), + 'visitTempBol': serializeParam( + widget.visitTempStr == 'Sim' ? true : false, + ParamType.bool, + ), + 'visitObsStr': serializeParam( + widget.visitObsStr, + ParamType.String, + ), + 'visitorStrList': serializeParam( + widget.visitorStrList, + ParamType.String, + ), + 'visitorJsonList': serializeParam( + filteredVisitorJsonList, + ParamType.JSON, + isList: true, + ), + }.withoutNulls, + ); }, - ), - ), - ), + child: Icon( + Icons.repeat, + color: widget.visitStatusColor, + size: 24.0, + ), + ); + } else { + return Container( + width: 100.0, + height: 100.0, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primaryBackground, + ), + ); + } + }, ), - ], + ].addToEnd(const SizedBox(height: 5.0)), ), ), ); diff --git a/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart b/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart index a5e922e8..2020de23 100644 --- a/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart +++ b/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart'; import 'package:hub/components/templates_components/view_visit_detail/view_visit_detail_widget.dart'; @@ -71,6 +73,23 @@ class _VisitDetailsModalTemplateComponentWidgetState @override Widget build(BuildContext context) { + log('------------------ VisitDetailsModalTemplateComponentWidget ------------------'); + log('visitStatusStr: ${widget.visitStatusStr}'); + log('visitStartDateStr: ${widget.visitStartDateStr}'); + log('visitEndDateStr: ${widget.visitEndDateStr}'); + log('visitReasonStr: ${widget.visitReasonStr}'); + log('visitLevelStr: ${widget.visitLevelStr}'); + log('visitTempStr: ${widget.visitTempStr}'); + log('visitObsStr: ${widget.visitObsStr}'); + log('visitorStrList: ${widget.visitorStrList}'); + log('visitorJsonList: ${widget.visitorJsonList}'); + log('visitorImgPath: ${widget.visitorImgPath}'); + log('visitorImgList: ${widget.visitorImgList}'); + log('visitIdStr: ${widget.visitIdStr}'); + log('updateToggleIdx: ${widget.updateToggleIdx}'); + log('repeatVisitSchedule: ${widget.repeatVisitSchedule}'); + log('visitStatusColor: ${widget.visitStatusColor}'); + log('-----------------------------------------------------------------------------'); return Builder( builder: (context) { if (widget.visitStatusStr != null && widget.visitStatusStr != '') { diff --git a/lib/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart b/lib/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart index faae71ee..a95cf428 100644 --- a/lib/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart +++ b/lib/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart @@ -1,3 +1,6 @@ +import 'dart:collection'; +import 'dart:developer'; + import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -8,11 +11,9 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:provider/provider.dart'; - - class VisitRequestTemplateComponentWidget extends StatefulWidget { const VisitRequestTemplateComponentWidget({ - super.key, + Key? key, required this.vteName, required this.vteReason, required this.vteMsg, @@ -27,8 +28,17 @@ class VisitRequestTemplateComponentWidget extends StatefulWidget { required this.vawStatus, this.vawDate, this.changeStatusAction, + required this.labelsHashMap, + required this.statusHashMap, + required this.imageHashMap, + this.onTapCardItemAction, }); + final Map labelsHashMap; + final List?> statusHashMap; + final Map imageHashMap; + final Future Function()? onTapCardItemAction; + final String? vteName; final String? vteReason; final String? vteMsg; @@ -60,6 +70,14 @@ class _VisitRequestTemplateComponentWidgetState extends State { late VisitRequestTemplateComponentModel _model; + LinkedHashMap get labelsLinkedHashMap => + LinkedHashMap.from(widget.labelsHashMap ?? {}); + + List> get statusLinkedHashMap => + widget.statusHashMap + .map((map) => LinkedHashMap.from(map ?? {})) + .toList(); + @override void setState(VoidCallback callback) { super.setState(callback); @@ -102,738 +120,160 @@ class _VisitRequestTemplateComponentWidgetState Widget build(BuildContext context) { context.watch(); bool isLoaded = false; + log('------------------ VisitRequestTemplateComponentWidget ------------------'); + log('vteName: ${widget.imageHashMap}'); + log('Teste: ${statusLinkedHashMap.expand((linkedHashMap) { + return [ + linkedHashMap.entries + .map((MapEntry item) => item.key) + .first + ]; + }).first}'); + log('-------------------------------------------------------------------------'); + 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 Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB(10.0, 0.0, 10.0, 0.0), - child: Container( - width: MediaQuery.sizeOf(context).width * 0.9, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primaryBackground, - borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(25.0), - bottomRight: Radius.circular(25.0), - topLeft: Radius.circular(25.0), - topRight: Radius.circular(25.0), + return LayoutBuilder( + builder: (context, constraints) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Container( + width: constraints.maxWidth, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primaryBackground, + borderRadius: const BorderRadius.all(Radius.circular(25.0)), ), - ), - child: SingleChildScrollView( - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Column( - mainAxisSize: MainAxisSize.max, - children: [ - Container( - width: 150.0, - height: 150.0, - clipBehavior: Clip.antiAlias, - decoration: const BoxDecoration( - shape: BoxShape.circle, - ), - child: CachedNetworkImage( - fadeInDuration: const Duration(milliseconds: 100), - fadeOutDuration: const Duration(milliseconds: 100), - imageUrl: valueOrDefault( - // 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.vteDocument}&tipo=E', - 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.vteDocument != null ? widget.vteDocument : widget.vteUUID}&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, - ), - ), - // Container( - // width: 153.0, - // height: 25.0, - // decoration: BoxDecoration( - // color: () { - // if (widget.vawStatus == 'L') { - // return FlutterFlowTheme.of(context).primary; - // } else if (widget.vawStatus == 'B') { - // return FlutterFlowTheme.of(context).error; - // } else if (widget.vawStatus == 'S') { - // return FlutterFlowTheme.of(context).warning; - // } else { - // return FlutterFlowTheme.of(context).warning; - // } - // }(), - // borderRadius: BorderRadius.circular(16.0), - // ), - // child: Align( - // alignment: const AlignmentDirectional(0.0, 0.0), - // child: Text( - // () { - // if (widget.vawStatus == 'L') { - // return FFLocalizations.of(context) - // .getVariableText( - // ptText: 'Ativo', - // enText: 'Active', - // ); - // } else if (widget.vawStatus == 'B') { - // return FFLocalizations.of(context) - // .getVariableText( - // ptText: 'Bloqueado', - // enText: 'Blocked', - // ); - // } else { - // return FFLocalizations.of(context) - // .getVariableText( - // ptText: 'Pendente', - // enText: 'Pending', - // ); - // } - // }(), - // style: FlutterFlowTheme.of(context) - // .bodyMedium - // .override( - // fontFamily: FlutterFlowTheme.of(context) - // .bodyMediumFamily, - // letterSpacing: 0.0, - // useGoogleFonts: GoogleFonts.asMap() - // .containsKey( - // FlutterFlowTheme.of(context) - // .bodyMediumFamily), - // ), - // ), - // ), - // ), - ].divide(const SizedBox(height: 5.0)), + child: SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + const SizedBox(height: 20.0), + Container( + width: 150.0, + height: 150.0, + clipBehavior: Clip.antiAlias, + decoration: const BoxDecoration( + shape: BoxShape.circle, ), - ] - .addToStart(const SizedBox(width: 10.0)) - .addToEnd(const SizedBox(width: 10.0)), - ), - // Padding( - // padding: const EdgeInsetsDirectional.fromSTEB( - // 24.0, 0.0, 24.0, 0.0), - // child: TextFormField( - // controller: _model.textController1, - // focusNode: _model.textFieldFocusNode1, - // autofocus: false, - // textInputAction: TextInputAction.next, - // readOnly: true, - // obscureText: false, - // decoration: InputDecoration( - // labelText: FFLocalizations.of(context).getText( - // 'ivfw4j04' /* Nome */, - // ), - // labelStyle: FlutterFlowTheme.of(context) - // .labelMedium - // .override( - // fontFamily: - // FlutterFlowTheme.of(context).labelMediumFamily, - // color: FlutterFlowTheme.of(context).primaryText, - // letterSpacing: 0.0, - // useGoogleFonts: GoogleFonts.asMap().containsKey( - // FlutterFlowTheme.of(context).labelMediumFamily), - // ), - // hintStyle: FlutterFlowTheme.of(context) - // .labelMedium - // .override( - // fontFamily: - // FlutterFlowTheme.of(context).labelMediumFamily, - // color: FlutterFlowTheme.of(context).primaryText, - // letterSpacing: 0.0, - // useGoogleFonts: GoogleFonts.asMap().containsKey( - // FlutterFlowTheme.of(context).labelMediumFamily), - // ), - // enabledBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).accent1, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // focusedBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).primary, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // errorBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).error, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // focusedErrorBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).error, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // suffixIcon: Icon( - // Icons.person, - // color: FlutterFlowTheme.of(context).accent1, - // ), - // ), - // style: FlutterFlowTheme.of(context).bodyMedium.override( - // fontFamily: - // FlutterFlowTheme.of(context).bodyMediumFamily, - // color: FlutterFlowTheme.of(context).primaryText, - // letterSpacing: 0.0, - // useGoogleFonts: GoogleFonts.asMap().containsKey( - // FlutterFlowTheme.of(context).bodyMediumFamily), - // ), - // maxLines: null, - // keyboardType: TextInputType.name, - // validator: - // _model.textController1Validator.asValidator(context), - // ), - // ), - // Padding( - // padding: const EdgeInsetsDirectional.fromSTEB( - // 24.0, 0.0, 24.0, 0.0), - // child: TextFormField( - // controller: _model.textController2, - // focusNode: _model.textFieldFocusNode2, - // autofocus: false, - // textInputAction: TextInputAction.next, - // readOnly: true, - // obscureText: false, - // decoration: InputDecoration( - // labelText: FFLocalizations.of(context).getText( - // 'ndzkqehm' /* Motivo */, - // ), - // labelStyle: FlutterFlowTheme.of(context) - // .labelMedium - // .override( - // fontFamily: - // FlutterFlowTheme.of(context).labelMediumFamily, - // color: FlutterFlowTheme.of(context).primaryText, - // letterSpacing: 0.0, - // useGoogleFonts: GoogleFonts.asMap().containsKey( - // FlutterFlowTheme.of(context).labelMediumFamily), - // ), - // hintStyle: FlutterFlowTheme.of(context) - // .labelMedium - // .override( - // fontFamily: - // FlutterFlowTheme.of(context).labelMediumFamily, - // color: FlutterFlowTheme.of(context).primaryText, - // letterSpacing: 0.0, - // useGoogleFonts: GoogleFonts.asMap().containsKey( - // FlutterFlowTheme.of(context).labelMediumFamily), - // ), - // enabledBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).accent1, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // focusedBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).primary, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // errorBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).error, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // focusedErrorBorder: OutlineInputBorder( - // borderSide: BorderSide( - // color: FlutterFlowTheme.of(context).error, - // width: 0.5, - // ), - // borderRadius: BorderRadius.circular(10.0), - // ), - // suffixIcon: Icon( - // Icons.history_edu, - // color: FlutterFlowTheme.of(context).accent1, - // ), - // ), - // style: FlutterFlowTheme.of(context).bodyMedium.override( - // fontFamily: - // FlutterFlowTheme.of(context).bodyMediumFamily, - // color: FlutterFlowTheme.of(context).primaryText, - // letterSpacing: 0.0, - // useGoogleFonts: GoogleFonts.asMap().containsKey( - // FlutterFlowTheme.of(context).bodyMediumFamily), - // ), - // maxLines: null, - // keyboardType: TextInputType.name, - // validator: - // _model.textController2Validator.asValidator(context), - // ), - // ), - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - child: TextFormField( - // controller: _model.textControllerStatus, - // focusNode: _model.textFieldFocusNodeStatus, - autofocus: false, - canRequestFocus: false, - readOnly: true, - obscureText: false, - decoration: InputDecoration( - isDense: true, - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.circular(10.0)), - filled: true, - fillColor: () { - if (widget.vawStatus == 'L') { - return FlutterFlowTheme.of(context).primary; - } else if (widget.vawStatus == 'B') { - return FlutterFlowTheme.of(context).error; - } else if (widget.vawStatus == 'S') { - return FlutterFlowTheme.of(context).warning; - } else { - return FlutterFlowTheme.of(context).warning; - } - }(), - labelText: () { - if (widget.vawStatus == 'L') { - return FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active', - ); - } else if (widget.vawStatus == 'B') { - return FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked', - ); - } else { - return FFLocalizations.of(context).getVariableText( - ptText: 'Pendente', - enText: 'Pending', - ); - } - }(), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), - ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), - ), - focusedBorder: InputBorder.none, - errorBorder: InputBorder.none, - focusedErrorBorder: InputBorder.none, - suffixIcon: Icon( - Icons.info, - color: FlutterFlowTheme.of(context).accent1, - ), - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - textAlign: TextAlign.start, - maxLines: null, - keyboardType: TextInputType.name, - validator: - _model.textController1Validator.asValidator(context), - ), - ), - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - child: TextFormField( - controller: _model.textController1, - focusNode: _model.textFieldFocusNode1, - autofocus: false, - textInputAction: TextInputAction.next, - readOnly: true, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - 'ivfw4j04' /* Nome */, - ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), - ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), - ), - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - errorBorder: InputBorder.none, - focusedErrorBorder: InputBorder.none, - suffixIcon: Icon( - Icons.person, - color: FlutterFlowTheme.of(context).accent1, - ), - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - textAlign: TextAlign.start, - maxLines: null, - keyboardType: TextInputType.name, - validator: - _model.textController1Validator.asValidator(context), - ), - ), - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - child: TextFormField( - controller: _model.textController2, - focusNode: _model.textFieldFocusNode2, - autofocus: false, - textInputAction: TextInputAction.next, - readOnly: true, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - 'ndzkqehm' /* Motivo */, - ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), - ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), - ), - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - errorBorder: InputBorder.none, - focusedErrorBorder: InputBorder.none, - suffixIcon: Icon( - Icons.history_edu, - color: FlutterFlowTheme.of(context).accent1, - ), - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - textAlign: TextAlign.start, - maxLines: null, - keyboardType: TextInputType.name, - validator: - _model.textController2Validator.asValidator(context), - ), - ), - if (widget.vawStatus != 'S') - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - child: TextFormField( - controller: _model.textController3, - focusNode: _model.textFieldFocusNode3, - autofocus: false, - textCapitalization: TextCapitalization.none, - textInputAction: TextInputAction.next, - readOnly: true, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - 'kt87omsz' /* Mensagem */, - ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - hintStyle: - FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - errorBorder: InputBorder.none, - focusedErrorBorder: InputBorder.none, - suffixIcon: Icon( - Icons.message, - color: FlutterFlowTheme.of(context).accent1, - ), - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - textAlign: TextAlign.start, - validator: - _model.textController3Validator.asValidator(context), + child: CachedNetworkImage( + fadeInDuration: const Duration(milliseconds: 100), + fadeOutDuration: const Duration(milliseconds: 100), + imageUrl: + 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', + fit: BoxFit.cover, ), ), - if (widget.vawStatus != 'S') - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - child: TextFormField( - controller: _model.textController4, - focusNode: _model.textFieldFocusNode4, - autofocus: false, - textCapitalization: TextCapitalization.none, - textInputAction: TextInputAction.next, - readOnly: true, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - 'yyni99pe' /* Data */, - ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - hintStyle: - FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - enabledBorder: InputBorder.none, - focusedBorder: InputBorder.none, - errorBorder: InputBorder.none, - focusedErrorBorder: InputBorder.none, - suffixIcon: Icon( - Icons.date_range, - color: FlutterFlowTheme.of(context).accent1, - ), - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - textAlign: TextAlign.start, - validator: - _model.textController4Validator.asValidator(context), - ), - ), - - if (widget.vawStatus == 'S') - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 20.0, 24.0, 20.0), - child: TextFormField( - controller: _model.textController5, - focusNode: _model.textFieldFocusNode5, - autofocus: false, - textInputAction: TextInputAction.next, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - 'ssz899es' /* Pergunta */, - ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).accent1, - width: 0.5, - ), - borderRadius: BorderRadius.circular(10.0), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).primary, - width: 0.5, - ), - borderRadius: BorderRadius.circular(10.0), - ), - errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 0.5, - ), - borderRadius: BorderRadius.circular(10.0), - ), - focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 0.5, - ), - borderRadius: BorderRadius.circular(10.0), - ), - suffixIcon: Icon( - Icons.question_answer, - color: FlutterFlowTheme.of(context).accent1, - ), - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - validator: - _model.textController5Validator.asValidator(context), - ), - ), - if (widget.vawStatus == 'S') + const SizedBox(height: 10.0), Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - FlutterFlowIconButton( - borderRadius: 20.0, - borderWidth: 1.0, - showLoadingIndicator: isLoaded, - buttonSize: 40.0, - fillColor: FlutterFlowTheme.of(context).error, - icon: Icon( - Icons.close, - color: FlutterFlowTheme.of(context).primaryBackground, - size: 24.0, - ), - onPressed: () async { - await widget.changeStatusAction?.call( - context, - 'B', - widget.vawRef ?? '', - _model.textController5.text, - widget.vteUUID ?? '', - ); - }, - ), - FlutterFlowIconButton( - borderRadius: 20.0, - showLoadingIndicator: isLoaded, - borderWidth: 1.0, - buttonSize: 40.0, - fillColor: FlutterFlowTheme.of(context).success, - icon: Icon( - Icons.done, - color: FlutterFlowTheme.of(context).primaryBackground, - size: 24.0, - ), - onPressed: () async { - await widget.changeStatusAction?.call( - context, - 'L', - widget.vawRef ?? '', - _model.textController5.text, - widget.vteUUID ?? '', - ); - }, - ), - ].divide(const SizedBox(width: 20.0)), + children: statusLinkedHashMap.expand((linkedHashMap) { + return linkedHashMap.entries + .map((MapEntry item) { + return Expanded( + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 24.0), + child: TextFormField( + // controller: _model.textControllerStatus, + // focusNode: _model.textFieldFocusNodeStatus, + autofocus: false, + canRequestFocus: false, + readOnly: true, + obscureText: false, + decoration: InputDecoration( + isDense: true, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + ), + filled: true, + fillColor: item.value, + labelText: item.key, + labelStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .labelMediumFamily, + color: FlutterFlowTheme.of(context) + .primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey( + FlutterFlowTheme.of(context) + .labelMediumFamily), + ), + hintStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .labelMediumFamily, + color: FlutterFlowTheme.of(context) + .primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey( + FlutterFlowTheme.of(context) + .labelMediumFamily), + ), + focusedBorder: InputBorder.none, + errorBorder: InputBorder.none, + focusedErrorBorder: InputBorder.none, + suffixIcon: Icon( + Icons.info, + color: FlutterFlowTheme.of(context).accent1, + ), + ), + style: FlutterFlowTheme.of(context) + .bodyMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .bodyMediumFamily, + color: FlutterFlowTheme.of(context) + .primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey( + FlutterFlowTheme.of(context) + .bodyMediumFamily), + ), + textAlign: TextAlign.start, + maxLines: null, + keyboardType: TextInputType.name, + validator: _model.textController1Validator + .asValidator(context), + ), + ), + ); + }).toList(); + }).toList(), ), - ] - .divide(const SizedBox(height: 10.0)) - .addToStart(const SizedBox(height: 20.0)) - .addToEnd(const SizedBox(height: 20.0)), + const SizedBox(height: 10.0), + // ListView.builder( + // shrinkWrap: true, + // itemCount: labelsLinkedHashMap.length, + // physics: const NeverScrollableScrollPhysics(), + // itemBuilder: (context, index) { + // String key = labelsLinkedHashMap.keys.elementAt(index); + // String value = labelsLinkedHashMap[key]!; + // return Text('key: $key, value: $value'); + // }, + // ), + const SizedBox(height: 20.0), + ], + ), ), ), - ), - ), + ); + }, ); } -} \ No newline at end of file +} diff --git a/lib/main.dart b/lib/main.dart index 2590c721..642f9e0b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,3 @@ - import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:hub/app_state.dart'; @@ -141,4 +140,4 @@ class _MyAppState extends State { routerConfig: _router, ); } -} \ No newline at end of file +} diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 3627c1b4..0bf40324 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -21,7 +21,6 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hub/pages/liberation_history/liberation_history_model.dart'; import 'package:provider/provider.dart'; - class LiberationHistoryWidget extends StatefulWidget { const LiberationHistoryWidget({super.key}); @@ -258,11 +257,9 @@ Widget liberationDynamicListView( .where((item) => jsonToStr(getJsonField( item, r'''$.VTE_NOME''', - )) - .toLowerCase() - .contains( - _model.textController.text.toLowerCase(), - )) + )).toLowerCase().contains( + _model.textController.text.toLowerCase(), + )) .toList() : liberationHistory; @@ -309,26 +306,28 @@ Widget liberationHistoryItemCard( 'Data:': liberationHistoryItem['NOT_DTENVIO'], 'Motivo:': liberationHistoryItem['NOT_MOTIVO'], }), - statusHashMap: [liberationHistoryItem['NOT_STATUS'] == 'L' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active', - ): FlutterFlowTheme.of(context).success, - }) - : liberationHistoryItem['NOT_STATUS'] == 'B' - ? Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked', - ): FlutterFlowTheme.of(context).error, - }) - : Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Pendente', - enText: 'Pending', - ): FlutterFlowTheme.of(context).warning, - })], + statusHashMap: [ + liberationHistoryItem['NOT_STATUS'] == 'L' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).success, + }) + : liberationHistoryItem['NOT_STATUS'] == 'B' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Bloqueado', + enText: 'Blocked', + ): FlutterFlowTheme.of(context).error, + }) + : Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Pendente', + enText: 'Pending', + ): FlutterFlowTheme.of(context).warning, + }) + ], onTapCardItemAction: () async { showModalBottomSheet( isScrollControlled: true, @@ -352,6 +351,39 @@ Widget liberationHistoryItemCard( vawUUID: liberationHistoryItem['NOT_ID'], vawName: liberationHistoryItem['NOT_NOME'], vawRef: liberationHistoryItem['NOT_ID'], + labelsHashMap: Map.from({ + 'Nome:': liberationHistoryItem['VTE_NOME'], + 'Data:': liberationHistoryItem['NOT_DTENVIO'], + 'Motivo:': liberationHistoryItem['NOT_MOTIVO'], + 'Mensagem:': liberationHistoryItem['NOT_MSGENVIO'], + // 'Resposta:': liberationHistoryItem['NOT_MSGRESPOSTA'], + }), + statusHashMap: [ + liberationHistoryItem['NOT_STATUS'] == 'L' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).success, + }) + : liberationHistoryItem['NOT_STATUS'] == 'B' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Bloqueado', + enText: 'Blocked', + ): FlutterFlowTheme.of(context).error, + }) + : Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Pendente', + enText: 'Pending', + ): FlutterFlowTheme.of(context).warning, + }) + ], + imageHashMap: Map.from({ + 'key': liberationHistoryItem['VTE_ID'], + 'value': 'E', + }), changeStatusAction: changeStatusAction, // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], ); @@ -380,4 +412,4 @@ Widget liberationHistoryItemCard( }); }, ); -} \ No newline at end of file +} 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 8d9d7d5c..7f242130 100644 --- a/lib/pages/message_history_page/message_history_page_widget.dart +++ b/lib/pages/message_history_page/message_history_page_widget.dart @@ -2,6 +2,7 @@ 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'; import 'package:hub/backend/api_requests/api_manager.dart'; @@ -171,24 +172,23 @@ Widget liberationDynamicListView( width: double.infinity, height: double.infinity, decoration: const BoxDecoration(), - child: FutureBuilder( - future: PhpGroup.getMessagesCall - .call( - devUUID: FFAppState().devUUID.toString(), - userUUID: FFAppState().userUUID.toString(), - cliID: FFAppState().cliUUID.toString(), - atividade: 'getMensagens', - pageSize: '100', - pageNumber: '1', - tipoDestino: DestIndex, - ) - .catchError((error) { - log('Error: ${error.toString()}'); - return Future.delayed(Duration(seconds: 1), () { - return Center( - child: Text('Erro ao carregar mensagens'), + child: FutureBuilder( + future: Future(() async { + try { + var response = await PhpGroup.getMessagesCall.call( + devUUID: FFAppState().devUUID.toString(), + userUUID: FFAppState().userUUID.toString(), + cliID: FFAppState().cliUUID.toString(), + atividade: 'getMensagens', + pageSize: '100', + pageNumber: '1', + tipoDestino: DestIndex, ); - }); + return response.jsonBody; + } catch (error) { + log('Error: ${error.toString()}'); + return {'mensagens': [], 'total_rows': 0}; + } }), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { @@ -203,15 +203,18 @@ Widget liberationDynamicListView( ), ); } - if (snapshot.hasError == true || snapshot.data == null) { + if (snapshot.hasError == true || + 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'), ); } - final mensagens = snapshot.data!.jsonBody['mensagens']; - final totalRows = snapshot.data!.jsonBody['total_rows']; + final mensagens = snapshot.data!['mensagens']; + final totalRows = snapshot.data!['total_rows']; if (totalRows == 0 || mensagens == null || mensagens.isEmpty) { return const Center( child: Text('Nenhuma mensagem encontrada'), @@ -225,7 +228,7 @@ Widget liberationDynamicListView( itemBuilder: (BuildContext context, int index) { return messageHistoryItem( context, - snapshot.data!.jsonBody['mensagens'][index], + snapshot.data!['mensagens'][index], ); }, ); @@ -237,72 +240,118 @@ Widget liberationDynamicListView( Widget messageHistoryItem(BuildContext context, dynamic jsonBody) { log(jsonBody.toString()); return Padding( - padding: const EdgeInsets.symmetric(horizontal: 15), - child: Card( - child: Container( - // height: 100, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.max, + padding: const EdgeInsets.symmetric(horizontal: 15), + child: Card( + color: FlutterFlowTheme.of(context).primaryBackground, + child: Container( + // height: 100, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 15.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only(left: 15.0), - child: Text( - jsonBody['MSG_DATE'].toString(), - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 10, - color: FlutterFlowTheme.of(context).customColor6, - overflow: TextOverflow.ellipsis, - ), - ), - ), - ], - ), - Row( - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 15.0), - child: Text( - jsonBody['MSG_ORIGEM_DESC'].toString(), - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 12, + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Icon( + jsonBody['MSG_DESTINO_TP'] == 'T' + ? EvaIcons.globe + : jsonBody['MSG_DESTINO_TP'] == 'P' + ? Icons.person + : Icons.home, color: FlutterFlowTheme.of(context).primary, + size: 25, ), - overflow: TextOverflow.fade, - ), + Expanded( + child: Text( + jsonBody['MSG_ORIGEM_DESC'].toString(), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 15, + color: FlutterFlowTheme.of(context).primary, + ), + overflow: TextOverflow.fade, + ), + ), + ].divide(const SizedBox(width: 10)), ), - Icon( - jsonBody['MSG_DESTINO_TP'] == 'T' - ? Icons.group - : Icons.person, - color: FlutterFlowTheme.of(context).primary, + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.history, + color: FlutterFlowTheme.of(context).customColor6, + size: 15, + ), + ), + Expanded( + child: Text( + jsonBody['MSG_DATE'].toString(), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 10, + color: + FlutterFlowTheme.of(context).customColor6, + ), + overflow: TextOverflow.ellipsis, + ), + ), + ].divide(const SizedBox(width: 15)), ), - ], + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: const EdgeInsets.only(left: 5), + child: Icon( + Icons.message, + color: FlutterFlowTheme.of(context).customColor6, + size: 15, + ), + ), + Expanded( + child: Text( + jsonBody['MSG_TEXTO'].toString(), + ), + ), + ].divide(const SizedBox(width: 15)), + ), + ].divide(const SizedBox(height: 4)), ), - ], - ), - SizedBox(height: 8), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - jsonBody['MSG_TEXTO'].toString(), ), + // Row( + // children: [ + // Icon( + // Icons.message, + // color: FlutterFlowTheme.of(context).customColor6, + // size: 15, + // ), + // Expanded( + // child: Padding( + // padding: const EdgeInsets.all(8.0), + // child: Text( + // jsonBody['MSG_TEXTO'].toString(), + // ), + // ), + // ), + // ] + // .addToStart(const SizedBox(width: 8)) + // .addToEnd(const SizedBox(width: 8))), + ].divide( + const SizedBox(height: 8), ), - SizedBox(height: 8), - ], + ), ), ), - ), - ), - ); + )); } diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index d7c05015..a27db0b9 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -45,14 +45,54 @@ class PreferencesPageModel with ChangeNotifier { ), ); }, - ).whenComplete(() => notifyListeners()); + ).then((value) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Fingerprint changed successfully', + ptText: 'Impressão digital alterada com sucesso', + ), + style: TextStyle(color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).success, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }).catchError((err, stack) { + log(err.toString()); + log(stack.toString()); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar impressão digital', + enText: 'Error changing fingerprint', + ), + style: TextStyle(color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }).whenComplete(() => notifyListeners()); } } void enablePerson(BuildContext context) { notifyListeners(); Share.share( - FFAppState().userDevUUID, + FFLocalizations.of(context).getVariableText( + ptText: + 'Este é o meu identificador de acesse: ${FFAppState().userDevUUID}', + enText: 'This is my access identifier: ${FFAppState().userDevUUID}', + ), ); } @@ -66,7 +106,24 @@ class PreferencesPageModel with ChangeNotifier { atividade: 'updVisitado', notifica: FFAppState().notify ? 'S' : 'N', ) - .catchError((err) { + .then((value) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Notificação alterada com sucesso', + enText: 'Notification changed successfully', + ), + style: TextStyle(color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).success, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }).catchError((err) { log(err.toString()); ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -89,151 +146,406 @@ class PreferencesPageModel with ChangeNotifier { } void localUnlink(BuildContext context) { - PhpGroup.resopndeVinculo - .call( - userUUID: FFAppState().userUUID, - devUUID: FFAppState().devUUID, - cliID: FFAppState().cliUUID, - tarefa: 'I', - ) - .catchError((err) { - log(err.toString()); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( + showDialog( + context: context, + builder: (context) { + return AlertDialog( + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + title: Text( FFLocalizations.of(context).getVariableText( - enText: 'Error unlinking device', - ptText: 'Erro ao desvincular dispositivo', + enText: 'Unlink device', + ptText: 'Desvincular dispositivo', ), - style: TextStyle(color: FlutterFlowTheme.of(context).info)), - backgroundColor: FlutterFlowTheme.of(context).error, - duration: const Duration(seconds: 3), - behavior: SnackBarBehavior.floating, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30), - ), - ), - ); - }).then( - (value) { - FFAppState().deleteCliUUID(); - FFAppState().deleteLocal(); - FFAppState().deleteOwnerUUID(); - Navigator.pop(context); - }, - ); + ), + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Are you sure you want to unlink this device?', + ptText: 'Tem certeza que deseja desvincular este dispositivo?', + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Cancel', + ptText: 'Cancelar', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).primaryText), + ), + ), + TextButton( + onPressed: () { + PhpGroup.resopndeVinculo + .call( + userUUID: FFAppState().userUUID, + devUUID: FFAppState().devUUID, + cliID: FFAppState().cliUUID, + tarefa: 'I', + ) + .catchError((err) { + log(err.toString()); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Error unlinking device', + ptText: 'Erro ao desvincular dispositivo', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }).then( + (value) { + FFAppState().deleteCliUUID(); + FFAppState().deleteLocal(); + FFAppState().deleteOwnerUUID(); + Navigator.pop(context); + Navigator.pop(context); + }, + ); + notifyListeners(); + }, + child: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Unlink', + ptText: 'Desvincular', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).primaryText), + ), + ), + ], + ); + }); notifyListeners(); } void deleteAccount(BuildContext context) { - FFAppState().deleteAll(); - FFAppState().isLogged = false; - context.goNamed( - 'welcomePage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); + showDialog( + context: context, + builder: (context) { + return AlertDialog( + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + title: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Delete account', + ptText: 'Deletar conta', + ), + ), + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Are you sure you want to delete your account?', + ptText: 'Tem certeza que deseja deletar sua conta?', + ), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Cancel', + ptText: 'Cancelar', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).primaryText), + ), + ), + TextButton( + onPressed: () { + PhpGroup.deleteAccount + .call( + devUUID: FFAppState().devUUID, + userUUID: FFAppState().userUUID, + ) + .then((value) { + FFAppState().deleteAll(); + FFAppState().isLogged = false; + context.goNamed( + 'welcomePage', + extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: true, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }, + ); + }).catchError((err) { + log(err.toString()); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Error deleting account', + ptText: 'Erro ao deletar conta', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }); + notifyListeners(); + }, + child: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Delete', + ptText: 'Deletar', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).primaryText), + ), + ), + ], + ); + }); + notifyListeners(); + + // PhpGroup.deleteAccount + // .call( + // devUUID: FFAppState().devUUID, + // userUUID: FFAppState().userUUID, + // ) + // .then((value) { + // FFAppState().deleteAll(); + // FFAppState().isLogged = false; + // context.goNamed( + // 'welcomePage', + // extra: { + // kTransitionInfoKey: const TransitionInfo( + // hasTransition: true, + // transitionType: PageTransitionType.scale, + // alignment: Alignment.bottomCenter, + // ), + // }, + // ); + // }).catchError((err) { + // log(err.toString()); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text( + // FFLocalizations.of(context).getVariableText( + // ptText: 'Erro ao deletar dispositivo', + // enText: 'Error deleting device', + // ), + // style: TextStyle(color: FlutterFlowTheme.of(context).info)), + // backgroundColor: FlutterFlowTheme.of(context).error, + // duration: const Duration(seconds: 3), + // behavior: SnackBarBehavior.floating, + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.circular(30), + // ), + // ), + // ); + // }); } Future togglePass(BuildContext context) async { debugPrint('pass: ${FFAppState().pass}'); - if (FFAppState().pass) { - FFAppState().pass = false; - FFAppState().deleteAccessPass(); - notifyListeners(); - } else { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - useSafeArea: true, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: PassKeyTemplateWidget( - toggleActionStatus: (key) async { - FFAppState().accessPass = key; - notifyListeners(); - debugPrint('key: $key'); - await PhpGroup.changePass - .call( - userUUID: FFAppState().userUUID, - devUUID: FFAppState().devUUID, - cliID: FFAppState().cliUUID, - atividade: 'updVisitado', - newSenha: FFAppState().accessPass, - ) - .then((value) { + // if (FFAppState().pass) { + // FFAppState().pass = false; + // FFAppState().deleteAccessPass(); + // notifyListeners(); + // } else { + await showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + useSafeArea: true, + context: context, + builder: (context) { + return Padding( + padding: MediaQuery.viewInsetsOf(context), + child: PassKeyTemplateWidget( + toggleActionStatus: (key) async { + FFAppState().accessPass = key; + notifyListeners(); + debugPrint('key: $key'); + await PhpGroup.changePass + .call( + userUUID: FFAppState().userUUID, + devUUID: FFAppState().devUUID, + cliID: FFAppState().cliUUID, + atividade: 'updVisitado', + newSenha: FFAppState().accessPass, + ) + .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; - // var error = jsonDecode(value.jsonBody['error'].toString()); - // log('${jsonDecode(value.jsonBody['error'].toString())}'); - if (jsonDecode(value.jsonBody['error'].toString()) == false) { - FFAppState().pass = true; - } else { - FFAppState().pass = false; - } - }).onError((error, StackTrace) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Access password changed successfully', + ptText: 'Senha de acesso alterada com sucesso', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).success, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de acesso', + enText: 'Error changing access password', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); FFAppState().pass = false; - log(error.toString()); - log(StackTrace.toString()); - }).whenComplete(() => notifyListeners()); - }, - ), - ); - }, - ); - } + } + }).catchError((error, StackTrace) { + FFAppState().pass = false; + log(error.toString()); + log(StackTrace.toString()); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de acesso', + enText: 'Error changing access password', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }).whenComplete(() => notifyListeners()); + }, + ), + ); + }, + ); + // } } Future togglePanic(BuildContext context) async { - if (FFAppState().panic) { - FFAppState().panic = false; - FFAppState().deletePanicPass(); - notifyListeners(); - } else { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - useSafeArea: true, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: PassKeyTemplateWidget( - toggleActionStatus: (key) async { - FFAppState().panicPass = key; - notifyListeners(); - await PhpGroup.changePass - .call( - userUUID: FFAppState().userUUID, - devUUID: FFAppState().devUUID, - cliID: FFAppState().cliUUID, - atividade: 'updVisitado', - newSenha: FFAppState().panicPass, - ) - .then((value) { + await showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + useSafeArea: true, + context: context, + builder: (context) { + return Padding( + padding: MediaQuery.viewInsetsOf(context), + child: PassKeyTemplateWidget( + toggleActionStatus: (key) async { + FFAppState().panicPass = key; + notifyListeners(); + await PhpGroup.changePanic + .call( + userUUID: FFAppState().userUUID, + devUUID: FFAppState().devUUID, + cliID: FFAppState().cliUUID, + atividade: 'updVisitado', + newSenhaPanico: FFAppState().panicPass, + ) + .then((value) { + FFAppState().panic = true; + if (jsonDecode(value.jsonBody['error'].toString()) == false) { FFAppState().panic = true; - if (jsonDecode(value.jsonBody['error'].toString()) == false) { - FFAppState().panic = true; - } else { - FFAppState().panic = false; - } - }).onError((e, s) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Panic password changed successfully', + ptText: 'Senha de pânico alterada com sucesso', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).success, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de pânico', + enText: 'Error changing panic password', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); FFAppState().panic = false; - log(e.toString()); - log(s.toString()); - }).whenComplete(() => notifyListeners()); - }, - ), - ); - }, - ); - } + } + }).catchError((e, s) { + FFAppState().panic = false; + + log(e.toString()); + log(s.toString()); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de pânico', + enText: 'Error changing panic password', + ), + style: TextStyle( + color: FlutterFlowTheme.of(context).info)), + backgroundColor: FlutterFlowTheme.of(context).error, + duration: const Duration(seconds: 3), + behavior: SnackBarBehavior.floating, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30), + ), + ), + ); + }).whenComplete(() => notifyListeners()); + }, + ), + ); + }, + ); } @override 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 20874759..dd0ed8b4 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 @@ -6,8 +6,11 @@ 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/backend/api_requests/api_calls.dart'; +import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart'; +import 'package:hub/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart'; import 'package:hub/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_widget.dart'; import 'package:hub/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart'; import 'package:hub/flutter_flow/custom_functions.dart'; @@ -1675,544 +1678,236 @@ Widget visitHistory( 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 ...'); - }, - ), - ], + child: FutureBuilder( + future: _model.visitHistory( + requestFn: () => PhpGroup.getVisitsCall.call( + devUUID: FFAppState().devUUID, + userUUID: FFAppState().userUUID, + cliID: FFAppState().cliUUID, + atividade: 'getVisitas', ), - FutureBuilder( - future: _model.visitHistory( - requestFn: () => PhpGroup.getVisitsCall.call( - devUUID: FFAppState().devUUID, - userUUID: FFAppState().userUUID, - cliID: FFAppState().cliUUID, - atividade: 'getVisitas', + ), + builder: (context, snapshot) { + // Customize what your widget looks like when it's loading. + if (!snapshot.hasData) { + return Center( + child: SizedBox( + width: 50.0, + height: 50.0, + child: SpinKitCircle( + color: FlutterFlowTheme.of(context).primary, + size: 50.0, + ), ), - ), - builder: (context, snapshot) { - // Customize what your widget looks like when it's loading. - if (!snapshot.hasData) { - return Center( - child: SizedBox( - width: 50.0, - height: 50.0, - child: SpinKitCircle( - color: FlutterFlowTheme.of(context).primary, - size: 50.0, - ), - ), - ); - } - 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) { + ); + } + 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).primaryBackground, - elevation: 5.0, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - ), - child: Container( - width: 350.0, - height: 115.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context) - .primaryBackground, - ), - 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, - ), - ), + 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: [ + visitaWrapItem['VAW_STATUS'] == 'A' + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).success, + }) + : visitaWrapItem['VAW_STATUS'] == 'F' || + visitaWrapItem['VAW_STATUS'] == 'B' || + visitaWrapItem['VAW_STATUS'] == 'C' || + visitaWrapItem['VAW_STATUS'] == 'I' + ? Map.from({ + FFLocalizations.of(context) + .getVariableText( + ptText: 'Pendente', + enText: 'Pending', + ): FlutterFlowTheme.of(context).warning, + }) + : Map.from({ + FFLocalizations.of(context) + .getVariableText( + ptText: 'Cancelado', + enText: 'Canceled', + ): FlutterFlowTheme.of(context).error, + }), + ], + onTapCardItemAction: () async { + showModalBottomSheet( + isScrollControlled: true, + isDismissible: true, + backgroundColor: Colors.transparent, + useSafeArea: true, + context: context, + builder: (context) { + 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', + labelsHashMap: Map.from({ + 'Nome:': visitaWrapItem['VTE_NOME'] ?? '', + 'Inicio:': + visitaWrapItem['VAW_DTINICIO'] ?? '', + 'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '', + }), + imageHashMap: Map.from({ + 'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '', + 'value': 'E', + }), + statusHashMap: [ + visitaWrapItem['VAW_STATUS'] == 'A' + ? Map.from({ + FFLocalizations.of(context) + .getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context) + .success, + }) + : visitaWrapItem['VAW_STATUS'] == 'F' || + visitaWrapItem['VAW_STATUS'] == + 'B' || + visitaWrapItem['VAW_STATUS'] == + 'C' || + visitaWrapItem['VAW_STATUS'] == + 'I' + ? Map.from({ + FFLocalizations.of(context) + .getVariableText( + ptText: 'Pendente', + enText: 'Pending', + ): FlutterFlowTheme.of(context) + .warning, + }) + : Map.from({ + FFLocalizations.of(context) + .getVariableText( + ptText: 'Cancelado', + enText: 'Canceled', + ): FlutterFlowTheme.of(context) + .error, + }), ], - ), - ), - ), - ); - }); - }, - ); + changeStatusAction: changeStatusAction, + // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], + ); + }, + ).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/pubspec.lock b/pubspec.lock index db941ddb..d60bd97b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -233,6 +233,14 @@ 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 8efce314..828e33cd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -29,7 +29,7 @@ dependencies: barcode_widget: 2.0.3 cached_network_image: 3.3.1 firebase_core: 3.1.0 - flutter_inappwebview: ^6.0.0 + flutter_inappwebview: ^6.0.0 webview_flutter: ^4.8.0 rxdart: ^0.27.7 collection: 1.18.0 @@ -49,6 +49,7 @@ 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 @@ -87,7 +88,7 @@ dependencies: shared_preferences_web: 2.3.0 sqflite: 2.3.3+1 synchronized: 3.1.0+1 - responsive_framework: 1.4.0 + responsive_framework: 1.4.0 timeago: 3.6.1 url_launcher: 6.3.0 url_launcher_android: 6.3.3 @@ -99,7 +100,6 @@ dependencies: video_player_platform_interface: 6.2.2 video_player_web: 2.3.1 - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.0 @@ -123,24 +123,20 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_launcher_icons: - android: 'launcher_icon' + android: "launcher_icon" ios: true web: generate: true - image_path: 'assets/images/app_launcher_icon.svg' - adaptive_icon_background: 'assets/images/adaptive_background_icon.svg' - adaptive_icon_foreground: 'assets/images/adaptive_foreground_icon.svg' - - + image_path: "assets/images/app_launcher_icon.svg" + adaptive_icon_background: "assets/images/adaptive_background_icon.svg" + adaptive_icon_foreground: "assets/images/adaptive_foreground_icon.svg" # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. @@ -158,7 +154,7 @@ flutter: - assets/rive_animations/ - assets/pdfs/ fonts: - - family: 'SF Pro' + - family: "SF Pro" fonts: - asset: assets/fonts/SFPRODISPLAYREGULAR.OTF - asset: assets/fonts/SFPRODISPLAYMEDIUM.OTF @@ -173,7 +169,6 @@ flutter: fonts: - asset: assets/fonts/menu.ttf - # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware.