public void Setup()
 {
     _viewStackService = new ViewStackService(new BenchmarkView());
     _viewStackService.PushPage(new ViewModel());
     _viewStackService.PushPage(new ViewModel());
     _viewStackService.PushPage(new ViewModel());
 }
示例#2
0
        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();
        }
示例#3
0
        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);
            });
        }
示例#4
0
        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));
        }
示例#5
0
        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);