From 2f7544193902e0a71617999da83cf9b200a36f23 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 2 Aug 2024 11:21:34 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20do=20modal=20de=20erro;=20?= =?UTF-8?q?Corre=C3=A7=C3=A3o=20no=20validator;=20Adi=C3=A7=C3=A3o=20de=20?= =?UTF-8?q?Tradu=C3=A7=C3=A3o=20nos=20Modais;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/actions/actions.dart | 15 +++-- .../sign_up_template_component_widget.dart | 62 +++++++++---------- lib/flutter_flow/internationalization.dart | 12 ++-- lib/shared/utils/validator_util.dart | 11 +++- 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 987a4a53..eaa81103 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -203,7 +203,7 @@ Future signUpRegisterAction( ApiCallResponse? registerCall; if ((email != null && email != '') && - (passwd != null && passwd != '') && + (passwd != null && passwd != '' && passwd.length > 7) && (name != null && name != '')) { registerCall = await PhpGroup.registerCall.call( name: name, @@ -239,17 +239,22 @@ Future signUpRegisterAction( false) { return true; } - await showDialog( context: context, builder: (alertDialogContext) { return AlertDialog( - title: const Text('Error'), - content: Text('${registerCall?.jsonBody}'), + 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: const Text('ERROR2 '), + child: Text( + FFLocalizations.of(context) + .getVariableText(enText: 'Close', ptText: 'Fechar'), + ), ), ], ); 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 f5b3c1d3..a7ac2727 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 @@ -1,4 +1,6 @@ import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart'; +import 'package:hub/shared/components/atoms/atom_terms_of_use.dart'; +import 'package:hub/shared/utils/validator_util.dart'; import '/flutter_flow/flutter_flow_animations.dart'; import '/flutter_flow/flutter_flow_theme.dart'; @@ -101,6 +103,26 @@ class _SignUpTemplateComponentWidgetState Widget build(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; double screenHeight = MediaQuery.of(context).size.height; + bool _isFormInvalid() { + if (_model.nameRegisterFormTextController.text == '' || + _model.emailRegisterFormTextController.text == '' || + _model.passwordRegisterFormTextController.text == '') { + return true; + } + + if (!ValidatorUtil.isValidEmail( + _model.emailRegisterFormTextController.text)) { + return true; + } + + if (!ValidatorUtil.isValidPassword( + _model.passwordRegisterFormTextController.text)) { + return true; + } + + return false; + } + context.watch(); return Row( @@ -662,26 +684,7 @@ class _SignUpTemplateComponentWidgetState padding: const EdgeInsetsDirectional .fromSTEB(0.0, 0.0, 0.0, 16.0), child: FFButtonWidget( - onPressed: (((_model - .nameRegisterFormTextController.text != - '') || - ((_model.nameRegisterFormFocusNode?.hasFocus ?? - false) != - null)) && - ((_model.emailRegisterFormTextController - .text != - '') || - ((_model.emailRegisterFormFocusNode - ?.hasFocus ?? - false) != - null)) && - ((_model.passwordRegisterFormTextController - .text != - '') || - ((_model.passwordRegisterFormFocusNode - ?.hasFocus ?? - false) != - null))) + onPressed: _isFormInvalid() ? null : () async { var shouldSetState = false; @@ -755,6 +758,10 @@ class _SignUpTemplateComponentWidgetState ), borderRadius: BorderRadius.circular(12.0), + disabledColor: + FlutterFlowTheme.of(context) + .customColor5, + disabledTextColor: Colors.white, ), showLoadingIndicator: false, ), @@ -837,6 +844,7 @@ class _SignUpTemplateComponentWidgetState ), ), ), + const AtomTermsOfUse(), ], ), ), @@ -847,20 +855,6 @@ class _SignUpTemplateComponentWidgetState ), ], ), - Text( - FFLocalizations.of(context).getText( - 'huygnka2' /* Termo de Uso */, - ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, - color: FlutterFlowTheme.of(context).secondaryText, - fontSize: 14.0, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), - ), ], ), ), diff --git a/lib/flutter_flow/internationalization.dart b/lib/flutter_flow/internationalization.dart index 39f338a9..21aa8aed 100644 --- a/lib/flutter_flow/internationalization.dart +++ b/lib/flutter_flow/internationalization.dart @@ -952,16 +952,16 @@ final kTranslationsMap = >>[ 'en': 'Password', }, '3bs10dfq': { - 'pt': 'Campo é necessário', - 'en': 'Field is required', + 'pt': 'Nome é Obrigatório', + 'en': 'Name is required', }, 'ph22karc': { 'pt': 'Please choose an option from the dropdown', 'en': '', }, 'mlvw63yj': { - 'pt': 'Campo é necessário', - 'en': 'Field is required', + 'pt': 'E-mail é Obrigatório', + 'en': 'E-mail is required', }, 'vobnktrz': { 'pt': 'Insira um email valido.', @@ -972,8 +972,8 @@ final kTranslationsMap = >>[ 'en': '', }, '6nn79lmh': { - 'pt': 'Campo é necessário', - 'en': 'Field is required', + 'pt': 'Senha é Obrigatório', + 'en': 'Password is required', }, 'duq5gpp6': { 'pt': 'A senha deve ter pelo menos 8 caracteres.', diff --git a/lib/shared/utils/validator_util.dart b/lib/shared/utils/validator_util.dart index 71e83154..a06591e9 100644 --- a/lib/shared/utils/validator_util.dart +++ b/lib/shared/utils/validator_util.dart @@ -1,5 +1,4 @@ class ValidatorUtil { - static bool isValidEmail(String email) { if (RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(email)) { return true; @@ -7,4 +6,12 @@ class ValidatorUtil { return false; } } -} \ No newline at end of file + + static bool isValidPassword(String password) { + if (password.length > 7) { + return true; + } else { + return false; + } + } +}