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 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 CatalogCategoryListViewModel(ICatalogCategoryRepo catalogCategoryRepo = null, IViewStackService viewStackService = null) : base(viewStackService) { catalogCategoryRepo = catalogCategoryRepo ?? Locator.Current.GetService <ICatalogCategoryRepo>(); LoadCatalogCategories = ReactiveCommand.CreateFromObservable( () => { return(catalogCategoryRepo.GetItems() .SelectMany(x => x) .Select(x => new CatalogCategoryCellViewModel(x) as ICatalogCategoryCellViewModel) .ToList() .Select(x => x as IReadOnlyList <ICatalogCategoryCellViewModel>) .SubscribeOn(RxApp.TaskpoolScheduler)); }); _catalogCategories = LoadCatalogCategories .ToProperty(this, x => x.CatalogCategories, scheduler: RxApp.MainThreadScheduler); this .WhenAnyValue(vm => vm.SelectedItem) .Where(x => x != null) .SelectMany(x => ViewStackService.PushPage(new CatalogCategoryViewModel(x.Id))) .Subscribe(); _isRefreshing = LoadCatalogCategories .IsExecuting .ToProperty(this, vm => vm.IsRefreshing, true); }
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 GreenViewModel(IViewStackService viewStackService) : base(viewStackService) { OpenModal = ReactiveCommand .CreateFromObservable(() => ViewStackService.PushModal(new FirstModalViewModel(viewStackService), string.Empty, false), outputScheduler: RxApp.MainThreadScheduler); }
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 static IObservable <Unit> PushPage(this ViewStackService viewStackService, INavigable viewModel, string contract = null, int pages = 1) { for (var i = 0; i < pages; i++) { viewStackService.PushPage(viewModel, contract).Subscribe(); } return(Observable.Return(Unit.Default)); }
public WalletInfoViewModel(KeyManager keyManager) : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); _keyManager = keyManager; Disposables = Disposables is null ? new CompositeDisposable() : throw new NotSupportedException($"Cannot open {GetType().Name} before closing it."); Closing = new CancellationTokenSource(); Closing.DisposeWith(Disposables); ClearSensitiveData(true); // TODO turn bool ToggleSensitiveKeysCommand = ReactiveCommand.Create <Unit, bool>(_ => { try { if (ShowSensitiveKeys) { ClearSensitiveData(true); } else { var secret = PasswordHelper.GetMasterExtKey(_keyManager, Password, out string isCompatibilityPasswordUsed); Password = ""; //if (isCompatibilityPasswordUsed != null) //{ // SetWarningMessage(PasswordHelper.CompatibilityPasswordWarnMessage); //} string master = secret.GetWif(Global.Network).ToWif(); string account = secret.Derive(_keyManager.AccountKeyPath).GetWif(Global.Network).ToWif(); string masterZ = secret.ToZPrv(Global.Network); string accountZ = secret.Derive(_keyManager.AccountKeyPath).ToZPrv(Global.Network); SetSensitiveData(master, account, masterZ, accountZ); } return(true); } catch (Exception ex) { return(false); } }); var canBackUp = this.WhenAnyValue(x => x.Global.UiConfig.HasSeed, hs => hs == true); NavBackUpCommand = ReactiveCommand.CreateFromObservable(() => { ViewStackService.PushPage(new StartBackUpViewModel()).Subscribe(); return(Observable.Return(Unit.Default)); }, canBackUp); ShareLogsCommand = ReactiveCommand.CreateFromTask(ShareLogs); ExportWalletCommand = ReactiveCommand.CreateFromTask(ExportWallet); }
public static NavigationPage CreateMainView() { var mainView = new MainView(RxApp.TaskpoolScheduler, RxApp.MainThreadScheduler, ViewLocator.Current); var viewStackService = new ViewStackService(mainView, Device.RuntimePlatform == Device.Android); Locator.CurrentMutable.RegisterConstant(viewStackService, typeof(IViewStackService)); viewStackService.PushPage(new HomeViewModel(new FakeToyService())).Subscribe(); return(mainView); }
public SentViewModel() : base(Locator.Current.GetService <IViewStackService>()) { NavWalletCommand = ReactiveCommand.CreateFromObservable(() => { ViewStackService.PopPage(false); ViewStackService.PopPage(false); return(ViewStackService.PopPage(true)); }); }
/// <summary> /// Registers a value for navigation. /// </summary> /// <typeparam name="TView">The type of view to register.</typeparam> /// <param name="dependencyResolver">The dependency resolver.</param> /// <param name="navigationViewFactory">The navigation view factory.</param> /// <returns>The dependencyResovler.</returns> public static IMutableDependencyResolver RegisterNavigation <TView>(this IMutableDependencyResolver dependencyResolver, Func <TView> navigationViewFactory) where TView : IViewFor, IView { var navigationView = navigationViewFactory(); var viewStackService = new ViewStackService(navigationView); dependencyResolver.RegisterLazySingleton <IViewStackService>(() => viewStackService); dependencyResolver.RegisterLazySingleton <IView>(() => navigationView, NavigationView); return(dependencyResolver); }
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 void Should_InvokeViewShellInsertPageTwice_When_InitializingViewStackServiceWithTwoPages() { // Arrange // Act var sut = new ViewStackService(_viewShell, new[] { _page, _page }); // Assert _viewShell.Received(2).InsertPage(Arg.Any <int>(), _page, null); }
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 void Should_InvokeViewShellPopPage_When_PageIsPopped() { // Arrange var sut = new ViewStackService(_viewShell, new[] { _page, _page }); // Act sut.PopPages().Subscribe(); // Assert _viewShell.Received(1).PopPage(true); }
public void Should_AddViewModelToModalStack_When_Pushed() { // Arrange var sut = new ViewStackService(_viewShell); // Act sut.PushModal(_page).Subscribe(); // Assert sut.ModalStack.FirstAsync().Wait().Count.Should().Be(1); }
private IObservable <Unit> HandleResult(AuthAction authAction, PhoneNumberSignInResult result, IObservable <Unit> completionObservable) { if (result.AuthResult != null) { return(completionObservable); } else { return(ViewStackService.PushPage(new PhoneAuthVerificationCodeEntryViewModel(authAction, result.VerificationId, completionObservable))); } }
public void Should_InvokeViewShellPushModal_When_PushModalIsInvoked() { // Arrange var sut = new ViewStackService(_viewShell); // Act sut.PushModal(_page).Subscribe(); // Assert _viewShell.Received(1).PushModal(_page, null, false); }
public void Should_InvokeViewShellPushPage_When_PushPageIsInvoked(string contract, bool resetStack, bool animate) { // Arrange var sut = new ViewStackService(_viewShell); // Act sut.PushPage(_page, contract, resetStack, animate).Subscribe(); // Assert _viewShell.Received(1).PushPage(_page, contract, resetStack, animate); }
private IObservable <Unit> WhenLinked() { return(Observable .Defer( () => { return Observable .Start(() => ViewStackService.InsertPage(1, new RewardsViewModel()), RxApp.MainThreadScheduler) .Concat(ViewStackService.PopToPage(1)); })); }
public RewardsProgramActivationViewModel(IFirebaseAuthService firebaseAuthService = null, IViewStackService viewStackService = null) : base(viewStackService) { _firebaseAuthService = firebaseAuthService ?? Locator.Current.GetService <IFirebaseAuthService>(); NavigateToPhoneNumberVerificationPage = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService .PushPage(new PhoneAuthPhoneNumberEntryViewModel(AuthAction.LinkAccount, WhenLinked()))); }); }
public void Should_HavePageIndexPlusOnePagesRemaining_When_PopToPageIsInvoked(int pageIndex) { // Arrange var sut = new ViewStackService(_viewShell, new[] { _page, _page, _page, _page }); // Act sut.PopToPage(pageIndex).Subscribe(); // Assert int numPages = pageIndex + 1; sut.PageStack.FirstAsync().Wait().Count.Should().Be(numPages); }
public MainViewModel(IFirebaseAuthService authService = null, IViewStackService viewStackService = null) : base(viewStackService) { _authService = authService ?? Locator.Current.GetService <IFirebaseAuthService>(); NavigateToCatalogPage = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushPage(new CatalogCategoryListViewModel())); }); NavigateToAlbumPage = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushPage(new AlbumListViewModel())); }); NavigateToStoreInfoPage = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushPage(new StoreInfoViewModel())); }); if (_authService.CurrentUser.Providers.Contains("phone")) { NavigateToRewardsPage = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushPage(new RewardsViewModel())); }); } else { NavigateToRewardsPage = ReactiveCommand.CreateFromObservable( () => { return(ViewStackService.PushPage(new RewardsProgramActivationViewModel())); }); } this.WhenActivated( d => { Disposable.Empty.DisposeWith(d); }); NavigateToCatalogPage.ThrownExceptions.Subscribe( ex => { System.Console.WriteLine(ex.Message); }); }
private static NavigationPage Initialize() { var bgScheduler = RxApp.TaskpoolScheduler; var mScheduler = RxApp.MainThreadScheduler; var vLocator = Locator.Current.GetService <IViewLocator>(); var navigationView = new NavigationView(mScheduler, bgScheduler, vLocator); var viewStackService = new ViewStackService(navigationView); Locator.CurrentMutable.Register <IViewStackService>(() => viewStackService); navigationView.PushPage(new MainViewModel(), null, true, false).Subscribe(); return(navigationView); }
public static NavigationView Initialize <TViewModel>(IScheduler mainThreadScheduler = null, IScheduler backgroundScheduler = null, IViewLocator viewLocator = null) where TViewModel : class, IViewModel { var bgScheduler = mainThreadScheduler ?? RxApp.TaskpoolScheduler; var mScheduler = backgroundScheduler ?? RxApp.MainThreadScheduler; var vLocator = viewLocator ?? Locator.Current.GetService <IViewLocator>(); var navigationView = new NavigationView(mScheduler, bgScheduler, vLocator); var viewStackService = new ViewStackService(navigationView); Locator.CurrentMutable.Register <IViewStackService>(() => viewStackService); navigationView.PushPage(Activator.CreateInstance(typeof(TViewModel), viewStackService) as TViewModel, null, true, false).Subscribe(); return(navigationView); }
public LandingViewModel() : base(Locator.Current.GetService <IViewStackService>()) { NewWalletCommand = ReactiveCommand.CreateFromObservable(() => { ViewStackService.PushPage(new NewPasswordViewModel()).Subscribe(); return(Observable.Return(Unit.Default)); }); LoadWalletCommand = ReactiveCommand.CreateFromObservable(() => { ViewStackService.PushPage(new LoadWalletViewModel()).Subscribe(); return(Observable.Return(Unit.Default)); }); }
public HomeViewModel(IViewStackService viewStackService) : base(viewStackService) { OpenModal = ReactiveCommand .CreateFromObservable(() => ViewStackService.PushModal(new FirstModalViewModel(ViewStackService)), outputScheduler: RxApp.MainThreadScheduler); PushPage = ReactiveCommand .CreateFromObservable(() => ViewStackService.PushPage(new RedViewModel(ViewStackService)), outputScheduler: RxApp.MainThreadScheduler); OpenModal.Subscribe(x => Debug.WriteLine("PagePushed")); }
public AppBootstrapper() { Locator.CurrentMutable.InitializeSplat(); Locator.CurrentMutable.InitializeReactiveUI(); _mainView = new MainView(RxApp.TaskpoolScheduler, RxApp.MainThreadScheduler, ViewLocator.Current); var viewStackService = new ViewStackService(_mainView); Locator.CurrentMutable.RegisterConstant(viewStackService, typeof(IViewStackService)); Locator.CurrentMutable.Register(() => new SignInPage(), typeof(IViewFor <ISignInViewModel>)); Locator.CurrentMutable.Register(() => new PhoneAuthPhoneNumberEntryPage(), typeof(IViewFor <IPhoneAuthPhoneNumberEntryViewModel>)); Locator.CurrentMutable.Register(() => new PhoneAuthVerificationCodeEntryPage(), typeof(IViewFor <IPhoneAuthVerificationCodeEntryViewModel>)); Locator.CurrentMutable.Register(() => new MainPage(), typeof(IViewFor <IMainViewModel>)); Locator.CurrentMutable.Register(() => new CatalogCategoryListPage(), typeof(IViewFor <ICatalogCategoryListViewModel>)); Locator.CurrentMutable.Register(() => new CatalogCategoryCell(), typeof(IViewFor <ICatalogCategoryCellViewModel>)); Locator.CurrentMutable.Register(() => new CatalogCategoryPage(), typeof(IViewFor <ICatalogCategoryViewModel>)); Locator.CurrentMutable.Register(() => new CatalogItemCell(), typeof(IViewFor <ICatalogItemCellViewModel>)); Locator.CurrentMutable.Register(() => new CatalogItemDetailsPage(), typeof(IViewFor <ICatalogItemDetailsViewModel>)); Locator.CurrentMutable.Register(() => new StoreInfoPage(), typeof(IViewFor <IStoreInfoViewModel>)); Locator.CurrentMutable.Register(() => new AlbumListPage(), typeof(IViewFor <IAlbumListViewModel>)); Locator.CurrentMutable.Register(() => new AlbumCell(), typeof(IViewFor <IAlbumCellViewModel>)); Locator.CurrentMutable.Register(() => new AlbumPage(), typeof(IViewFor <IAlbumViewModel>)); Locator.CurrentMutable.Register(() => new RewardsPage(), typeof(IViewFor <IRewardsViewModel>)); Locator.CurrentMutable.Register(() => new RewardsProgramActivationPage(), typeof(IViewFor <IRewardsProgramActivationViewModel>)); Locator.CurrentMutable.Register(() => new AuthService(), typeof(IAuthService)); IFirebaseAuthService firebaseAuthService = CrossFirebaseAuth.Current; Locator.CurrentMutable.RegisterConstant(firebaseAuthService, typeof(IFirebaseAuthService)); Locator.CurrentMutable.RegisterLazySingleton(() => new FacebookPhotoService(), typeof(IFacebookPhotoService)); var repoContainer = new RepositoryRegistrar(firebaseAuthService, Locator.CurrentMutable); //Square.Connect.Client.Configuration.Default.AccessToken = ApiKeys.SQUARE_CONNECT; //viewStackService.PushPage(new MainViewModel()).Subscribe(); //return; if (firebaseAuthService.CurrentUser != null) { viewStackService.PushPage(new MainViewModel()).Subscribe(); } else { viewStackService.PushPage(new SignInViewModel()).Subscribe(); } }
public StartBackUpViewModel() : base(Locator.Current.GetService <IViewStackService>()) { Global = Locator.Current.GetService <Global>(); var hsm = Locator.Current.GetService <IHsmStorage>(); NextCommand = ReactiveCommand.CreateFromObservable(() => { List <string> seedWords = hsm.GetAsync($"{Global.Network}-seedWords").Result?.Split(' ').ToList(); if (seedWords != null) { ViewStackService.PushPage(new BackUpViewModel(seedWords)).Subscribe(); } return(Observable.Return(Unit.Default)); }); }