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 AddressViewModel(HdPubKey model) : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); Global.NotificationManager.RequestAuthorization(); Model = model; _bitcoinUri = this .WhenAnyValue(x => x.RequestAmountViewModel.RequestAmount) .Select(amount => { return($"bitcoin:{Address}?amount={amount}"); }) .ToProperty(this, nameof(BitcoinUri)); this.WhenAnyValue(x => x.BitcoinUri) .Subscribe((uri) => EncodeQRCode()); RequestAmountCommand = ReactiveCommand.CreateFromObservable <Unit, Unit>(_ => { if (RequestAmountViewModel is null) { RequestAmountViewModel = new RequestAmountViewModel(); } ViewStackService.PushModal(RequestAmountViewModel).Subscribe(); return(Observable.Return(Unit.Default)); }); ShareCommand = ReactiveCommand.CreateFromTask <string>(ShareBoundString); NavWalletCommand = ReactiveCommand.CreateFromObservable <Unit, Unit>(_ => { ViewStackService.PopPage(false); return(ViewStackService.PopPage(true)); }); }
public BackUpViewModel(List <string> seedWords) : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); SeedWords = seedWords; IndexedWords = new string[SeedWords.Count()]; for (int i = 0; i < SeedWords.Count(); i++) { IndexedWords[i] = $"{i+1}. {SeedWords[i]}"; } VerifyCommand = ReactiveCommand.CreateFromObservable(() => { if (Global.UiConfig.IsBackedUp) { // pop back home ViewStackService.PopPage(); ViewStackService.PopPage(); } else { // verify backup ViewStackService.PushPage(new VerifyMnemonicViewModel(SeedWords, null)).Subscribe(); } return(Observable.Return(Unit.Default)); }); }
public static IObservable <Unit> PopPage(this ViewStackService viewStackService, int pages = 1) { for (var i = 0; i < pages; i++) { viewStackService.PopPage().Subscribe(); } return(Observable.Return(Unit.Default)); }
public SentViewModel() : base(Locator.Current.GetService <IViewStackService>()) { NavWalletCommand = ReactiveCommand.CreateFromObservable(() => { ViewStackService.PopPage(false); ViewStackService.PopPage(false); return(ViewStackService.PopPage(true)); }); }
// <param name="isFinal"> // we verify 2 words, isFinal -> we verified 1 word already // </param> public VerifyMnemonicViewModel(List <string> seedWords, string previouslyVerified) : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); SeedWords = seedWords; while (WordToVerify == null || WordToVerify == previouslyVerified) { // "random" check words were written. no need for CSPRNG WordToVerify = seedWords.RandomElement(); } IndexToVerify = seedWords.IndexOf(WordToVerify); VerifiedCommand = ReactiveCommand.CreateFromObservable(() => { if (previouslyVerified != null) { Global.UiConfig.IsBackedUp = true; Global.UiConfig.ToFile(); // successfully backed up! ViewStackService.PopPage(false); // this ViewStackService.PopPage(false); // previouslyVerified ViewStackService.PopPage(false); ViewStackService.PopPage(); // words } else { ViewStackService.PushPage(new VerifyMnemonicViewModel(seedWords, WordToVerify)).Subscribe(); } return(Observable.Return(Unit.Default)); }); FailedCommand = ReactiveCommand.CreateFromObservable(() => { ViewStackService.PopPage(false); // this if (previouslyVerified != null) { ViewStackService.PopPage(false); // previouslyVerified } return(Observable.Return(Unit.Default)); }); }