private void prepareViews() { NavigationController.NavigationBarHidden = true; ActivityIndicator.Alpha = 0; ActivityIndicator.StartSpinning(); SignupButton.SetTitleColor( Color.Login.DisabledButtonColor.ToNativeColor(), UIControlState.Disabled ); EmailTextField.ShouldReturn += _ => { PasswordTextField.BecomeFirstResponder(); return(false); }; PasswordTextField.ShouldReturn += _ => { ViewModel.SignupCommand.Execute(); PasswordTextField.ResignFirstResponder(); return(false); }; View.AddGestureRecognizer(new UITapGestureRecognizer(() => { EmailTextField.ResignFirstResponder(); PasswordTextField.ResignFirstResponder(); })); SignupShakeTriggerButton.TouchUpInside += (sender, e) => { if (!ViewModel.Email.IsValid) { EmailTextField.Shake(); } if (!ViewModel.Password.IsValid) { PasswordTextField.Shake(); } if (!ViewModel.IsCountryValid) { SelectCountryButton.Shake(); CountryNotSelectedImageView.Shake(); CountryDropDownCaretImageView.Shake(); } }; ShowPasswordButton.SetupShowPasswordButton(); EmailTextField.ResignFirstResponder(); PasswordTextField.ResignFirstResponder(); }
public override void ViewDidLoad() { base.ViewDidLoad(); EmailTextField.Placeholder = Resources.EmailAddress; PasswordTextField.Placeholder = Resources.Password; SignUpCardTitleLabel.Text = Resources.AlreadyHaveAnAccountQuestionMark; SignUpCardLoginLabel.Text = Resources.LoginTitle; OrLabel.Text = Resources.Or.ToUpper(); GoogleSignupButton.SetTitle(Resources.GoogleSignUp, UIControlState.Normal); NavigationController.NavigationBarHidden = true; UIKeyboard.Notifications.ObserveWillShow(KeyboardWillShow); UIKeyboard.Notifications.ObserveWillHide(KeyboardWillHide); ViewModel.SuccessfulSignup .Subscribe(logAdjustSignupEvent) .DisposedBy(DisposeBag); //Text ViewModel.ErrorMessage .Subscribe(ErrorLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.Email .Subscribe(EmailTextField.Rx().TextObserver()) .DisposedBy(DisposeBag); ViewModel.Password .Subscribe(PasswordTextField.Rx().TextObserver()) .DisposedBy(DisposeBag); EmailTextField.Rx().Text() .Select(Email.From) .Subscribe(ViewModel.SetEmail) .DisposedBy(DisposeBag); PasswordTextField.Rx().Text() .Select(Password.From) .Subscribe(ViewModel.SetPassword) .DisposedBy(DisposeBag); ViewModel.IsLoading .Select(signupButtonTitle) .Subscribe(SignupButton.Rx().AnimatedTitle()) .DisposedBy(DisposeBag); ViewModel.CountryButtonTitle .Subscribe(SelectCountryButton.Rx().AnimatedTitle()) .DisposedBy(DisposeBag); //Visibility ViewModel.HasError .Subscribe(ErrorLabel.Rx().AnimatedIsVisible()) .DisposedBy(DisposeBag); ViewModel.IsLoading .Subscribe(ActivityIndicator.Rx().IsVisibleWithFade()) .DisposedBy(DisposeBag); ViewModel.IsPasswordMasked .Skip(1) .Subscribe(PasswordTextField.Rx().SecureTextEntry()) .DisposedBy(DisposeBag); ViewModel.IsShowPasswordButtonVisible .Subscribe(ShowPasswordButton.Rx().IsVisible()) .DisposedBy(DisposeBag); PasswordTextField.FirstResponder .Subscribe(ViewModel.SetIsShowPasswordButtonVisible) .DisposedBy(DisposeBag); ViewModel.IsCountryErrorVisible .Subscribe(CountryNotSelectedImageView.Rx().AnimatedIsVisible()) .DisposedBy(DisposeBag); //Commands LoginCard.Rx() .BindAction(ViewModel.Login) .DisposedBy(DisposeBag); SignupButton.Rx() .BindAction(ViewModel.Signup) .DisposedBy(DisposeBag); GoogleSignupButton.Rx() .BindAction(ViewModel.GoogleSignup) .DisposedBy(DisposeBag); ShowPasswordButton.Rx().Tap() .Subscribe(ViewModel.TogglePasswordVisibility) .DisposedBy(DisposeBag); SelectCountryButton.Rx() .BindAction(ViewModel.PickCountry) .DisposedBy(DisposeBag); //Color ViewModel.HasError .Select(signupButtonTintColor) .Subscribe(SignupButton.Rx().TintColor()) .DisposedBy(DisposeBag); ViewModel.SignupEnabled .Select(signupButtonTitleColor) .Subscribe(SignupButton.Rx().TitleColor()) .DisposedBy(DisposeBag); //Animation ViewModel.Shake .Subscribe(shakeTargets => { if (shakeTargets.HasFlag(SignupViewModel.ShakeTargets.Email)) { EmailTextField.Shake(); } if (shakeTargets.HasFlag(SignupViewModel.ShakeTargets.Password)) { PasswordTextField.Shake(); } if (shakeTargets.HasFlag(SignupViewModel.ShakeTargets.Country)) { SelectCountryButton.Shake(); } }) .DisposedBy(DisposeBag); prepareViews(); UIColor signupButtonTintColor(bool hasError) => hasError ? UIColor.White : UIColor.Black; UIColor signupButtonTitleColor(bool enabled) => enabled ? Core.UI.Helper.Colors.Login.EnabledButtonColor.ToNativeColor() : Core.UI.Helper.Colors.Login.DisabledButtonColor.ToNativeColor(); }
void ReleaseDesignerOutlets() { if (ActivityIndicator != null) { ActivityIndicator.Dispose(); ActivityIndicator = null; } if (CountryDropDownCaretImageView != null) { CountryDropDownCaretImageView.Dispose(); CountryDropDownCaretImageView = null; } if (CountryNotSelectedImageView != null) { CountryNotSelectedImageView.Dispose(); CountryNotSelectedImageView = null; } if (EmailTextField != null) { EmailTextField.Dispose(); EmailTextField = null; } if (ErrorLabel != null) { ErrorLabel.Dispose(); ErrorLabel = null; } if (GoogleSignupButton != null) { GoogleSignupButton.Dispose(); GoogleSignupButton = null; } if (LoginCard != null) { LoginCard.Dispose(); LoginCard = null; } if (PasswordTextField != null) { PasswordTextField.Dispose(); PasswordTextField = null; } if (SelectCountryButton != null) { SelectCountryButton.Dispose(); SelectCountryButton = null; } if (ShowPasswordButton != null) { ShowPasswordButton.Dispose(); ShowPasswordButton = null; } if (SignupButton != null) { SignupButton.Dispose(); SignupButton = null; } if (SignupShakeTriggerButton != null) { SignupShakeTriggerButton.Dispose(); SignupShakeTriggerButton = null; } if (TopConstraint != null) { TopConstraint.Dispose(); TopConstraint = null; } if (EmailFieldTopConstraint != null) { EmailFieldTopConstraint.Dispose(); EmailFieldTopConstraint = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationController.NavigationBarHidden = true; UIKeyboard.Notifications.ObserveWillShow(KeyboardWillShow); UIKeyboard.Notifications.ObserveWillHide(KeyboardWillHide); //Text this.Bind(ViewModel.ErrorMessage, ErrorLabel.Rx().Text()); this.Bind(ViewModel.Email, EmailTextField.Rx().TextObserver()); this.Bind(ViewModel.Password, PasswordTextField.Rx().TextObserver()); this.Bind(EmailTextField.Rx().Text().Select(Email.From), ViewModel.SetEmail); this.Bind(PasswordTextField.Rx().Text().Select(Password.From), ViewModel.SetPassword); this.Bind(ViewModel.IsLoading.Select(signupButtonTitle), SignupButton.Rx().AnimatedTitle()); this.Bind(ViewModel.CountryButtonTitle, SelectCountryButton.Rx().AnimatedTitle()); //Visibility this.Bind(ViewModel.HasError, ErrorLabel.Rx().AnimatedIsVisible()); this.Bind(ViewModel.IsLoading, ActivityIndicator.Rx().IsVisibleWithFade()); this.Bind(ViewModel.IsPasswordMasked.Skip(1), PasswordTextField.Rx().SecureTextEntry()); this.Bind(ViewModel.IsShowPasswordButtonVisible, ShowPasswordButton.Rx().IsVisible()); this.Bind(PasswordTextField.FirstResponder, ViewModel.SetIsShowPasswordButtonVisible); this.Bind(ViewModel.IsCountryErrorVisible, CountryNotSelectedImageView.Rx().AnimatedIsVisible()); //Commands this.Bind(LoginCard.Rx().Tap(), ViewModel.Login); this.Bind(SignupButton.Rx().Tap(), ViewModel.Signup); this.BindVoid(GoogleSignupButton.Rx().Tap(), ViewModel.GoogleSignup); this.BindVoid(ShowPasswordButton.Rx().Tap(), ViewModel.TogglePasswordVisibility); this.Bind(SelectCountryButton.Rx().Tap(), ViewModel.PickCountry); //Color this.Bind(ViewModel.HasError.Select(signupButtonTintColor), SignupButton.Rx().TintColor()); this.Bind(ViewModel.SignupEnabled.Select(signupButtonTitleColor), SignupButton.Rx().TitleColor()); //Animation this.Bind(ViewModel.Shake, shakeTargets => { if (shakeTargets.HasFlag(SignupViewModel.ShakeTargets.Email)) { EmailTextField.Shake(); } if (shakeTargets.HasFlag(SignupViewModel.ShakeTargets.Password)) { PasswordTextField.Shake(); } if (shakeTargets.HasFlag(SignupViewModel.ShakeTargets.Country)) { SelectCountryButton.Shake(); } }); prepareViews(); UIColor signupButtonTintColor(bool hasError) => hasError ? UIColor.White : UIColor.Black; UIColor signupButtonTitleColor(bool enabled) => enabled ? Color.Login.EnabledButtonColor.ToNativeColor() : Color.Login.DisabledButtonColor.ToNativeColor(); }