Add height for item

This commit is contained in:
Ivan Zinovyev 2018-04-22 01:50:04 +03:00
parent 02f77ed699
commit 279fdd4854
3 changed files with 9 additions and 0 deletions

View File

@ -29,6 +29,8 @@ public protocol ConfigurableCell {
static var defaultHeight: CGFloat? { get }
func configure(with _: T)
func height(for _: T) -> CGFloat
}
public extension ConfigurableCell where Self: UITableViewCell {

View File

@ -31,6 +31,8 @@ public struct TableKitUserInfoKeys {
public protocol RowConfigurable {
func configure(_ cell: UITableViewCell)
func height(for _: UITableViewCell) -> CGFloat
}
public protocol RowActionable {

View File

@ -60,6 +60,11 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
(cell as? CellType)?.configure(with: item)
}
open func height(for cell: UITableViewCell) -> CGFloat {
return (cell as? CellType)?.height(for: item) ?? UITableViewAutomaticDimension
}
// MARK: - RowActionable -
open func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]? = nil) -> Any? {