Fixing CXTDT-586497 issue, table contents alignment is based on the row type, is header
This commit is contained in:
parent
71c5e444f4
commit
bf46f85622
@ -147,7 +147,8 @@ extension Table: UICollectionViewDelegate, UICollectionViewDataSource, TableColl
|
||||
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TableCellItem.Identifier, for: indexPath) as? TableCellItem else { return UICollectionViewCell() }
|
||||
let currentItem = tableData[indexPath.section].columns[indexPath.row]
|
||||
let shouldStrip = striped ? (indexPath.section % 2 != 0) : false
|
||||
cell.updateCell(content: currentItem, surface: surface, striped: shouldStrip, padding: padding)
|
||||
let isHeader = tableData[indexPath.section].isHeader
|
||||
cell.updateCell(content: currentItem, surface: surface, striped: shouldStrip, padding: padding, isHeader: isHeader)
|
||||
return cell
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ final class TableCellItem: UICollectionViewCell {
|
||||
//--------------------------------------------------
|
||||
|
||||
/// Updates the cell content with ``TableItemModel`` and styling/padding attributes from other parameters
|
||||
public func updateCell(content: TableItemModel, surface: Surface, striped: Bool = false, padding: Table.Padding = .standard) {
|
||||
public func updateCell(content: TableItemModel, surface: Surface, striped: Bool = false, padding: Table.Padding = .standard, isHeader: Bool = false) {
|
||||
|
||||
containerView.subviews.forEach({ $0.removeFromSuperview() })
|
||||
self.padding = padding
|
||||
@ -83,10 +83,10 @@ final class TableCellItem: UICollectionViewCell {
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
component.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: VDSLayout.space1X),
|
||||
component.topAnchor.constraint(greaterThanOrEqualTo: containerView.topAnchor, constant: padding.verticalValue()),
|
||||
containerView.bottomAnchor.constraint(greaterThanOrEqualTo: component.bottomAnchor, constant: padding.verticalValue()),
|
||||
containerView.trailingAnchor.constraint(greaterThanOrEqualTo: component.trailingAnchor, constant: padding.horizontalValue()),
|
||||
containerView.centerYAnchor.constraint(equalTo: component.centerYAnchor)
|
||||
containerView.trailingAnchor.constraint(greaterThanOrEqualTo: component.trailingAnchor, constant: padding.horizontalValue())
|
||||
])
|
||||
|
||||
component.topAnchor.constraint(equalTo: containerView.topAnchor, constant: padding.verticalValue()).isActive = !isHeader
|
||||
containerView.bottomAnchor.constraint(equalTo: component.bottomAnchor, constant: padding.verticalValue()).isActive = isHeader
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,11 +11,14 @@ public struct TableRowModel {
|
||||
|
||||
public var columns: [TableItemModel]
|
||||
|
||||
public var isHeader: Bool = false
|
||||
|
||||
public var columnsCount: Int {
|
||||
return columns.count
|
||||
}
|
||||
|
||||
public init(columns: [TableItemModel]) {
|
||||
public init(columns: [TableItemModel], isHeader: Bool = false) {
|
||||
self.columns = columns
|
||||
self.isHeader = isHeader
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user