public void Setup() { _viewStackService = new ViewStackService(new BenchmarkView()); _viewStackService.PushPage(new ViewModel()); _viewStackService.PushPage(new ViewModel()); _viewStackService.PushPage(new ViewModel()); }
public CatalogCategoryListViewModel( ICatalogCategoryRepo categoryRepo = null, ICatalogSynchronizer catalogSynchronizer = null, IViewStackService viewStackService = null) { categoryRepo = categoryRepo ?? Locator.Current.GetService <ICatalogCategoryRepo>(); catalogSynchronizer = catalogSynchronizer ?? Locator.Current.GetService <ICatalogSynchronizer>(); viewStackService = viewStackService ?? Locator.Current.GetService <IViewStackService>(); _categoryCache = new SourceCache <CatalogCategory, string>(x => x.Id); SyncWithPosSystem = ReactiveCommand.CreateFromObservable( () => { return(catalogSynchronizer .PullFromPosSystemAndStoreInFirebase(_categoryCache)); }); LoadCategories = ReactiveCommand.CreateFromObservable( () => { return(categoryRepo .GetItems() .Do(x => _categoryCache.AddOrUpdate(x)) .Select(_ => Unit.Default)); }); //LoadCategories.InvokeCommand(this, x => x.SyncWithPosSystem); _categoryCache .Connect() //.Filter(dynamicFilter) .Transform(x => new CatalogCategoryCellViewModel(x, categoryRepo) as ICatalogCategoryCellViewModel) .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _categoryCells) .DisposeMany() .Subscribe(); NavigateToCategory = ReactiveCommand.CreateFromObservable <ICatalogCategoryCellViewModel, Unit>( categoryCell => { return(viewStackService.PushPage(new CatalogItemListViewModel(categoryCell.Id))); }); this .WhenAnyValue(x => x.SelectedItem) .Where(x => x != null) .SelectMany(categoryCell => viewStackService.PushPage(new CatalogItemListViewModel(categoryCell.Id))) .Subscribe(); }
public TabViewModel(string tabTitle, string tabIcon, IViewStackService viewStackService, Func <IPageViewModel> pageCreate) : base(viewStackService) { TabIcon = tabIcon; TabTitle = tabTitle; this.WhenActivated(disposable => { viewStackService.PushPage(pageCreate(), resetStack: true).Subscribe().DisposeWith(disposable); }); }
public MainViewModel(AppBootstrapper appBootstrapper, IViewStackService viewStackService = null, IFirebaseAuthService firebaseAuthService = null) { viewStackService = viewStackService ?? Locator.Current.GetService <IViewStackService>(); firebaseAuthService = firebaseAuthService ?? Locator.Current.GetService <IFirebaseAuthService>(); MenuItems = GetMenuItems(); NavigateToMenuItem = ReactiveCommand.CreateFromObservable <IPageViewModel, Unit>( pageVm => viewStackService.PushPage(pageVm, resetStack: true)); this.WhenAnyValue(x => x.Selected) .Where(x => x != null) .StartWith(MenuItems.First()) .Select(x => Locator.Current.GetService <IPageViewModel>(x.TargetType.FullName)) .InvokeCommand(NavigateToMenuItem); SignOut = ReactiveCommand.Create(() => firebaseAuthService.SignOut()); SignOut.Subscribe(_ => appBootstrapper.MainView = new SignInViewModel(appBootstrapper)); }
public RewardsMemberDirectoryViewModel( IRepository <RewardsMember> rewardsMemberRepo = null, IRewardsMemberSynchronizer rewardsMemberSynchronizer = null, IViewStackService viewStackService = null) { rewardsMemberRepo = rewardsMemberRepo ?? Locator.Current.GetService <IRepository <RewardsMember> >(); rewardsMemberSynchronizer = rewardsMemberSynchronizer ?? Locator.Current.GetService <IRewardsMemberSynchronizer>(); viewStackService = viewStackService ?? Locator.Current.GetService <IViewStackService>(); _rewardsMemberCache = new SourceCache <RewardsMember, string>(x => x.Id); LoadRewardsMembers = ReactiveCommand.CreateFromObservable( () => { //return Observable.Return(Unit.Default); return(rewardsMemberRepo .GetItems() .Do(x => _rewardsMemberCache.AddOrUpdate(x)) .Select(_ => Unit.Default)); }); SyncWithPosSystem = ReactiveCommand.CreateFromObservable( () => { return(rewardsMemberSynchronizer .PullFromPosSystemAndStoreInFirebase(_rewardsMemberCache)); }); SyncWithPosSystem.ThrownExceptions .Subscribe( x => { Console.WriteLine(x.Message); }); //LoadRewardsMembers.InvokeCommand(this, x => x.SyncWithPosSystem); var dynamicFilter = this.WhenValueChanged(@this => @this.SearchText) .Throttle(TimeSpan.FromMilliseconds(250), RxApp.TaskpoolScheduler) .Select(CreatePredicate); _rewardsMemberCache .Connect() //.Filter(dynamicFilter) .Transform(x => new RewardsMemberCellViewModel(x) as IRewardsMemberCellViewModel) .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _rewardsMemberCells) .DisposeMany() .Subscribe(); //NavigateToRewardsMember = ReactiveCommand.CreateFromObservable<IRewardsMemberCellViewModel, Unit>( // customerCell => // { // return viewStackService.PushPage(new RewardsMemberViewModel()); // }); this .WhenAnyValue(x => x.SelectedItem) .Where(x => x != null) .SelectMany(rewardsMemberCell => viewStackService.PushPage(new StampCardViewModel(rewardsMemberCell.Model, rewardsMemberRepo))) .Subscribe(); }
public void BenchmarkSetup() { _viewStackService.PushPage(new ViewModel()); }
public IObservable <Unit> PushPage() => _viewStackService.PushPage(_viewModel);