add TableRowAction

This commit is contained in:
Max Sokolov 2016-06-02 00:48:10 +03:00
parent bdf009b980
commit 08fb8af74e
2 changed files with 27 additions and 0 deletions

View File

@ -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)

View File

@ -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)