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.Rx().TextObserver()); this.Bind(ViewModel.ErrorMessage, ErrorLabel.Rx().Text()); 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(loginButtonTitle), LoginButton.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); //Commands this.Bind(SignupCard.Rx().Tap(), ViewModel.Signup); this.BindVoid(LoginButton.Rx().Tap(), ViewModel.Login); this.BindVoid(GoogleLoginButton.Rx().Tap(), ViewModel.GoogleLogin); this.Bind(ForgotPasswordButton.Rx().Tap(), ViewModel.ForgotPassword); this.Bind(PasswordManagerButton.Rx().Tap(), ViewModel.StartPasswordManager); this.BindVoid(ShowPasswordButton.Rx().Tap(), ViewModel.TogglePasswordVisibility); //Color this.Bind(ViewModel.HasError.Select(loginButtonTintColor), LoginButton.Rx().TintColor()); this.Bind(ViewModel.LoginEnabled.Select(loginButtonTitleColor), LoginButton.Rx().TitleColor()); //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(); }
public override void ViewDidLoad() { base.ViewDidLoad(); EmailTextField.Placeholder = Resources.EmailAddress; PasswordTextField.Placeholder = Resources.Password; OrLabel.Text = Resources.Or.ToUpper(); LoginButton.SetTitle(Resources.LoginTitle, UIControlState.Normal); GoogleLoginButton.SetTitle(Resources.GoogleLogin, UIControlState.Normal); DontHaveAnAccountLabel.Text = Resources.DoNotHaveAnAccountWithQuestionMark; SignUpForFreeLabel.Text = Resources.SignUpTitle; NavigationController.NavigationBarHidden = true; UIKeyboard.Notifications.ObserveWillShow(KeyboardWillShow); UIKeyboard.Notifications.ObserveWillHide(KeyboardWillHide); //Text ViewModel.Email .Subscribe(EmailTextField.Rx().TextObserver()) .DisposedBy(DisposeBag); ViewModel.ErrorMessage .Subscribe(ErrorLabel.Rx().Text()) .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(loginButtonTitle) .Subscribe(LoginButton.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); //Commands SignupCard.Rx() .BindAction(ViewModel.Signup) .DisposedBy(DisposeBag); LoginButton.Rx().Tap() .Subscribe(ViewModel.Login) .DisposedBy(DisposeBag); GoogleLoginButton.Rx().Tap() .Subscribe(ViewModel.GoogleLogin) .DisposedBy(DisposeBag); ForgotPasswordButton.Rx() .BindAction(ViewModel.ForgotPassword) .DisposedBy(DisposeBag); ShowPasswordButton.Rx().Tap() .Subscribe(ViewModel.TogglePasswordVisibility) .DisposedBy(DisposeBag); //Color ViewModel.HasError .Select(loginButtonTintColor) .Subscribe(LoginButton.Rx().TintColor()) .DisposedBy(DisposeBag); ViewModel.LoginEnabled .Select(loginButtonTitleColor) .Subscribe(LoginButton.Rx().TitleColor()) .DisposedBy(DisposeBag); //Animation ViewModel.Shake .Subscribe(shakeTargets => { if (shakeTargets.HasFlag(LoginViewModel.ShakeTargets.Email)) { EmailTextField.Shake(); } if (shakeTargets.HasFlag(LoginViewModel.ShakeTargets.Password)) { PasswordTextField.Shake(); } }) .DisposedBy(DisposeBag); prepareViews(); UIColor loginButtonTintColor(bool hasError) => hasError ? UIColor.White : UIColor.Black; UIColor loginButtonTitleColor(bool enabled) => enabled ? UIColor.White : UIColor.White.ColorWithAlpha((nfloat)0.5); }
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(); }
public override void ViewDidLoad() { base.ViewDidLoad(); TitleLabel.Text = Resources.NewProject; NameTextField.Placeholder = Resources.ProjectName; ErrorLabel.Text = Resources.ProjectNameTakenError; DoneButton.SetTitle(Resources.Create, UIControlState.Normal); ProjectNameUsedErrorTextHeight.Constant = 0; // Name NameTextField.Rx().Text() .Subscribe(ViewModel.Name.Accept) .DisposedBy(DisposeBag); ViewModel.Name .Subscribe(NameTextField.Rx().TextObserver()) .DisposedBy(DisposeBag); // Color ColorPickerOpeningView.Rx() .BindAction(ViewModel.PickColor) .DisposedBy(DisposeBag); ViewModel.Color .Select(color => color.ToNativeColor()) .Subscribe(ColorCircleView.Rx().BackgroundColor()) .DisposedBy(DisposeBag); // Error ViewModel.Error .Subscribe(ErrorLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.Error .Select(e => string.IsNullOrEmpty(e) ? new nfloat(0) : errorVisibleHeight) .Subscribe(ProjectNameUsedErrorTextHeight.Rx().Constant()) .DisposedBy(DisposeBag); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { ViewModel.Error .Select(e => string.IsNullOrEmpty(e) ? desiredIpadHeight : errorVisibleHeight + desiredIpadHeight) .Select(h => new CGSize(0, h)) .Subscribe(this.Rx().PreferredContentSize()) .DisposedBy(DisposeBag); } // Workspace WorkspaceLabel.Rx() .BindAction(ViewModel.PickWorkspace) .DisposedBy(DisposeBag); ViewModel.WorkspaceName .Subscribe(WorkspaceLabel.Rx().Text()) .DisposedBy(DisposeBag); // Client ClientLabel.Rx() .BindAction(ViewModel.PickClient) .DisposedBy(DisposeBag); var emptyText = Resources.AddClient.PrependWithAddIcon(ClientLabel.Font.CapHeight); ViewModel.ClientName .Select(attributedClientName) .Subscribe(ClientLabel.Rx().AttributedText()) .DisposedBy(DisposeBag); // Is Private PrivateProjectSwitchContainer.Rx().Tap() .Select(_ => PrivateProjectSwitch.On) .Subscribe(ViewModel.IsPrivate.Accept) .DisposedBy(DisposeBag); ViewModel.IsPrivate .Subscribe(PrivateProjectSwitch.Rx().On()) .DisposedBy(DisposeBag); // Save DoneButton.Rx() .BindAction(ViewModel.Save) .DisposedBy(DisposeBag); CloseButton.Rx() .BindAction(ViewModel.Close) .DisposedBy(DisposeBag); NSAttributedString attributedClientName(string clientName) { if (string.IsNullOrEmpty(clientName)) { return(emptyText); } return(new NSAttributedString(clientName)); } }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = Resources.LoginTitle; ResetSuccessLabel.Text = Resources.APITokenResetSuccess; InstructionLabel.Text = Resources.TokenResetInstruction; PasswordTextField.Placeholder = Resources.Password; SignOutButton.SetTitle(Resources.OrSignOut, UIControlState.Normal); prepareViews(); ViewModel.Error .Subscribe(ErrorLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.Email .SelectToString() .Subscribe(EmailLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.Password .Subscribe(PasswordTextField.Rx().TextObserver()) .DisposedBy(DisposeBag); PasswordTextField.Rx().Text() .Subscribe(ViewModel.Password) .DisposedBy(DisposeBag); ViewModel.IsPasswordMasked .Subscribe(PasswordTextField.Rx().SecureTextEntry()) .DisposedBy(DisposeBag); SignOutButton.Rx() .BindAction(ViewModel.SignOut) .DisposedBy(DisposeBag); ShowPasswordButton.Rx() .BindAction(ViewModel.TogglePasswordVisibility) .DisposedBy(DisposeBag); nextButton.Rx().Tap() .Subscribe(ViewModel.Done.Inputs) .DisposedBy(DisposeBag); PasswordTextField.Rx().ShouldReturn() .Subscribe(ViewModel.Done.Inputs) .DisposedBy(DisposeBag); //Enabled ViewModel.NextIsEnabled .Subscribe(nextButton.Rx().Enabled()) .DisposedBy(DisposeBag); //Visibility ViewModel.HasError .Subscribe(ErrorView.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.Done.Executing .Invert() .Subscribe(ShowPasswordButton.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.Done.Executing .Subscribe(ActivityIndicatorView.Rx().IsVisible()) .DisposedBy(DisposeBag); PasswordTextField.BecomeFirstResponder(); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = Resources.LoginTitle; ResetSuccessLabel.Text = Resources.APITokenResetSuccess; InstructionLabel.Text = Resources.TokenResetInstruction; PasswordTextField.Placeholder = Resources.Password; SignOutButton.SetTitle(Resources.OrSignOut, UIControlState.Normal); EmailLabel.Text = ViewModel.Email.ToString(); ViewModel.Error .Subscribe(ErrorLabel.Rx().Text()) .DisposedBy(DisposeBag); ViewModel.Password .Subscribe(PasswordTextField.Rx().TextObserver()) .DisposedBy(DisposeBag); PasswordTextField.Rx().Text() .Subscribe(ViewModel.Password) .DisposedBy(DisposeBag); SignOutButton.Rx() .BindAction(ViewModel.SignOut) .DisposedBy(DisposeBag); ViewModel.SignOut.Elements .Subscribe(IosDependencyContainer.Instance.IntentDonationService.ClearAll) .DisposedBy(DisposeBag); ShowPasswordButton.Rx().Tap() .Subscribe(_ => { PasswordTextField.ResignFirstResponder(); PasswordTextField.SecureTextEntry = !PasswordTextField.SecureTextEntry; PasswordTextField.BecomeFirstResponder(); }) .DisposedBy(DisposeBag); LoginButton.Rx().Tap() .Subscribe(ViewModel.Done.Inputs) .DisposedBy(DisposeBag); PasswordTextField.Rx().ShouldReturn() .Subscribe(ViewModel.Done.Inputs) .DisposedBy(DisposeBag); //Enabled ViewModel.NextIsEnabled .Subscribe(LoginButton.Rx().Enabled()) .DisposedBy(DisposeBag); //Visibility ErrorLabel.Hidden = true; ViewModel.HasError .Subscribe(ErrorLabel.Rx().AnimatedIsVisible()) .DisposedBy(DisposeBag); ViewModel.Done.Executing .Invert() .Subscribe(ShowPasswordButton.Rx().IsVisible()) .DisposedBy(DisposeBag); ViewModel.Done.Executing .Subscribe(ActivityIndicatorView.Rx().IsVisibleWithFade()) .DisposedBy(DisposeBag); ViewModel.Done.Executing.Select(loginButtonTitle) .Subscribe(LoginButton.Rx().AnimatedTitle()) .DisposedBy(DisposeBag); PasswordTextField.BecomeFirstResponder(); ShowPasswordButton.SetupShowPasswordButton(); //Color ViewModel.HasError .Select(loginButtonTintColor) .Subscribe(LoginButton.Rx().TintColor()) .DisposedBy(DisposeBag); ViewModel.NextIsEnabled .Select(loginButtonTitleColor) .Subscribe(LoginButton.Rx().TitleColor()) .DisposedBy(DisposeBag); UIColor loginButtonTintColor(bool hasError) => hasError ? UIColor.White : UIColor.Black; UIColor loginButtonTitleColor(bool enabled) => enabled ? Core.UI.Helper.Colors.Login.EnabledButtonColor.ToNativeColor() : Core.UI.Helper.Colors.Login.DisabledButtonColor.ToNativeColor(); }