public override void ViewDidLoad() { base.ViewDidLoad(); NavigationController.NavigationBarHidden = true; PasswordManagerButton.Hidden = !ViewModel.IsPasswordManagerAvailable; UIKeyboard.Notifications.ObserveWillShow(KeyboardWillShow); UIKeyboard.Notifications.ObserveWillHide(KeyboardWillHide); //Text this.Bind(ViewModel.Email, EmailTextField.BindText()); this.Bind(ViewModel.ErrorMessage, ErrorLabel.BindText()); this.Bind(ViewModel.Password, PasswordTextField.BindText()); this.Bind(EmailTextField.Text().Select(Email.From), ViewModel.SetEmail); this.Bind(PasswordTextField.Text().Select(Password.From), ViewModel.SetPassword); this.Bind(ViewModel.IsLoading.Select(loginButtonTitle), LoginButton.BindAnimatedTitle()); //Visibility this.Bind(ViewModel.HasError, ErrorLabel.BindAnimatedIsVisible()); this.Bind(ViewModel.IsLoading, ActivityIndicator.BindIsVisibleWithFade()); this.Bind(ViewModel.IsPasswordMasked.Skip(1), PasswordTextField.BindSecureTextEntry()); this.Bind(ViewModel.IsShowPasswordButtonVisible, ShowPasswordButton.BindIsVisible()); this.Bind(PasswordTextField.FirstResponder, ViewModel.SetIsShowPasswordButtonVisible); //Commands this.Bind(SignupCard.Tapped(), ViewModel.Signup); this.BindVoid(LoginButton.Tapped(), ViewModel.Login); this.BindVoid(GoogleLoginButton.Tapped(), ViewModel.GoogleLogin); this.Bind(ForgotPasswordButton.Tapped(), ViewModel.ForgotPassword); this.Bind(PasswordManagerButton.Tapped(), ViewModel.StartPasswordManager); this.BindVoid(ShowPasswordButton.Tapped(), ViewModel.TogglePasswordVisibility); //Color this.Bind(ViewModel.HasError.Select(loginButtonTintColor), LoginButton.BindTintColor()); this.Bind(ViewModel.LoginEnabled.Select(loginButtonTitleColor), LoginButton.BindTitleColor()); //Animation this.Bind(ViewModel.Shake, shakeTargets => { if (shakeTargets.HasFlag(LoginViewModel.ShakeTargets.Email)) { EmailTextField.Shake(); } if (shakeTargets.HasFlag(LoginViewModel.ShakeTargets.Password)) { PasswordTextField.Shake(); } }); prepareViews(); UIColor loginButtonTintColor(bool hasError) => hasError ? UIColor.White : UIColor.Black; UIColor loginButtonTitleColor(bool enabled) => enabled ? Color.Login.EnabledButtonColor.ToNativeColor() : Color.Login.DisabledButtonColor.ToNativeColor(); }