From 6f441b2f7d763d4d5e58ba352bf91ce97b974be6 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 01:45:39 +0300
Subject: [PATCH 1/8] reduce first generic parameter
---
.../AutolayoutCellsController.swift | 4 ++--
.../Controllers/MainController.swift | 6 ++---
.../Controllers/NibCellsController.swift | 4 ++--
Sources/TableRow.swift | 14 +++++------
Sources/TableRowAction.swift | 24 +++++++++----------
5 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift b/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift
index 9340070..9d9d3ad 100644
--- a/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift
+++ b/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift
@@ -30,10 +30,10 @@ class AutolayoutCellsController: UIViewController {
while rows <= 1000 {
rows += 1
- let row = TableRow(item: ())
+ let row = TableRow(item: ())
section += row
}
tableDirector += section
}
-}
\ No newline at end of file
+}
diff --git a/Demo/Classes/Presentation/Controllers/MainController.swift b/Demo/Classes/Presentation/Controllers/MainController.swift
index dfb92c7..7c0afdd 100644
--- a/Demo/Classes/Presentation/Controllers/MainController.swift
+++ b/Demo/Classes/Presentation/Controllers/MainController.swift
@@ -23,7 +23,7 @@ class MainController: UIViewController {
title = "TableKit"
- let clickAction = TableRowAction(.click) { [weak self] (data) in
+ let clickAction = TableRowAction(.click) { [weak self] (data) in
switch (data.indexPath as NSIndexPath).row {
case 0:
@@ -37,8 +37,8 @@ class MainController: UIViewController {
let rows = [
- TableRow(item: "Autolayout cells", actions: [clickAction]),
- TableRow(item: "Nib cells", actions: [clickAction])
+ TableRow(item: "Autolayout cells", actions: [clickAction]),
+ TableRow(item: "Nib cells", actions: [clickAction])
]
// automatically creates a section, also could be used like tableDirector.append(rows: rows)
diff --git a/Demo/Classes/Presentation/Controllers/NibCellsController.swift b/Demo/Classes/Presentation/Controllers/NibCellsController.swift
index 082af9c..32736a6 100644
--- a/Demo/Classes/Presentation/Controllers/NibCellsController.swift
+++ b/Demo/Classes/Presentation/Controllers/NibCellsController.swift
@@ -22,11 +22,11 @@ class NibCellsController: UITableViewController {
let numbers = [1000, 2000, 3000, 4000, 5000]
- let shouldHighlightAction = TableRowAction(.shouldHighlight) { (_) -> Bool in
+ let shouldHighlightAction = TableRowAction(.shouldHighlight) { (_) -> Bool in
return false
}
- let rows: [Row] = numbers.map { TableRow(item: $0, actions: [shouldHighlightAction]) }
+ let rows = numbers.map { TableRow(item: $0, actions: [shouldHighlightAction]) }
tableDirector.append(rows: rows)
}
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index bc40ec3..6cf3738 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -48,10 +48,10 @@ public protocol Row: RowConfigurable, RowActionable, RowHashable {
var defaultHeight: CGFloat? { get }
}
-open class TableRow: Row where CellType.T == ItemType, CellType: UITableViewCell {
+open class TableRow: Row where CellType: UITableViewCell {
- open let item: ItemType
- private lazy var actions = [String: TableRowAction]()
+ open let item: CellType.T
+ private lazy var actions = [String: TableRowAction]()
private(set) open var editingActions: [UITableViewRowAction]?
open var hashValue: Int {
@@ -74,7 +74,7 @@ open class TableRow: Row where CellType.T
return CellType.self
}
- public init(item: ItemType, actions: [TableRowAction]? = nil, editingActions: [UITableViewRowAction]? = nil) {
+ public init(item: CellType.T, actions: [TableRowAction]? = nil, editingActions: [UITableViewRowAction]? = nil) {
self.item = item
self.editingActions = editingActions
@@ -108,16 +108,16 @@ open class TableRow: Row where CellType.T
// MARK: - actions -
@discardableResult
- open func action(_ action: TableRowAction) -> Self {
+ open func action(_ action: TableRowAction) -> Self {
actions[action.type.key] = action
return self
}
@discardableResult
- open func action(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> T) -> Self {
+ open func action(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> T) -> Self {
- actions[type.key] = TableRowAction(type, handler: handler)
+ actions[type.key] = TableRowAction(type, handler: handler)
return self
}
}
diff --git a/Sources/TableRowAction.swift b/Sources/TableRowAction.swift
index dac4b49..2533b6a 100644
--- a/Sources/TableRowAction.swift
+++ b/Sources/TableRowAction.swift
@@ -45,14 +45,14 @@ public enum TableRowActionType {
}
}
-open class TableRowActionData where CellType.T == ItemType, CellType: UITableViewCell {
+open class TableRowActionData where CellType: UITableViewCell {
- open let item: ItemType
+ open let item: CellType.T
open let cell: CellType?
open let indexPath: IndexPath
open let userInfo: [AnyHashable: Any]?
- init(item: ItemType, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) {
+ init(item: CellType.T, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) {
self.item = item
self.cell = cell
@@ -61,12 +61,12 @@ open class TableRowActionData where CellTy
}
}
-private enum TableRowActionHandler where CellType.T == ItemType, CellType: UITableViewCell {
+private enum TableRowActionHandler where CellType: UITableViewCell {
- case voidAction((TableRowActionData) -> Void)
- case action((TableRowActionData) -> Any?)
+ case voidAction((TableRowActionData) -> Void)
+ case action((TableRowActionData) -> Any?)
- func invoke(item: ItemType, cell: UITableViewCell?, path: IndexPath) -> Any? {
+ func invoke(item: CellType.T, cell: UITableViewCell?, path: IndexPath) -> Any? {
switch self {
case .voidAction(let handler):
@@ -77,24 +77,24 @@ private enum TableRowActionHandler where C
}
}
-open class TableRowAction where CellType.T == ItemType, CellType: UITableViewCell {
+open class TableRowAction where CellType: UITableViewCell {
open let type: TableRowActionType
- private let handler: TableRowActionHandler
+ private let handler: TableRowActionHandler
- public init(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> Void) {
+ public init(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> Void) {
self.type = type
self.handler = .voidAction(handler)
}
- public init(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> T) {
+ public init(_ type: TableRowActionType, handler: @escaping (_ data: TableRowActionData) -> T) {
self.type = type
self.handler = .action(handler)
}
- func invoke(item: ItemType, cell: UITableViewCell?, path: IndexPath) -> Any? {
+ func invoke(item: CellType.T, cell: UITableViewCell?, path: IndexPath) -> Any? {
return handler.invoke(item: item, cell: cell, path: path)
}
}
From 24d3540dd5a90a63a8e028746f9da6ac336d3346 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 01:48:40 +0300
Subject: [PATCH 2/8] fix tests
---
Tests/TableKitTests.swift | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Tests/TableKitTests.swift b/Tests/TableKitTests.swift
index a2cded4..014cf4d 100644
--- a/Tests/TableKitTests.swift
+++ b/Tests/TableKitTests.swift
@@ -94,7 +94,7 @@ class TabletTests: XCTestCase {
let data = TestData(title: "title")
- let row = TableRow(item: data)
+ let row = TableRow(item: data)
testController.tableDirector += row
testController.tableView.reloadData()
@@ -111,7 +111,7 @@ class TabletTests: XCTestCase {
let data = [TestData(title: "1"), TestData(title: "2"), TestData(title: "3")]
- let rows: [Row] = data.map({ TableRow(item: $0) })
+ let rows: [Row] = data.map({ TableRow(item: $0) })
testController.tableDirector += rows
testController.tableView.reloadData()
@@ -129,7 +129,7 @@ class TabletTests: XCTestCase {
func testTableSectionCreatesSectionWithHeaderAndFooterTitles() {
- let row = TableRow(item: TestData(title: "title"))
+ let row = TableRow(item: TestData(title: "title"))
let sectionHeaderTitle = "Header Title"
let sectionFooterTitle = "Footer Title"
@@ -148,7 +148,7 @@ class TabletTests: XCTestCase {
func testTableSectionCreatesSectionWithHeaderAndFooterViews() {
- let row = TableRow(item: TestData(title: "title"))
+ let row = TableRow(item: TestData(title: "title"))
let sectionHeaderView = UIView()
let sectionFooterView = UIView()
@@ -170,7 +170,7 @@ class TabletTests: XCTestCase {
let expectation = self.expectation(description: "cell action")
- let row = TableRow(item: TestData(title: "title"))
+ let row = TableRow(item: TestData(title: "title"))
.action(TableRowAction(.custom(TestTableViewCellOptions.CellAction)) { (data) in
XCTAssertNotNil(data.cell, "Action data should have a cell")
From 9ba8ef4932d94a8fe561d2c865f7b2e0b0c6ce71 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 01:51:43 +0300
Subject: [PATCH 3/8] bump readme
---
README.md | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index af32809..7542811 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
@@ -36,9 +36,9 @@ Create your rows:
```swift
import TableKit
-let row1 = TableRow(item: "1")
-let row2 = TableRow(item: 2)
-let row3 = TableRow(item: User(name: "John Doe", rating: 5))
+let row1 = TableRow(item: "1")
+let row2 = TableRow(item: 2)
+let row3 = TableRow(item: User(name: "John Doe", rating: 5))
```
Put rows into section:
```swift
@@ -84,20 +84,20 @@ You could have as many rows and sections as you need.
It nice to have some actions that related to your cells:
```swift
-let action = TableRowAction(.click) { (data) in
+let action = TableRowAction(.click) { (data) in
// you could access any useful information that relates to the action
// data.cell - StringTableViewCell?
// data.item - String
- // data.indexPath - NSIndexPath
+ // data.indexPath - IndexPath
}
-let row = TableRow(item: "some", actions: [action])
+let row = TableRow(item: "some", actions: [action])
```
Or, using nice chaining approach:
```swift
-let row = TableRow(item: "some")
+let row = TableRow(item: "some")
.action(.click) { (data) in
}
@@ -126,7 +126,7 @@ class MyTableViewCell: UITableViewCell, ConfigurableCell {
```
And handle them accordingly:
```swift
-let myAction = TableRowAction(.custom(MyActions.ButtonClicked)) { (data) in
+let myAction = TableRowAction(.custom(MyActions.ButtonClicked)) { (data) in
}
```
@@ -173,11 +173,11 @@ It's never been so easy to deal with table views.
```swift
let users = /* some users array */
-let click = TableRowAction(.click) {
+let click = TableRowAction(.click) {
}
-let rows = users.filter({ $0.state == .active }).map({ TableRow(item: $0.name, actions: [click]) })
+let rows = users.filter({ $0.state == .active }).map({ TableRow(item: $0.name, actions: [click]) })
tableDirector += rows
```
From 04e62a8bc0bd730f64a37d1944c934284fb29a09 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 01:54:28 +0300
Subject: [PATCH 4/8] bump podspec
---
TableKit.podspec | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/TableKit.podspec b/TableKit.podspec
index 30cbdea..bf12a0f 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 = '1.3.1'
+ s.version = '1.4.0'
s.homepage = 'https://github.com/maxsokolov/TableKit'
s.summary = 'Type-safe declarative table views with Swift.'
From da98b9892fb8b3e55baf2254d14893f1d3c7ca36 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 02:09:01 +0300
Subject: [PATCH 5/8] add changelog
---
CHANGELOG.md | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..b1c4667
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,27 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+
+## [1.4.0](https://github.com/maxsokolov/TableKit/releases/tag/1.4.0)
+Released on 2016-09-06. Breaking changes in 1.4.0:
+The signatures of `TableRow` and `TableRowAction` classes were changed from
+```swift
+let action = TableRowAction(.click) { (data) in
+}
+
+let row = TableRow(item: "some string", actions: [action])
+```
+to
+```swift
+let action = TableRowAction(.click) { (data) in
+}
+
+let row = TableRow(item: "some string", actions: [action])
+```
+This is the great improvement that comes from the community. Thanks a lot!
+
+## [1.3.0](https://github.com/maxsokolov/TableKit/releases/tag/1.3.0)
+Released on 2016-09-04. Swift 3.0 support.
+
+## [0.1.0](https://github.com/maxsokolov/TableKit/releases/tag/0.1.0)
+Released on 2015-11-15. Initial release called Tablet.
\ No newline at end of file
From 6601b14b7f33f6e30ccf21b2bc60e813cc4ec220 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 02:11:17 +0300
Subject: [PATCH 6/8] bump changelog
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b1c4667..7b32ad5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
## [1.4.0](https://github.com/maxsokolov/TableKit/releases/tag/1.4.0)
Released on 2016-09-06. Breaking changes in 1.4.0:
-The signatures of `TableRow` and `TableRowAction` classes were changed from
+
The signatures of `TableRow` and `TableRowAction` classes were changed from
```swift
let action = TableRowAction(.click) { (data) in
}
From be410f0cc3346985eab50d7b755d8410c206b19e Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 02:14:08 +0300
Subject: [PATCH 7/8] bump readme
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 7542811..304fe11 100644
--- a/README.md
+++ b/README.md
@@ -215,6 +215,10 @@ Clone the repo and drag files from `Sources` folder into your Xcode project.
- iOS 8.0
- Xcode 8.0
+# Changelog
+
+Keep eye on [changes](CHANGELOG.md).
+
# License
TableKit is available under the MIT license. See LICENSE for details.
\ No newline at end of file
From 8de932b1db7a56ebda672d5676cf48edf2474708 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Thu, 6 Oct 2016 11:22:50 +0300
Subject: [PATCH 8/8] bump version
---
CHANGELOG.md | 4 ++--
README.md | 2 +-
TableKit.podspec | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b32ad5..2b60b00 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,8 +2,8 @@
All notable changes to this project will be documented in this file.
-## [1.4.0](https://github.com/maxsokolov/TableKit/releases/tag/1.4.0)
-Released on 2016-09-06. Breaking changes in 1.4.0:
+## [2.0.0](https://github.com/maxsokolov/TableKit/releases/tag/1.4.0)
+Released on 2016-09-06. Breaking changes in 2.0.0:
The signatures of `TableRow` and `TableRowAction` classes were changed from
```swift
let action = TableRowAction(.click) { (data) in
diff --git a/README.md b/README.md
index 304fe11..dfad30d 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
diff --git a/TableKit.podspec b/TableKit.podspec
index bf12a0f..1af280b 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 = '1.4.0'
+ s.version = '2.0.0'
s.homepage = 'https://github.com/maxsokolov/TableKit'
s.summary = 'Type-safe declarative table views with Swift.'