deprecate action method on TableRow, add on instead

This commit is contained in:
Max Sokolov 2016-10-14 20:35:18 +03:00
parent 9e1372252a
commit a240acee2d
2 changed files with 24 additions and 5 deletions

View File

@ -21,12 +21,13 @@ class NibCellsController: UITableViewController {
tableDirector = TableDirector(tableView: tableView)
let numbers = [1000, 2000, 3000, 4000, 5000]
let shouldHighlightAction = TableRowAction<NibTableViewCell>(.shouldHighlight) { (_) -> Bool in
return false
}
let rows = numbers.map { TableRow<NibTableViewCell>(item: $0, actions: [shouldHighlightAction]) }
let rows = numbers.map {
TableRow<NibTableViewCell>(item: $0)
.on(.shouldHighlight) { (_) -> Bool in
return false
}
}
tableDirector.append(rows: rows)
}

View File

@ -107,6 +107,23 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
// MARK: - actions -
@discardableResult
open func on(_ action: TableRowAction<CellType>) -> Self {
actions[action.type.key] = action
return self
}
@discardableResult
open func on<T>(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData<CellType>) -> T) -> Self {
actions[type.key] = TableRowAction<CellType>(type, handler: handler)
return self
}
// MARK: - deprecated actions -
@available(*, deprecated, message: "Use 'on' method instead")
@discardableResult
open func action(_ action: TableRowAction<CellType>) -> Self {
@ -114,6 +131,7 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
return self
}
@available(*, deprecated, message: "Use 'on' method instead")
@discardableResult
open func action<T>(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData<CellType>) -> T) -> Self {