From 08fb8af74eb5ea99c548196b3eea46f786760864 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Thu, 2 Jun 2016 00:48:10 +0300 Subject: [PATCH] add TableRowAction --- Tablet/TableBaseRowBuilder.swift | 19 +++++++++++++++++++ .../Controllers/MainController.swift | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/Tablet/TableBaseRowBuilder.swift b/Tablet/TableBaseRowBuilder.swift index e84fff5..13c6cd9 100644 --- a/Tablet/TableBaseRowBuilder.swift +++ b/Tablet/TableBaseRowBuilder.swift @@ -22,6 +22,21 @@ import UIKit public typealias ReturnValue = AnyObject? +public enum TableActionType { + + case Click + case Custom(String) +} + +public class TableRowAction { + + let type: TableActionType + + public init(type: TableActionType, handler: (data: ActionData) -> Void) { + self.type = type + } +} + /** Responsible for building cells of given type and passing items to them. */ @@ -63,6 +78,10 @@ public class TableBaseRowBuilder) { + + } + public func action(key: String, handler: (data: ActionData) -> Void) -> Self { actions[key] = .Handler(handler) diff --git a/TabletDemo/Classes/Presentation/Controllers/MainController.swift b/TabletDemo/Classes/Presentation/Controllers/MainController.swift index 77b07bc..f527e9b 100644 --- a/TabletDemo/Classes/Presentation/Controllers/MainController.swift +++ b/TabletDemo/Classes/Presentation/Controllers/MainController.swift @@ -33,6 +33,14 @@ class MainController: UIViewController { let rows2 = TableRowBuilder(items: ["1", "1", "1", "1"]) + + + rowBuilder + .addAction(TableRowAction(type: .Click) { (data) in + + + }) + rowBuilder .delete(indexes: [0], animated: .None) .insert(["2"], atIndex: 0, animated: .None)