table row improvements
This commit is contained in:
parent
234e0efc85
commit
01dc5dfd21
|
|
@ -81,8 +81,7 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
|
|||
}
|
||||
|
||||
public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
|
||||
return UITableViewAutomaticDimension
|
||||
return sections[indexPath.section].items[indexPath.row].defaultHeight
|
||||
}
|
||||
|
||||
// MARK: UITableViewDataSource - configuration
|
||||
|
|
@ -92,13 +91,12 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
|
|||
}
|
||||
|
||||
public func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return sections[section].numberOfRowsInSection
|
||||
return sections[section].numberOfRows
|
||||
}
|
||||
|
||||
public func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
||||
|
||||
let row = sections[indexPath.section].items[indexPath.row]
|
||||
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier(row.reusableIdentifier, forIndexPath: indexPath)
|
||||
|
||||
if cell.frame.size.width != tableView.frame.size.width {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public protocol Row {
|
|||
|
||||
var reusableIdentifier: String { get }
|
||||
var estimatedHeight: CGFloat { get }
|
||||
var defaultHeight: CGFloat { get }
|
||||
|
||||
func configure(cell: UITableViewCell)
|
||||
}
|
||||
|
|
@ -39,6 +40,10 @@ public class TableRow<ItemType, CellType: ConfigurableCell where CellType.T == I
|
|||
public var estimatedHeight: CGFloat {
|
||||
return CellType.estimatedHeight()
|
||||
}
|
||||
|
||||
public var defaultHeight: CGFloat {
|
||||
return CellType.defaultHeight() ?? UITableViewAutomaticDimension
|
||||
}
|
||||
|
||||
public init(item: ItemType) {
|
||||
self.item = item
|
||||
|
|
|
|||
|
|
@ -26,13 +26,7 @@ import UIKit
|
|||
*/
|
||||
public class TableSection {
|
||||
|
||||
weak var tableDirector: TableDirector? {
|
||||
didSet {
|
||||
|
||||
//guard let director = tableDirector else { return }
|
||||
//builders.forEach { $0.willUpdateDirector(director) }
|
||||
}
|
||||
}
|
||||
weak var tableDirector: TableDirector?
|
||||
|
||||
public private(set) var items = [Row]()
|
||||
|
||||
|
|
@ -43,7 +37,7 @@ public class TableSection {
|
|||
public private(set) var footerView: UIView?
|
||||
|
||||
/// A total number of rows in section of each row builder.
|
||||
public var numberOfRowsInSection: Int {
|
||||
public var numberOfRows: Int {
|
||||
return items.count
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue