public RedViewModel(IViewStackService viewStackService) : base(viewStackService) { PopModal = ReactiveCommand .CreateFromObservable(() => ViewStackService.PopModal(), outputScheduler: RxApp.MainThreadScheduler); PopPage = ReactiveCommand .CreateFromObservable(() => ViewStackService.PopPage(), outputScheduler: RxApp.MainThreadScheduler); PushPage = ReactiveCommand .CreateFromObservable(() => ViewStackService.PushPage(new RedViewModel(ViewStackService)), outputScheduler: RxApp.MainThreadScheduler); PopToRoot = ReactiveCommand .CreateFromObservable(() => ViewStackService.PopToRootPage(), outputScheduler: RxApp.MainThreadScheduler); PopModal.Subscribe(x => Debug.WriteLine("PagePushed")); PopModal.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe()); PopPage.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe()); PushPage.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe()); PopToRoot.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe()); }
public static IObservable <Unit> PopModal(this ViewStackService viewStackService, int pages = 1) { for (var i = 0; i < pages; i++) { viewStackService.PopModal().Subscribe(); } return(Observable.Return(Unit.Default)); }
public RequestAmountViewModel() : base(Locator.Current.GetService <IViewStackService>()) { RequestAmount = "0"; CreateCommand = ReactiveCommand.CreateFromObservable <Unit, Unit>(_ => { return(ViewStackService.PopModal()); }); }
public FeeViewModel(SendAmountViewModel sendAmountViewModel) : base(Locator.Current.GetService <IViewStackService>()) { SendAmountViewModel = sendAmountViewModel; NavBackCommand = ReactiveCommand.CreateFromObservable <Unit, Unit>(_ => { return(ViewStackService.PopModal()); }); }
public CoinListViewModel(bool isPrivate = false) : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); RootList = new SourceList <CoinViewModel>(); RootList .Connect() .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _coinViewModels) .Subscribe(); SelectPrivateSwitchState = true; Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it."); UpdateRootList(); Observable .Merge(Observable.FromEventPattern <ProcessedResult>(Global.Wallet.TransactionProcessor, nameof(Global.Wallet.TransactionProcessor.WalletRelevantTransactionProcessed)).Select(_ => Unit.Default)) .Throttle(TimeSpan.FromSeconds(1)) // Throttle TransactionProcessor events adds/removes. .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { UpdateRootList(); }) .DisposeWith(Disposables); SelectPrivateSwitchCommand = ReactiveCommand.Create(() => { switch (SelectPrivateSwitchState) { case true: // FIXME MixUntilAnonymitySet SelectCoins(x => x.AnonymitySet >= Global.Config.PrivacyLevelSome); break; case false: SelectCoins(x => false); SelectPrivateSwitchState = false; break; } }); OpenCoinDetail = ReactiveCommand.CreateFromObservable((CoinViewModel cvm) => { ViewStackService.PushModal(cvm).Subscribe(); return(Observable.Return(Unit.Default)); }); NavBackCommand = ReactiveCommand.CreateFromObservable <Unit, Unit>(_ => { return(ViewStackService.PopModal()); }); }
public FirstModalViewModel(IViewStackService viewStackService) : base(viewStackService) { OpenModal = ReactiveCommand .CreateFromObservable(() => ViewStackService.PushModal(new SecondModalViewModel(viewStackService)), outputScheduler: RxApp.MainThreadScheduler); PopModal = ReactiveCommand .CreateFromObservable(() => ViewStackService.PopModal(), outputScheduler: RxApp.MainThreadScheduler); OpenModal.Subscribe(x => Debug.WriteLine("PagePushed")); PopModal.Subscribe(x => Debug.WriteLine("PagePopped")); PopModal.ThrownExceptions.Subscribe(error => Interactions.ErrorMessage.Handle(error).Subscribe()); }
public SendWhoViewModel(SendAmountViewModel savm) : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); Memo = ""; Address = ""; SendAmountViewModel = savm; var canPromptPassword = this.WhenAnyValue(x => x.Memo, x => x.Address, x => x.IsBusy, (memo, addr, isBusy) => { BitcoinAddress address; try { address = BitcoinAddress.Create(addr.Trim(), Global.Network); } catch (FormatException) { // SetWarningMessage("Invalid address."); return(false); } return(!isBusy && memo.Length > 0 && address is BitcoinAddress); }); _promptViewModel = new PasswordPromptViewModel("SEND"); _promptViewModel.ValidatePasswordCommand.Subscribe(async validPassword => { if (validPassword != null) { await ViewStackService.PopModal(); await BuildTransaction(validPassword); await ViewStackService.PushPage(new SentViewModel()); } }); PromptCommand = ReactiveCommand.CreateFromObservable(() => { ViewStackService.PushModal(_promptViewModel).Subscribe(); return(Observable.Return(Unit.Default)); }, canPromptPassword); }
public HomeViewModel(IViewStackService viewStackService) : base(viewStackService) { PushPage = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushPage(new HomeViewModel(ViewStackService))); }); PushModalWithNav = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushModal(new NavigationPageViewModel(new HomeViewModel(ViewStackService)))); }); PushModalWithoutNav = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushModal(new HomeViewModel(ViewStackService))); }); PopModal = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PopModal()); }); var canPop = this.WhenAnyValue( vm => vm.PopCount, vm => vm.PageCount, (popCount, pageCount) => popCount > 0 && popCount < pageCount); PopPages = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService .PopPages(_popCount ?? 0, true)); }, canPop); var canPopToNewPage = this.WhenAnyValue( vm => vm.PageIndex, pageIndex => pageIndex >= 0 && pageIndex < PageCount); PopToNewPage = ReactiveCommand.CreateFromObservable( () => { return(Observable .Start(() => ViewStackService.InsertPage(PageIndex ?? 0, new LoginViewModel(ViewStackService)), RxApp.MainThreadScheduler) .SelectMany(_ => ViewStackService.PopToPage(PageIndex ?? 0))); }, canPopToNewPage); this.WhenActivated( disposables => { _pageCount = ViewStackService .PageStack .Select( x => { return(x != null ? x.Count : 0); }) .ToProperty(this, vm => vm.PageCount, default(int), false, RxApp.MainThreadScheduler) .DisposeWith(disposables); }); }
private IObservable <Unit> ExecuteCancel() => ViewStackService.PopModal();