public UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath) { UICollectionViewCell cell; LandingItem item = Items [(int)indexPath.Section][(int)indexPath.Item]; if (item is MyDayItem) { MyDayCollectionViewCell myDayCell = (MyDayCollectionViewCell)collectionView.DequeueReusableCell(MyDayCollectionViewCell.REUSE_IDENTIFIER, indexPath); myDayCell.SetItem((MyDayItem)item); cell = myDayCell; } else if (item is TransactionsItem) { TransactionsCollectionViewCell transactionsCell = (TransactionsCollectionViewCell)collectionView.DequeueReusableCell(TransactionsCollectionViewCell.REUSE_IDENTIFIER, indexPath); transactionsCell.SetItem((TransactionsItem)item); cell = transactionsCell; } else { LandingCollectionViewCell landingCell = (LandingCollectionViewCell)collectionView.DequeueReusableCell(LandingCollectionViewCell.REUSE_IDENTIFIER, indexPath); landingCell.SetItem(item); cell = landingCell; } return(cell); }
public void SetItem(LandingItem item) { Item = item; TitleLabel.Text = LocalizedStrings.GetString(Item.TitleId); if (Item.IconName != null) { IconImageView.Image = new UIImage(Item.IconName); } }
public void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { CollectionView.DeselectItem(indexPath, true); LandingItem item = Items [(int)indexPath.Section][(int)indexPath.Item]; Action action = item.Action; if (action != null) { action(); } }
public CGSize GetSizeForItem(UICollectionView collectionView, UICollectionViewLayout layout, NSIndexPath indexPath) { float screenWidth = (float)UIScreen.MainScreen.Bounds.Size.Width; int itemsCount = Items [indexPath.Section].Count; float cellHeight = CELL_HEIGHT; LandingItem item = Items [(int)indexPath.Section][(int)indexPath.Item]; if (item is MyDayItem || item is TransactionsItem) { cellHeight = CELL_HEIGHT / 2; } CGSize itemSize = new CGSize(screenWidth / itemsCount, cellHeight); return(new CGSize(itemSize.Width - CELL_MARGIN * 2, itemSize.Height)); }