From da51e2b7e9c7f7b5fa0aa9cbbc0571c1d51268eb Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Wed, 17 Aug 2016 11:53:08 +0300
Subject: [PATCH 1/4] remove row builder
---
.../RowBuilderCellsController.swift | 42 --------------
.../Storyboards/LaunchScreen.storyboard | 2 +-
Demo/Resources/Storyboards/Main.storyboard | 41 +------------
Demo/TableKitDemo.xcodeproj/project.pbxproj | 4 --
Sources/TableRowBuilder.swift | 58 -------------------
TableKit.xcodeproj/project.pbxproj | 4 --
6 files changed, 4 insertions(+), 147 deletions(-)
delete mode 100644 Demo/Classes/Presentation/Controllers/RowBuilderCellsController.swift
delete mode 100644 Sources/TableRowBuilder.swift
diff --git a/Demo/Classes/Presentation/Controllers/RowBuilderCellsController.swift b/Demo/Classes/Presentation/Controllers/RowBuilderCellsController.swift
deleted file mode 100644
index 02ec115..0000000
--- a/Demo/Classes/Presentation/Controllers/RowBuilderCellsController.swift
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// RowBuilderCellsController.swift
-// TableKitDemo
-//
-// Created by Max Sokolov on 18/06/16.
-// Copyright © 2016 Tablet. All rights reserved.
-//
-
-import UIKit
-import TableKit
-
-class RowBuilderCellsController: UIViewController {
-
- @IBOutlet weak var tableView: UITableView! {
- didSet {
- tableDirector = TableDirector(tableView: tableView)
- tableDirector.register(ConfigurableTableViewCell.self)
- }
- }
- var tableDirector: TableDirector!
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- title = "Row builder cells"
-
- let numbers = ["1", "2", "3", "4", "5"]
-
- let clickAction = TableRowAction(.click) { (data) in
-
- print(data.item)
- }
-
- let rowBuilder = TableRowBuilder(items: numbers, actions: [clickAction])
-
- let section = TableSection(headerTitle: "Header title", footerTitle: "Footer title")
-
- section.append(builder: rowBuilder)
-
- tableDirector.append(section: section)
- }
-}
\ No newline at end of file
diff --git a/Demo/Resources/Storyboards/LaunchScreen.storyboard b/Demo/Resources/Storyboards/LaunchScreen.storyboard
index f4fc7f7..d995c7c 100644
--- a/Demo/Resources/Storyboards/LaunchScreen.storyboard
+++ b/Demo/Resources/Storyboards/LaunchScreen.storyboard
@@ -1,5 +1,5 @@
-
+
diff --git a/Demo/Resources/Storyboards/Main.storyboard b/Demo/Resources/Storyboards/Main.storyboard
index 2aeae2e..620edcb 100644
--- a/Demo/Resources/Storyboards/Main.storyboard
+++ b/Demo/Resources/Storyboards/Main.storyboard
@@ -1,5 +1,5 @@
-
+
@@ -43,7 +43,7 @@
-
+
@@ -139,7 +139,6 @@
-
@@ -147,40 +146,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -197,7 +162,7 @@
-
+
diff --git a/Demo/TableKitDemo.xcodeproj/project.pbxproj b/Demo/TableKitDemo.xcodeproj/project.pbxproj
index 0de8bcb..c230c79 100644
--- a/Demo/TableKitDemo.xcodeproj/project.pbxproj
+++ b/Demo/TableKitDemo.xcodeproj/project.pbxproj
@@ -10,7 +10,6 @@
DA08A0531CF4E9B500BBF1F8 /* AutolayoutTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA08A0521CF4E9B500BBF1F8 /* AutolayoutTableViewCell.swift */; };
DA55465D1D1569CC00AA83EE /* AutolayoutCellsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55465C1D1569CC00AA83EE /* AutolayoutCellsController.swift */; };
DA5546601D156A4F00AA83EE /* ConfigurableTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA55465F1D156A4F00AA83EE /* ConfigurableTableViewCell.swift */; };
- DA5546621D1573D300AA83EE /* RowBuilderCellsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5546611D1573D300AA83EE /* RowBuilderCellsController.swift */; };
DA5546641D15762000AA83EE /* NibTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5546631D15762000AA83EE /* NibTableViewCell.swift */; };
DA5546661D15765900AA83EE /* NibTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DA5546651D15765900AA83EE /* NibTableViewCell.xib */; };
DA5546681D15771D00AA83EE /* NibCellsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5546671D15771D00AA83EE /* NibCellsController.swift */; };
@@ -65,7 +64,6 @@
DA08A0521CF4E9B500BBF1F8 /* AutolayoutTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutolayoutTableViewCell.swift; sourceTree = ""; };
DA55465C1D1569CC00AA83EE /* AutolayoutCellsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutolayoutCellsController.swift; sourceTree = ""; };
DA55465F1D156A4F00AA83EE /* ConfigurableTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConfigurableTableViewCell.swift; sourceTree = ""; };
- DA5546611D1573D300AA83EE /* RowBuilderCellsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowBuilderCellsController.swift; sourceTree = ""; };
DA5546631D15762000AA83EE /* NibTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NibTableViewCell.swift; sourceTree = ""; };
DA5546651D15765900AA83EE /* NibTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NibTableViewCell.xib; sourceTree = ""; };
DA5546671D15771D00AA83EE /* NibCellsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NibCellsController.swift; sourceTree = ""; };
@@ -184,7 +182,6 @@
children = (
DACB71751CC2D63D00432BD3 /* MainController.swift */,
DA55465C1D1569CC00AA83EE /* AutolayoutCellsController.swift */,
- DA5546611D1573D300AA83EE /* RowBuilderCellsController.swift */,
DA5546671D15771D00AA83EE /* NibCellsController.swift */,
);
path = Controllers;
@@ -300,7 +297,6 @@
buildActionMask = 2147483647;
files = (
DACB71761CC2D63D00432BD3 /* MainController.swift in Sources */,
- DA5546621D1573D300AA83EE /* RowBuilderCellsController.swift in Sources */,
DA55465D1D1569CC00AA83EE /* AutolayoutCellsController.swift in Sources */,
DA5546681D15771D00AA83EE /* NibCellsController.swift in Sources */,
DAC2D5CA1C9D303E009E9C19 /* AppDelegate.swift in Sources */,
diff --git a/Sources/TableRowBuilder.swift b/Sources/TableRowBuilder.swift
deleted file mode 100644
index 23158c2..0000000
--- a/Sources/TableRowBuilder.swift
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 2015 Max Sokolov https://twitter.com/max_sokolov
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy of
-// this software and associated documentation files (the "Software"), to deal in
-// the Software without restriction, including without limitation the rights to
-// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-// the Software, and to permit persons to whom the Software is furnished to do so,
-// subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-import UIKit
-
-public protocol RowBuilder {
-
- func rows() -> [Row]?
-}
-
-public class TableRowBuilder: RowBuilder {
-
- public var items: [ItemType]?
- public var actions: [TableRowAction]?
-
- public init(handler: (TableRowBuilder) -> ()) {
- handler(self)
- }
-
- public init(items: [ItemType], actions: [TableRowAction]? = nil) {
-
- self.items = items
- self.actions = actions
- }
-
- // MARK: - RowBuilder -
-
- public func rows() -> [Row]? {
- return items?.map { TableRow(item: $0, actions: actions) }
- }
-}
-
-public extension TableSection {
-
- public func append(builder builder: RowBuilder) {
-
- if let rows = builder.rows() {
- append(rows: rows)
- }
- }
-}
\ No newline at end of file
diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj
index 9695039..b72ffe3 100644
--- a/TableKit.xcodeproj/project.pbxproj
+++ b/TableKit.xcodeproj/project.pbxproj
@@ -14,7 +14,6 @@
DA9EA7B31D0EC2C90021F650 /* TableDirector.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AA1D0EC2C90021F650 /* TableDirector.swift */; };
DA9EA7B41D0EC2C90021F650 /* TableRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AB1D0EC2C90021F650 /* TableRow.swift */; };
DA9EA7B51D0EC2C90021F650 /* TableRowAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AC1D0EC2C90021F650 /* TableRowAction.swift */; };
- DA9EA7B61D0EC2C90021F650 /* TableRowBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AD1D0EC2C90021F650 /* TableRowBuilder.swift */; };
DA9EA7B71D0EC2C90021F650 /* TableSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7AE1D0EC2C90021F650 /* TableSection.swift */; };
DA9EA7C91D0EC45F0021F650 /* TableKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA9EA7561D0B679A0021F650 /* TableKit.framework */; };
DA9EA7CF1D0EC4930021F650 /* TableKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7BE1D0EC41D0021F650 /* TableKitTests.swift */; };
@@ -39,7 +38,6 @@
DA9EA7AA1D0EC2C90021F650 /* TableDirector.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableDirector.swift; sourceTree = ""; };
DA9EA7AB1D0EC2C90021F650 /* TableRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRow.swift; sourceTree = ""; };
DA9EA7AC1D0EC2C90021F650 /* TableRowAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRowAction.swift; sourceTree = ""; };
- DA9EA7AD1D0EC2C90021F650 /* TableRowBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRowBuilder.swift; sourceTree = ""; };
DA9EA7AE1D0EC2C90021F650 /* TableSection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableSection.swift; sourceTree = ""; };
DA9EA7B91D0EC34E0021F650 /* TableKit.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = TableKit.plist; sourceTree = ""; };
DA9EA7BA1D0EC34E0021F650 /* TableKitTests.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = TableKitTests.plist; sourceTree = ""; };
@@ -90,7 +88,6 @@
children = (
DA9EA7AA1D0EC2C90021F650 /* TableDirector.swift */,
DA9EA7AB1D0EC2C90021F650 /* TableRow.swift */,
- DA9EA7AD1D0EC2C90021F650 /* TableRowBuilder.swift */,
DA9EA7AC1D0EC2C90021F650 /* TableRowAction.swift */,
DA9EA7AE1D0EC2C90021F650 /* TableSection.swift */,
DA9EA7A91D0EC2C90021F650 /* TableCellAction.swift */,
@@ -233,7 +230,6 @@
DA9EA7B21D0EC2C90021F650 /* TableCellAction.swift in Sources */,
DA9EA7B11D0EC2C90021F650 /* Operators.swift in Sources */,
DA9EA7B41D0EC2C90021F650 /* TableRow.swift in Sources */,
- DA9EA7B61D0EC2C90021F650 /* TableRowBuilder.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
From 2e8b3f3232afe49bde5f3be7174374a9609144e8 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Wed, 17 Aug 2016 12:02:00 +0300
Subject: [PATCH 2/4] implement custom cell height action
---
Demo/Classes/Presentation/Controllers/MainController.swift | 3 ---
.../Classes/Presentation/Controllers/NibCellsController.swift | 2 +-
Sources/TableDirector.swift | 4 +++-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/Demo/Classes/Presentation/Controllers/MainController.swift b/Demo/Classes/Presentation/Controllers/MainController.swift
index 251ab9e..5a286a1 100644
--- a/Demo/Classes/Presentation/Controllers/MainController.swift
+++ b/Demo/Classes/Presentation/Controllers/MainController.swift
@@ -30,8 +30,6 @@ class MainController: UIViewController {
case 0:
self?.performSegueWithIdentifier("autolayoutcells", sender: nil)
case 1:
- self?.performSegueWithIdentifier("rowbuildercells", sender: nil)
- case 2:
self?.performSegueWithIdentifier("nibcells", sender: nil)
default:
break
@@ -41,7 +39,6 @@ class MainController: UIViewController {
let rows: [Row] = [
TableRow(item: "Autolayout cells", actions: [clickAction]),
- TableRow(item: "Row builder cells", actions: [clickAction]),
TableRow(item: "Nib cells", actions: [clickAction])
]
diff --git a/Demo/Classes/Presentation/Controllers/NibCellsController.swift b/Demo/Classes/Presentation/Controllers/NibCellsController.swift
index 15a6cce..c6d69f5 100644
--- a/Demo/Classes/Presentation/Controllers/NibCellsController.swift
+++ b/Demo/Classes/Presentation/Controllers/NibCellsController.swift
@@ -26,7 +26,7 @@ class NibCellsController: UITableViewController {
let shouldHighlightAction = TableRowAction(.shouldHighlight) { (_) -> Bool in
return false
}
-
+
let rows: [Row] = numbers.map { TableRow(item: $0, actions: [shouldHighlightAction]) }
tableDirector.append(rows: rows)
diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift
index 2ad6581..710c77a 100644
--- a/Sources/TableDirector.swift
+++ b/Sources/TableDirector.swift
@@ -119,7 +119,9 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let row = sections[indexPath.section].items[indexPath.row]
- return heightStrategy?.height(row, path: indexPath) ?? row.defaultHeight
+ let rowHeight = invoke(action: .height, cell: nil, indexPath: indexPath) as? CGFloat
+
+ return rowHeight ?? heightStrategy?.height(row, path: indexPath) ?? row.defaultHeight
}
// MARK: UITableViewDataSource - configuration
From 26192a89b8f22295b0da35a2d6f7957cf06ac734 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Wed, 17 Aug 2016 12:07:12 +0300
Subject: [PATCH 3/4] bump readme
---
README.md | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/README.md b/README.md
index c6c3639..60a5329 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
@@ -91,25 +91,6 @@ let row = TableRow(item: "some")
```
You could find all available actions [here](Sources/TableRowAction.swift).
-#### Batch rows
-You could have a situation when you need a lot of cells with the same type. In that case it's better to use `TableRowBuilder`:
-```swift
-let builder = TableRowBuilder {
-
- // do some additional setup here
- $0.items = ["1", "2", "3"]
- $0.actions = [action]
-}
-
-section.append(builder: builder)
-```
-Or if you don't need an additional setup for your data, just use standart init:
-```swift
-let builder = TableRowBuilder(items: ["1", "2", "3"], actions: [actions])
-
-section.append(builder: builder)
-```
-
## Advanced
#### Cell height calculating strategy
From 663111500ffcf2df58beff3d3702624fbc1dc80c Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Wed, 17 Aug 2016 12:08:12 +0300
Subject: [PATCH 4/4] bump podspec
---
TableKit.podspec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/TableKit.podspec b/TableKit.podspec
index d1c04c4..6835141 100644
--- a/TableKit.podspec
+++ b/TableKit.podspec
@@ -2,7 +2,7 @@ Pod::Spec.new do |s|
s.name = 'TableKit'
s.module_name = 'TableKit'
- s.version = '0.8.2'
+ s.version = '0.9.0'
s.homepage = 'https://github.com/maxsokolov/TableKit'
s.summary = 'Type-safe declarative table views. Swift 2.2 is required.'