This commit is contained in:
Max Sokolov 2016-10-15 11:13:54 +03:00
parent b74403e2c6
commit e18c6ef669
3 changed files with 7 additions and 7 deletions

View File

@ -71,7 +71,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
@discardableResult
open func invoke(action: TableRowActionType, cell: UITableViewCell?, indexPath: IndexPath) -> Any? {
return sections[indexPath.section].rows[indexPath.row].invoke(action, cell: cell, path: indexPath)
return sections[indexPath.section].rows[indexPath.row].invoke(action: action, cell: cell, path: indexPath)
}
open override func responds(to selector: Selector) -> Bool {
@ -85,7 +85,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
// MARK: - Internal -
func hasAction(_ action: TableRowActionType, atIndexPath indexPath: IndexPath) -> Bool {
return sections[indexPath.section].rows[indexPath.row].hasAction(action)
return sections[indexPath.section].rows[indexPath.row].has(action: action)
}
func didReceiveAction(_ notification: Notification) {

View File

@ -30,8 +30,8 @@ public protocol RowActionable {
var editingActions: [UITableViewRowAction]? { get }
func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool
func invoke(_ action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any?
func hasAction(_ action: TableRowActionType) -> Bool
func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any?
func has(action: TableRowActionType) -> Bool
}
public protocol RowHashable {

View File

@ -62,12 +62,12 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
// MARK: - RowActionable -
open func invoke(_ action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any? {
open func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any? {
return actions[action.key]?.flatMap({ $0.invokeActionOn(cell: cell, item: item, path: path) }).last
}
open func hasAction(_ action: TableRowActionType) -> Bool {
open func has(action: TableRowActionType) -> Bool {
return actions[action.key] != nil
}
@ -75,7 +75,7 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
open func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool {
if actions[TableRowActionType.canEdit.key] != nil {
return invoke(.canEdit, cell: nil, path: indexPath) as? Bool ?? false
return invoke(action: .canEdit, cell: nil, path: indexPath) as? Bool ?? false
}
return editingActions?.isEmpty == false || actions[TableRowActionType.clickDelete.key] != nil
}