add RowHashable protocol

This commit is contained in:
Max Sokolov 2016-06-14 23:50:30 +03:00
parent cc75e84f58
commit fadb2f4e60
3 changed files with 12 additions and 5 deletions

View File

@ -35,9 +35,7 @@ class MainController: UIViewController {
let row1 = TableRow<String, StoryboardImageTableViewCell>(item: "1")
let row2 = TableRow<String, StoryboardImageTableViewCell>(item: "2")
let row3 = TableRow<String, StoryboardImageTableViewCell>(item: "3", actions: [a])
row1
.addAction(TableRowAction(.shouldHighlight) { (data) -> Bool in

View File

@ -27,7 +27,7 @@ public protocol HeightCalculatingStrategy {
func height(indexPath: NSIndexPath, reusableIdentifier: String, configure: (cell: UITableViewCell) -> Void) -> CGFloat
}
public class PrototypeHeightStrategy {
public class PrototypeHeightStrategy: HeightCalculatingStrategy {
public weak var tableView: UITableView?
private var cachedHeights = [Int: CGFloat]()

View File

@ -31,7 +31,12 @@ public protocol RowActionable {
func hasAction(action: TableRowActionType) -> Bool
}
public protocol Row: RowConfigurable, RowActionable {
public protocol RowHashable {
var hashValue: Int { get }
}
public protocol Row: RowConfigurable, RowActionable, RowHashable {
var reusableIdentifier: String { get }
var estimatedHeight: CGFloat { get }
@ -42,6 +47,10 @@ public class TableRow<ItemType, CellType: ConfigurableCell where CellType.T == I
public let item: ItemType
private lazy var actions = [String: TableRowAction<ItemType, CellType>]()
public var hashValue: Int {
return ObjectIdentifier(self).hashValue
}
public var reusableIdentifier: String {
return CellType.reusableIdentifier()