コード例 #1
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);
                }
            }
        }
コード例 #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);
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.

            var set = this.CreateBindingSet <BaseUserViewController, BaseUserViewModel>();

            //set.Bind(TakeButton).To(vm => vm.TakePictureCommand);
            //set.Bind(PhotoImageTapGestureRecognizer).To(vm => vm.ChoosePictureCommand);
            //set.Bind(LoginButton).To(vm => vm.LoginCommand);
            set.Bind <UITextField>(CompanyNameTextField).To(vm => vm.CompanyName);
            set.Bind <UITextField>(FullNameTextField).To(vm => vm.FullName);
            set.Bind <UITextField>(UsernameTextField).To(vm => vm.Username);
            set.Bind <UITextField>(PasswordTextField).To(vm => vm.Password);
            set.Bind <UITextField>(ConfirmPasswordTextField).To(vm => vm.ConfirmPassword);
            // set.Bind(AddButtonItem).To(vm => vm.AddUserCommand);
            set.Bind <UIImageView>(PhotoImageView).To(vm => vm.PhotoDataBytes).WithConversion("InMemoryImage");
            set.Apply();

            PropertiesTapGestureRecognizer.AddTarget(() =>
            {
                var controller = this.CreateViewControllerFor <PropertyPickerViewModel>(new
                {
                    viewOnlyMode             = !Editing,
                    jsonSelectedPropertyList = JsonConvert.SerializeObject(ViewModel.Properties),
                    requestedViewId          = ViewModel.ViewInstanceId,
                    userId = ViewModel.UserId
                }) as PropertyPickerViewController;

                NavigationController.PushViewController(controller, true);
            });

            PhotoImageTapGestureRecognizer.AddTarget(() =>
            {
                if (Editing)
                {
                    if (Runtime.Arch == Arch.DEVICE)
                    {
                        ViewModel.TakePictureCommand.Execute(null);
                    }
                    else if (Runtime.Arch == Arch.SIMULATOR)
                    {
                        ViewModel.ChoosePictureCommand.Execute(null);
                    }
                }
            });

            ViewModel.OnPictureEventHandler += (object sender, EventArgs e) => {
                PlaceholderImageView.Hidden = true;
            };

            ViewModel.OnPictureCancelledEventHandler += (object sender, EventArgs e) => {
            };

            // Dismiss view controller after user added
            //ViewModel.AddUserSuccessEventHandler += (object sender, EventArgs e) => NavigationController.PopViewControllerAnimated (true);

            // CancelButtonItem.Clicked += (object sender, EventArgs e) => NavigationController.PopViewControllerAnimated (true);

            FullNameTextField.ShouldReturn += (textField) => {
                textField.ResignFirstResponder();
                UsernameTextField.BecomeFirstResponder();
                return(true);
            };

            UsernameTextField.ShouldReturn += (textField) => {
                textField.ResignFirstResponder();
                PasswordTextField.BecomeFirstResponder();
                return(true);
            };

            PasswordTextField.ShouldReturn += (textField) => {
                textField.ResignFirstResponder();
                ConfirmPasswordTextField.BecomeFirstResponder();
                return(true);
            };

            // Done button pressed
            ConfirmPasswordTextField.ShouldReturn += (textField) => {
                textField.ResignFirstResponder();
                return(true);
            };

            SetEditing(true, false);
        }