diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index d7a4ae22..a9f15c57 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -343,6 +343,7 @@ Future visitRequestComponentAction( ); if (respondeSolicitacaoCall.statusCode == 200) { + log('jsonBody: ${respondeSolicitacaoCall.jsonBody}; actionValue: $actionValue; refUUID: $refUUID; responseValue: $responseValue; vteUUID: $vteUUID'); return true; } else { log('headers: ${respondeSolicitacaoCall.headers}'); 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 cb5cd657..53ce841e 100644 --- a/lib/components/templates_components/details_component/details_component_action.dart +++ b/lib/components/templates_components/details_component/details_component_action.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:hub/app_state.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; @@ -5,15 +7,28 @@ 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:hub/flutter_flow/nav/nav.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; +enum status { active, unknown, canceled, finished, blocked, inactive } + +status? getStatus(dynamic data) { + debugPrint('getStatus: $data'); + switch (data) { + case 'A': + return status.active; + case 'F': + return status.finished; + case 'B': + return status.blocked; + case 'C': + return status.canceled; + case 'I': + return status.inactive; + default: + return status.unknown; + } } Widget buildDetails( @@ -34,10 +49,10 @@ Widget buildDetails( vawUUID: 'Lorem Ipsus', vawName: 'Lorem Ipsus', vawRef: 'Lorem Ipsus', - changeStatusAction: changeStatusAction, buttons: [ - if (getStatus(visitaWrapItem['VAW_STATUS']) == null) // ACCEPT ACTION + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.active) // ACCEPT ACTION FlutterFlowIconButton( icon: const Icon(Icons.done), onPressed: () async { @@ -93,9 +108,9 @@ Widget buildDetails( await changeStatusAction?.call( context, 'L', - visitaWrapItem['VAW_REF'] ?? '', + visitaWrapItem['VAW_ID'] ?? '', 'Mensagem', - visitaWrapItem['VTE_ID'] ?? '', + visitaWrapItem['VTE_DOCUMENTO'] ?? '', ); }, options: FFButtonOptions( @@ -118,7 +133,8 @@ Widget buildDetails( }); }, ), - if (getStatus(visitaWrapItem['VAW_STATUS']) == null) // REJECT ACTION + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.active) // REJECT ACTION FlutterFlowIconButton( icon: const Icon(Icons.close), onPressed: () async { @@ -199,185 +215,45 @@ Widget buildDetails( }); }, ), - if (getStatus(visitaWrapItem['VAW_STATUS']) == false) // RECALL ACTION + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.finished) // 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), - ), - ), - ], - ); - }); + Navigator.pop(context); + Navigator.pop(context); + context.pushNamed( + 'scheduleCompleteVisitPage', + queryParameters: { + 'visitorStrList': serializeParam( + visitaWrapItem['VTE_DOCUMENTO'], + ParamType.String, + ), + 'visitorJsonList': serializeParam( + [visitaWrapItem], + ParamType.JSON, + isList: true, + ), + }.withoutNulls, + ); }, ), - if (getStatus(visitaWrapItem['VAW_STATUS']) == false) // SHARE ACTION + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.finished) // SHARE ACTION FlutterFlowIconButton( icon: const Icon(Icons.share), onPressed: () async { - Share.share(r''' - Olá ${visitaWrapItem['VTE_NOME']} - Você foi convidado para ${visitaWrapItem['NAC_DESCRICAO']} + Share.share(''' +Olá, \*${visitaWrapItem['VTE_NOME']}\*! Você foi convidado para \*${visitaWrapItem['NAC_DESCRICAO']}\*. - Validade do Convite: - visitaWrapItem['VAW_DTINICIO'] - visitaWrapItem['VAW_DTFIM'] +\*Validade do Convite\*: +- Início: ${visitaWrapItem['VAW_DTINICIO']} +- Fim: ${visitaWrapItem['VAW_DTFIM']} - URL do Convite: https://visita.freaccess.com.br/${visitaWrapItem['VAW_ID']}/${visitaWrapItem['CLI_ID']}/${visitaWrapItem['VAW_CHAVE']} +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'] ?? '', @@ -389,27 +265,48 @@ Widget buildDetails( '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, - }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).warning, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.unknown) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Pendente', + enText: 'Pending', + ): FlutterFlowTheme.of(context).alternate, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.canceled) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Cancelado', + enText: 'Canceled', + ): FlutterFlowTheme.of(context).error, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.finished) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Finalizado', + enText: 'Finished', + ): FlutterFlowTheme.of(context).success, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.blocked) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Bloqueado', + enText: 'Blocked', + ): FlutterFlowTheme.of(context).error, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == status.inactive) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Inativo', + enText: 'Inactive', + ): FlutterFlowTheme.of(context).error, + }), ], - // vteDocument: liberationHistoryItem['VTE_DOCUMENTO'], ); } diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart index 3440eb7b..f1cc977d 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart @@ -154,136 +154,142 @@ class _RegisiterVistorTemplateComponentWidgetState Padding( padding: const EdgeInsetsDirectional.fromSTEB( 24.0, 0.0, 24.0, 0.0), - child: TextFormField( - controller: _model.textController2, - focusNode: _model.textFieldFocusNode2, - autovalidateMode: AutovalidateMode.onUserInteraction, - autofocus: false, - textCapitalization: TextCapitalization.none, - autofillHints: const [AutofillHints.password], - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - 'rl8tvwnr' /* Documento */, + child: Column(children: [ + TextFormField( + controller: _model.textController2, + focusNode: _model.textFieldFocusNode2, + autovalidateMode: AutovalidateMode.onUserInteraction, + autofocus: false, + textCapitalization: TextCapitalization.none, + autofillHints: const [AutofillHints.password], + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + obscureText: false, + decoration: InputDecoration( + isDense: true, + labelText: FFLocalizations.of(context).getText( + 'rl8tvwnr' /* Documento */, + ), + 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: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).customColor6, + 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.document_scanner, + color: FlutterFlowTheme.of(context).accent1, + ), ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( + style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + FlutterFlowTheme.of(context).bodyMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).customColor6, - 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.document_scanner, - color: FlutterFlowTheme.of(context).accent1, - ), + validator: + _model.textController2Validator.asValidator(context), + inputFormatters: [ + FilteringTextInputFormatter.allow(RegExp('[0-9]')), + ], ), - 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.textController2Validator.asValidator(context), - inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp('[0-9]')), - ], - ), - ), - FutureBuilder( - future: _model.textController2.text.isNotEmpty - ? _model.getVisitanteByDocument( - _model.textController2.text, context) - : null, - builder: (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return const SizedBox(); - } else if (snapshot.hasError || - snapshot.data == null || - snapshot.data == '') { - // safeSetState(() => _isVisitorRegistered = false); - _isVisitorRegistered = false; - visitorAlreadyRegistered.add(true); - return const SizedBox(); - } else { - _isVisitorRegistered = true; - visitorAlreadyRegistered.add(false); - return _model.textController2.text.isEmpty - ? const SizedBox() - : Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Padding( - padding: EdgeInsets.only( - right: MediaQuery.sizeOf(context).width * - 0.1), - child: Text( - FFLocalizations.of(context) - .getVariableText( - enText: 'Visitor already registered', - ptText: 'Visitante já cadastrado', - ), - style: FlutterFlowTheme.of(context) - .bodySmall - .override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context) - .error, - fontSize: 14.0, - letterSpacing: 0.0, - )), - ), - ], - ); - } - }, + FutureBuilder( + future: _model.textController2.text.isNotEmpty + ? _model.getVisitanteByDocument( + _model.textController2.text, context) + : null, + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == + ConnectionState.waiting) { + return const SizedBox(); + } else if (snapshot.hasError || + snapshot.data == null || + snapshot.data == '') { + // safeSetState(() => _isVisitorRegistered = false); + _isVisitorRegistered = false; + visitorAlreadyRegistered.add(true); + return const SizedBox(); + } else { + _isVisitorRegistered = true; + visitorAlreadyRegistered.add(false); + return _model.textController2.text.isEmpty + ? const SizedBox() + : Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsetsDirectional.only( + top: 5, start: 12), + child: Text( + FFLocalizations.of(context) + .getVariableText( + enText: + 'Visitor already registered', + ptText: 'Visitante já cadastrado', + ), + style: FlutterFlowTheme.of(context) + .labelSmall + .override( + fontFamily: 'Nunito', + color: Color.alphaBlend( + Colors.white + .withOpacity(0.7), + Colors.red), + fontSize: 13.0, + letterSpacing: 0.0, + )), + ), + ], + ); + } + }, + ), + ]), ), Padding( padding: const EdgeInsetsDirectional.fromSTEB( @@ -419,26 +425,33 @@ class _RegisiterVistorTemplateComponentWidgetState ), if (_model.dropDownValue == null || _model.dropDownValue == '') - Align( - alignment: const AlignmentDirectional(0.4, 0), - child: Text( - FFLocalizations.of(context).getVariableText( - enText: 'This field is required', - ptText: 'Este campo é obrigatório', - ), - style: FlutterFlowTheme.of(context) - .bodySmall - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodySmallFamily, - color: FlutterFlowTheme.of(context) - .customColor6, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodySmallFamily), - )), + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: const EdgeInsetsDirectional.only( + top: 5, start: 15), + child: Text( + FFLocalizations.of(context).getVariableText( + enText: 'This field is required', + ptText: 'Este campo é obrigatório', + ), + style: FlutterFlowTheme.of(context) + .bodySmall + .override( + fontFamily: FlutterFlowTheme.of(context) + .bodySmallFamily, + color: FlutterFlowTheme.of(context) + .customColor6, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey( + FlutterFlowTheme.of(context) + .bodySmallFamily), + )), + ), + ], ), ], ), 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 2020de23..bc39e658 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 @@ -73,23 +73,6 @@ 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/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index a7936422..40ef200a 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -98,51 +98,120 @@ class PreferencesPageModel with ChangeNotifier { } void toggleNotify(BuildContext context) { - FFAppState().notify = !FFAppState().notify; - PhpGroup.changeNotifica - .call( - userUUID: FFAppState().userUUID, - devUUID: FFAppState().devUUID, - cliID: FFAppState().cliUUID, - atividade: 'updVisitado', - notifica: FFAppState().notify ? 'S' : 'N', - ) - .then((value) { - 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( - ptText: 'Notificação alterada com sucesso', - enText: 'Notification changed successfully', + enText: FFAppState().notify + ? 'Access Notification' + : 'Disable Access Notification', + ptText: FFAppState().notify + ? 'Notificação de acesso' + : 'Desativar notificação de acesso', ), - 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( - content: Text( + ), + content: Text( FFLocalizations.of(context).getVariableText( - enText: 'Error changing notification', - ptText: 'Erro ao alterar notificação', + ptText: 'Tem certeza que deseja desvincular este dispositivo?', + enText: 'Are you sure you want to unlink this 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), - ), - ), - ); - }); + ), + actions: [ + FFButtonWidget( + text: FFLocalizations.of(context).getVariableText( + enText: 'Cancel', + ptText: 'Cancelar', + ), + 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( + onPressed: () async { + FFAppState().notify = !FFAppState().notify; + PhpGroup.changeNotifica + .call( + userUUID: FFAppState().userUUID, + devUUID: FFAppState().devUUID, + cliID: FFAppState().cliUUID, + atividade: 'updVisitado', + notifica: FFAppState().notify ? 'S' : 'N', + ) + .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( + content: Text( + FFLocalizations.of(context).getVariableText( + enText: 'Error changing notification', + ptText: 'Erro ao alterar notificação', + ), + 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()); + }, + text: FFLocalizations.of(context).getVariableText( + enText: 'Unlink', + ptText: 'Desvincular', + ), + 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), + ), + ), + ], + ); + }); notifyListeners(); } 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 7253a8c6..fbd53d4f 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 @@ -160,12 +160,24 @@ class _ScheduleCompleteVisitPageWidgetState } } -bool? getStatus(dynamic data) { - return data == 'A' - ? true - : data == 'F' || data == 'B' || data == 'C' || data == 'I' - ? null - : false; +enum status { active, unknown, canceled, finished, blocked, inactive } + +status? getStatus(dynamic data) { + debugPrint('getStatus: $data'); + switch (data) { + case 'A': + return status.active; + case 'F': + return status.finished; + case 'B': + return status.blocked; + case 'C': + return status.canceled; + case 'I': + return status.inactive; + default: + return status.unknown; + } } PreferredSizeWidget appBarScheduleCompleteVisit(BuildContext context) { @@ -1739,28 +1751,54 @@ Widget visitHistory( 'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '', }), 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, - }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.active) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Ativo', + enText: 'Active', + ): FlutterFlowTheme.of(context).warning, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.finished) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Finalizado', + enText: 'Finished', + ): FlutterFlowTheme.of(context).success, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.unknown) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Desconhecido', + enText: 'Unknown', + ): FlutterFlowTheme.of(context).alternate, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.canceled) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Cancelado', + enText: 'Canceled', + ): FlutterFlowTheme.of(context).error, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.blocked) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Bloqueado', + enText: 'Blocked', + ): FlutterFlowTheme.of(context).error, + }), + if (getStatus(visitaWrapItem['VAW_STATUS']) == + status.inactive) + Map.from({ + FFLocalizations.of(context).getVariableText( + ptText: 'Inactive', + enText: 'Inactive', + ): FlutterFlowTheme.of(context).error, + }), ], onTapCardItemAction: () async { showModalBottomSheet(