// Get the view for the section header - create and style container view, label, and image view public override UIView GetViewForHeader(UITableView tableView, nint section) { if (loading) { return(null); } UILabel headerLabel = new UILabel(); headerLabel.Frame = new CGRect(40.0f, 5.0f, TableView.Frame.Width - 60.0f, 20.0f); headerLabel.Font = UIFont.PreferredHeadline; headerLabel.Text = TitleForHeader(TableView, section); headerLabel.TextColor = UIColor.White; UIImageView artworkView = new UIImageView(new CGRect(0.0f, 0.0f, 30.0f, 30.0f)); NSIndexPath indexPath = NSIndexPath.FromRowSection(0, section); Song song = Songs.GetSongBySectionRow(indexPath.Section, indexPath.Row); if (song.artwork != null) { artworkView.Image = song.artwork.ImageWithSize(new CGSize(30.0f, 30.0f)); } UIView headerView = new UIView(new CGRect(0, 0, TableView.Frame.Width, 30)); headerView.BackgroundColor = UIColor.DarkGray; headerView.Add(headerLabel); headerView.Add(artworkView); return(headerView); }
// Set up the table view cells public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = TableView.DequeueReusableCell("cell"); if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Subtitle, "cell"); } if (loading) { cell.TextLabel.Text = "Loading..."; cell.DetailTextLabel.Text = "This may take a bit for a large library"; } else { Song song = Songs.GetSongBySectionRow(indexPath.Section, indexPath.Row); cell.TextLabel.Text = song.song; cell.TextLabel.Font = UIFont.PreferredBody; cell.DetailTextLabel.Text = String.Format("Album: {0}", song.album); if (song == MyMusicPlayer.GetInstance().currentSong) { cell.BackgroundColor = UIColor.FromRGB(0.9f, 0.9f, 0.9f); } else { cell.BackgroundColor = UIColor.White; } } return(cell); }
// Get ready to segue to the detail view controller public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) { // The segue to use if (segue.Identifier == "showDetail") { detailViewController = segue.DestinationViewController as DetailViewController; if (sender == leftBBI) { Song song = Songs.GetStreamingSongByIndex(0); // Pass song info to the detail view controller detailViewController.song = song; } else if (sender == rightBBI) { Song playingSong = MyMusicPlayer.GetInstance().currentSong; detailViewController.song = playingSong; } else { // Selected song NSIndexPath indexPath = Songs.searching ? searchController.SearchResultsTableView.IndexPathForSelectedRow : TableView.IndexPathForSelectedRow; Song song = Songs.GetSongBySectionRow(indexPath.Section, indexPath.Row); song.streamingURL = null; // Pass song info to the detail view controller detailViewController.song = song; } } }