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

            Title = Resources.LoginForgotPassword;
            ResetPasswordButton.SetTitle(Resources.GetPasswordResetLink, UIControlState.Normal);
            EmailTextField.Placeholder = Resources.EmailAddress;
            SuccessMessageLabel.Text   = Resources.PasswordResetSuccess;

            prepareViews();

            //Text
            ViewModel.ErrorMessage
            .Subscribe(errorMessage =>
            {
                ErrorLabel.Text   = errorMessage;
                ErrorLabel.Hidden = string.IsNullOrEmpty(errorMessage);
            })
            .DisposedBy(DisposeBag);

            EmailTextField.Rx().Text()
            .Select(Email.From)
            .Subscribe(ViewModel.Email.OnNext)
            .DisposedBy(DisposeBag);

            ViewModel.Reset.Executing
            .Subscribe(loading =>
            {
                UIView.Transition(
                    ResetPasswordButton,
                    Animation.Timings.EnterTiming,
                    UIViewAnimationOptions.TransitionCrossDissolve,
                    () => ResetPasswordButton.SetTitle(loading ? "" : Resources.GetPasswordResetLink, UIControlState.Normal),
                    null
                    );
            })
            .DisposedBy(DisposeBag);

            //Visibility
            ViewModel.PasswordResetSuccessful
            .Subscribe(DoneCard.Rx().IsVisibleWithFade())
            .DisposedBy(DisposeBag);

            ViewModel.PasswordResetSuccessful
            .Invert()
            .Subscribe(ResetPasswordButton.Rx().IsVisibleWithFade())
            .DisposedBy(DisposeBag);

            ViewModel.PasswordResetSuccessful
            .Where(s => s == false)
            .Subscribe(_ => EmailTextField.BecomeFirstResponder())
            .DisposedBy(DisposeBag);

            ViewModel.Reset.Executing
            .Subscribe(ActivityIndicator.Rx().IsVisibleWithFade())
            .DisposedBy(DisposeBag);

            //Commands
            ResetPasswordButton.Rx()
            .BindAction(ViewModel.Reset)
            .DisposedBy(DisposeBag);
        }