diff --git a/Tablet.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate b/Tablet.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate index e78d368..b905fec 100644 Binary files a/Tablet.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate and b/Tablet.xcworkspace/xcuserdata/max.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Tablet/TableRow.swift b/Tablet/TableRow.swift index 4c5c0d4..86338d4 100644 --- a/Tablet/TableRow.swift +++ b/Tablet/TableRow.swift @@ -20,13 +20,21 @@ import UIKit -public protocol Row { - +public protocol RowConfigurable { + + func configure(cell: UITableViewCell) +} + +public protocol RowActionable { + + func invoke(action: TableRowActionType, cell: UITableViewCell?, path: NSIndexPath) -> Any? +} + +public protocol Row: RowConfigurable, RowActionable { + var reusableIdentifier: String { get } var estimatedHeight: CGFloat { get } var defaultHeight: CGFloat { get } - - func configure(cell: UITableViewCell) } public class TableRow: Row { @@ -50,14 +58,23 @@ public class TableRow Any? { + + return nil + } + // MARK: - actions - - public func addAction(action: TableRowAction) { - + public func action(action: TableRowAction) -> Self { + return self } } \ No newline at end of file diff --git a/Tablet/TableRowAction.swift b/Tablet/TableRowAction.swift index 05740e6..00cfd18 100644 --- a/Tablet/TableRowAction.swift +++ b/Tablet/TableRowAction.swift @@ -20,7 +20,7 @@ import UIKit -public enum TableActionType { +public enum TableRowActionType { case Click case Custom(String) @@ -32,10 +32,11 @@ protocol RowAction { public class TableRowAction: RowAction { - public init(_ action: TableActionType, handler: (row: TableRow) -> Void) { - - - - + public init(_ action: ActionType, handler: (row: TableRow) -> Void) { + + } + + public init(_ action: ActionType, handler: (row: TableRow) -> T) { + } } \ No newline at end of file diff --git a/TabletDemo/Classes/Presentation/Controllers/MainController.swift b/TabletDemo/Classes/Presentation/Controllers/MainController.swift index 905c33f..b055272 100644 --- a/TabletDemo/Classes/Presentation/Controllers/MainController.swift +++ b/TabletDemo/Classes/Presentation/Controllers/MainController.swift @@ -30,7 +30,7 @@ class MainController: UIViewController { - let a = TableRowAction(.Click) { + let a = TableRowAction(.click) { (row) in } @@ -41,10 +41,15 @@ class MainController: UIViewController { let row2 = TableRow(item: "2") let row3 = TableRow(item: "3", actions: [a]) + row1 + .action(TableRowAction(.click) { (row) in - .addAction(TableRowAction(.Click) { (row) in - + + }) + .action(TableRowAction(.click) { (row) -> String in + + return "" })