Exemple #1
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();
        }