add TableRowAction
This commit is contained in:
parent
bdf009b980
commit
08fb8af74e
|
|
@ -22,6 +22,21 @@ import UIKit
|
|||
|
||||
public typealias ReturnValue = AnyObject?
|
||||
|
||||
public enum TableActionType {
|
||||
|
||||
case Click
|
||||
case Custom(String)
|
||||
}
|
||||
|
||||
public class TableRowAction<DataType, CellType> {
|
||||
|
||||
let type: TableActionType
|
||||
|
||||
public init(type: TableActionType, handler: (data: ActionData<DataType, CellType>) -> Void) {
|
||||
self.type = type
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Responsible for building cells of given type and passing items to them.
|
||||
*/
|
||||
|
|
@ -63,6 +78,10 @@ public class TableBaseRowBuilder<DataType, CellType where CellType: UITableViewC
|
|||
|
||||
// MARK: - Chaining actions -
|
||||
|
||||
public func addAction(action: TableRowAction<DataType, CellType>) {
|
||||
|
||||
}
|
||||
|
||||
public func action(key: String, handler: (data: ActionData<DataType, CellType>) -> Void) -> Self {
|
||||
|
||||
actions[key] = .Handler(handler)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,14 @@ class MainController: UIViewController {
|
|||
|
||||
let rows2 = TableRowBuilder<String, StoryboardImageTableViewCell>(items: ["1", "1", "1", "1"])
|
||||
|
||||
|
||||
|
||||
rowBuilder
|
||||
.addAction(TableRowAction(type: .Click) { (data) in
|
||||
|
||||
|
||||
})
|
||||
|
||||
rowBuilder
|
||||
.delete(indexes: [0], animated: .None)
|
||||
.insert(["2"], atIndex: 0, animated: .None)
|
||||
|
|
|
|||
Loading…
Reference in New Issue