From 736f3080e162d8b76f4ce0b084ff3a2a6153c353 Mon Sep 17 00:00:00 2001 From: FlutterFlow <140657486+FlutterFlowEng@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:09:38 +0000 Subject: [PATCH] fix forgot password template --- ios/Runner.xcodeproj/project.pbxproj | 8 +- ...got_password_template_component_model.dart | 21 +- ...ot_password_template_component_widget.dart | 226 +++++++++--------- lib/flutter_flow/internationalization.dart | 20 +- 4 files changed, 153 insertions(+), 122 deletions(-) diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index cc761af2..4ad69147 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -44,8 +44,8 @@ 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 6436409727A31CDB00820AF7 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; }; - 6436409B27A31CDF00820AF7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 6436409827A31CD800820AF7 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; }; + 6436409D27A31CD300820AF7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ @@ -225,8 +225,8 @@ 6436409C27A31CD800820AF7 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( - 6436409727A31CDB00820AF7 /* pt */, - 6436409B27A31CDF00820AF7 /* en */, + 6436409827A31CD800820AF7 /* pt */, + 6436409D27A31CD300820AF7 /* en */, ); name = InfoPlist.strings; sourceTree = ""; diff --git a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart index 4178de7c..c7fe19a6 100644 --- a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart +++ b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart @@ -8,15 +8,34 @@ class ForgotPasswordTemplateComponentModel extends FlutterFlowModel { /// State fields for stateful widgets in this component. + final formKey = GlobalKey(); // State field(s) for emailAddress widget. FocusNode? emailAddressFocusNode; TextEditingController? emailAddressTextController; String? Function(BuildContext, String?)? emailAddressTextControllerValidator; + String? _emailAddressTextControllerValidator( + BuildContext context, String? val) { + if (val == null || val.isEmpty) { + return FFLocalizations.of(context).getText( + '3hqg8buh' /* E-mail é Obrigatório */, + ); + } + + if (!RegExp(kTextValidatorEmailRegex).hasMatch(val)) { + return FFLocalizations.of(context).getText( + 'jh5r2b1w' /* E-mail Inválido */, + ); + } + return null; + } + // Stores action output result for [Backend Call - API (forgotPassword)] action in Button-Login widget. ApiCallResponse? req; @override - void initState(BuildContext context) {} + void initState(BuildContext context) { + emailAddressTextControllerValidator = _emailAddressTextControllerValidator; + } @override void dispose() { diff --git a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart index 39cce295..5e82ed3d 100644 --- a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart +++ b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart @@ -3,6 +3,7 @@ import '/components/molecular_components/throw_exception/throw_exception_widget. import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; +import 'package:easy_debounce/easy_debounce.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'forgot_password_template_component_model.dart'; @@ -148,95 +149,92 @@ class _ForgotPasswordTemplateComponentWidgetState ), ), ), - Padding( - padding: const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 16.0, 0.0), - child: SizedBox( - width: double.infinity, - child: TextFormField( - controller: _model.emailAddressTextController, - focusNode: _model.emailAddressFocusNode, - autofillHints: const [AutofillHints.email], - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelText: FFLocalizations.of(context).getText( - 'mtz8l7ft' /* Email */, + Form( + key: _model.formKey, + autovalidateMode: AutovalidateMode.disabled, + child: Padding( + padding: const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 16.0, 0.0), + child: SizedBox( + width: double.infinity, + child: TextFormField( + controller: _model.emailAddressTextController, + focusNode: _model.emailAddressFocusNode, + onChanged: (_) => EasyDebounce.debounce( + '_model.emailAddressTextController', + const Duration(milliseconds: 500), + () => setState(() {}), ), - labelStyle: - FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: 'Plus Jakarta Sans', - color: FlutterFlowTheme.of(context).accent1, - fontSize: 14.0, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), - ), - hintText: FFLocalizations.of(context).getText( - 'w7y5wlnv' /* digite o seu email..... */, - ), - hintStyle: - FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: 'Plus Jakarta Sans', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 14.0, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( + autofocus: true, + autofillHints: const [AutofillHints.email], + obscureText: false, + decoration: InputDecoration( + isDense: true, + labelText: FFLocalizations.of(context).getText( + 'mtz8l7ft' /* E-mail */, + ), + labelStyle: + FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).accent1, + fontSize: 14.0, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap() + .containsKey('Plus Jakarta Sans'), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primary, + width: 2.0, + ), + borderRadius: BorderRadius.circular(12.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primary, + width: 2.0, + ), + borderRadius: BorderRadius.circular(12.0), + ), + errorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).error, + width: 2.0, + ), + borderRadius: BorderRadius.circular(12.0), + ), + focusedErrorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).error, + width: 2.0, + ), + borderRadius: BorderRadius.circular(12.0), + ), + filled: true, + fillColor: FlutterFlowTheme.of(context).primaryBackground, + contentPadding: const EdgeInsetsDirectional.fromSTEB( + 24.0, 24.0, 20.0, 24.0), + suffixIcon: Icon( + Icons.email, color: FlutterFlowTheme.of(context).accent1, - width: 2.0, + size: 22.0, ), - borderRadius: BorderRadius.circular(12.0), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).accent3, - width: 2.0, - ), - borderRadius: BorderRadius.circular(12.0), - ), - errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 2.0, - ), - borderRadius: BorderRadius.circular(12.0), - ), - focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 2.0, - ), - borderRadius: BorderRadius.circular(12.0), - ), - filled: true, - fillColor: FlutterFlowTheme.of(context).primaryBackground, - contentPadding: - const EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 20.0, 24.0), - suffixIcon: Icon( - Icons.email, - color: FlutterFlowTheme.of(context).accent1, - size: 22.0, ), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 14.0, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap() + .containsKey('Plus Jakarta Sans'), + ), + maxLines: null, + keyboardType: TextInputType.emailAddress, + cursorColor: FlutterFlowTheme.of(context).primary, + validator: _model.emailAddressTextControllerValidator + .asValidator(context), ), - style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: 'Plus Jakarta Sans', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 14.0, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), - ), - maxLines: null, - keyboardType: TextInputType.emailAddress, - cursorColor: const Color(0xFF6F61EF), - validator: _model.emailAddressTextControllerValidator - .asValidator(context), ), ), ), @@ -245,37 +243,39 @@ class _ForgotPasswordTemplateComponentWidgetState child: Padding( padding: const EdgeInsetsDirectional.fromSTEB(0.0, 24.0, 0.0, 0.0), child: FFButtonWidget( - onPressed: () async { - _model.req = await PhpGroup.forgotPasswordCall.call( - email: _model.emailAddressTextController.text, - ); - - if (PhpGroup.forgotPasswordCall.error( - (_model.req?.jsonBody ?? ''), - ) == - false) { - Navigator.pop(context); - } else { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: ThrowExceptionWidget( - msg: PhpGroup.forgotPasswordCall.msg( - (_model.req?.jsonBody ?? ''), - )!, - ), + onPressed: (_model.emailAddressTextController.text == '') + ? null + : () async { + _model.req = await PhpGroup.forgotPasswordCall.call( + email: _model.emailAddressTextController.text, ); - }, - ).then((value) => safeSetState(() {})); - } - setState(() {}); - }, + if (PhpGroup.forgotPasswordCall.error( + (_model.req?.jsonBody ?? ''), + ) == + false) { + Navigator.pop(context); + } else { + await showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + enableDrag: false, + context: context, + builder: (context) { + return Padding( + padding: MediaQuery.viewInsetsOf(context), + child: ThrowExceptionWidget( + msg: PhpGroup.forgotPasswordCall.msg( + (_model.req?.jsonBody ?? ''), + )!, + ), + ); + }, + ).then((value) => safeSetState(() {})); + } + + setState(() {}); + }, text: FFLocalizations.of(context).getText( '74rnd5bu' /* Enviar */, ), diff --git a/lib/flutter_flow/internationalization.dart b/lib/flutter_flow/internationalization.dart index 91cb14b0..fd3f7663 100644 --- a/lib/flutter_flow/internationalization.dart +++ b/lib/flutter_flow/internationalization.dart @@ -1002,12 +1002,24 @@ final kTranslationsMap = >>[ 'Don\'t worry, we will help you, enter the email registered in the application and click send.', }, 'mtz8l7ft': { - 'pt': 'Email', - 'en': 'Email', + 'pt': 'E-mail', + 'en': 'E-mail', }, 'w7y5wlnv': { - 'pt': 'digite o seu email.....', - 'en': 'enter your email.....', + 'pt': '', + 'en': '', + }, + '3hqg8buh': { + 'pt': 'E-mail é Obrigatório', + 'en': '', + }, + 'jh5r2b1w': { + 'pt': 'E-mail Inválido', + 'en': '', + }, + '1p76vmkn': { + 'pt': 'Please choose an option from the dropdown', + 'en': '', }, '74rnd5bu': { 'pt': 'Enviar',