diff --git a/assets/images/dark/register.svg b/assets/images/dark/register.svg new file mode 100644 index 00000000..5e7071f7 --- /dev/null +++ b/assets/images/dark/register.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/light/register.svg b/assets/images/light/register.svg new file mode 100644 index 00000000..2fecef14 --- /dev/null +++ b/assets/images/light/register.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 93d93c55..53994b42 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -51,8 +51,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 = ""; }; - 6436409227A31CD800820AF7 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; }; - 6436409127A31CDB00820AF7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 6436409727A31CDC00820AF7 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; }; + 6436409027A31CD400820AF7 /* 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 = ""; }; C1B4A503715BC7B0F8826983 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -301,8 +301,8 @@ 6436409C27A31CD800820AF7 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( - 6436409227A31CD800820AF7 /* pt */, - 6436409127A31CDB00820AF7 /* en */, + 6436409727A31CDC00820AF7 /* pt */, + 6436409027A31CD400820AF7 /* en */, ); name = InfoPlist.strings; sourceTree = ""; diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 987a4a53..d7a4ae22 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -200,87 +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 != '') && - (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: const Text('Error'), - content: Text('${registerCall?.jsonBody}'), - actions: [ - TextButton( - onPressed: () => Navigator.pop(alertDialogContext), - child: const Text('ERROR2 '), - ), - ], - ); - }, - ); - 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_model.dart b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_model.dart index bbcd4725..370ff262 100644 --- a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_model.dart +++ b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_model.dart @@ -21,9 +21,6 @@ class SignUpTemplateComponentModel ); } - if (!RegExp(kTextValidatorUsernameRegex).hasMatch(val)) { - return 'Must start with a letter and can only contain letters, digits and - or _.'; - } return null; } @@ -41,7 +38,9 @@ class SignUpTemplateComponentModel } if (!RegExp(kTextValidatorEmailRegex).hasMatch(val)) { - return 'Has to be a valid email address.'; + return FFLocalizations.of(context).getText( + 'vobnktrz' /* Insira um email valido. */, + ); } return null; } @@ -60,6 +59,12 @@ class SignUpTemplateComponentModel ); } + if (val.length < 8) { + return FFLocalizations.of(context).getText( + 'duq5gpp6' /* A senha deve ter pelo menos 8 ... */, + ); + } + return null; } 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 0d5327b0..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 @@ -1,3 +1,7 @@ +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'; import '/flutter_flow/flutter_flow_util.dart'; @@ -17,7 +21,6 @@ class SignUpTemplateComponentWidget extends StatefulWidget { super.key, required this.toggleSignInPage, }); - final Future Function()? toggleSignInPage; @override @@ -98,6 +101,28 @@ class _SignUpTemplateComponentWidgetState @override 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( @@ -135,7 +160,8 @@ class _SignUpTemplateComponentWidgetState children: [ Expanded( child: Align( - alignment: const AlignmentDirectional(0.0, -1.0), + alignment: + const AlignmentDirectional(0.0, -1.0), child: Padding( padding: const EdgeInsets.all(4.0), child: Text( @@ -149,7 +175,7 @@ class _SignUpTemplateComponentWidgetState fontFamily: 'Plus Jakarta Sans', color: FlutterFlowTheme.of(context) .primaryText, - fontSize: 24.0, + fontSize: screenWidth * 0.06, letterSpacing: 0.0, fontWeight: FontWeight.w500, useGoogleFonts: GoogleFonts.asMap() @@ -171,11 +197,10 @@ class _SignUpTemplateComponentWidgetState decoration: const BoxDecoration(), child: ClipRRect( borderRadius: BorderRadius.circular(8.0), - child: SvgPicture.network( - 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/ug2zlyhca2sh/Frame_5.svg', - width: 603.0, - height: 155.0, - fit: BoxFit.contain, + child: const AtomImageSvgTheme( + filename: 'register', + width: 600, + height: 155, ), ), ), @@ -208,13 +233,14 @@ class _SignUpTemplateComponentWidgetState Form( key: _model.formKey, autovalidateMode: - AutovalidateMode.disabled, + AutovalidateMode.onUserInteraction, child: Column( mainAxisSize: MainAxisSize.max, children: [ Padding( - padding: const EdgeInsetsDirectional - .fromSTEB( + padding: + const EdgeInsetsDirectional + .fromSTEB( 0.0, 0.0, 0.0, 16.0), child: SizedBox( width: double.infinity, @@ -347,8 +373,6 @@ class _SignUpTemplateComponentWidgetState .containsKey( 'Plus Jakarta Sans'), ), - keyboardType: - TextInputType.name, validator: _model .nameRegisterFormTextControllerValidator .asValidator(context), @@ -356,8 +380,9 @@ class _SignUpTemplateComponentWidgetState ), ), Padding( - padding: const EdgeInsetsDirectional - .fromSTEB( + padding: + const EdgeInsetsDirectional + .fromSTEB( 0.0, 0.0, 0.0, 16.0), child: SizedBox( width: double.infinity, @@ -499,8 +524,9 @@ class _SignUpTemplateComponentWidgetState ), ), Padding( - padding: const EdgeInsetsDirectional - .fromSTEB( + padding: + const EdgeInsetsDirectional + .fromSTEB( 0.0, 0.0, 0.0, 16.0), child: SizedBox( width: double.infinity, @@ -564,7 +590,8 @@ class _SignUpTemplateComponentWidgetState ), focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( + borderSide: + const BorderSide( color: Color(0xFF1AAB5F), width: 0.25, @@ -575,7 +602,8 @@ class _SignUpTemplateComponentWidgetState ), errorBorder: OutlineInputBorder( - borderSide: const BorderSide( + borderSide: + const BorderSide( color: Color(0xFFFF5963), width: 0.25, @@ -586,7 +614,8 @@ class _SignUpTemplateComponentWidgetState ), focusedErrorBorder: OutlineInputBorder( - borderSide: const BorderSide( + borderSide: + const BorderSide( color: Color(0xFFFF5963), width: 0.25, @@ -652,29 +681,10 @@ class _SignUpTemplateComponentWidgetState ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 16.0), + 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; @@ -716,11 +726,11 @@ class _SignUpTemplateComponentWidgetState options: FFButtonOptions( width: double.infinity, height: 44.0, - padding: - const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional + .fromSTEB(0.0, 0.0, 0.0, 0.0), iconPadding: - const EdgeInsetsDirectional.fromSTEB( + const EdgeInsetsDirectional + .fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context) .accent1, @@ -748,15 +758,19 @@ class _SignUpTemplateComponentWidgetState ), borderRadius: BorderRadius.circular(12.0), + disabledColor: + FlutterFlowTheme.of(context) + .customColor5, + disabledTextColor: Colors.white, ), - showLoadingIndicator: false, + showLoadingIndicator: true, ), ), // You will have to add an action on this rich text to go to your login page. Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 12.0, 0.0, 12.0), + padding: const EdgeInsetsDirectional + .fromSTEB(0.0, 12.0, 0.0, 12.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, @@ -830,6 +844,7 @@ class _SignUpTemplateComponentWidgetState ), ), ), + const AtomTermsOfUse(), ], ), ), @@ -840,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/flutter_flow_drop_down.dart b/lib/flutter_flow/flutter_flow_drop_down.dart index 26476a81..ab6bdf5e 100644 --- a/lib/flutter_flow/flutter_flow_drop_down.dart +++ b/lib/flutter_flow/flutter_flow_drop_down.dart @@ -214,12 +214,11 @@ class _FlutterFlowDropDownState extends State> { List> _createMenuItems() => widget.options .map( (option) => DropdownMenuItem( - value: option, - child: Padding( - padding: _useDropdown2() ? horizontalMargin : EdgeInsets.zero, - child: Text(optionLabels[option] ?? '', style: widget.textStyle), - ), - ), + value: option, + child: Padding( + padding: _useDropdown2() ? horizontalMargin : EdgeInsets.zero, + child: Text(optionLabels[option] ?? '', style: widget.textStyle), + )), ) .toList(); @@ -234,37 +233,36 @@ class _FlutterFlowDropDownState extends State> { final isSelected = multiSelectController.value?.contains(item) ?? false; return InkWell( - onTap: () { - multiSelectController.value ??= []; - isSelected - ? multiSelectController.value!.remove(item) - : multiSelectController.value!.add(item); - multiSelectController.update(); - // This rebuilds the StatefulWidget to update the button's text. - setState(() {}); - // This rebuilds the dropdownMenu Widget to update the check mark. - menuSetState(() {}); - }, - child: Container( - height: double.infinity, - padding: horizontalMargin, - child: Row( - children: [ - if (isSelected) - const Icon(Icons.check_box_outlined) - else - const Icon(Icons.check_box_outline_blank), - const SizedBox(width: 16), - Expanded( - child: Text( - optionLabels[item]!, - style: widget.textStyle, + onTap: () { + multiSelectController.value ??= []; + isSelected + ? multiSelectController.value!.remove(item) + : multiSelectController.value!.add(item); + multiSelectController.update(); + // This rebuilds the StatefulWidget to update the button's text. + setState(() {}); + // This rebuilds the dropdownMenu Widget to update the check mark. + menuSetState(() {}); + }, + child: Container( + height: double.infinity, + padding: horizontalMargin, + child: Row( + children: [ + if (isSelected) + const Icon(Icons.check_box_outlined) + else + const Icon(Icons.check_box_outline_blank), + const SizedBox(width: 16), + Expanded( + child: Text( + optionLabels[item]!, + style: widget.textStyle, + ), ), - ), - ], - ), - ), - ); + ], + ), + )); }, ), ), @@ -307,21 +305,19 @@ class _FlutterFlowDropDownState extends State> { : (isMultiSelect ? (_) {} : (val) => widget.controller!.value = val), isExpanded: true, selectedItemBuilder: (context) => widget.options - .map( - (item) => Align( - alignment: AlignmentDirectional.centerStart, - child: Text( - isMultiSelect - ? currentValues - .where((v) => optionLabels.containsKey(v)) - .map((v) => optionLabels[v]) - .join(', ') - : optionLabels[item]!, - style: widget.textStyle, - maxLines: 1, - ), - ), - ) + .map((item) => Align( + alignment: AlignmentDirectional.centerStart, + child: Text( + isMultiSelect + ? currentValues + .where((v) => optionLabels.containsKey(v)) + .map((v) => optionLabels[v]) + .join(', ') + : optionLabels[item]!, + style: widget.textStyle, + maxLines: 1, + ), + )) .toList(), dropdownSearchData: widget.isSearchable ? DropdownSearchData( diff --git a/lib/flutter_flow/internationalization.dart b/lib/flutter_flow/internationalization.dart index 1a825db4..ca57ae4a 100644 --- a/lib/flutter_flow/internationalization.dart +++ b/lib/flutter_flow/internationalization.dart @@ -952,24 +952,32 @@ 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': 'E-mail Inválido.', + 'en': 'Invalid E-mail', }, 'z0bv6wi2': { 'pt': 'Please choose an option from the dropdown', 'en': '', }, '6nn79lmh': { - 'pt': 'Campo é necessário', - 'en': 'Field is required', + 'pt': 'Senha é Obrigatório', + 'en': 'Password is required', + }, + 'duq5gpp6': { + 'pt': 'Mínimo 8 caracteres.', + 'en': 'Minimum 8 characters.', }, 'rcikqhf1': { 'pt': 'Please choose an option from the dropdown', @@ -1298,4 +1306,4 @@ final kTranslationsMap = >>[ 'en': 'Block completed', }, }, -].reduce((a, b) => a..addAll(b)); \ No newline at end of file +].reduce((a, b) => a..addAll(b)); diff --git a/lib/shared/utils/validator_util.dart b/lib/shared/utils/validator_util.dart index 71e83154..3188c18e 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 >= 8) { + return true; + } else { + return false; + } + } +}