public StageEventListRootPageViewModel(INavigationService navigationService, IFilterGroupingStageEvent eventUsecase) { _eventUsecase = eventUsecase; Title.AddTo(this.Disposable); SelectedSegment.AddTo(this.Disposable); FavStateObservable.AddTo(this.Disposable); SelectedSegment.Subscribe(selectedSegment => { _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId); }).AddTo(this.Disposable); FavButtonClickCommand = new DelegateCommand(() => { FavStateObservable.Value = !FavStateObservable.Value; _eventUsecase.UpdateFilterConditions(SelectedSegment.Value, FavStateObservable.Value, PlaceId); }); IconSource = FavStateObservable.Select((isFavActive) => { return($@"ion_ios_heart{(isFavActive ? "" : "_outline")}"); }).ToReadOnlyReactiveProperty("ion_ios_heart").AddTo(this.Disposable); Plannings = _eventUsecase.Plannings.ToReadOnlyReactiveCollection().AddTo(this.Disposable); SelectedItemCommand = new AsyncReactiveCommand <IPlanning>(); SelectedItemCommand.Subscribe(async(item) => { await navigationService.NavigateAsync( nameof(PlanningDetailPageViewModel).GetViewNameFromRule(), PlanningDetailPageViewModel.GetNavigationParameter(item.Id, item.PlanningType)); }).AddTo(this.Disposable); }
public PlanningListRootPageViewModel() { SelectedSegment.Subscribe(selectedSegment => { if (selectedSegment == 0) { } else { } }); SearchQuery.Throttle(TimeSpan.FromMilliseconds(400)).Subscribe(query => { System.Diagnostics.Debug.WriteLine($"Query Update: {query}"); }); FavButtonClickCommand = new DelegateCommand(() => { FavStateObservable.Value = !FavStateObservable.Value; }); IconSource = FavStateObservable.Select((isFavActive) => { return($@"ion-ios-heart{(isFavActive ? "" : "-outline")}".Replace("-", $@"{(IsAndroid ? "_" : "-")}")); }).ToReadOnlyReactiveProperty("ion-ios-heart".Replace("-", $@"{(IsAndroid ? "_" : "-")}")); }
public PlanningListRootPageViewModel(INavigationService navigationService, IFilterGroupingPlanning planningUsecase, IEventAggregator eventAggregator) { _planningUsecase = planningUsecase; Title.AddTo(this.Disposable); SelectedSegment.AddTo(this.Disposable); SearchQuery.AddTo(this.Disposable); FavStateObservable.AddTo(this.Disposable); PlanningType = SelectedSegment.Select((index) => index.SegmentedControlIndexToPlanningTypeEnum()) .ToReactiveProperty() .AddTo(this.Disposable); SelectedSegment.Subscribe(selectedSegment => { if (IsDirty) { _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId); } }).AddTo(this.Disposable); SearchQuery.Throttle(TimeSpan.FromMilliseconds(400)).ObserveOnUIDispatcher().Subscribe(query => { if (IsDirty) { _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId); } }).AddTo(this.Disposable); FavButtonClickCommand = new DelegateCommand(() => { FavStateObservable.Value = !FavStateObservable.Value; _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId); }); IconSource = FavStateObservable.Select((isFavActive) => { return($@"ion_ios_heart{(isFavActive ? "" : "_outline")}"); }).ToReadOnlyReactiveProperty("ion_ios_heart").AddTo(this.Disposable); Plannings = _planningUsecase.Plannings.ToReadOnlyReactiveCollection().AddTo(this.Disposable); SelectedItemCommand = new AsyncReactiveCommand <IPlanning>(); SelectedItemCommand.Subscribe(async(item) => { await navigationService.NavigateAsync( nameof(PlanningDetailPageViewModel).GetViewNameFromRule(), PlanningDetailPageViewModel.GetNavigationParameter(item.Id, item.PlanningType)); }).AddTo(this.Disposable); OpenPlceDetailCommand = new AsyncReactiveCommand <string>(); OpenPlceDetailCommand.Subscribe(async(placeName) => { await navigationService.NavigateAsync("NavigationPage/DetailFloorPage", DetailFloorPageViewModel.GetNavigationParameter(placeName), true); }).AddTo(this.Disposable); eventAggregator.GetEvent <TabbedPageOpendEvent>().Subscribe((ev) => { if (ev.Name != this.GetType().Name.Replace("ViewModel", "")) { return; } if (!IsDirty) { IsDirty = true; _planningUsecase.UpdateFilterConditions(SearchQuery.Value, PlanningType.Value, FavStateObservable.Value, PlaceId); } }).AddTo(this.Disposable); }