From 279fdd4854f261cff83296119e4e27140934c2f5 Mon Sep 17 00:00:00 2001 From: Ivan Zinovyev Date: Sun, 22 Apr 2018 01:50:04 +0300 Subject: [PATCH] Add height for item --- Sources/ConfigurableCell.swift | 2 ++ Sources/TableKit.swift | 2 ++ Sources/TableRow.swift | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift index cc96430..4cc3161 100644 --- a/Sources/ConfigurableCell.swift +++ b/Sources/ConfigurableCell.swift @@ -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 { diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index c2b10c9..f0cb0ff 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -31,6 +31,8 @@ public struct TableKitUserInfoKeys { public protocol RowConfigurable { func configure(_ cell: UITableViewCell) + func height(for _: UITableViewCell) -> CGFloat + } public protocol RowActionable { diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index edfca6e..5819bc7 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -60,6 +60,11 @@ open class TableRow: 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? {