support any actions on row

This commit is contained in:
Max Sokolov 2016-10-17 19:40:07 +03:00
parent f794dea7ee
commit 135bc22804
2 changed files with 13 additions and 6 deletions

View File

@ -30,6 +30,7 @@ public protocol RowActionable {
var editingActions: [UITableViewRowAction]? { get }
func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool
func on(anyAction action: RowAction) -> Self
func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any?
func has(action: TableRowActionType) -> Bool
}

View File

@ -84,13 +84,8 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
@discardableResult
open func on(_ action: TableRowAction<CellType>) -> Self {
if actions[action.type.key] == nil {
actions[action.type.key] = [RowAction]()
}
actions[action.type.key]?.append(action)
return self
return on(anyAction: action)
}
@discardableResult
@ -99,6 +94,17 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
return on(TableRowAction<CellType>(type, handler: handler))
}
@discardableResult
open func on(anyAction action: RowAction) -> Self {
if actions[action.type.key] == nil {
actions[action.type.key] = [RowAction]()
}
actions[action.type.key]?.append(action)
return self
}
open func removeAllActions() {
actions.removeAll()