示例#1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (collection != null)
            {
                Title = collection.Title;
            }
            else
            {
                Title = "All Products";
            }

            TableView.RegisterClassForCellReuse(typeof(UITableViewCell), "Cell");
            TableView.RegisterClassForCellReuse(typeof(ProductViewControllerToggleTableViewCell), "ProductViewControllerToggleCell");
            TableView.RegisterClassForCellReuse(typeof(ProductViewControllerThemeStyleTableViewCell), "ThemeStyleCell");
            TableView.RegisterClassForCellReuse(typeof(ProductViewControllerThemeTintColorTableViewCell), "ThemeTintColorCell");
            TableView.RegisterClassForCellReuse(typeof(ProductViewControllerToggleTableViewCell), "ThemeShowsBackgroundToggleCell");
            TableView.RegisterClassForCellReuse(typeof(ProductViewControllerToggleTableViewCell), "ProductViewControllerPresentViewControllerToggleCell");

            themeTintColors = new [] {
                UIColor.FromRGBA(0.48f, 0.71f, 0.36f, 1.0f),
                UIColor.FromRGBA(0.88f, 0.06f, 0.05f, 1.0f),
                UIColor.FromRGBA(0.02f, 0.54f, 1.0f, 1.0f)
            };
            themeTintColorSelectedIndex = 0;
            showsProductImageBackground = true;
            presentViewController       = true;

            if (collection != null)
            {
                // If we're presenting with a collection, add the ability to sort
                UIBarButtonItem sortBarButtonItem = new UIBarButtonItem("Sort", UIBarButtonItemStyle.Plain, PresentCollectionSortOptions);
                NavigationItem.RightBarButtonItem = sortBarButtonItem;

                GetCollection(CollectionSort.Default);
            }
            else
            {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
                client.GetProductsPage(1, (products, page, reachedEnd, error) => {
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

                    if (error == null && products != null)
                    {
                        this.products = products;
                        TableView.ReloadData();
                    }
                    else
                    {
                        Console.WriteLine("Error fetching products: {0}", error);
                    }
                });
            }
        }