diff --git a/lib/backend/push_notification/pushNotificationService.dart b/lib/backend/push_notification/pushNotificationService.dart index 563095f5..ac25aea2 100644 --- a/lib/backend/push_notification/pushNotificationService.dart +++ b/lib/backend/push_notification/pushNotificationService.dart @@ -14,8 +14,10 @@ import 'package:hub/backend/api_requests/api_calls.dart'; 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/components/templates_components/details_component/details_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:rxdart/rxdart.dart'; @@ -446,9 +448,20 @@ class NotificationHandler { vteUUID: message['idVisitante'].toString(), vawRef: message['referencia'].toString(), vawStatus: 'S', + buttons: [], labelsHashMap: Map.from({ - 'key': message['documento'], - 'value': 'E', + FFLocalizations.of(context).getVariableText( + enText: 'Visitor', + ptText: 'Visitante', + ): message['nomevisita'], + FFLocalizations.of(context).getVariableText( + enText: 'Reason', + ptText: 'Motivo', + ): message['motivo'], + FFLocalizations.of(context).getVariableText( + enText: 'Message', + ptText: 'Mensagem', + ): message['mensagem'], }), imageHashMap: Map.from({ 'key': message['documento'], @@ -459,7 +472,7 @@ class NotificationHandler { FFLocalizations.of(context).getVariableText( enText: 'Pending', ptText: 'Pendente', - ): FlutterFlowTheme.of(context).primary, + ): FlutterFlowTheme.of(context).warning, }, ], changeStatusAction: changeStatusAction, diff --git a/lib/components/templates_components/details_component/details_component_action.dart b/lib/components/templates_components/details_component/details_component_action.dart new file mode 100644 index 00000000..cb5cd657 --- /dev/null +++ b/lib/components/templates_components/details_component/details_component_action.dart @@ -0,0 +1,415 @@ +import 'package:flutter/material.dart'; +import 'package:hub/app_state.dart'; +import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; +import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; +import 'package:rxdart/rxdart.dart'; +import 'package:share_plus/share_plus.dart'; + +bool? getStatus(dynamic data) { + return data == 'A' + ? true + : data == 'F' || data == 'B' || data == 'C' || data == 'I' + ? false + : null; +} + +Widget buildDetails( + dynamic visitaWrapItem, + BuildContext context, + Future Function(BuildContext, String, String, String, String)? + changeStatusAction) { + return VisitRequestTemplateComponentWidget( + vteName: 'Lorem Ipsus', + vteReason: 'Lorem Ipsus', + vawDate: 'Lorem Ipsus', + vawStatus: 'Lorem Ipsus', + vteMsg: 'Lorem Ipsus', + vteUUID: 'Lorem Ipsus', + cliUUID: FFAppState().cliUUID, + msgUUID: 'Lorem Ipsus', + vawDestino: 'Lorem Ipsus', + vawUUID: 'Lorem Ipsus', + vawName: 'Lorem Ipsus', + vawRef: 'Lorem Ipsus', + + changeStatusAction: changeStatusAction, + buttons: [ + if (getStatus(visitaWrapItem['VAW_STATUS']) == null) // ACCEPT ACTION + FlutterFlowIconButton( + icon: const Icon(Icons.done), + onPressed: () async { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Aprovar Visita', + enText: 'Approve Visit', + ), + ), + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: + 'Você tem certeza que deseja aprovar essa visita?', + enText: 'Are you sure you want to approve this visit?', + ), + ), + backgroundColor: + FlutterFlowTheme.of(context).primaryBackground, + actions: [ + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'No', + ptText: 'Não', + ), + onPressed: () { + Navigator.pop(context); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: + FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10)), + ), + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'Yes', + ptText: 'Sim', + ), + onPressed: () async { + await changeStatusAction?.call( + context, + 'L', + visitaWrapItem['VAW_REF'] ?? '', + 'Mensagem', + visitaWrapItem['VTE_ID'] ?? '', + ); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: + FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + ], + ); + }); + }, + ), + if (getStatus(visitaWrapItem['VAW_STATUS']) == null) // REJECT ACTION + FlutterFlowIconButton( + icon: const Icon(Icons.close), + onPressed: () async { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Bloquear Visita', + enText: 'Block Visit', + ), + ), + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: + 'Você tem certeza que deseja bloquear essa visita?', + enText: 'Are you sure you want to block this visit?', + ), + ), + backgroundColor: + FlutterFlowTheme.of(context).primaryBackground, + actions: [ + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'No', + ptText: 'Não', + ), + onPressed: () { + Navigator.pop(context); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: + FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10)), + ), + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'Yes', + ptText: 'Sim', + ), + onPressed: () async { + // await changeStatusAction?.call( + // context, + // 'B', + // visitaWrapItem['VAW_REF'] ?? '', + // 'Mensagem', + // visitaWrapItem['VTE_ID'] ?? '', + // ); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: + FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + ], + ); + }); + }, + ), + if (getStatus(visitaWrapItem['VAW_STATUS']) == false) // RECALL ACTION + FlutterFlowIconButton( + icon: const Icon(Icons.refresh), + onPressed: () async { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Bloquear Visita', + enText: 'Block Visit', + ), + ), + content: Text( + FFLocalizations.of(context).getVariableText( + ptText: + 'Você tem certeza que deseja bloquear essa visita?', + enText: 'Are you sure you want to block this visit?', + ), + ), + backgroundColor: + FlutterFlowTheme.of(context).primaryBackground, + actions: [ + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'No', + ptText: 'Não', + ), + onPressed: () { + Navigator.pop(context); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: + FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10)), + ), + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'Yes', + ptText: 'Sim', + ), + onPressed: () async { + // await changeStatusAction?.call( + // context, + // 'B', + // visitaWrapItem['VAW_REF'] ?? '', + // 'Mensagem', + // visitaWrapItem['VTE_ID'] ?? '', + // ); + }, + options: FFButtonOptions( + width: 100, + height: 40, + color: FlutterFlowTheme.of(context).primaryBackground, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: + FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + ], + ); + }); + }, + ), + if (getStatus(visitaWrapItem['VAW_STATUS']) == false) // SHARE ACTION + FlutterFlowIconButton( + icon: const Icon(Icons.share), + onPressed: () async { + Share.share(r''' + Olá ${visitaWrapItem['VTE_NOME']} + Você foi convidado para ${visitaWrapItem['NAC_DESCRICAO']} + + Validade do Convite: + visitaWrapItem['VAW_DTINICIO'] + visitaWrapItem['VAW_DTFIM'] + + URL do Convite: https://visita.freaccess.com.br/${visitaWrapItem['VAW_ID']}/${visitaWrapItem['CLI_ID']}/${visitaWrapItem['VAW_CHAVE']} + '''); + }, + ), + + // if (getStatus(visitaWrapItem['VAW_STATUS']) == null) // SEND ACTION + // FlutterFlowIconButton( + // icon: const Icon(Icons.send), + // onPressed: () async { + // showDialog( + // context: context, + // builder: (context) { + // return AlertDialog( + // title: Text( + // FFLocalizations.of(context).getVariableText( + // ptText: 'Bloquear Visita', + // enText: 'Block Visit', + // ), + // ), + // content: Text( + // FFLocalizations.of(context).getVariableText( + // ptText: + // 'Você tem certeza que deseja bloquear essa visita?', + // enText: 'Are you sure you want to block this visit?', + // ), + // ), + // backgroundColor: + // FlutterFlowTheme.of(context).primaryBackground, + // actions: [ + // FFButtonWidget( + // text: FFLocalizations.of(context).getVariableText( + // enText: 'No', + // ptText: 'Não', + // ), + // onPressed: () { + // Navigator.pop(context); + // }, + // options: FFButtonOptions( + // width: 100, + // height: 40, + // color: + // FlutterFlowTheme.of(context).primaryBackground, + // textStyle: TextStyle( + // color: FlutterFlowTheme.of(context).primaryText, + // ), + // borderSide: BorderSide( + // color: FlutterFlowTheme.of(context) + // .primaryBackground, + // width: 1, + // ), + // borderRadius: BorderRadius.circular(10)), + // ), + // FFButtonWidget( + // text: FFLocalizations.of(context).getVariableText( + // enText: 'Yes', + // ptText: 'Sim', + // ), + // onPressed: () async { + // // await changeStatusAction?.call( + // // context, + // // 'B', + // // visitaWrapItem['VAW_REF'] ?? '', + // // 'Mensagem', + // // visitaWrapItem['VTE_ID'] ?? '', + // // ); + // }, + // options: FFButtonOptions( + // width: 100, + // height: 40, + // color: FlutterFlowTheme.of(context).primaryBackground, + // textStyle: TextStyle( + // color: FlutterFlowTheme.of(context).primaryText, + // ), + // borderSide: BorderSide( + // color: + // FlutterFlowTheme.of(context).primaryBackground, + // width: 1, + // ), + // borderRadius: BorderRadius.circular(10), + // ), + // ), + // ], + // ); + // }); + // }, + // ), + ], + 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: [ + getStatus(visitaWrapItem['VAW_STATUS']) == true + ? Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).success, + }) + : getStatus(visitaWrapItem['VAW_STATUS']) == null + ? 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, + }), + ], + // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], + ); +} diff --git a/lib/components/templates_components/visit_request_template_component/visit_request_template_component_model.dart b/lib/components/templates_components/details_component/details_component_model.dart similarity index 93% rename from lib/components/templates_components/visit_request_template_component/visit_request_template_component_model.dart rename to lib/components/templates_components/details_component/details_component_model.dart index a5a7eb07..765e2f2c 100644 --- a/lib/components/templates_components/visit_request_template_component/visit_request_template_component_model.dart +++ b/lib/components/templates_components/details_component/details_component_model.dart @@ -1,6 +1,5 @@ - import 'package:flutter/material.dart'; -import 'package:hub/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart'; +import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; class VisitRequestTemplateComponentModel @@ -55,4 +54,4 @@ class VisitRequestTemplateComponentModel textFieldFocusNodeStatus?.dispose(); textControllerStatus?.dispose(); } -} \ No newline at end of file +} diff --git a/lib/components/templates_components/details_component/details_component_widget.dart b/lib/components/templates_components/details_component/details_component_widget.dart new file mode 100644 index 00000000..f6576993 --- /dev/null +++ b/lib/components/templates_components/details_component/details_component_widget.dart @@ -0,0 +1,357 @@ +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'; +import 'package:hub/components/templates_components/details_component/details_component_model.dart'; +import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +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({ + Key? key, + required this.vteName, + required this.vteReason, + required this.vteMsg, + this.vteDocument, + this.cliUUID, + this.vteUUID, + this.vawName, + this.msgUUID, + this.vawRef, + this.vawUUID, + this.vawDestino, + required this.vawStatus, + this.vawDate, + this.changeStatusAction, + required this.labelsHashMap, + required this.statusHashMap, + required this.imageHashMap, + this.onTapCardItemAction, + required this.buttons, + }); + + final Map labelsHashMap; + final List?> statusHashMap; + final Map imageHashMap; + final Future Function()? onTapCardItemAction; + final List buttons; + + final String? vteName; + final String? vteReason; + final String? vteMsg; + final String? vteDocument; + final String? cliUUID; + final String? vteUUID; + final String? vawName; + final String? msgUUID; + final String? vawRef; + final String? vawUUID; + final String? vawDestino; + final String? vawStatus; + final String? vawDate; + + final Future Function( + BuildContext context, + String status, + String vawREF, + String msg, + String vteUUID, + )? changeStatusAction; + + @override + State createState() => + _VisitRequestTemplateComponentWidgetState(); +} + +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); + _model.onUpdate(); + } + + @override + void initState() { + super.initState(); + _model = createModel(context, () => VisitRequestTemplateComponentModel()); + + _model.textController1 ??= TextEditingController(text: widget.vteName); + _model.textFieldFocusNode1 ??= FocusNode(); + + _model.textController2 ??= TextEditingController(text: widget.vteReason); + _model.textFieldFocusNode2 ??= FocusNode(); + + _model.textController3 ??= TextEditingController(text: widget.vteMsg); + _model.textFieldFocusNode3 ??= FocusNode(); + + _model.textController4 ??= TextEditingController(text: widget.vawDate); + _model.textFieldFocusNode4 ??= FocusNode(); + + _model.textController5 ??= TextEditingController(); + _model.textFieldFocusNode5 ??= FocusNode(); + + _model.textControllerStatus ??= + TextEditingController(text: widget.vawStatus); + _model.textFieldFocusNodeStatus ??= FocusNode(); + } + + @override + void dispose() { + _model.maybeDispose(); + + super.dispose(); + } + + @override + Widget build(BuildContext context) { + log('VAW_STATUS: ${statusLinkedHashMap}'); + context.watch(); + bool isLoaded = false; + final pending = FFLocalizations.of(context).getVariableText( + enText: 'Pending', + ptText: 'Pendente', + ); + final active = FFLocalizations.of(context).getVariableText( + enText: 'Ativo', + ptText: 'Ativo', + ); + final canceled = FFLocalizations.of(context).getVariableText( + enText: 'Canceled', + ptText: 'Cancelado', + ); + + 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: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + 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: + 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', + fit: BoxFit.cover, + ), + ), + Row( + 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), + borderSide: BorderSide( + color: item.value, + ), + ), + filled: true, + fillColor: item.value, + labelText: item.key, + labelStyle: FlutterFlowTheme.of(context) + .labelMedium + .override( + fontFamily: FlutterFlowTheme.of(context) + .labelMediumFamily, + color: FlutterFlowTheme.of(context).info, + 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).info, + 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).info, + 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(), + ), + 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'); + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10.0, vertical: 3.0), + child: TextFormField( + readOnly: true, + initialValue: '$value', + 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, + ), + ), + decoration: InputDecoration( + labelText: key, + filled: true, + fillColor: + FlutterFlowTheme.of(context).primaryBackground, + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + 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( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10.0), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context) + .primaryBackground, // Change border color here + ), + ), + ), + ), + ); + }, + ), + if (widget.buttons.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: widget.buttons, + ), + ), + ] + .divide(const SizedBox(height: 20.0)) + .addToEnd(const SizedBox(height: 20.0)) + .addToStart(const SizedBox(height: 20.0)), + ), + ), + ); + }, + ); + } +} 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 deleted file mode 100644 index a95cf428..00000000 --- a/lib/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart +++ /dev/null @@ -1,279 +0,0 @@ -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'; -import 'package:hub/components/templates_components/visit_request_template_component/visit_request_template_component_model.dart'; -import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; -import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -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({ - Key? key, - required this.vteName, - required this.vteReason, - required this.vteMsg, - this.vteDocument, - this.cliUUID, - this.vteUUID, - this.vawName, - this.msgUUID, - this.vawRef, - this.vawUUID, - this.vawDestino, - required this.vawStatus, - this.vawDate, - this.changeStatusAction, - required this.labelsHashMap, - required this.statusHashMap, - required this.imageHashMap, - this.onTapCardItemAction, - }); - - final Map labelsHashMap; - final List?> statusHashMap; - final Map imageHashMap; - final Future Function()? onTapCardItemAction; - - final String? vteName; - final String? vteReason; - final String? vteMsg; - final String? vteDocument; - final String? cliUUID; - final String? vteUUID; - final String? vawName; - final String? msgUUID; - final String? vawRef; - final String? vawUUID; - final String? vawDestino; - final String? vawStatus; - final String? vawDate; - - final Future Function( - BuildContext context, - String status, - String vawREF, - String msg, - String vteUUID, - )? changeStatusAction; - - @override - State createState() => - _VisitRequestTemplateComponentWidgetState(); -} - -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); - _model.onUpdate(); - } - - @override - void initState() { - super.initState(); - _model = createModel(context, () => VisitRequestTemplateComponentModel()); - - _model.textController1 ??= TextEditingController(text: widget.vteName); - _model.textFieldFocusNode1 ??= FocusNode(); - - _model.textController2 ??= TextEditingController(text: widget.vteReason); - _model.textFieldFocusNode2 ??= FocusNode(); - - _model.textController3 ??= TextEditingController(text: widget.vteMsg); - _model.textFieldFocusNode3 ??= FocusNode(); - - _model.textController4 ??= TextEditingController(text: widget.vawDate); - _model.textFieldFocusNode4 ??= FocusNode(); - - _model.textController5 ??= TextEditingController(); - _model.textFieldFocusNode5 ??= FocusNode(); - - _model.textControllerStatus ??= - TextEditingController(text: widget.vawStatus); - _model.textFieldFocusNodeStatus ??= FocusNode(); - } - - @override - void dispose() { - _model.maybeDispose(); - - super.dispose(); - } - - @override - 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 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: [ - const SizedBox(height: 20.0), - 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: - 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${widget.imageHashMap['key']}&tipo=${widget.imageHashMap['value']}', - fit: BoxFit.cover, - ), - ), - const SizedBox(height: 10.0), - Row( - 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(), - ), - 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), - ], - ), - ), - ), - ); - }, - ); - } -} diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 0bf40324..005a3b6b 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -7,7 +7,7 @@ import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/backend/push_notification/pushNotificationService.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_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/details_component/details_component_widget.dart'; import 'package:hub/flutter_flow/custom_functions.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; @@ -358,6 +358,7 @@ Widget liberationHistoryItemCard( 'Mensagem:': liberationHistoryItem['NOT_MSGENVIO'], // 'Resposta:': liberationHistoryItem['NOT_MSGRESPOSTA'], }), + buttons: [], statusHashMap: [ liberationHistoryItem['NOT_STATUS'] == 'L' ? Map.from({ 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 7f242130..df268d4d 100644 --- a/lib/pages/message_history_page/message_history_page_widget.dart +++ b/lib/pages/message_history_page/message_history_page_widget.dart @@ -5,7 +5,6 @@ import 'dart:developer'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:hub/app_state.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; @@ -16,6 +15,7 @@ import 'package:hub/pages/message_history_page/message_history_page_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/shared/utils/log_util.dart'; import 'package:provider/provider.dart'; class MessageHistoryPageWidget extends StatefulWidget { @@ -31,6 +31,8 @@ class _MessageHistoryPageWidgetState extends State late MessageHistoryPageModel _model; final scaffoldKey = GlobalKey(); + int currentPage = 0; + int totalPage = 0; @override void initState() { @@ -65,13 +67,13 @@ class _MessageHistoryPageWidgetState extends State return Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - appBar: appBarMessage(context), - body: bodyMessage(context, _model), + appBar: buildAppBar(context), + body: buildBody(context, _model), ); } } -PreferredSizeWidget appBarMessage(BuildContext context) { +PreferredSizeWidget buildAppBar(BuildContext context) { return AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, automaticallyImplyLeading: false, @@ -107,7 +109,7 @@ PreferredSizeWidget appBarMessage(BuildContext context) { ); } -Widget bodyMessage(BuildContext context, MessageHistoryPageModel _model) { +Widget buildBody(BuildContext context, MessageHistoryPageModel _model) { return SafeArea( top: true, child: Column( @@ -157,16 +159,16 @@ Widget bodyMessage(BuildContext context, MessageHistoryPageModel _model) { ), Expanded( child: TabBarView(controller: _model.tabBarController, children: [ - liberationDynamicListView(context, _model, 'P'), - liberationDynamicListView(context, _model, 'A'), - liberationDynamicListView(context, _model, 'T'), + buildListView(context, _model, 'P'), + buildListView(context, _model, 'A'), + buildListView(context, _model, 'T'), ])), ].addToStart(const SizedBox(height: 0)), ), ); } -Widget liberationDynamicListView( +Widget buildListView( BuildContext context, MessageHistoryPageModel _model, String DestIndex) { return Container( width: double.infinity, @@ -174,19 +176,29 @@ Widget liberationDynamicListView( decoration: const BoxDecoration(), child: FutureBuilder( future: Future(() async { + var body = { + 'devUUID': FFAppState().devUUID.toString(), + 'userUUID': FFAppState().userUUID.toString(), + 'cliID': FFAppState().cliUUID.toString(), + 'atividade': 'getMensagens', + 'pageSize': '100', + 'pageNumber': '1', + 'tipoDestino': DestIndex.toString(), + }; 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', + devUUID: body['devUUID'], + userUUID: body['userUUID'], + cliID: body['cliID'], + atividade: body['atividade'], + pageSize: body['pageSize'], + pageNumber: body['pageNumber'], tipoDestino: DestIndex, ); return response.jsonBody; - } catch (error) { - log('Error: ${error.toString()}'); + } catch (error, stack) { + LogUtil.requestAPIFailed('processRequest.php', jsonEncode(body), + 'Mensagens não Encontradas', error, stack); return {'mensagens': [], 'total_rows': 0}; } }), @@ -226,7 +238,7 @@ Widget liberationDynamicListView( addRepaintBoundaries: true, cacheExtent: 1000.0, itemBuilder: (BuildContext context, int index) { - return messageHistoryItem( + return buildListItem( context, snapshot.data!['mensagens'][index], ); @@ -237,7 +249,7 @@ Widget liberationDynamicListView( ); } -Widget messageHistoryItem(BuildContext context, dynamic jsonBody) { +Widget buildListItem(BuildContext context, dynamic jsonBody) { log(jsonBody.toString()); return Padding( padding: const EdgeInsets.symmetric(horizontal: 15), @@ -329,24 +341,6 @@ Widget messageHistoryItem(BuildContext context, dynamic jsonBody) { ].divide(const SizedBox(height: 4)), ), ), - // 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), ), diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 87b3dae7..a7936422 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -91,7 +91,7 @@ class PreferencesPageModel with ChangeNotifier { Share.share( FFLocalizations.of(context).getVariableText( ptText: - 'Este é o meu identificador de acesse: ${FFAppState().userDevUUID}', + 'Este é o meu identificador de acesso: ${FFAppState().userDevUUID}', enText: 'This is my access identifier: ${FFAppState().userDevUUID}', ), ); diff --git a/lib/pages/qr_code_page/qr_code_page_widget.dart b/lib/pages/qr_code_page/qr_code_page_widget.dart index a6994b95..7ddd315d 100644 --- a/lib/pages/qr_code_page/qr_code_page_widget.dart +++ b/lib/pages/qr_code_page/qr_code_page_widget.dart @@ -16,7 +16,6 @@ import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/qr_code_page/qr_code_page_model.dart'; import 'package:percent_indicator/circular_percent_indicator.dart'; - import 'dart:async'; // import 'package:barcode_widget/barcode_widget.dart'; import 'package:flutter/material.dart'; @@ -27,81 +26,76 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:qr_flutter/qr_flutter.dart'; - - - class QrCodePageWidget extends StatefulWidget { const QrCodePageWidget({super.key}); - @override State createState() => _QrCodePageWidgetState(); } - - class _QrCodePageWidgetState extends State with TickerProviderStateMixin { late QrCodePageModel _model; - final scaffoldKey = GlobalKey(); final animationsMap = {}; -@override -void initState() { - super.initState(); - _model = createModel(context, () => QrCodePageModel()); + @override + void initState() { + super.initState(); + _model = createModel(context, () => QrCodePageModel()); - // On page load action. - SchedulerBinding.instance.addPostFrameCallback((_) async { - if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { - animationsMap['barcodeOnActionTriggerAnimation']!.controller.fling(); - } - }); + // On page load action. + SchedulerBinding.instance.addPostFrameCallback((_) async { + if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { + animationsMap['barcodeOnActionTriggerAnimation']!.controller.fling(); + } + }); - animationsMap.addAll({ - 'barcodeOnActionTriggerAnimation': AnimationInfo( - trigger: AnimationTrigger.onActionTrigger, - applyInitialState: true, - effectsBuilder: () => [ - VisibilityEffect(duration: 1.ms), - BlurEffect( - curve: Curves.linear, - delay: 0.0.ms, - duration: 600.0.ms, - begin: const Offset(0.0, 0.0), - end: const Offset(10.0, 10.0), - ), - ], - ), - }); - setupAnimations( - animationsMap.values.where((anim) => - anim.trigger == AnimationTrigger.onActionTrigger || - !anim.applyInitialState), - this, - ); + animationsMap.addAll({ + 'barcodeOnActionTriggerAnimation': AnimationInfo( + trigger: AnimationTrigger.onActionTrigger, + applyInitialState: true, + effectsBuilder: () => [ + VisibilityEffect(duration: 1.ms), + BlurEffect( + curve: Curves.linear, + delay: 0.0.ms, + duration: 600.0.ms, + begin: const Offset(0.0, 0.0), + end: const Offset(10.0, 10.0), + ), + ], + ), + }); + setupAnimations( + animationsMap.values.where((anim) => + anim.trigger == AnimationTrigger.onActionTrigger || + !anim.applyInitialState), + this, + ); - // // Adicionando um ouvinte de status à animação para reiniciá-la após a conclusão - // animationsMap['barcodeOnActionTriggerAnimation']?.controller.addStatusListener((status) { - // if (status == AnimationStatus.completed) { - // animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset(); - // animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward(); - // } - // }); -} - -@override -void dispose() { - // Removendo o ouvinte antes de chamar super.dispose para evitar vazamentos de memória - if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { - animationsMap['barcodeOnActionTriggerAnimation']!.controller.removeStatusListener((status) {}); + // // Adicionando um ouvinte de status à animação para reiniciá-la após a conclusão + // animationsMap['barcodeOnActionTriggerAnimation']?.controller.addStatusListener((status) { + // if (status == AnimationStatus.completed) { + // animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset(); + // animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward(); + // } + // }); + } + + @override + void dispose() { + // Removendo o ouvinte antes de chamar super.dispose para evitar vazamentos de memória + if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { + animationsMap['barcodeOnActionTriggerAnimation']! + .controller + .removeStatusListener((status) {}); + } + + super.dispose(); } - - super.dispose(); -} @override Widget build(BuildContext context) { @@ -114,46 +108,46 @@ void dispose() { } Widget buildBody(BuildContext context) { - double screenWidth = MediaQuery.of(context).size.width; - double screenHeight = MediaQuery.of(context).size.height; - double smallerDimension = screenWidth < screenHeight ? screenWidth : screenHeight; - double dimension = smallerDimension * 0.75; - double totalTimeInSeconds = 100.0; + double screenWidth = MediaQuery.of(context).size.width; + double screenHeight = MediaQuery.of(context).size.height; + double smallerDimension = + screenWidth < screenHeight ? screenWidth : screenHeight; + double dimension = smallerDimension * 0.75; + double totalTimeInSeconds = 100.0; return SafeArea( - // top: true, - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - if (_model.isAccess == true && _model.key != null) + // top: true, + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + if (_model.isAccess == true && _model.key != null) Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Use esse QR Code para acesso', - enText: 'Use this QR Code for access', - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - fontSize: 20.0, - letterSpacing: 0.0, - fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), + FFLocalizations.of(context).getVariableText( + ptText: 'Use esse QR Code para acesso', + enText: 'Use this QR Code for access', ), - Stack( - children: [ - if (_model.isAccess == true && _model.key != null) + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + fontSize: 20.0, + letterSpacing: 0.0, + fontWeight: FontWeight.bold, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).bodyMediumFamily), + ), + ), + Stack( + children: [ + if (_model.isAccess == true && _model.key != null) Align( alignment: const AlignmentDirectional(0.0, 0.0), child: InkWell( - onTap: () { - - safeSetState(() async { - _resetAnimationAndToggleAccess(); - FFAppState().fingerprint ? await _showBiometricsAuth(context) : await _showQrCodeBottomSheet(context); - }); - + onTap: () async { + safeSetState(() async { + _resetAnimationAndToggleAccess(); + }); + FFAppState().fingerprint + ? await _showBiometricsAuth(context) + : await _showQrCodeBottomSheet(context); }, child: buildQrCode( dimension: dimension, @@ -164,260 +158,268 @@ void dispose() { ), ), ), - if(_model.isAccess == false && _model.key == null) + if (_model.isAccess == false && _model.key == null) Align( alignment: const AlignmentDirectional(0, 0), child: BarcodeWidget( - data: 'Barcode', - barcode: Barcode.qrCode(), + data: 'Barcode', + barcode: Barcode.qrCode(), + width: 300.0, + height: 200.0, + color: FlutterFlowTheme.of(context).primaryText, + backgroundColor: Colors.transparent, + errorBuilder: (context, error) => const SizedBox( width: 300.0, height: 200.0, - color: FlutterFlowTheme.of(context).primaryText, - backgroundColor: Colors.transparent, - errorBuilder: (context, error) => const SizedBox( - width: 300.0, - height: 200.0, - ), - drawText: false, - ).animateOnActionTrigger( - animationsMap['barcodeOnActionTriggerAnimation']!, ), + drawText: false, + ).animateOnActionTrigger( + animationsMap['barcodeOnActionTriggerAnimation']!, + ), ), - if (_model.isAccess == false && _model.key == null) + if (_model.isAccess == false && _model.key == null) Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: InkWell( - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onLongPress: () async { - await _model.qrCodeEncoder( - context, - key: _model.key, - ); - setState(() {}); - }, - child: Container( - width: 200.0, - height: 200.0, - decoration: const BoxDecoration(), - child: Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: FFButtonWidget( - onPressed: () async { - FFAppState().fingerprint ? await _showBiometricsAuth(context) : await _showQrCodeBottomSheet(context); - }, - text: FFLocalizations.of(context).getVariableText( - ptText: 'Gerar QR Code', - enText: 'Generate QR Code', - ), - options: FFButtonOptions( - height: 40.0, - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - iconPadding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 0.0), - color: FlutterFlowTheme.of(context).primary, - textStyle: FlutterFlowTheme.of(context) - .titleSmall - .override( - fontFamily: FlutterFlowTheme.of(context) - .titleSmallFamily, - color: Colors.white, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .titleSmallFamily), - ), - elevation: 3.0, - borderSide: const BorderSide( - color: Colors.transparent, - width: 1.0, - ), - borderRadius: BorderRadius.circular(8.0), - ), + alignment: const AlignmentDirectional(0.0, 0.0), + child: InkWell( + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onLongPress: () async { + await _model.qrCodeEncoder( + context, + key: _model.key, + ); + setState(() {}); + }, + child: Container( + width: 200.0, + height: 200.0, + decoration: const BoxDecoration(), + child: Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: FFButtonWidget( + onPressed: () async { + FFAppState().fingerprint + ? await _showBiometricsAuth(context) + : await _showQrCodeBottomSheet(context); + }, + text: FFLocalizations.of(context).getVariableText( + ptText: 'Gerar QR Code', + enText: 'Generate QR Code', ), - ), - ), - ), - ), - ], - ), - if (_model.isAccess == true && _model.key != null) - Container( - width: 300.0, - decoration: const BoxDecoration(), - child: Visibility( - visible: _model.isAccess == true, - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Certifique-se de que o QRCode está visivel para o leitor', - enText: 'Make sure the QRCode is visible to the reader', - // '6z6kvmhl' /* Certifique-se de que o QRCode ... */, - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), - ), - ), - if (_model.isAccess == true && _model.key != null) - Container( - width: 250.0, - height: 80.0, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(100.0), - border: Border.all( - color: FlutterFlowTheme.of(context).primary, - ), - ), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 10.0, 0.0, 0.0, 0.0), - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Expirando QR code em', - enText: 'Expiring QR code in', - // 'wkjkxd2e' /* Trocando QR code em */, - ), - textAlign: TextAlign.center, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, - letterSpacing: 0.0, - fontWeight: FontWeight.w600, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context) - .bodyMediumFamily), - ), - ), - ), - ), - Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 20.0, 0.0), - child: StreamBuilder( - stream: getProgressValue(), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return CircularProgressIndicator(); - } else if (snapshot.hasError) { - return Text('Error: ${snapshot.error}'); - } else if (!snapshot.hasData) { - return Text('No data'); - } else { - final progress = snapshot.data!; - return CircularPercentIndicator( - percent: progress, - restartAnimation: true, - reverse: false, - radius: 30.0, - lineWidth: 7.0, - animation: true, - animateFromLastPercent: true, - onAnimationEnd: () { - _resetAnimationAndToggleAccess(); - }, - progressColor: FlutterFlowTheme.of(context).primary, - backgroundColor: FlutterFlowTheme.of(context).primaryText, - center: Text( - '${(progress * totalTimeInSeconds / 5).toStringAsFixed(1)}s', - style: FlutterFlowTheme.of(context).headlineSmall.override( - fontFamily: FlutterFlowTheme.of(context).headlineSmallFamily, - fontSize: 14.0, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineSmallFamily), - ), - ), - startAngle: 20.0, - ); - } - }, + options: FFButtonOptions( + height: 40.0, + padding: const EdgeInsetsDirectional.fromSTEB( + 24.0, 0.0, 24.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB( + 0.0, 0.0, 0.0, 0.0), + color: FlutterFlowTheme.of(context).primary, + textStyle: FlutterFlowTheme.of(context) + .titleSmall + .override( + fontFamily: FlutterFlowTheme.of(context) + .titleSmallFamily, + color: Colors.white, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context) + .titleSmallFamily), ), + elevation: 3.0, + borderSide: const BorderSide( + color: Colors.transparent, + width: 1.0, + ), + borderRadius: BorderRadius.circular(8.0), + ), + ), ), ), - ], + ), + ), + ], + ), + if (_model.isAccess == true && _model.key != null) + Container( + width: 300.0, + decoration: const BoxDecoration(), + child: Visibility( + visible: _model.isAccess == true, + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: + 'Certifique-se de que o QRCode está visivel para o leitor', + enText: 'Make sure the QRCode is visible to the reader', + // '6z6kvmhl' /* Certifique-se de que o QRCode ... */, + ), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: + FlutterFlowTheme.of(context).bodyMediumFamily, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).bodyMediumFamily), + ), ), ), - ], - ), - ); + ), + if (_model.isAccess == true && _model.key != null) + Container( + width: 250.0, + height: 80.0, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(100.0), + border: Border.all( + color: FlutterFlowTheme.of(context).primary, + ), + ), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + child: Padding( + padding: const EdgeInsetsDirectional.fromSTEB( + 10.0, 0.0, 0.0, 0.0), + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Expirando QR code em', + enText: 'Expiring QR code in', + // 'wkjkxd2e' /* Trocando QR code em */, + ), + textAlign: TextAlign.center, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: + FlutterFlowTheme.of(context).bodyMediumFamily, + letterSpacing: 0.0, + fontWeight: FontWeight.w600, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context) + .bodyMediumFamily), + ), + ), + ), + ), + Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: Padding( + padding: const EdgeInsetsDirectional.fromSTEB( + 0.0, 0.0, 20.0, 0.0), + child: StreamBuilder( + stream: getProgressValue(), + builder: (context, snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else if (!snapshot.hasData) { + return Text('No data'); + } else { + final progress = snapshot.data!; + return CircularPercentIndicator( + percent: progress, + restartAnimation: true, + reverse: false, + radius: 30.0, + lineWidth: 7.0, + animation: true, + animateFromLastPercent: true, + onAnimationEnd: () { + _resetAnimationAndToggleAccess(); + }, + progressColor: + FlutterFlowTheme.of(context).primary, + backgroundColor: + FlutterFlowTheme.of(context).primaryText, + center: Text( + '${(progress * totalTimeInSeconds / 5).toStringAsFixed(1)}s', + style: FlutterFlowTheme.of(context) + .headlineSmall + .override( + fontFamily: FlutterFlowTheme.of(context) + .headlineSmallFamily, + fontSize: 14.0, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey( + FlutterFlowTheme.of(context) + .headlineSmallFamily), + ), + ), + startAngle: 20.0, + ); + } + }, + ), + ), + ), + ], + ), + ), + ], + ), + ); } - - Future _showBiometricsAuth(BuildContext context) async { - FFAppState().checkBiometrics() - .then((value) => FFAppState().authenticateBiometric() - .then( (value) { - safeSetState(() { - if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { - animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop(); - animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse(); - } - _model.isAccess = !_model.isAccess; - _model.key = FFAppState().fingerprintPass; - }); - } )) - .onError((error, StackTrace) { - _showQrCodeBottomSheet(context); - }); - + FFAppState() + .checkBiometrics() + .then((value) => FFAppState().authenticateBiometric().then((value) { + safeSetState(() { + if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { + animationsMap['barcodeOnActionTriggerAnimation']! + .controller + .stop(); + animationsMap['barcodeOnActionTriggerAnimation']! + .controller + .reverse(); + } + _model.isAccess = !_model.isAccess; + _model.key = FFAppState().fingerprintPass; + }); + })) + .onError((error, StackTrace) { + _showQrCodeBottomSheet(context); + }); } Future _showQrCodeBottomSheet(BuildContext context) async { - await showModalBottomSheet( + await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, useSafeArea: true, context: context, builder: (context) { return GestureDetector( - onTap: () => _model - .unfocusNode.canRequestFocus - ? FocusScope.of(context) - .requestFocus(_model.unfocusNode) + onTap: () => _model.unfocusNode.canRequestFocus + ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Padding( - padding: - MediaQuery.viewInsetsOf(context), - child: - QrCodePassKeyTemplateComponentWidget( + padding: MediaQuery.viewInsetsOf(context), + child: QrCodePassKeyTemplateComponentWidget( toggleActionStatus: (key) async { log('Key: $key'); safeSetState(() { - if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { - animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop(); - animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse(); + if (animationsMap['barcodeOnActionTriggerAnimation'] != + null) { + animationsMap['barcodeOnActionTriggerAnimation']! + .controller + .stop(); + animationsMap['barcodeOnActionTriggerAnimation']! + .controller + .reverse(); } - _model.isAccess = !_model.isAccess; - _model.key = key; - }); + _model.isAccess = !_model.isAccess; + _model.key = key; + }); }, ), ), ); }, - ) - - .catchError((error) => safeSetState((){ - log('Error: $error'); - _resetAnimationAndToggleAccess(); + ).catchError((error) => safeSetState(() { + log('Error: $error'); + _resetAnimationAndToggleAccess(); })); unawaited( () async { @@ -431,50 +433,50 @@ void dispose() { } void _resetAnimationAndToggleAccess() { - safeSetState(() { - // Reinicia a animação - animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset(); - animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward(); - // Alterna o estado de acesso - _model.isAccess = !_model.isAccess; - _model.key = null; - }); -} + safeSetState(() { + // Reinicia a animação + animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset(); + animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward(); + // Alterna o estado de acesso + _model.isAccess = !_model.isAccess; + _model.key = null; + }); + } AppBar buildAppBar(BuildContext context) { return AppBar( - backgroundColor: FlutterFlowTheme.of(context).primaryBackground, - automaticallyImplyLeading: false, - leading: FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 30.0, - borderWidth: 1.0, - buttonSize: 60.0, - icon: Icon( - Icons.keyboard_arrow_left, - color: FlutterFlowTheme.of(context).primaryText, - size: 30.0, - ), - onPressed: () async { - context.pop(); - }, + backgroundColor: FlutterFlowTheme.of(context).primaryBackground, + automaticallyImplyLeading: false, + leading: FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 30.0, + borderWidth: 1.0, + buttonSize: 60.0, + icon: Icon( + Icons.keyboard_arrow_left, + color: FlutterFlowTheme.of(context).primaryText, + size: 30.0, ), - title: Text( - FFLocalizations.of(context).getText( - 'ku7jqe53' /* QR Code de Acesso */, - ), - style: FlutterFlowTheme.of(context).headlineMedium.override( - fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 16.0, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineMediumFamily), - ), + onPressed: () async { + context.pop(); + }, + ), + title: Text( + FFLocalizations.of(context).getText( + 'ku7jqe53' /* QR Code de Acesso */, ), - actions: const [], - centerTitle: true, - elevation: 0.0, - ); + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 16.0, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).headlineMediumFamily), + ), + ), + actions: const [], + centerTitle: true, + elevation: 0.0, + ); } -} \ No newline at end of file +} 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 dd0ed8b4..7253a8c6 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 @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:auto_size_text/auto_size_text.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; @@ -9,9 +7,8 @@ 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/details_component/details_component_action.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'; import 'package:hub/flutter_flow/flutter_flow_drop_down.dart'; @@ -163,6 +160,14 @@ class _ScheduleCompleteVisitPageWidgetState } } +bool? getStatus(dynamic data) { + return data == 'A' + ? true + : data == 'F' || data == 'B' || data == 'C' || data == 'I' + ? null + : false; +} + PreferredSizeWidget appBarScheduleCompleteVisit(BuildContext context) { return AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, @@ -1734,17 +1739,14 @@ Widget visitHistory( 'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '', }), statusHashMap: [ - visitaWrapItem['VAW_STATUS'] == 'A' + getStatus(visitaWrapItem['VAW_STATUS']) == true ? 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' + : getStatus(visitaWrapItem['VAW_STATUS']) == null ? Map.from({ FFLocalizations.of(context) .getVariableText( @@ -1768,71 +1770,15 @@ Widget visitHistory( 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'], + return buildDetails( + visitaWrapItem, + context, + changeStatusAction, ); }, ).then((_) { // PushNotificationManager _pushNotificationService = // PushNotificationManager(); - // _pushNotificationService.onMessageReceived // .listen((received) { // if (received.data['click_action'] == @@ -1853,7 +1799,6 @@ Widget visitHistory( // } // }); }); - // await showModalBottomSheet( // isScrollControlled: true, // backgroundColor: Colors.transparent,