From d26eb5d8fa205f01d6160d1d79b950460b6d9c88 Mon Sep 17 00:00:00 2001 From: jantunesmesias Date: Thu, 8 Aug 2024 14:34:39 -0300 Subject: [PATCH] WIP --- .../details_component_action.dart | 156 ++++++------------ lib/flutter_flow/flutter_flow_util.dart | 8 +- .../visit_history_page_widget.dart | 18 +- 3 files changed, 57 insertions(+), 125 deletions(-) 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 0225d38f..4a7ad9c8 100644 --- a/lib/components/templates_components/details_component/details_component_action.dart +++ b/lib/components/templates_components/details_component/details_component_action.dart @@ -25,115 +25,57 @@ Widget buildDetails( 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', - ), + 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 changeStatusAction + ?.call( + context, + int.parse(visitaWrapItem['VAW_DESTINO']), + int.parse(visitaWrapItem['VAW_ID']), + visitaWrapItem['VAW_CHAVE'] ?? '', + visitaWrapItem['VTE_DOCUMENTO'] ?? '', + ) + .then((value) { + Navigator.pop(context); + if (value == false) { + showSnackbar( + context, + FFLocalizations.of(context).getVariableText( + enText: 'Error blocking visit', + ptText: 'Erro ao bloquear visita', ), - 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, - int.parse(visitaWrapItem['VAW_DESTINO']), - int.parse(visitaWrapItem['VAW_ID']), - visitaWrapItem['VAW_CHAVE'] ?? '', - visitaWrapItem['VTE_DOCUMENTO'] ?? '', - ) - .then((value) { - Navigator.pop(context); - if (value == false) { - showSnackbar( - context, - FFLocalizations.of(context).getVariableText( - enText: 'Error blocking visit', - ptText: 'Erro ao bloquear visita', - ), - true, - ); - } else if (value == true) { - showSnackbar( - context, - FFLocalizations.of(context).getVariableText( - enText: 'Success canceling visit', - ptText: 'Succeso ao cancelar visita', - ), - false, - ); - } - }).catchError((err, stack) { - Navigator.pop(context); - - showSnackbar( - context, - FFLocalizations.of(context).getVariableText( - enText: 'Error blocking visit', - ptText: 'Erro ao bloquear visita', - ), - true, - ); - }); - }, - 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), - ), - ), - ], + true, ); - }); + } else if (value == true) { + showSnackbar( + context, + FFLocalizations.of(context).getVariableText( + enText: 'Success canceling visit', + ptText: 'Succeso ao cancelar visita', + ), + false, + ); + } + }).catchError((err, stack) { + Navigator.pop(context); + showSnackbar( + context, + FFLocalizations.of(context).getVariableText( + enText: 'Error blocking visit', + ptText: 'Erro ao bloquear visita', + ), + true, + ); + }); + }); }, ), if (getStatus(visitaWrapItem['VAW_STATUS']) != diff --git a/lib/flutter_flow/flutter_flow_util.dart b/lib/flutter_flow/flutter_flow_util.dart index 78192536..8d1ffe11 100644 --- a/lib/flutter_flow/flutter_flow_util.dart +++ b/lib/flutter_flow/flutter_flow_util.dart @@ -549,8 +549,8 @@ void showSnackbar( ); } -void showAlertDialog( - BuildContext context, String title, String content, Future action) { +void showAlertDialog(BuildContext context, String title, String content, + Future Function() action) { showDialog( context: context, builder: (context) { @@ -577,6 +577,7 @@ void showAlertDialog( width: 1, ), borderRadius: BorderRadius.circular(10), + elevation: 0, ), text: FFLocalizations.of(context).getVariableText( enText: 'No', @@ -585,12 +586,13 @@ void showAlertDialog( ), FFButtonWidget( onPressed: () async { - await action; + action(); }, options: FFButtonOptions( width: MediaQuery.of(context).size.width * 0.3, height: MediaQuery.of(context).size.height * 0.05, color: FlutterFlowTheme.of(context).primaryBackground, + elevation: 0, textStyle: TextStyle( color: FlutterFlowTheme.of(context).primaryText, ), diff --git a/lib/pages/visit_history_page/visit_history_page_widget.dart b/lib/pages/visit_history_page/visit_history_page_widget.dart index b7291b9f..4cb01778 100644 --- a/lib/pages/visit_history_page/visit_history_page_widget.dart +++ b/lib/pages/visit_history_page/visit_history_page_widget.dart @@ -63,8 +63,6 @@ class _VisitHistoryWidgetState extends State { .visitasList(wrapGetVisitsResponse.jsonBody) ?.toList() ?? []; - log('updated'); - log('visitaWrap: ${visitaWrap[0]}'); return ListView.builder( itemCount: visitaWrap.length, shrinkWrap: true, @@ -147,7 +145,6 @@ class _VisitHistoryWidgetState extends State { ); }, ).whenComplete(() async { - log('Complete'); final newResponseStream = ScheduleCompleteVisitPageModel().visitHistory( requestFn: () => PhpGroup.getVisitsCall.call( @@ -160,22 +157,13 @@ class _VisitHistoryWidgetState extends State { ), ); newResponseStream.listen((newResponse) { - log('New response received: $newResponse'); if (mounted) { safeSetState(() { response = newResponse.jsonBody; - log('Response updated: $response'); }); - } else { - log('Widget is not mounted, skipping state update.'); - } - }).onError((err) { - log('Error: $err'); - }); - }).catchError((err, stack) { - log('Error: $err'); - log('Stack: $stack'); - }); + } else {} + }).onError((err) {}); + }).catchError((err, stack) {}); }, ); },