From c27a386807686209c7fa55971c0bb1d532379beb Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Tue, 7 Jun 2016 23:40:46 +0300 Subject: [PATCH] rowitem improvements --- Tablet/TableDynamicRowBuilder.swift | 29 ++++++++++--------- .../Controllers/MainController.swift | 29 ++++++++++++++++--- .../Views/StoryboardImageTableViewCell.swift | 2 +- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/Tablet/TableDynamicRowBuilder.swift b/Tablet/TableDynamicRowBuilder.swift index 5e2a0a4..63b9daa 100644 --- a/Tablet/TableDynamicRowBuilder.swift +++ b/Tablet/TableDynamicRowBuilder.swift @@ -23,6 +23,7 @@ import UIKit public protocol RowItemable { var reusableIdentifier: String { get } + var estimatedHeight: CGFloat { get } func configure(cell: UITableViewCell) } @@ -35,6 +36,10 @@ public class RowItem Void) -> Self { + + return self + } + // MARK: - RowHeightCalculatable - public func rowHeight(index: Int, indexPath: NSIndexPath) -> CGFloat { @@ -94,6 +95,6 @@ public class TableDynamicRowBuilder: RowBuilder { } public func estimatedRowHeight(index: Int, indexPath: NSIndexPath) -> CGFloat { - return 0 //CellType.estimatedHeight() + return items[index].estimatedHeight } } \ No newline at end of file diff --git a/TabletDemo/Classes/Presentation/Controllers/MainController.swift b/TabletDemo/Classes/Presentation/Controllers/MainController.swift index 89d29cb..0a4da70 100644 --- a/TabletDemo/Classes/Presentation/Controllers/MainController.swift +++ b/TabletDemo/Classes/Presentation/Controllers/MainController.swift @@ -22,7 +22,8 @@ class MainController: UIViewController { super.viewDidLoad() let rowBuilder = TableRowBuilder(items: ["1", "1", "1", "1"]) - .action(.click) { [unowned self] e in + .action(.click) { [unowned self] data in + self.performSegueWithIdentifier("headerfooter", sender: nil) } @@ -34,13 +35,33 @@ class MainController: UIViewController { let cellItem = RowItem(item: "1") - let cellItem2 = RowItem(item: "1") - let cellItem3 = RowItem(item: "1") + let cellItem2 = RowItem(item: "2") + let cellItem3 = RowItem(item: "3") let b = TableDynamicRowBuilder(items: [cellItem, cellItem2, cellItem3]) + .action { (item, path) in + + if let x = item as? RowItem { + + } + } + .action { (item, path) in + + + } + + + + tableDirector += b + + + + + + /*rowBuilder @@ -70,6 +91,6 @@ class MainController: UIViewController { //tableDirector.performBatchUpdates { //}*/ - tableDirector.append(section: section) + //tableDirector.append(section: section) } } \ No newline at end of file diff --git a/TabletDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift b/TabletDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift index b161b36..45bf5b6 100644 --- a/TabletDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift +++ b/TabletDemo/Classes/Presentation/Views/StoryboardImageTableViewCell.swift @@ -19,7 +19,7 @@ class StoryboardImageTableViewCell: UITableViewCell, ConfigurableCell { func configure(string: T) { - titleLabel.text = "Test" + titleLabel.text = string subtitleLabel.text = "Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.Copyright © 2016 Tablet. All rights reserved.1" }