diff --git a/Demo/Classes/Presentation/Controllers/MainController.swift b/Demo/Classes/Presentation/Controllers/MainController.swift index a8360f4..50a244a 100644 --- a/Demo/Classes/Presentation/Controllers/MainController.swift +++ b/Demo/Classes/Presentation/Controllers/MainController.swift @@ -23,9 +23,9 @@ class MainController: UIViewController { title = "TableKit" - let clickAction = TableRowAction(.click) { [weak self] (data) in + let clickAction = TableRowAction(.click) { [weak self] (options) in - switch data.indexPath.row { + switch options.indexPath.row { case 0: self?.performSegue(withIdentifier: "autolayoutcells", sender: nil) case 1: @@ -35,9 +35,9 @@ class MainController: UIViewController { } } - let printClickAction = TableRowAction(.click) { (data) in + let printClickAction = TableRowAction(.click) { (options) in - print("click", data.indexPath) + print("click", options.indexPath) } let rows = [ diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 5e6b607..3fbe569 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -94,7 +94,7 @@ open class TableRow: Row where CellType: UITableView } @discardableResult - open func on(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> T) -> Self { + open func on(_ type: TableRowActionType, handler: @escaping (_ options: TableRowActionOptions) -> T) -> Self { return on(TableRowAction(type, handler: handler)) } @@ -124,7 +124,7 @@ open class TableRow: Row where CellType: UITableView @available(*, deprecated, message: "Use 'on' method instead") @discardableResult - open func action(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> T) -> Self { + open func action(_ type: TableRowActionType, handler: @escaping (_ options: TableRowActionOptions) -> T) -> Self { return on(TableRowAction(type, handler: handler)) } diff --git a/Sources/TableRowAction.swift b/Sources/TableRowAction.swift index 2bf5641..df415d3 100644 --- a/Sources/TableRowAction.swift +++ b/Sources/TableRowAction.swift @@ -20,7 +20,7 @@ import UIKit -open class TableRowActionData where CellType: UITableViewCell { +open class TableRowActionOptions where CellType: UITableViewCell { open let item: CellType.T open let cell: CellType? @@ -38,17 +38,17 @@ open class TableRowActionData where CellType: UITabl private enum TableRowActionHandler where CellType: UITableViewCell { - case voidAction((TableRowActionData) -> Void) - case action((TableRowActionData) -> Any?) + case voidAction((TableRowActionOptions) -> Void) + case action((TableRowActionOptions) -> Any?) - func invoke(withActionData actionData: TableRowActionData) -> Any? { + func invoke(withOptions options: TableRowActionOptions) -> Any? { switch self { case .voidAction(let handler): - handler(actionData) + handler(options) return nil case .action(let handler): - return handler(actionData) + return handler(options) } } } @@ -59,13 +59,13 @@ open class TableRowAction: RowAction where CellType: open let type: TableRowActionType private let handler: TableRowActionHandler - public init(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> Void) { + public init(_ type: TableRowActionType, handler: @escaping (_ options: TableRowActionOptions) -> Void) { self.type = type self.handler = .voidAction(handler) } - public init(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> T) { + public init(_ type: TableRowActionType, handler: @escaping (_ options: TableRowActionOptions) -> T) { self.type = type self.handler = .action(handler) @@ -74,6 +74,6 @@ open class TableRowAction: RowAction where CellType: public func invokeActionOn(cell: UITableViewCell?, item: Any, path: IndexPath) -> Any? { guard let item = item as? CellType.T else { return nil } - return handler.invoke(withActionData: TableRowActionData(item: item, cell: cell as? CellType, path: path, userInfo: nil)) + return handler.invoke(withOptions: TableRowActionOptions(item: item, cell: cell as? CellType, path: path, userInfo: nil)) } }