internal void SetContent(StructureElementDto structureElement) { BackgroundColor = UIColor.Clear; labLabel.TextColor = ColorHelper.FromType(ColorType.Label); labLabel.Text = structureElement.description; imgImage.Image = UIImage.FromBundle(structureElement.image); imgImage.TintColor = ColorHelper.FromType(ColorType.Icon); }
public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath) { const string normalCellIdentifier = "MainNormalCell"; const string positionIdentifier = "MainLocationCell"; const string addressIdentifier = "AddressCell"; int section = indexPath.Section; int row = indexPath.Row; string cellIdenifier; StructureElementDto structureElement = null; if (sectionsWithRows.structureSectionList != null && sectionsWithRows.structureSectionList.Count > 0) { StructureSectionDto structureSection = sectionsWithRows.structureSectionList[(int)section]; if (structureSection.structureElementList != null && structureSection.structureElementList.Count > 0) { structureElement = structureSection.structureElementList[row]; } } if (structureElement == null) { cellIdenifier = null; } if (structureElement.elementType == StructureElementDto.ElementType.Normal) { cellIdenifier = normalCellIdentifier; } else if (structureElement.elementType == StructureElementDto.ElementType.Position) { cellIdenifier = positionIdentifier; } else if (structureElement.elementType == StructureElementDto.ElementType.Address) { cellIdenifier = addressIdentifier; } else { cellIdenifier = null; } var cell = tableView.DequeueReusableCell(cellIdenifier); return(cell.Bounds.Height); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = null; const string normalCellIdentifier = "MainNormalCell"; const string positionIdentifier = "MainLocationCell"; const string addressIdentifier = "AddressCell"; int section = indexPath.Section; int row = indexPath.Row; StructureElementDto structureElement = null; if (sectionsWithRows.structureSectionList != null && sectionsWithRows.structureSectionList.Count > 0) { StructureSectionDto structureSection = sectionsWithRows.structureSectionList[(int)section]; if (structureSection.structureElementList != null && structureSection.structureElementList.Count > 0) { structureElement = structureSection.structureElementList[row]; } } if (structureElement == null) { return(null); } if (structureElement.elementType == StructureElementDto.ElementType.Normal) { // Normal row MainNormalRowViewCell mainNormalRowViewCell = tableView.DequeueReusableCell(normalCellIdentifier, indexPath) as MainNormalRowViewCell; mainNormalRowViewCell.SetContent(structureElement); cell = mainNormalRowViewCell; } else if (structureElement.elementType == StructureElementDto.ElementType.Position) { // Location row MainLocationRowViewCell locationCell = tableView.DequeueReusableCell(positionIdentifier, indexPath) as MainLocationRowViewCell; locationCell.SetContent(); cell = locationCell; } else if (structureElement.elementType == StructureElementDto.ElementType.Address) { var addressCell = tableView.DequeueReusableCell(addressIdentifier, indexPath) as AddressViewCell; addressCell.SetContent(); cell = addressCell; } else { return(null); } if (cell != null) { if (IsOdd((int)section + 1)) { cell.BackgroundColor = ColorHelper.FromType(ColorType.OddRow); } else { cell.BackgroundColor = ColorHelper.FromType(ColorType.EvenRow); } } return(cell); }