public override void ViewDidLoad() { base.ViewDidLoad(); Debug.Assert(this.viewModel.IsInitialized); // Add all of the child items var localRoot = new RootElement(this.viewModel.PageTitle); localRoot.UnevenRows = true; var topSection = new Section(); localRoot.Add(topSection); foreach (var user in this.viewModel.Friends) { UIImage image = UIImage.FromBundle("unknownUserImage_50.png"); var element = new CreateGamePlayerCell(image, user.Name, "", () => { IOSUtilities.ShowSetupGameScreen(user, this.NavigationController, this); }); element.ImageDownloadTask = PopPicImageCache.GetUserProfileImage(user.UserId, user.ProfilePictureUri.ToString()); topSection.Add(element); } this.Root = localRoot; }
public override void ViewDidLoad() { base.ViewDidLoad(); Debug.Assert(this.viewModel.IsInitialized); UIBarButtonItem startGameButton = new UIBarButtonItem("Start", UIBarButtonItemStyle.Done, null); // startGameButton.Style = UIBarButtonItemStyle.Done; startGameButton.Clicked += (object sender, EventArgs e) => { BTProgressHUD.Show("Creating Game", -1, ProgressHUD.MaskType.Black); this.viewModel.CreateNewGame(this.View.Frame.Height, this.View.Frame.Width).ContinueWith(t => { this.InvokeOnMainThread(() => { BTProgressHUD.Dismiss(); if (!t.IsFaulted && t.Result != null) { var gameplayViewController = AppDelegate.GameplayStoryboard.InstantiateViewController("GameplayViewController") as GameplayViewController; gameplayViewController.SetGameplayViewModel(t.Result); // Need to pop off the set up stack var navController = this.NavigationController; var targetController = this.NavigationController.ViewControllers.Where(vc => vc.GetType() == typeof(GameListTableViewController)).FirstOrDefault(); if (targetController != null) { this.NavigationController.PopToViewController(targetController, false); } navController.PushViewController(gameplayViewController, true); } else { // TODO Error } }); }); }; this.NavigationItem.RightBarButtonItems = new UIBarButtonItem[] { startGameButton }; var localRoot = new RootElement("New Game"); var opponentSection = new Section("Opponent"); localRoot.Add(opponentSection); UIImage image = UIImage.FromBundle("unknownUserImage_50.png"); var opponentElement = new CreateGamePlayerCell(image, this.viewModel.Opponent.Name, "", () => { // TODO - allow the user to change who the opponent is }); opponentElement.ImageDownloadTask = PopPicImageCache.GetUserProfileImage(this.viewModel.Opponent.UserId, this.viewModel.Opponent.ProfilePictureUri.ToString()); opponentSection.Add(opponentElement); this.Root = localRoot; }