Ejemplo n.º 1
0
        private void GestureGecognizer()
        {
            var gestureRecognizer = new UITapGestureRecognizer(() =>
            {
                FirstNameTextField.ResignFirstResponder();
                LastNameTextField.ResignFirstResponder();
                EmailTextField.ResignFirstResponder();
                PasswordTextField.ResignFirstResponder();
                ConfirmPasswordTextField.ResignFirstResponder();
                PhoneNumberTextField.ResignFirstResponder();
            });

            View.AddGestureRecognizer(gestureRecognizer);
        }
Ejemplo n.º 2
0
        private void SetDataAndStyleToView()
        {
            // init strings in view
            InitializeAllStrings();

            // set up the background
            //BackgroundImageView2.Image = UIImage.FromBundle("LoginBackground");

            // dissmiss the keyboard when i press return key on email TextField
            EmailTextField.ShouldReturn += (textField) =>
            {
                EmailTextField.ResignFirstResponder();
                PasswordTextField.BecomeFirstResponder();
                return(true);
            };

            // dissmiss the keyboard when i press return key on password TextField
            PasswordTextField.ShouldReturn += (textField) =>
            {
                PasswordTextField.ResignFirstResponder();
                LoginButton_TouchUpInside(null, null);
                return(true);
            };

            // dissmiss the keyboard when i press return key on Name TextField
            FirstNameTextField.ShouldReturn += (textField) =>
            {
                FirstNameTextField.ResignFirstResponder();
                LastNameTextField.BecomeFirstResponder();
                return(true);
            };

            // dissmiss the keyboard when i press return key on FirstName TextField
            LastNameTextField.ShouldReturn += (textField) =>
            {
                LastNameTextField.ResignFirstResponder();
                EmailTextFieldOfRegistration.BecomeFirstResponder();
                return(true);
            };

            // dissmiss the keyboard when i press return key on email TextField
            EmailTextFieldOfRegistration.ShouldReturn += (textField) =>
            {
                EmailTextFieldOfRegistration.ResignFirstResponder();
                PasswordTextFieldOfRegistration.BecomeFirstResponder();
                return(true);
            };

            // dissmiss the keyboard when i press return key on password TextField
            PasswordTextFieldOfRegistration.ShouldReturn += (textField) =>
            {
                PasswordTextFieldOfRegistration.ResignFirstResponder();
                ConfirmPasswordTextField.BecomeFirstResponder();
                return(true);
            };
            PasswordTextFieldOfRegistration.EditingChanged += (o, e) =>
            {
                ErrorMessageLabel.Hidden = true;
            };
            PasswordTextFieldOfRegistration.ShouldBeginEditing += (textField) =>
            {
                if (View.Frame.Y >= 0)
                {
                    bottom = ((float)(RegistrationContainer.Frame.Y + PasswordTextFieldOfRegistration.Frame.Y + PasswordTextFieldOfRegistration.Frame.Height + 10));
                }
                return(true);
            };

            // dissmiss the keyboard when i press return key on Confirm Password TextField
            ConfirmPasswordTextField.ShouldReturn += (textField) =>
            {
                ConfirmPasswordTextField.ResignFirstResponder();
                return(true);
            };
            ConfirmPasswordTextField.EditingChanged += (o, e) =>
            {
                ErrorMessageLabel.Hidden = true;
            };
            ConfirmPasswordTextField.ShouldBeginEditing += (textField) =>
            {
                if (View.Frame.Y >= 0)
                {
                    bottom = ((float)(RegistrationContainer.Frame.Y + ConfirmPasswordTextField.Frame.Y + ConfirmPasswordTextField.Frame.Height + 10));
                }
                return(true);
            };

            // dissmiss the keyboard when i press return key on Confirm Password TextField
            EmailTextFieldOfForgetPassword.ShouldReturn += (textField) =>
            {
                EmailTextFieldOfForgetPassword.ResignFirstResponder();
                return(true);
            };

            EmailTextField.KeyboardType                       = UIKeyboardType.EmailAddress;
            EmailTextField.AutocorrectionType                 = UITextAutocorrectionType.No;
            PasswordTextField.AutocorrectionType              = UITextAutocorrectionType.No;
            FirstNameTextField.ReturnKeyType                  = UIReturnKeyType.Next;
            LastNameTextField.AutocorrectionType              = UITextAutocorrectionType.No;
            LastNameTextField.ReturnKeyType                   = UIReturnKeyType.Next;
            EmailTextFieldOfRegistration.KeyboardType         = UIKeyboardType.EmailAddress;
            EmailTextFieldOfRegistration.AutocorrectionType   = UITextAutocorrectionType.No;
            EmailTextFieldOfRegistration.ReturnKeyType        = UIReturnKeyType.Next;
            PasswordTextFieldOfRegistration.ReturnKeyType     = UIReturnKeyType.Next;
            ConfirmPasswordTextField.ReturnKeyType            = UIReturnKeyType.Next;
            EmailTextFieldOfForgetPassword.KeyboardType       = UIKeyboardType.EmailAddress;
            EmailTextFieldOfForgetPassword.AutocorrectionType = UITextAutocorrectionType.No;

            // set up the rounded corner fot the button
            LoadingIndicator.Hidden         = true;
            LoginButton.Layer.CornerRadius  = 4;
            LoginButton.Layer.MasksToBounds = true;

            RegistrationButton.Layer.CornerRadius  = 4;
            RegistrationButton.Layer.MasksToBounds = true;
            RegistrationButton.Enabled             = false;

            ResetPasswordButton.Layer.CornerRadius  = 4;
            ResetPasswordButton.Layer.MasksToBounds = true;
            ResetPasswordButton.Enabled             = false;

            //DisplayFacebookButton();
            //_facebookButton.Layer.CornerRadius = 4;
            //_facebookButton.Layer.MasksToBounds = true;

            CreateAccountButton.ContentEdgeInsets  = new UIEdgeInsets(5, 0, 5, 5);
            ForgetPasswordButton.ContentEdgeInsets = new UIEdgeInsets(5, 5, 5, 0);

            LoginContainer.Hidden          = false;
            RegistrationContainer.Hidden   = true;
            ForgetPasswordContainer.Hidden = true;
            BackButton.Hidden           = true;
            CreateAccountButton.Hidden  = false;
            ForgetPasswordButton.Hidden = false;
            ErrorMessageLabel.Hidden    = true;
            ErrorMessageLabel.TextColor = UIColor.FromRGB(255, 76, 56);
        }
