public FilterSessionsViewModel(INavigation navigation) : base(navigation) { AllCategory = new Category { Name = "All", IsEnabled = true, IsFiltered = Settings.ShowAllCategories }; AllCategory.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsFiltered") SetShowAllCategories(AllCategory.IsFiltered); }; }
void LoadCategories() { vm.LoadCategoriesAsync().ContinueWith((result) => { Device.BeginInvokeOnMainThread(()=> { var allCell = new CategoryCell { BindingContext = vm.AllCategory }; TableSectionCategories.Add(allCell); foreach (var item in vm.Categories) { TableSectionCategories.Add(new CategoryCell { BindingContext = item }); } var color = Device.OS == TargetPlatform.Windows || Device.OS == TargetPlatform.WinPhone ? "#7635EB" : string.Empty; showPast = new Category { Name = "Show Past Sessions", IsEnabled = true, ShortName = "Show Past Sessions", Color = color }; showFavorites = new Category { Name = "Show Favorites Only", IsEnabled = true, ShortName = "Show Favorites Only", Color = color }; TableSectionFilters.Add(new CategoryCell { BindingContext = showPast }); TableSectionFilters.Add(new CategoryCell { BindingContext = showFavorites }); //if end of evolve if (DateTime.UtcNow > Settings.EndOfEvolve) showPast.IsEnabled = false; showPast.IsFiltered = Settings.Current.ShowPastSessions; showFavorites.IsFiltered = Settings.Current.FavoritesOnly; }); }); }