support userInfo in custom actions
This commit is contained in:
parent
8991138f18
commit
a5d8f0874a
|
|
@ -72,8 +72,8 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
|
|||
// MARK: Public
|
||||
|
||||
@discardableResult
|
||||
open func invoke(action: TableRowActionType, cell: UITableViewCell?, indexPath: IndexPath) -> Any? {
|
||||
return sections[indexPath.section].rows[indexPath.row].invoke(action: action, cell: cell, path: indexPath)
|
||||
open func invoke(action: TableRowActionType, cell: UITableViewCell?, indexPath: IndexPath, userInfo: [AnyHashable: Any]? = nil) -> Any? {
|
||||
return sections[indexPath.section].rows[indexPath.row].invoke(action: action, cell: cell, path: indexPath, userInfo: userInfo)
|
||||
}
|
||||
|
||||
open override func responds(to selector: Selector) -> Bool {
|
||||
|
|
@ -93,7 +93,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
|
|||
func didReceiveAction(_ notification: Notification) {
|
||||
|
||||
guard let action = notification.object as? TableCellAction, let indexPath = tableView?.indexPath(for: action.cell) else { return }
|
||||
invoke(action: .custom(action.key), cell: action.cell, indexPath: indexPath)
|
||||
invoke(action: .custom(action.key), cell: action.cell, indexPath: indexPath, userInfo: notification.userInfo)
|
||||
}
|
||||
|
||||
// MARK: - Height
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public protocol RowActionable {
|
|||
var editingActions: [UITableViewRowAction]? { get }
|
||||
func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool
|
||||
|
||||
func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath) -> Any?
|
||||
func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any?
|
||||
func has(action: TableRowActionType) -> Bool
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ public protocol RowAction {
|
|||
var id: String? { get set }
|
||||
var type: TableRowActionType { get }
|
||||
|
||||
func invokeActionOn(cell: UITableViewCell?, item: Any, path: IndexPath) -> Any?
|
||||
func invokeActionOn(cell: UITableViewCell?, item: Any, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any?
|
||||
}
|
||||
|
||||
public protocol RowHeightCalculator {
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ 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, userInfo: [AnyHashable: Any]? = nil) -> Any? {
|
||||
|
||||
return actions[action.key]?.flatMap({ $0.invokeActionOn(cell: cell, item: item, path: path) }).last
|
||||
return actions[action.key]?.flatMap({ $0.invokeActionOn(cell: cell, item: item, path: path, userInfo: userInfo) }).last
|
||||
}
|
||||
|
||||
open func has(action: TableRowActionType) -> Bool {
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ open class TableRowAction<CellType: ConfigurableCell>: RowAction where CellType:
|
|||
self.handler = .action(handler)
|
||||
}
|
||||
|
||||
public func invokeActionOn(cell: UITableViewCell?, item: Any, path: IndexPath) -> Any? {
|
||||
public func invokeActionOn(cell: UITableViewCell?, item: Any, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any? {
|
||||
guard let item = item as? CellType.T else { return nil }
|
||||
|
||||
return handler.invoke(withOptions: TableRowActionOptions(item: item, cell: cell as? CellType, path: path, userInfo: nil))
|
||||
return handler.invoke(withOptions: TableRowActionOptions(item: item, cell: cell as? CellType, path: path, userInfo: userInfo))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue