public UserPreferencesView() : base(UITableViewStyle.Grouped, null) { bool filtered = PreferencesProvider.GetFilter() == 1 ? true : false; var filter = new CheckboxElement("Filter explicit jokes and photos", filtered); this.Pushing = true; Root = new RootElement("Settings") { new Section("") { filter } }; this.NavigationItem.SetRightBarButtonItem( new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) => { int success = PreferencesProvider.SetFilter(filter.Value); if (success > 0) { new UIAlertView("Settings", "Your settings have been saved!", null, "ok", null).Show(); } else { new UIAlertView("Settings", "Uh oh something went wrong. Please try again.", null, "ok", null).Show(); } }) , true); }
public override void ViewDidLoad() { base.ViewDidLoad(); //determine explicit filter long filtered = PreferencesProvider.GetFilter(); var vcRecentPhotos = new UINavigationController(); var vcPopularPhotos = new UINavigationController(); if (filtered == 1) { vcRecentPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostRecentNoExplicit), false); vcPopularPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostPopularNoExplicit), false); } else { vcRecentPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostRecent), false); vcPopularPhotos.PushViewController(new PhotosViewController(Enums.PhotoFilter.MostPopular), false); } var vcSearchPhotos = new PhotosSearchViewController(); var vcs = new UIViewController[] { vcRecentPhotos, vcPopularPhotos, vcSearchPhotos }; ViewControllers = vcs; vcRecentPhotos.TabBarItem = new UITabBarItem(UITabBarSystemItem.MostRecent, 0); vcPopularPhotos.TabBarItem = new UITabBarItem(UITabBarSystemItem.TopRated, 0); vcSearchPhotos.TabBarItem = new UITabBarItem(UITabBarSystemItem.Search, 0); this.Title = "Laftrip Photos"; }