Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }
Exemplo n.º 4
0
        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();
        }