diff --git a/lib/backend/push_notification/pushNotificationService.dart b/lib/backend/push_notification/pushNotificationService.dart index 09751698..537e780a 100644 --- a/lib/backend/push_notification/pushNotificationService.dart +++ b/lib/backend/push_notification/pushNotificationService.dart @@ -491,85 +491,25 @@ class NotificationHandler { 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 answersRequest.call( - context, - message['referencia'].toString(), - 'B', - 'Mensagem', - message['idVisitante'].toString(), - ); - }, - 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), - ), - ), - ], - ); - }); + showAlertDialog( + context, + FFLocalizations.of(context).getVariableText( + ptText: 'Bloquear Visita', + enText: 'Block Visit', + ), + FFLocalizations.of(context).getVariableText( + ptText: + 'Você tem certeza que deseja bloquear essa visita?', + enText: 'Are you sure you want to block this visit?', + ), () async { + await answersRequest.call( + context, + message['referencia'].toString(), + 'B', + 'Mensagem', + message['idVisitante'].toString(), + ); + }); }, ), ], diff --git a/lib/components/templates_components/details_component/details_component_action.dart b/lib/components/templates_components/details_component/details_component_action.dart index 3e3b07d7..21e7808a 100644 --- a/lib/components/templates_components/details_component/details_component_action.dart +++ b/lib/components/templates_components/details_component/details_component_action.dart @@ -1,4 +1,4 @@ -import 'dart:math'; +import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:hub/actions/actions.dart'; @@ -18,11 +18,16 @@ Widget buildDetails( BuildContext context, Future Function(BuildContext, int, int, String, String)? changeStatusAction) { + log('visitaWrapItem: ${visitaWrapItem.toString()}'); return VisitRequestTemplateComponentWidget( buttons: [ if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active) // REJECT ACTION - FlutterFlowIconButton( + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + ptText: 'Cancelar', + enText: 'Cancel', + ), icon: const Icon(Icons.close), onPressed: () async { showAlertDialog( @@ -77,6 +82,20 @@ Widget buildDetails( }); }); }, + options: FFButtonOptions( + width: 130, + height: 40, + color: FlutterFlowTheme.of(context).primaryBackground, + elevation: 0, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + // borderRadius: 12, + ), ), if (getStatus(visitaWrapItem['VAW_STATUS']) != status.active) // RECALL ACTION @@ -89,9 +108,15 @@ Widget buildDetails( onPressed: () async { Navigator.pop(context); Navigator.pop(context); + context.pushNamed( 'scheduleCompleteVisitPage', queryParameters: { + 'dropdownValue1': visitaWrapItem['MOT_DESCRICAO'], + 'dropdownValue2': serializeParam( + visitaWrapItem['NAC_DESCRICAO'], + ParamType.String, + ), 'visitorStrList': serializeParam( visitaWrapItem['VTE_DOCUMENTO'], ParamType.String, @@ -121,7 +146,11 @@ Widget buildDetails( ), if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active) // SHARE ACTION - FlutterFlowIconButton( + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + ptText: 'Reagendar', + enText: 'Reschedule', + ), icon: const Icon(Icons.share), onPressed: () async { Share.share(''' @@ -134,6 +163,20 @@ Olá, \*${visitaWrapItem['VTE_NOME']}\*! Você foi convidado para \*${visitaWrap URL do Convite: https://visita.freaccess.com.br/${visitaWrapItem['VAW_ID']}/${visitaWrapItem['CLI_ID']}/${visitaWrapItem['VAW_CHAVE']} '''); }, + options: FFButtonOptions( + width: 130, + height: 40, + color: FlutterFlowTheme.of(context).primaryBackground, + elevation: 0, + textStyle: TextStyle( + color: FlutterFlowTheme.of(context).primaryText, + ), + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primaryBackground, + width: 1, + ), + // borderRadius: 12, + ), ), ], labelsHashMap: Map.from({ diff --git a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart index 0239cf0b..b545ed9f 100644 --- a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart +++ b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart @@ -37,7 +37,7 @@ class _VisitorSearchModalTemplateComponentWidgetState late VisitorSearchModalTemplateComponentModel _model; @override - void setState(VoidCallback callback) { + safeSetState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } @@ -88,7 +88,7 @@ class _VisitorSearchModalTemplateComponentWidgetState focusNode: _model.textFieldFocusNode, onFieldSubmitted: (_) async { await addVisitor(context); - setState(() {}); + safeSetState(() {}); }, autofocus: false, textInputAction: TextInputAction.done, @@ -267,7 +267,7 @@ class _VisitorSearchModalTemplateComponentWidgetState // ), // ); // }, - // ).then((value) => safeSetState(() {})); + // ).then((value) => safeSetState(() {})); }, child: Container( width: 100.0, @@ -356,7 +356,7 @@ class _VisitorSearchModalTemplateComponentWidgetState onPressed: () async { _model.removeFromVisitors( visitorItem); - setState(() {}); + safeSetState(() {}); }, ), ], @@ -391,7 +391,7 @@ class _VisitorSearchModalTemplateComponentWidgetState ? () async { await addVisitor(context); - setState(() {}); + safeSetState(() {}); } : () async { await sendVisitors(context); @@ -437,7 +437,7 @@ class _VisitorSearchModalTemplateComponentWidgetState ], ), const SizedBox( - height: 10.0, + height: 20.0, ) ], ), @@ -456,7 +456,7 @@ class _VisitorSearchModalTemplateComponentWidgetState } Future addVisitor(BuildContext context) async { - setState(() { + safeSetState(() { _model.textController?.text = _model.textController.text; _model.textController?.selection = TextSelection.collapsed(offset: _model.textController!.text.length); @@ -470,15 +470,22 @@ class _VisitorSearchModalTemplateComponentWidgetState ); if (PhpGroup.getVisitorByDocCall.vistanteId( - (_model.getVisitorByDoc?.jsonBody ?? ''), - ) != - '0') { + (_model.getVisitorByDoc?.jsonBody ?? ''), + ) != + '0' && + PhpGroup.getVisitorByDocCall + .error((_model.getVisitorByDoc?.jsonBody ?? '')) == + false && + PhpGroup.getVisitorByDocCall + .vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != + null) { + log('visitor found: ${PhpGroup.getVisitorByDocCall.vistanteId((_model.getVisitorByDoc?.jsonBody ?? ''))}'); _model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante( (_model.getVisitorByDoc?.jsonBody ?? ''), )); - setState(() {}); + safeSetState(() {}); _model.addToDocs(_model.textController.text); - setState(() {}); + safeSetState(() {}); } else { await showAdaptiveDialog( useSafeArea: true, diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 9ad1dfcf..7389a2c8 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -53,7 +53,7 @@ class _LiberationHistoryWidgetState extends State { void onUpdate(BuildContext context) { _model.clearGetLiberationsCache(); - setState(() {}); + safeSetState(() {}); } @override @@ -338,20 +338,6 @@ Widget liberationHistoryItemCard( return Dialog( alignment: Alignment.center, child: VisitRequestTemplateComponentWidget( - // vteName: liberationHistoryItem['VTE_NOME'], - // vteReason: liberationHistoryItem['NOT_MOTIVO'], - // vawDate: liberationHistoryItem['NOT_STATUS'] == 'S' - // ? liberationHistoryItem['NOT_DTENVIO'] - // : liberationHistoryItem['NOT_DTRESPOSTA'], - // vawStatus: liberationHistoryItem['NOT_STATUS'], - // vteMsg: liberationHistoryItem['NOT_MSGENVIO'], - // vteUUID: liberationHistoryItem['VTE_ID'], - // cliUUID: FFAppState().cliUUID, - // msgUUID: liberationHistoryItem['NOT_ID'], - // vawDestino: liberationHistoryItem['NOT_DESTINO'], - // vawUUID: liberationHistoryItem['NOT_ID'], - // vawName: liberationHistoryItem['NOT_NOME'], - // vawRef: liberationHistoryItem['NOT_ID'], labelsHashMap: Map.from({ 'Nome:': liberationHistoryItem['VTE_NOME'], 'Data:': liberationHistoryItem['NOT_DTENVIO'], @@ -364,182 +350,32 @@ Widget liberationHistoryItemCard( 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 { - Navigator.pop(context); - Navigator.pop(context); - await answersRequest - .call( - context, - liberationHistoryItem['NOT_ID'] - .toString(), - 'L', - 'Mensagem', - liberationHistoryItem['VTE_ID'] - .toString(), - ) - .then((value) {}); - }, - 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 (liberationHistoryItem['NOT_STATUS'] == 'S') - 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 answersRequest.call( - context, - liberationHistoryItem['NOT_ID'] - .toString(), - 'B', - 'Mensagem', - liberationHistoryItem['VTE_ID'] - .toString(), - ); - }, - 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), - ), - ), - ], - ); - }); + Navigator.pop(context); + await answersRequest + .call( + context, + liberationHistoryItem['NOT_ID'].toString(), + 'L', + 'Mensagem', + liberationHistoryItem['VTE_ID'].toString(), + ) + .then((value) { + if (value) { + return showSnackbar( + context, + FFLocalizations.of(context).getVariableText( + enText: 'Successfully resolved visit', + ptText: 'Visita resolvida com sucesso'), + false); + } else { + return showSnackbar( + context, + FFLocalizations.of(context).getVariableText( + enText: 'Error resolving visit', + ptText: 'Erro ao resolver visita'), + true); + } + }); }, ), ], @@ -567,9 +403,6 @@ Widget liberationHistoryItemCard( ], imagePath: 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${liberationHistoryItem['VTE_ID'] ?? ''}&tipo=E', - - // changeStatusAction: answersRequest, - // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], ), ); }, @@ -580,7 +413,12 @@ Widget liberationHistoryItemCard( _pushNotificationService.onMessageReceived.listen((received) { if (received.data['click_action'] == 'cancel_request') { _pushNotificationService.dispose(); - snackbar(context, opt: true); + showSnackbar( + context, + FFLocalizations.of(context).getVariableText( + enText: 'Successfully resolved visit', + ptText: 'Visita resolvida com sucesso'), + false); context.pushReplacementNamed( 'liberationHistory', extra: { 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 6a4798b2..6bcc97b4 100644 --- a/lib/pages/message_history_page/message_history_page_widget.dart +++ b/lib/pages/message_history_page/message_history_page_widget.dart @@ -20,10 +20,12 @@ class MessageHistoryPageWidget extends StatefulWidget { const MessageHistoryPageWidget({super.key}); @override - State createState() => _MessageHistoryPageWidgetState(); + State createState() => + _MessageHistoryPageWidgetState(); } -class _MessageHistoryPageWidgetState extends State with TickerProviderStateMixin { +class _MessageHistoryPageWidgetState extends State + with TickerProviderStateMixin { late MessageHistoryPageModel _model; final scaffoldKey = GlobalKey(); @@ -47,25 +49,29 @@ class _MessageHistoryPageWidgetState extends State wit _messageFuture = fetchMessage(); - _scrollController = ScrollController()..addListener(() { - if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { - _loadMore(); - } - }); + _scrollController = ScrollController() + ..addListener(() { + if (_scrollController.position.atEdge && + _scrollController.position.pixels != 0) { + _loadMore(); + } + }); - _model.tabBarController = TabController(vsync: this, length: 3, initialIndex: 0)..addListener(() { - if (_model.tabBarController?.index == 0) { - _destinyType = "P"; - } else if (_model.tabBarController?.index == 1) { - _destinyType = "A"; - } else { - _destinyType = "T"; - } + _model.tabBarController = + TabController(vsync: this, length: 3, initialIndex: 0) + ..addListener(() { + if (_model.tabBarController?.index == 0) { + _destinyType = "P"; + } else if (_model.tabBarController?.index == 1) { + _destinyType = "A"; + } else { + _destinyType = "T"; + } - _pageNumber = 1; - _messageWrap = []; - _messageFuture = fetchMessage(); - }); + _pageNumber = 1; + _messageWrap = []; + _messageFuture = fetchMessage(); + }); _model.textController ??= TextEditingController(); _model.textFieldFocusNode ??= FocusNode(); @@ -80,7 +86,7 @@ class _MessageHistoryPageWidgetState extends State wit void onUpdate(BuildContext context) { _model.clearGetLiberationsCache(); - setState(() {}); + safeSetState(() {}); } @override @@ -129,7 +135,8 @@ class _MessageHistoryPageWidgetState extends State wit return null; } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Mensagems", e, s); + LogUtil.requestAPIFailed( + "proccessRequest.php", "", "Consulta de Mensagems", e, s); setState(() { _hasData = false; _loading = false; @@ -168,12 +175,12 @@ class _MessageHistoryPageWidgetState extends State wit ptText: 'Histórico de Mensagens', ), style: FlutterFlowTheme.of(context).headlineMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 17.0, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - ), + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 17.0, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), ), actions: const [], centerTitle: true, @@ -193,12 +200,12 @@ class _MessageHistoryPageWidgetState extends State wit labelColor: FlutterFlowTheme.of(context).primaryText, unselectedLabelColor: FlutterFlowTheme.of(context).primaryText, labelStyle: FlutterFlowTheme.of(context).titleMedium.override( - fontFamily: FlutterFlowTheme.of(context).titleMediumFamily, - fontSize: 13.0, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).titleMediumFamily), - ), + fontFamily: FlutterFlowTheme.of(context).titleMediumFamily, + fontSize: 13.0, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).titleMediumFamily), + ), unselectedLabelStyle: const TextStyle(), indicatorColor: FlutterFlowTheme.of(context).primary, padding: const EdgeInsets.all(4.0), @@ -232,19 +239,16 @@ class _MessageHistoryPageWidgetState extends State wit mainAxisSize: MainAxisSize.max, children: [ Center( - child: Text( - FFLocalizations.of(context).getVariableText( + child: Text(FFLocalizations.of(context).getVariableText( ptText: "Nenhuma mensagem encontrada!", - enText: "No message found" - ) - ), + enText: "No message found")), ) ], ), ) else if (_hasData == true || _pageNumber >= 1) Expanded( - child: FutureBuilder( + child: FutureBuilder( future: _messageFuture, builder: (context, snapshot) { return ListView.builder( @@ -255,8 +259,7 @@ class _MessageHistoryPageWidgetState extends State wit itemBuilder: (context, index) { final item = _messageWrap[index]; return _item(context, item); - } - ); + }); }, ), ), @@ -280,7 +283,8 @@ class _MessageHistoryPageWidgetState extends State wit ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText( + ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, @@ -288,7 +292,6 @@ class _MessageHistoryPageWidgetState extends State wit ); } - Widget _item(BuildContext context, dynamic jsonBody) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 15), @@ -314,8 +317,8 @@ class _MessageHistoryPageWidgetState extends State wit jsonBody['MSG_DESTINO_TP'] == 'T' ? Icons.language : jsonBody['MSG_DESTINO_TP'] == 'P' - ? Icons.person - : Icons.home, + ? Icons.person + : Icons.home, color: FlutterFlowTheme.of(context).primary, size: 25, ), @@ -340,7 +343,8 @@ class _MessageHistoryPageWidgetState extends State wit padding: const EdgeInsets.only(left: 5), child: Icon( Icons.history, - color: FlutterFlowTheme.of(context).customColor6, + color: + FlutterFlowTheme.of(context).customColor6, size: 15, ), ), @@ -351,7 +355,7 @@ class _MessageHistoryPageWidgetState extends State wit fontWeight: FontWeight.bold, fontSize: 10, color: - FlutterFlowTheme.of(context).customColor6, + FlutterFlowTheme.of(context).customColor6, ), overflow: TextOverflow.ellipsis, ), @@ -366,7 +370,8 @@ class _MessageHistoryPageWidgetState extends State wit padding: const EdgeInsets.only(left: 5), child: Icon( Icons.message, - color: FlutterFlowTheme.of(context).customColor6, + color: + FlutterFlowTheme.of(context).customColor6, size: 15, ), ), @@ -388,7 +393,4 @@ class _MessageHistoryPageWidgetState extends State wit ), )); } - } - -