public MainWindowViewModel()
 {
     Button1Command = new AsyncReactiveCommand().WithSubscribe(Button1Processing).AddTo(Disposable);
     Button2Command = IsButtonEnable.ToAsyncReactiveCommand().WithSubscribe(Button2Processing).AddTo(Disposable);
     Button3Command = IsButtonEnable.ToAsyncReactiveCommand().WithSubscribe(Button3Processing).AddTo(Disposable);
     ClosedCommand.Subscribe(Close).AddTo(Disposable);
 }
Beispiel #2
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IAuthService authService)
            : base(navigationService)
        {
            _pageDialogService = pageDialogService;
            _authService       = authService;

            Title = "Main Page";

            _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) =>
            {
                _isSignedIn.Value = auth.CurrentUser != null;
            });

            ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand();

            SignUpCommand.Subscribe(SignUp);
            SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword);
            SignInWithGoogleCommand.Subscribe(SignInWithGoogle);
            SignInWithTwitterCommand.Subscribe(SignInWithTwitter);
            SignInWithFacebookCommand.Subscribe(SignInWithFacebook);
            SignInWithGitHubCommand.Subscribe(SignInWithGitHub);
            SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber);
            SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously);
            ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>());
        }
Beispiel #3
0
        public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IGoogleService googleService, IFacebookService facebookService, IAppleService appleService)
            : base(navigationService)
        {
            _pageDialogService = pageDialogService;
            _googleService     = googleService;
            _facebookService   = facebookService;
            _appleService      = appleService;

            _multiFactorService = new MultiFactorService(this);

            Title = "Main Page";

            _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) =>
            {
                _isSignedIn.Value = auth.CurrentUser != null;
            });

            ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand();

            SignUpCommand.Subscribe(SignUp);
            SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword);
            SignInWithGoogleCommand.Subscribe(SignInWithGoogle);
            SignInWithTwitterCommand.Subscribe(() => SignInWithProvider("twitter.com"));
            SignInWithFacebookCommand.Subscribe(SignInWithFacebook);
            SignInWithGitHubCommand.Subscribe(() => SignInWithProvider("github.com"));
            SignInWithYahooCommand.Subscribe(() => SignInWithProvider("yahoo.com"));
            SignInWithMicrosoftCommand.Subscribe(() => SignInWithProvider("microsoft.com"));
            SignInWithAppleCommand.Subscribe(SignInWithApple);
            SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber);
            SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously);
            ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>());
        }
Beispiel #4
0
        public LoginPageViewModel(INavigationService navigationService, IGoogleLoginService googleLoginService, IPageDialogService pageDialogService) : base(navigationService)
        {
            _googleLoginService = googleLoginService;
            _pageDialogService  = pageDialogService;

            _googleLoginService.LoginCompletedNotifier
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ =>
            {
                var navigation = NavigationFactory.Create <MainPageViewModel>()
                                 .Add(NavigationNameProvider.DefaultNavigationPageName)
                                 .Add <HomePageViewModel>();
                return(NavigateAsync(navigation, noHistory: true));
            })
            .Subscribe()
            .AddTo(_disposables);

            _googleLoginService.LoginErrorNotifier
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(_ => _pageDialogService.DisplayAlertAsync("エラー", "ログインに失敗しました", "OK"))
            .AddTo(_disposables);

            _googleLoginService.IsLoggingIn
            .Skip(1)
            .Where(b => b)
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ => NavigateAsync <LoadingPageViewModel>())
            .Subscribe()
            .AddTo(_disposables);

            _googleLoginService.IsLoggingIn
            .Skip(1)
            .Where(b => !b)
            .ObserveOn(SynchronizationContext.Current)
            .SelectMany(_ => GoBackAsync())
            .Subscribe()
            .AddTo(_disposables);

            LoginWithGoogleCommand = _isIdle.ToAsyncReactiveCommand();
            LoginWithGoogleCommand.Subscribe(async() => await _googleLoginService.Login());

            LoginWithEmailCommand = _isIdle.ToAsyncReactiveCommand();
            LoginWithEmailCommand.Subscribe(async() => await NavigateAsync <EmailLoginPageViewModel>());

            SignupCommand = _isIdle.ToAsyncReactiveCommand();
            SignupCommand.Subscribe(async() => await NavigateAsync <SignupPageViewModel>());
        }
