public override void ViewDidLoad() { base.ViewDidLoad(); // The loading overlay pnlLoadingOverlay.BackgroundColor = UIColor.FromPatternImage(new UIImage("pizza-bg-pattern.png")); pnlLoadingOverlay.Hidden = false; pbProgress.Progress = 0; // Start loading the data var rawData = new PizzaDataset(); rawData.loadData( // Loading progress callback (bytesRead, bytesTotal) => { float percentage = (float)((double)bytesRead / (double)bytesTotal); // Update the UI InvokeOnMainThread(() => { pbProgress.Progress = percentage; }); }, // Finish callback (success) => { if (!success) { return; } var displayData = new PizzaTableViewSource(rawData); // Update the UI InvokeOnMainThread(() => { // hide the progress bar pnlLoadingOverlay.Hidden = true; // set the table data tvPizzaList.Source = displayData; tvPizzaList.ReloadData(); }); } ); // Update the header icon updateExpandAllIcon(); // Setup the TableView decoration //tvPizzaList.BackgroundColor = UIColor.FromRGB(34, 35, 40); tvPizzaList.BackgroundColor = UIColor.FromPatternImage(new UIImage("pizza-bg-pattern.png")); // Setup the TableView data tvPizzaList.RowHeight = UITableView.AutomaticDimension; tvPizzaList.EstimatedRowHeight = 60; }
public PizzaTableViewSource(PizzaDataset data) { _topPizzas = new List <TopPizzaData>(); /*var random = new Random(); * * List<string> allToppings = new List<string>( * * new string []{ * "mozzarella cheese", * "bacon", * "beef", * "onions", * "pineapple", * "mushrooms", * "pepperoni" * }); * * for (int i = 0; i < 200; i++) * { * int toppingsCount = 1 + random.Next(allToppings.Count); * var dataItem = new TopPizzaData() * { * ordersCount = 2 + (uint)random.Next(200) * }; * * allToppings.Shuffle(random); * * for (int j=0; j< toppingsCount; j++) * { * dataItem.toppings.Add(allToppings[j]); * } * * _topPizzas.Add(dataItem); * }*/ foreach (var pizza in data.topData) { _topPizzas.Add(pizza); } }