From 9f18ed1de98dd112e7630d805a994af84c8c4fd8 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 2 Aug 2024 12:09:29 -0300 Subject: [PATCH] Trocado os ShowDialog para utilizar o Componente de DialogUtil --- lib/actions/actions.dart | 132 +++++++----------- .../sign_up_template_component_widget.dart | 2 +- 2 files changed, 49 insertions(+), 85 deletions(-) diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index eaa81103..d7a4ae22 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -200,92 +200,56 @@ Future signUpRegisterAction( required String? email, String? device, }) async { - ApiCallResponse? registerCall; + try { + ApiCallResponse? registerCall; + if ((email != null && email != '') && + (passwd != null && passwd != '' && passwd.length > 7) && + (name != null && name != '')) { + registerCall = await PhpGroup.registerCall.call( + name: name, + password: passwd, + email: email, + token: randomString( + 36, + 36, + false, + false, + true, + ), + uuid: randomString( + 36, + 36, + false, + false, + true, + ), + tipo: device, + descricao: randomString( + 36, + 36, + true, + false, + false, + ), + ); - if ((email != null && email != '') && - (passwd != null && passwd != '' && passwd.length > 7) && - (name != null && name != '')) { - registerCall = await PhpGroup.registerCall.call( - name: name, - password: passwd, - email: email, - token: randomString( - 36, - 36, - false, - false, - true, - ), - uuid: randomString( - 36, - 36, - false, - false, - true, - ), - tipo: device, - descricao: randomString( - 36, - 36, - true, - false, - false, - ), - ); - - if (PhpGroup.registerCall.error( - (registerCall.jsonBody ?? ''), - ) == - false) { - return true; + if (PhpGroup.registerCall.error( + (registerCall.jsonBody ?? ''), + ) == + false) { + return true; + } + final errorMessage = registerCall?.jsonBody['error_msg']; + DialogUtil.error(context, errorMessage); + return false; + } else { + DialogUtil.errorDefault(context); + return false; } - await showDialog( - context: context, - builder: (alertDialogContext) { - return AlertDialog( - title: Text( - FFLocalizations.of(context).getVariableText( - enText: 'An error occurred:', ptText: 'Ocorreu um erro:'), - ), - content: Text(registerCall?.jsonBody['error_msg']), - actions: [ - TextButton( - onPressed: () => Navigator.pop(alertDialogContext), - child: Text( - FFLocalizations.of(context) - .getVariableText(enText: 'Close', ptText: 'Fechar'), - ), - ), - ], - ); - }, - ); - return false; - } else { - await showDialog( - context: context, - builder: (alertDialogContext) { - return AlertDialog( - title: Text(FFLocalizations.of(context).getVariableText( - enText: 'Error', - ptText: 'Erro', - )), - content: Text(FFLocalizations.of(context).getVariableText( - enText: 'Please fill in all fields', - ptText: 'Por favor, preencha todos os campos', - )), - actions: [ - TextButton( - onPressed: () => Navigator.pop(alertDialogContext), - child: Text(FFLocalizations.of(context).getVariableText( - ptText: 'Fechar', - enText: 'Close', - )), - ), - ], - ); - }, - ); + } catch (e, s) { + DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed( + 'registro.php', email.toString(), "Register", e, s); return false; } } diff --git a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart index a7ac2727..8b0eac27 100644 --- a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart +++ b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart @@ -763,7 +763,7 @@ class _SignUpTemplateComponentWidgetState .customColor5, disabledTextColor: Colors.white, ), - showLoadingIndicator: false, + showLoadingIndicator: true, ), ),