public override void ViewDidLoad() { base.ViewDidLoad (); this.ForgotPassword.TouchUpInside += (object sender, EventArgs e) => { var board = UIStoryboard.FromName ("MainStoryboard", null); var password = (ForgotPasswordController)board.InstantiateViewController ("forgotpassword"); this.NavigationController.PushViewController(password, true); }; this.Login.TouchUpInside += (object sender, EventArgs e) => { //((UIWindow)UIApplication.SharedApplication.Delegate.Window).RootViewController = // new MainTabController(); var request = new RestRequest(); var model = new LoginModel { Email = this.Email.Text, Password = this.Password.Text, RememberMe = true }; request.Send(RequestConfig.Login, "POST", model); request.RequestFinished += (object send, RequestEndedArgs ev) => { var jsonId = (int)JsonConvert.DeserializeObject (ev.Result, typeof(int)); InvokeOnMainThread (delegate { AppDelegate.SaveProfileId(jsonId); var tabbar = new MainTabController(); UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar; }); }; }; }
private void getData() { // load the articles and the menu from the server on a background thread var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (CategoryVideoModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryVideoModel)); var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Video.MenuViewLeft; // add 'all sports' item to the categories list if(data.Parent.Link == 0) { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 }); } else { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link }); } TableView.Source = new VideoControllerSource(data.News, data.CategoryId); menuController.TableView.Source = new MenuControllerSource(data.Categories, "video"); menuController.TableView.ReloadData(); TableView.ReloadData(); spinner.StopAnimating(); }); }; request.Send (string.Format(RequestConfig.Videos, 0, 0), "GET"); }
public override void ViewDidLoad() { base.ViewDidLoad (); this.CreateAccount.TouchUpInside += (object sender, EventArgs e) => { //UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); //PreferencesController welcome = (PreferencesController)board.InstantiateViewController ("preferencescontroller"); //welcome.ImageSources = new string[] { "aaa", "a", "a", "a", "a", "a", "a", "a", "a" }; //this.NavigationController.PushViewController(welcome, true); model = new RegisterModel { Email = this.Email.Text, FirstName = this.FirstName.Text, LastName = this.LastName.Text, Password = this.Password.Text }; var request = new RestRequest(); request.Send("http://www.sport.net/api/content/register", "POST", model); }; this.ImagePicker.TouchUpInside += (s, e) => { // create a new picker controller imagePicker = new UIImagePickerController (); // set our source to the photo library imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; // set what media types imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.PhotoLibrary); imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia; imagePicker.Canceled += Handle_Canceled; // show the picker NavigationController.PresentViewController (imagePicker, true, null); }; }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var request = new RestRequest (); var tab = (MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController; if (indexPath.Row == 0 && !root) { request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (List<LiveScoreSportModel>)JsonConvert.DeserializeObject(e.Result, typeof(List<LiveScoreSportModel>)); tableView.Source = new SwitchCategorySource(data, target); tableView.ReloadData(); }); }; request.Send (RequestConfig.LiveScoreSports, "GET"); var request2 = new RestRequest (); request2.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel)); this.target.Source = new TodayTableSource(data); this.target.ReloadData(); }); }; request2.Send (string.Format (RequestConfig.LiveScore, categories [indexPath.Row].Id, 0), "GET"); //tab.LiveScore.SportToday.Text = "All Sports"; } else { request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (List<LiveScoreCategoryModel>)JsonConvert.DeserializeObject(e.Result, typeof(List<LiveScoreCategoryModel>)); data.Insert(0, new LiveScoreCategoryModel { Name = "Back" }); tableView.Source = new SwitchCategorySource(data, target, currentSport); tableView.ReloadData(); }); }; var request2 = new RestRequest (); request2.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel)); this.target.Source = new TodayTableSource(data); this.target.ReloadData(); }); }; if (root) { request.Send (string.Format (RequestConfig.LiveScoreCategories, items [indexPath.Row].Id), "GET"); request2.Send (string.Format (RequestConfig.LiveScore, items[indexPath.Row].Id, 0), "GET"); //tab.LiveScore.SportToday.Text = items [indexPath.Row].Name; } else { request2.Send (string.Format (RequestConfig.LiveScore, currentSport, categories [indexPath.Row].Id), "GET"); } } }
private void getData() { var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel)); var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News.MenuViewLeft; var featured = (List<NewsModelItem>)data.News; featured = featured.Where(c => !string.IsNullOrEmpty(c.Img)).Take(4).ToList(); TableView.Source = new HomeControllerSource(featured, data.Categories); menuController.TableView.Source = new MenuControllerSource(data.Categories, "news"); menuController.TableView.ReloadData(); TableView.ReloadData(); spinner.StopAnimating(); }); }; request.Send (string.Format(RequestConfig.News(), 0, 0), "GET"); }
private void changeNewsCategory(NSIndexPath indexPath) { var controller = (SlideoutNavigationController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News; var news = (NewsController)controller.TopView; var request = new RestRequest (); ((NewsController)controller.TopView).Spinner.StartAnimating (); //controller.Hide (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel)); var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News.MenuViewLeft; // slice the news list into featured and normal articles var featured = (List<NewsModelItem>)data.News; featured = featured.Where(c => !string.IsNullOrEmpty(c.Img)).Take(4).ToList(); foreach(var i in featured) { data.News.Remove(i); } // add 'all sports' item to the categories list if(data.CategoryId == 0) { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 }); } else { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link }); } news.TableView.Source = new NewsControllerSource(data.News, featured, data.CategoryId); menuController.TableView.Source = new MenuControllerSource(data.Categories, "news"); menuController.TableView.ReloadData(); news.TableView.ReloadData(); try { news.TableView.ScrollToRow(NSIndexPath.FromRowSection(0, 0), UITableViewScrollPosition.Top, false); } catch (Exception) {} news.Spinner.StopAnimating(); }); }; request.Send(string.Format(RequestConfig.News(), categories[indexPath.Row].Link, 0), "GET"); }
public override void ViewWillAppear(bool animated) { this.DateToday.Text = DateTime.Now.ToLongDateString(); this.SportImageToday.Image = UIImage.FromFile ("./Assets/football-icon.png"); this.SwitchTo.Frame = new RectangleF(0, 44, 640, 504); this.SwitchTo.ContentSize=new SizeF (640, 504); this.SwitchTo.ScrollEnabled = false; var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (LiveScoreViewModel)JsonConvert.DeserializeObject(e.Result, typeof(LiveScoreViewModel)); this.TodayTable.Source = new TodayTableSource(data); this.TodayTable.ReloadData(); }); }; request.Send (string.Format (RequestConfig.LiveScore, 0, 0), "GET"); this.TodayTable.ShowsVerticalScrollIndicator = false; this.TodayTable.BackgroundColor= UIColor.FromRGB (26, 26, 26); this.SwitchCategory.SetBackgroundImage (UIImage.FromFile ("./Assets/dropdown.png"), UIControlState.Normal); request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (List<LiveScoreSportModel>)JsonConvert.DeserializeObject(e.Result, typeof(List<LiveScoreSportModel>)); this.Categories.Source = new SwitchCategorySource(data, TodayTable); this.Categories.ReloadData(); }); }; request.Send (RequestConfig.LiveScoreSports, "GET"); if(((AppDelegate)UIApplication.SharedApplication.Delegate).IsSeven) { this.AutomaticallyAdjustsScrollViewInsets = false; } }
public override void ViewWillAppear(bool animated) { spinner = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge); spinner.Center = new PointF (160, 160); spinner.HidesWhenStopped = true; View.AddSubview (spinner); spinner.StartAnimating (); TableView.Hidden = true; var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null); var custom = new UIButton (new RectangleF (0, 0, 26, 15)); custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal); custom.TouchUpInside += (sender, e) => NavigationController.PopViewControllerAnimated (true); button.CustomView = custom; this.NavigationItem.LeftBarButtonItem = button; var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel)); InvokeOnMainThread(delegate { AppDelegate.SubCategories = data; var all = new AddContentItem(); all.Name = "All from " + data.ParentCategory.Name; all.HasChildren = false; all.Checked = ParentChecked; all.Id = data.ParentCategory.Id; AppDelegate.SubCategories.Categories.Insert(0, all); TableView.ReloadData(); TableView.Hidden = false; spinner.StopAnimating(); }); }; request.Send (string.Format(RequestConfig.SubCategories, CategoryId), "GET"); this.TableView.Source = new PreferencesSubControllerSource (); this.TableView.AllowsMultipleSelection = true; }
private void getData() { // load the articles and the menu from the server on a background thread var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (CategoryModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryModel)); var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).News.MenuViewLeft; // slice the news list into featured and normal articles var featured = (List<NewsModelItem>)data.News; featured = featured.Where(c => !string.IsNullOrEmpty(c.Img)).Take(4).ToList(); foreach(var i in featured) { data.News.Remove(i); } // add 'all sports' item to the categories list if(data.Parent.Link == 0) { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 }); } else { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link }); } TableView.Source = new NewsControllerSource(data.News, featured, data.CategoryId); menuController.TableView.Source = new MenuControllerSource(data.Categories, "news"); menuController.TableView.ReloadData(); TableView.ReloadData(); spinner.StopAnimating(); }); }; if (Category.HasValue) { request.Send (string.Format(RequestConfig.News(), Category, 0), "GET"); } else { request.Send (string.Format(RequestConfig.News(), 0, 0), "GET"); } }
public override void ViewDidLoad() { base.ViewDidLoad (); var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel)); InvokeOnMainThread(delegate { AppDelegate.MainCategories = data; CollectionView.ReloadData(); spinner.StopAnimating(); }); }; request.Send (string.Format (RequestConfig.MainCategories, AppDelegate.GetProfileId ()), "GET"); }
public override void Scrolled(UIScrollView scrollView) { if (loading) { return; } PointF offset = scrollView.ContentOffset; RectangleF bounds = scrollView.Bounds; SizeF size = scrollView.ContentSize; UIEdgeInsets inset = scrollView.ContentInset; float y = offset.Y + bounds.Size.Height - inset.Bottom; float h = size.Height; if(y > h - 50) { var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (List<NewsModelItem>)JsonConvert.DeserializeObject(e.Result, typeof(List<NewsModelItem>)); items.AddRange(new List<NewsModelItem>(data)); loading = false; var tabController = (MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController; ((NewsController)tabController.News.TopView).TableView.ReloadData(); NextPage++; }); }; request.Send (string.Format(RequestConfig.NewsPaged, CurrentCategory, NextPage), "GET"); loading = true; } }
private void changePicturesCategory(NSIndexPath indexPath) { var controller = (SlideoutNavigationController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Pictures; var pictures = (PicturesController)controller.TopView; var request = new RestRequest (); ((PicturesController)controller.TopView).Spinner.StartAnimating (); //controller.Hide (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (CategoryPicturesModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryPicturesModel)); var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Pictures.MenuViewLeft; // add 'all sports' item to the categories list if(data.Parent.Link == 0) { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 }); } else { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link }); } pictures.TableView.Source = new PicturesControllerSource(data.News, data.CategoryId); menuController.TableView.Source = new MenuControllerSource(data.Categories, "pictures"); menuController.TableView.ReloadData(); pictures.TableView.ReloadData(); pictures.Spinner.StopAnimating(); }); }; request.Send (string.Format(RequestConfig.Pictures, categories[indexPath.Row].Link, 0), "GET"); }
private void changeVideoCategory(NSIndexPath indexPath) { var controller = (SlideoutNavigationController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Video; var video = (VideoController)controller.TopView; var request = new RestRequest (); ((VideoController)controller.TopView).Spinner.StartAnimating (); //controller.Hide (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (CategoryVideoModel)JsonConvert.DeserializeObject(e.Result, typeof(CategoryVideoModel)); var menuController = (MenuController)((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController).Video.MenuViewLeft; // add 'all sports' item to the categories list if(data.CategoryId == 0) { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "All Sports", Link = 0 }); } else { data.Categories.Insert(0, new CategoriesMenuModelItem { Name = "Back" , Link = data.Parent.Link }); } video.TableView.Source = new VideoControllerSource(data.News, data.CategoryId); menuController.TableView.Source = new MenuControllerSource(data.Categories, "video"); menuController.TableView.ReloadData(); video.TableView.ReloadData(); try { video.TableView.ScrollToRow(NSIndexPath.FromRowSection(0, 0), UITableViewScrollPosition.Top, false); } catch(Exception) {} video.Spinner.StopAnimating(); }); }; request.Send(string.Format(RequestConfig.Videos, categories[indexPath.Row].Link, 0), "GET"); }
public override void ViewWillAppear(bool animated) { this.Email.Background = UIImage.FromFile ("./Assets/input.png"); this.Password.Background = UIImage.FromFile ("./Assets/input.png"); this.Login.SetBackgroundImage (UIImage.FromFile ("./Assets/buttonlong.png"), UIControlState.Normal); this.Email.LeftView = new UIView (new RectangleF (0, 0, 5, 30)); this.Email.LeftViewMode = UITextFieldViewMode.Always; this.Password.LeftView = new UIView (new RectangleF (0, 0, 5, 30)); this.Password.LeftViewMode = UITextFieldViewMode.Always; var button = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null); var custom = new UIButton (new RectangleF (0, 0, 26, 15)); custom.SetBackgroundImage(UIImage.FromFile("./Assets/back.png"), UIControlState.Normal); custom.TouchUpInside += (sender, e) => NavigationController.PopViewControllerAnimated (true); button.CustomView = custom; this.NavigationItem.LeftBarButtonItem = button; this.NavigationController.SetNavigationBarHidden (false, false); // FACEBOOK LOGIN fbLogin = new FBLoginView (AppDelegate.Permissions); FacebookView.AddSubview (fbLogin); fbLogin.SizeToFit (); fbLogin.FetchedUserInfo += (object sender, FBLoginViewUserInfoEventArgs e) => { if (FBSession.ActiveSession.IsOpen) { var model = new FacebookProfile { Id = long.Parse (e.User.Id), Name = e.User.Name, first_name = e.User.FirstName, last_name = e.User.LastName, Birthday = e.User.Birthday, Email = e.User.ObjectForKey ("email").ToString (), UserName = e.User.Username }; var request = new RestRequest (); request.RequestFinished += (object sendr, RequestEndedArgs ev) => { var jsonId = (int)JsonConvert.DeserializeObject (ev.Result, typeof(int)); InvokeOnMainThread (delegate { AppDelegate.SaveProfileId(jsonId); var tabbar = new MainTabController(); UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar; }); }; request.Send (RequestConfig.Facebook, "POST", model); } }; fbLogin.ShowingLoggedOutUser += (object sender, EventArgs e) => { Console.WriteLine(e.ToString()); }; fbLogin.ShowingLoggedInUser += (object sender, EventArgs e) => { Console.WriteLine("Logged in."); }; // GOOGLE LOGIN var signIn = SignIn.SharedInstance; signIn.ClientId = AppDelegate.GoogleClientId; signIn.Scopes = new [] { PlusConstants.AuthScopePlusLogin, PlusConstants.AuthScopePlusMe, "https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email" }; signIn.ShouldFetchGoogleUserEmail = true; signIn.ShouldFetchGoogleUserId = true; signIn.Finished += (object sender, SignInDelegateFinishedEventArgs e) => { if(e.Error != null) { InvokeOnMainThread(delegate { new UIAlertView("Error.", "Could not sign in.", null, "Ok", null).Show(); }); } else { var request = new RestRequest(); request.RequestFinished += (object sendr, RequestEndedArgs ev) => { var data = (GoogleClient)JsonConvert.DeserializeObject(ev.Result, typeof(GoogleClient)); var request2 = new RestRequest(); request2.RequestFinished += (object sndr, RequestEndedArgs evnt) => { var jsonId = (int)JsonConvert.DeserializeObject (evnt.Result, typeof(int)); InvokeOnMainThread (delegate { AppDelegate.SaveProfileId(jsonId); var tabbar = new MainTabController(); UIApplication.SharedApplication.Delegate.Window.RootViewController = tabbar; }); }; request2.Send(RequestConfig.Google, "POST", data); }; request.Send(String.Format(RequestConfig.GoogleFetch, Uri.EscapeDataString(signIn.Authentication.AccessToken)), "GET"); } }; var signInButton = new SignInButton (); GoogleView.AddSubview (signInButton); signInButton.Frame = new RectangleF (0, 0, GoogleView.Frame.Size.Width - 8, GoogleView.Frame.Size.Height); signInButton.SizeToFit (); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var cell = tableView.CellAt (indexPath); if (indexPath.Row != 0) { if (AppDelegate.SubCategories.Categories [indexPath.Row].HasChildren) { UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); var prefs = (PreferencesSubController)board.InstantiateViewController ("preferencessub"); prefs.CategoryId = AppDelegate.SubCategories.Categories [indexPath.Row].Id; prefs.ParentChecked = AppDelegate.SubCategories.Categories [indexPath.Row].Checked; prefs.Title = AppDelegate.SubCategories.Categories [indexPath.Row].Name; ((UINavigationController)UIApplication.SharedApplication.KeyWindow.RootViewController).PushViewController (prefs, true); } else { AppDelegate.SubCategories.Categories [indexPath.Row].Checked = !AppDelegate.SubCategories.Categories [indexPath.Row].Checked; setCell (cell, indexPath); var request = new RestRequest (); request.RequestFailed += (object sender, EventArgs e) => { AppDelegate.SubCategories.Categories [indexPath.Row].Checked = !AppDelegate.SubCategories.Categories [indexPath.Row].Checked; setCell (cell, indexPath); }; request.Send (RequestConfig.AddContent, "POST", AppDelegate.SubCategories.Categories [indexPath.Row]); } } else { AddContentItem model = AppDelegate.MainCategories.Categories.Find (i => i.Id == AppDelegate.SubCategories.ParentCategory.Id); if (model == null) { var request2 = new RestRequest (); request2.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate() { var data = (AddContentModel)JsonConvert.DeserializeObject(e.Result, typeof(AddContentModel)); model = data.Categories.Find(i => i.Id == AppDelegate.SubCategories.ParentCategory.Id); model.Checked = !model.Checked; AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked; setCell (cell, indexPath); var request = new RestRequest (); request.RequestFailed += (object snder, EventArgs ev) => { InvokeOnMainThread(delegate() { model.Checked = !model.Checked; AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked; setCell (cell, indexPath); }); }; request.Send (RequestConfig.AddContent, "POST", model); }); }; request2.Send (string.Format (RequestConfig.SubCategories, AppDelegate.SubCategories.ParentCategory.fkParent), "GET"); } else { model.Checked = !model.Checked; AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked; setCell (cell, indexPath); var request = new RestRequest (); request.RequestFailed += (object snder, EventArgs ev) => { InvokeOnMainThread(delegate() { model.Checked = !model.Checked; AppDelegate.SubCategories.Categories [0].Checked = !AppDelegate.SubCategories.Categories [0].Checked; setCell (cell, indexPath); }); }; request.Send (RequestConfig.AddContent, "POST", model); } } }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); PicturesCollectionController gallery = (PicturesCollectionController)board.InstantiateViewController ("picturesCollectionController"); var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { InvokeOnMainThread(delegate { var data = (GalleryArticleModel)JsonConvert.DeserializeObject(e.Result, typeof(GalleryArticleModel)); gallery.Items = data; gallery.Title = data.CategoryName; gallery.Spinner.StopAnimating (); gallery.CollectionView.ReloadData(); }); }; request.Send (string.Format (RequestConfig.PicturesArticle, items [indexPath.Row].Id), "GET"); ((MainTabController)UIApplication.SharedApplication.Delegate.Window.RootViewController). Pictures.InternalTopNavigation.PushViewController (gallery,true); }
public override void ViewDidLoad() { base.ViewDidLoad (); //AppDelegate appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; //UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); if (AppDelegate.IsLoggedIn ()) { this.Login.Hidden = true; this.SignUp.Hidden = true; var request = new RestRequest (); request.RequestFinished += (object sender, RequestEndedArgs e) => { var data = (ProfileUpdateModel)JsonConvert.DeserializeObject(e.Result, typeof(ProfileUpdateModel)); InvokeOnMainThread(delegate { this.Name.SetTitle(data.FirstName + " " + data.LastName, UIControlState.Normal); this.Settings.SetTitle("Logout", UIControlState.Normal); if(!string.IsNullOrEmpty(data.PictureUrl)) { AppDelegate.MakeImageFromURL(this.Image, data.PictureUrl); } }); }; request.Send (string.Format (RequestConfig.Profile, AppDelegate.GetProfileId()), "GET"); } else { this.Name.Hidden = true; this.Settings.Hidden = true; } this.Login.TouchUpInside += (object sender, EventArgs e) => { UINavigationController welcomeNav = new UINavigationController (); welcomeNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"), MonoTouch.UIKit.UIBarMetrics.Default); UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); WelcomeController welcome = (WelcomeController)board.InstantiateViewController ("welcomecontroller"); UINavigationBar.Appearance.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) }); welcomeNav.PushViewController (welcome, false); UIApplication.SharedApplication.KeyWindow.RootViewController = welcomeNav; }; this.SignUp.TouchUpInside += (object sender, EventArgs e) => { //AccountSettingsController accSettings = (AccountSettingsController)board.InstantiateViewController ("accountSettingsController"); //this.NavigationController.PushViewController(accSettings, true); UINavigationController welcomeNav = new UINavigationController (); welcomeNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"), MonoTouch.UIKit.UIBarMetrics.Default); UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); WelcomeController welcome = (WelcomeController)board.InstantiateViewController ("welcomecontroller"); UINavigationBar.Appearance.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) }); welcomeNav.PushViewController (welcome, false); UIApplication.SharedApplication.KeyWindow.RootViewController = welcomeNav; }; this.Settings.TouchUpInside += (object sender, EventArgs e) => { AppDelegate.DeleteProfileId(); UINavigationController welcomeNav = new UINavigationController (); welcomeNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"), MonoTouch.UIKit.UIBarMetrics.Default); UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); WelcomeController welcome = (WelcomeController)board.InstantiateViewController ("welcomecontroller"); UINavigationBar.Appearance.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) }); welcomeNav.PushViewController (welcome, false); UIApplication.SharedApplication.KeyWindow.RootViewController = welcomeNav; }; this.AddContent.TouchUpInside += (object sender, EventArgs e) => { UINavigationController prefsNav = new UINavigationController (); prefsNav.NavigationBar.SetBackgroundImage (UIImage.FromFile ("./Assets/navbar.png"), MonoTouch.UIKit.UIBarMetrics.Default); UIStoryboard board = UIStoryboard.FromName ("MainStoryboard", null); var prefs = (PreferencesController)board.InstantiateViewController ("preferencescontroller"); UINavigationBar.Appearance.SetTitleTextAttributes (new UITextAttributes { TextColor = UIColor.FromRGB(102, 102, 102) }); prefs.Title = "Welcome"; prefsNav.PushViewController (prefs, false); UIApplication.SharedApplication.Delegate.Window.RootViewController = prefsNav; }; }