Beispiel #5
0
        public ProgressDialogViewModel()
        {
            this.CurrentProgessInfo = model.CurrentProgessInfo
                                      .Buffer(TimeSpan.FromMilliseconds(500))
                                      .Where(x => x.Any())
                                      .Select(x => x.Last())
                                      .ObserveOnUIDispatcher()
                                      .ToReadOnlyReactivePropertySlim()
                                      .AddTo(this.CompositeDisposable);

            //ダブルクリックなどで2回以上キャンセルを押されるのを防ぐため、専用のプロパティを使用
            CancelCommand = limitOneceCancel
                            .ToAsyncReactiveCommand()
                            .WithSubscribe(() =>
            {
                limitOneceCancel.Value = false;
                model.CancelWork?.Cancel();
                return(Task.CompletedTask);
            });
        }
        public ReactiveCommandViewModel()
        {
            InvokedDateTime           = new ReactivePropertySlim <string>();
            CreateAndSubscribeCommand = new ReactiveCommand()
                                        .WithSubscribe(() => InvokedDateTime.Value = $"The command was invoked at {DateTime.Now}.")
                                        .AddTo(Disposables);

            InvokedDateTimeFromCommand = CreateAndSubscribeCommand
                                         .Select(_ => $"The command was invoked at {DateTime.Now}.")
                                         .ToReadOnlyReactivePropertySlim()
                                         .AddTo(Disposables);

            IsChecked = new ReactivePropertySlim <bool>()
                        .AddTo(Disposables);
            CreateFromIObservableBoolCommand = IsChecked.ToReactiveCommand()
                                               .AddTo(Disposables);
            InvokedDateTimeForCreateFromIObservableBoolCommand = CreateFromIObservableBoolCommand
                                                                 .Select(_ => $"The command was invoked at {DateTime.Now}.")
                                                                 .ToReadOnlyReactivePropertySlim()
                                                                 .AddTo(Disposables);

            ReactiveCommandWithParameter = new ReactiveCommand <string>()
                                           .AddTo(Disposables);
            ReactiveCommandWithParameterOutput = ReactiveCommandWithParameter
                                                 .Select(x => $"The command was invoked with {x}.")
                                                 .ToReadOnlyReactivePropertySlim()
                                                 .AddTo(Disposables);

            LongRunningCommandOutput = new ReactivePropertySlim <string>();
            LongRunningCommand       = new AsyncReactiveCommand()
                                       .WithSubscribe(async() =>
            {
                LongRunningCommandOutput.Value = "Long running command was started.";
                await Task.Delay(5000);
                LongRunningCommandOutput.Value = "Long running command was finished.";
            })
                                       .AddTo(Disposables);

            IsCheckedForAsyncReactiveCommand = new ReactivePropertySlim <bool>()
                                               .AddTo(Disposables);
            CreateFromIObservableBoolAsyncReactiveCommandOutput = new ReactivePropertySlim <string>()
                                                                  .AddTo(Disposables);
            CreateFromIObservableBoolAsyncReactiveCommand = IsCheckedForAsyncReactiveCommand
                                                            .ToAsyncReactiveCommand()
                                                            .WithSubscribe(async() =>
            {
                CreateFromIObservableBoolAsyncReactiveCommandOutput.Value = "Long running command was started.";
                await Task.Delay(5000);
                CreateFromIObservableBoolAsyncReactiveCommandOutput.Value = "Long running command was finished.";
            })
                                                            .AddTo(Disposables);

            var sharedStatus = new ReactivePropertySlim <bool>(true)
                               .AddTo(Disposables);

            IsCheckedForSharedStatus = new ReactivePropertySlim <bool>()
                                       .AddTo(Disposables);
            SharedStatusOutput = new ReactivePropertySlim <string>()
                                 .AddTo(Disposables);
            ACommand = IsCheckedForSharedStatus
                       .ToAsyncReactiveCommand(sharedStatus)
                       .WithSubscribe(async() =>
            {
                SharedStatusOutput.Value = "A command was started.";
                await Task.Delay(5000);
                SharedStatusOutput.Value = "A command was finished.";
            })
                       .AddTo(Disposables);
            BCommand = IsCheckedForSharedStatus
                       .ToAsyncReactiveCommand(sharedStatus)
                       .WithSubscribe(async() =>
            {
                SharedStatusOutput.Value = "B command was started.";
                await Task.Delay(5000);
                SharedStatusOutput.Value = "B command was finished.";
            })
                       .AddTo(Disposables);
        }