Ejemplo n.º 3
0
        async partial void Register(UIButton sender)
        {
            var fname = FullNameRegisterTextField.Text;
            var email = EmailRegisterTextField.Text;
            var passw = PasswordRegisterTextField.Text;

            // TODO: Should refactor validation to a helper class as this is shared with LoginVC
            if (string.IsNullOrWhiteSpace(fname))
            {
                ErrorMessageDialog(StringResources.register_ui_fullname_validate_empty);
            }
            else if (string.IsNullOrWhiteSpace(email))
            {
                ErrorMessageDialog(StringResources.common_ui_forms_email_validate_empty);
            }
            else if (string.IsNullOrWhiteSpace(passw))
            {
                ErrorMessageDialog(StringResources.common_ui_forms_password_validate_empty);
            }
            else if (!Regex.Match(email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success)
            {
                ErrorMessageDialog(StringResources.common_ui_forms_email_validate_invalid);
            }
            else if (PasswordRegisterTextField.Text != ConfirmPasswordTextField.Text)
            {
                ErrorMessageDialog(StringResources.common_ui_forms_password_validate_mismatch);
            }
            else if (pickerModel.GetChoice(LanguagePicker) == null)
            {
                ErrorMessageDialog(StringResources.common_ui_forms_language_error);
            }
            else
            {
                ConfirmPasswordTextField.BecomeFirstResponder();
                ConfirmPasswordTextField.ResignFirstResponder();

                RegisterUIButton.Enabled = false;
                Logger.LOG_EVENT_WITH_ACTION("REGISTER", "ATTEMPT");

                LoadingOverlay.Alpha = 1;

                var response = await RestClient.Register(fname, email, passw, pickerModel.GetChoice(LanguagePicker).Id);

                RegisterUIButton.Enabled = true;

                LoadingOverlay.Alpha = 0;

                if (response.Meta.Success)
                {
                    Logger.LOG_EVENT_WITH_ACTION("REGISTER", "SUCCESS");
                    NSUserDefaults.StandardUserDefaults.SetString(email, "username");
                    PerformSegue("ShowVerifySegue", this);
                }
                else if (response.Meta.Messages.Count > 0)
                {
                    Logger.LOG_EVENT_WITH_ACTION("REGISTER", "ERROR");
                    // Note: errors returned by register are the same as logjn, hence using that for lookup.
                    var err = StringResources.ResourceManager.GetString($"login.api.error.{response.Meta.Messages[0]}");
                    ErrorMessageDialog(err);
                }
            }
        }