Example #1
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var beerCheckedIn = beers[indexPath.Row];
            var beer          = beerCheckedIn.CheckIns.FirstOrDefault().Beer;

            var cell = tableView.DequeueReusableCell(cellIdentifier) as MyBeersTableViewCell ?? new MyBeersTableViewCell(cellIdentifier);

            cell.Name    = beerCheckedIn.Name;
            cell.Brewery = beer?.Brewery;

            if (beer.ImageMedium != null)
            {
                cell.Image.SetImage(new NSUrl(beer?.ImageMedium), UIImage.FromBundle("BeerDrinkin.png"));
            }
            else
            {
                cell.Image.Image = UIImage.FromBundle("BeerDrinkin.png");
            }

            var cellDelegate = new MyBeerCellDelegate();

            cellDelegate.DeleteBeer += () =>
            {
                var beerId = beers[indexPath.Row].BreweryDbId;
                DeleteItem(beerId.ToString());
                beers.RemoveAt(indexPath.Row);
            };

            cell.Delegate = cellDelegate;
            var deleteButton = new UIButton(UIButtonType.RoundedRect)
            {
                BackgroundColor = Colour.Red.ToNative(),
                TintColor       = Colour.White.ToNative()
            };

            deleteButton.SetImage(UIImage.FromFile("*****@*****.**"), UIControlState.Normal);
            cell.SetRightUtilityButtons(new[] { deleteButton }, 90);


            return(cell);
        }
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var beerCheckedIn = beers[indexPath.Row];
            var beer = beerCheckedIn.CheckIns.FirstOrDefault().Beer;

            var cell = tableView.DequeueReusableCell(cellIdentifier) as MyBeersTableViewCell ?? new MyBeersTableViewCell(cellIdentifier);
            cell.Name = beerCheckedIn.Name;
            cell.Brewery = beer.Brewery;
           

            if (beer.Large != null)
            {
                cell.Image.SetImage(new NSUrl(beer.Large), UIImage.FromBundle("BeerDrinkin.png"));
            }
            else
            {
                cell.Image.Image = UIImage.FromBundle("BeerDrinkin.png");
            }

            var cellDelegate = new MyBeerCellDelegate();
            cellDelegate.DeleteBeer += () =>
            {
                var beerId = beers[indexPath.Row].BreweryDBId;
                DeleteItem(beerId);
                beers.RemoveAt(indexPath.Row);                
            };

            cell.Delegate = cellDelegate;
            var deleteButton = new UIButton(UIButtonType.RoundedRect)
            {
                BackgroundColor = Colour.Red.ToNative(),
                TintColor = Colour.White.ToNative()
            };
            deleteButton.SetImage(UIImage.FromFile("*****@*****.**"), UIControlState.Normal);
            cell.SetRightUtilityButtons(new[] { deleteButton }, 90);


            return cell;
        }