From 279fdd4854f261cff83296119e4e27140934c2f5 Mon Sep 17 00:00:00 2001
From: Ivan Zinovyev
Date: Sun, 22 Apr 2018 01:50:04 +0300
Subject: [PATCH 01/15] Add height for item
---
Sources/ConfigurableCell.swift | 2 ++
Sources/TableKit.swift | 2 ++
Sources/TableRow.swift | 5 +++++
3 files changed, 9 insertions(+)
diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift
index cc96430..4cc3161 100644
--- a/Sources/ConfigurableCell.swift
+++ b/Sources/ConfigurableCell.swift
@@ -29,6 +29,8 @@ public protocol ConfigurableCell {
static var defaultHeight: CGFloat? { get }
func configure(with _: T)
+ func height(for _: T) -> CGFloat
+
}
public extension ConfigurableCell where Self: UITableViewCell {
diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift
index c2b10c9..f0cb0ff 100644
--- a/Sources/TableKit.swift
+++ b/Sources/TableKit.swift
@@ -31,6 +31,8 @@ public struct TableKitUserInfoKeys {
public protocol RowConfigurable {
func configure(_ cell: UITableViewCell)
+ func height(for _: UITableViewCell) -> CGFloat
+
}
public protocol RowActionable {
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index edfca6e..5819bc7 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -60,6 +60,11 @@ open class TableRow: Row where CellType: UITableView
(cell as? CellType)?.configure(with: item)
}
+ open func height(for cell: UITableViewCell) -> CGFloat {
+
+ return (cell as? CellType)?.height(for: item) ?? UITableViewAutomaticDimension
+ }
+
// MARK: - RowActionable -
open func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]? = nil) -> Any? {
From b62dea8702e2ad789e9106b31f1a9652eb7cf732 Mon Sep 17 00:00:00 2001
From: Ivan Zinovyev
Date: Sun, 22 Apr 2018 01:59:58 +0300
Subject: [PATCH 02/15] Add default implementation for height(for:)
---
Sources/ConfigurableCell.swift | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift
index 4cc3161..dfb0ce1 100644
--- a/Sources/ConfigurableCell.swift
+++ b/Sources/ConfigurableCell.swift
@@ -33,6 +33,14 @@ public protocol ConfigurableCell {
}
+public extension ConfigurableCell {
+
+ func height(for _: T) -> CGFloat {
+ return UITableViewAutomaticDimension
+ }
+
+}
+
public extension ConfigurableCell where Self: UITableViewCell {
static var reuseIdentifier: String {
From cc02531b27ce26bad9842f28a39839b7c1a500e2 Mon Sep 17 00:00:00 2001
From: into
Date: Tue, 8 May 2018 13:24:52 +0200
Subject: [PATCH 03/15] added: canDelete, editingStyle
---
Sources/TableDirector.swift | 14 ++++++++++----
Sources/TableKit.swift | 1 +
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift
index 548eafb..9088f45 100644
--- a/Sources/TableDirector.swift
+++ b/Sources/TableDirector.swift
@@ -257,7 +257,6 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
// MARK: UITableViewDelegate - actions
open func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-
let cell = tableView.cellForRow(at: indexPath)
if invoke(action: .click, cell: cell, indexPath: indexPath) != nil {
@@ -284,10 +283,10 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
}
open func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
-
if hasAction(.willSelect, atIndexPath: indexPath) {
return invoke(action: .willSelect, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? IndexPath
}
+
return indexPath
}
@@ -300,15 +299,22 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
return sections[indexPath.section].rows[indexPath.row].editingActions
}
- open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
+ open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
+ if invoke(action: .canDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? false {
+ return UITableViewCellEditingStyle.delete
+ }
+ return UITableViewCellEditingStyle.none
+ }
+
+ open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
invoke(action: .clickDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath)
}
}
open func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
- return invoke(action: .canMove, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? true
+ return invoke(action: .canMove, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? false
}
open func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift
index c2b10c9..f5f17ef 100644
--- a/Sources/TableKit.swift
+++ b/Sources/TableKit.swift
@@ -74,6 +74,7 @@ public enum TableRowActionType {
case height
case canEdit
case configure
+ case canDelete
case canMove
case move
case custom(String)
From 21aab6256f51b5192e6b8ccade4171990e0d9f3e Mon Sep 17 00:00:00 2001
From: into
Date: Tue, 8 May 2018 16:54:13 +0200
Subject: [PATCH 04/15] added: canMoveTo
---
Sources/TableDirector.swift | 8 ++++++++
Sources/TableKit.swift | 2 ++
2 files changed, 10 insertions(+)
diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift
index 9088f45..132a411 100644
--- a/Sources/TableDirector.swift
+++ b/Sources/TableDirector.swift
@@ -307,6 +307,14 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
return UITableViewCellEditingStyle.none
}
+ public func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
+ return false
+ }
+
+ public func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath {
+ return invoke(action: .canMoveTo, cell: tableView.cellForRow(at: sourceIndexPath), indexPath: sourceIndexPath, userInfo: [TableKitUserInfoKeys.CellCanMoveProposedIndexPath: proposedDestinationIndexPath]) as? IndexPath ?? proposedDestinationIndexPath
+ }
+
open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
invoke(action: .clickDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath)
diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift
index f5f17ef..5d554d5 100644
--- a/Sources/TableKit.swift
+++ b/Sources/TableKit.swift
@@ -26,6 +26,7 @@ struct TableKitNotifications {
public struct TableKitUserInfoKeys {
public static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath"
+ public static let CellCanMoveProposedIndexPath = "CellCanMoveProposedIndexPath"
}
public protocol RowConfigurable {
@@ -76,6 +77,7 @@ public enum TableRowActionType {
case configure
case canDelete
case canMove
+ case canMoveTo
case move
case custom(String)
From 1d28233ebeaa2c2b3afe1d9ea37d251dafd9ff35 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Tue, 26 Jun 2018 22:37:40 +0300
Subject: [PATCH 05/15] meaningful associatedtype name for ConfigurableCell
---
README.md | 2 +-
Sources/ConfigurableCell.swift | 4 ++--
Sources/TableRow.swift | 4 ++--
Sources/TableRowAction.swift | 6 +++---
TableKit.podspec | 2 +-
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 4e10a91..663a157 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift
index cc96430..349a401 100644
--- a/Sources/ConfigurableCell.swift
+++ b/Sources/ConfigurableCell.swift
@@ -22,13 +22,13 @@ import UIKit
public protocol ConfigurableCell {
- associatedtype T
+ associatedtype CellData
static var reuseIdentifier: String { get }
static var estimatedHeight: CGFloat? { get }
static var defaultHeight: CGFloat? { get }
- func configure(with _: T)
+ func configure(with _: CellData)
}
public extension ConfigurableCell where Self: UITableViewCell {
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index edfca6e..57957e7 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -22,7 +22,7 @@ import UIKit
open class TableRow: Row where CellType: UITableViewCell {
- open let item: CellType.T
+ open let item: CellType.CellData
private lazy var actions = [String: [TableRowAction]]()
private(set) open var editingActions: [UITableViewRowAction]?
@@ -46,7 +46,7 @@ open class TableRow: Row where CellType: UITableView
return CellType.self
}
- public init(item: CellType.T, actions: [TableRowAction]? = nil, editingActions: [UITableViewRowAction]? = nil) {
+ public init(item: CellType.CellData, actions: [TableRowAction]? = nil, editingActions: [UITableViewRowAction]? = nil) {
self.item = item
self.editingActions = editingActions
diff --git a/Sources/TableRowAction.swift b/Sources/TableRowAction.swift
index 73c7419..8156466 100644
--- a/Sources/TableRowAction.swift
+++ b/Sources/TableRowAction.swift
@@ -22,12 +22,12 @@ import UIKit
open class TableRowActionOptions where CellType: UITableViewCell {
- open let item: CellType.T
+ open let item: CellType.CellData
open let cell: CellType?
open let indexPath: IndexPath
open let userInfo: [AnyHashable: Any]?
- init(item: CellType.T, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) {
+ init(item: CellType.CellData, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) {
self.item = item
self.cell = cell
@@ -76,7 +76,7 @@ open class TableRowAction where CellType: UITableVie
self.handler = .action(handler)
}
- public func invokeActionOn(cell: UITableViewCell?, item: CellType.T, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any? {
+ public func invokeActionOn(cell: UITableViewCell?, item: CellType.CellData, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any? {
return handler.invoke(withOptions: TableRowActionOptions(item: item, cell: cell as? CellType, path: path, userInfo: userInfo))
}
diff --git a/TableKit.podspec b/TableKit.podspec
index 3e2852e..a6c3ab9 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 = '2.6.0'
+ s.version = '2.7.0'
s.homepage = 'https://github.com/maxsokolov/TableKit'
s.summary = 'Type-safe declarative table views with Swift.'
From 12883a33de3df78cb6e3dc99d351f83a6d30d874 Mon Sep 17 00:00:00 2001
From: Ivan Smolin
Date: Wed, 19 Sep 2018 12:01:11 +0300
Subject: [PATCH 06/15] update project to recommended settings
---
TableKit.xcodeproj/project.pbxproj | 6 +++++-
.../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++
.../xcshareddata/xcschemes/TableKit.xcscheme | 4 +---
3 files changed, 14 insertions(+), 4 deletions(-)
create mode 100644 TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj
index 6212938..e06e325 100644
--- a/TableKit.xcodeproj/project.pbxproj
+++ b/TableKit.xcodeproj/project.pbxproj
@@ -177,7 +177,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
- LastUpgradeCheck = 0900;
+ LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "Max Sokolov";
TargetAttributes = {
DA9EA7551D0B679A0021F650 = {
@@ -275,12 +275,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -333,12 +335,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
diff --git a/TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/TableKit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme b/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme
index 9016615..d3c3b98 100644
--- a/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme
+++ b/TableKit.xcodeproj/xcshareddata/xcschemes/TableKit.xcscheme
@@ -1,6 +1,6 @@
Date: Wed, 19 Sep 2018 12:03:51 +0300
Subject: [PATCH 07/15] perform automatic migration with warning suggestions
---
Sources/TableCellAction.swift | 6 +++---
Sources/TableDirector.swift | 16 ++++++++--------
Sources/TablePrototypeCellHeightCalculator.swift | 4 ++--
Sources/TableRow.swift | 4 ++--
Sources/TableRowAction.swift | 10 +++++-----
TableKit.xcodeproj/project.pbxproj | 12 ++++++------
6 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/Sources/TableCellAction.swift b/Sources/TableCellAction.swift
index b962dab..b3ea0ba 100644
--- a/Sources/TableCellAction.swift
+++ b/Sources/TableCellAction.swift
@@ -27,13 +27,13 @@ import UIKit
open class TableCellAction {
/// The cell that triggers an action.
- open let cell: UITableViewCell
+ public let cell: UITableViewCell
/// The action unique key.
- open let key: String
+ public let key: String
/// The custom user info.
- open let userInfo: [AnyHashable: Any]?
+ public let userInfo: [AnyHashable: Any]?
public init(key: String, sender: UITableViewCell, userInfo: [AnyHashable: Any]? = nil) {
diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift
index 132a411..c17ce2c 100644
--- a/Sources/TableDirector.swift
+++ b/Sources/TableDirector.swift
@@ -147,7 +147,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
return row.defaultHeight
?? row.estimatedHeight
?? rowHeightCalculator?.estimatedHeight(forRow: row, at: indexPath)
- ?? UITableViewAutomaticDimension
+ ?? UITableView.automaticDimension
}
open func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
@@ -163,7 +163,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
return rowHeight
?? row.defaultHeight
?? rowHeightCalculator?.height(forRow: row, at: indexPath)
- ?? UITableViewAutomaticDimension
+ ?? UITableView.automaticDimension
}
// MARK: UITableViewDataSource - configuration
@@ -215,7 +215,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
open func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
let section = sections[section]
- return section.headerHeight ?? section.headerView?.frame.size.height ?? UITableViewAutomaticDimension
+ return section.headerHeight ?? section.headerView?.frame.size.height ?? UITableView.automaticDimension
}
open func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
@@ -223,7 +223,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
let section = sections[section]
return section.footerHeight
?? section.footerView?.frame.size.height
- ?? UITableViewAutomaticDimension
+ ?? UITableView.automaticDimension
}
// MARK: UITableViewDataSource - Index
@@ -299,12 +299,12 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
return sections[indexPath.section].rows[indexPath.row].editingActions
}
- open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
+ open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
if invoke(action: .canDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? false {
- return UITableViewCellEditingStyle.delete
+ return UITableViewCell.EditingStyle.delete
}
- return UITableViewCellEditingStyle.none
+ return UITableViewCell.EditingStyle.none
}
public func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool {
@@ -315,7 +315,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
return invoke(action: .canMoveTo, cell: tableView.cellForRow(at: sourceIndexPath), indexPath: sourceIndexPath, userInfo: [TableKitUserInfoKeys.CellCanMoveProposedIndexPath: proposedDestinationIndexPath]) as? IndexPath ?? proposedDestinationIndexPath
}
- open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
+ open func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
invoke(action: .clickDelete, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath)
}
diff --git a/Sources/TablePrototypeCellHeightCalculator.swift b/Sources/TablePrototypeCellHeightCalculator.swift
index 462d7a7..aa6341d 100644
--- a/Sources/TablePrototypeCellHeightCalculator.swift
+++ b/Sources/TablePrototypeCellHeightCalculator.swift
@@ -57,7 +57,7 @@ open class TablePrototypeCellHeightCalculator: RowHeightCalculator {
cell.setNeedsLayout()
cell.layoutIfNeeded()
- let height = cell.contentView.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height + (tableView.separatorStyle != .none ? separatorHeight : 0)
+ let height = cell.contentView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height + (tableView.separatorStyle != .none ? separatorHeight : 0)
cachedHeights[hash] = height
@@ -78,7 +78,7 @@ open class TablePrototypeCellHeightCalculator: RowHeightCalculator {
return estimatedHeight
}
- return UITableViewAutomaticDimension
+ return UITableView.automaticDimension
}
open func invalidate() {
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index 57957e7..411f5aa 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -22,7 +22,7 @@ import UIKit
open class TableRow: Row where CellType: UITableViewCell {
- open let item: CellType.CellData
+ public let item: CellType.CellData
private lazy var actions = [String: [TableRowAction]]()
private(set) open var editingActions: [UITableViewRowAction]?
@@ -64,7 +64,7 @@ open class TableRow: Row where CellType: UITableView
open func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]? = nil) -> Any? {
- return actions[action.key]?.flatMap({ $0.invokeActionOn(cell: cell, item: item, path: path, userInfo: userInfo) }).last
+ return actions[action.key]?.compactMap({ $0.invokeActionOn(cell: cell, item: item, path: path, userInfo: userInfo) }).last
}
open func has(action: TableRowActionType) -> Bool {
diff --git a/Sources/TableRowAction.swift b/Sources/TableRowAction.swift
index 8156466..bee3d7a 100644
--- a/Sources/TableRowAction.swift
+++ b/Sources/TableRowAction.swift
@@ -22,10 +22,10 @@ import UIKit
open class TableRowActionOptions where CellType: UITableViewCell {
- open let item: CellType.CellData
- open let cell: CellType?
- open let indexPath: IndexPath
- open let userInfo: [AnyHashable: Any]?
+ public let item: CellType.CellData
+ public let cell: CellType?
+ public let indexPath: IndexPath
+ public let userInfo: [AnyHashable: Any]?
init(item: CellType.CellData, cell: CellType?, path: IndexPath, userInfo: [AnyHashable: Any]?) {
@@ -55,7 +55,7 @@ private enum TableRowActionHandler where CellType: U
open class TableRowAction where CellType: UITableViewCell {
open var id: String?
- open let type: TableRowActionType
+ public let type: TableRowActionType
private let handler: TableRowActionHandler
public init(_ type: TableRowActionType, handler: @escaping (_ options: TableRowActionOptions) -> Void) {
diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj
index e06e325..9afc02f 100644
--- a/TableKit.xcodeproj/project.pbxproj
+++ b/TableKit.xcodeproj/project.pbxproj
@@ -182,11 +182,11 @@
TargetAttributes = {
DA9EA7551D0B679A0021F650 = {
CreatedOnToolsVersion = 7.3;
- LastSwiftMigration = 0800;
+ LastSwiftMigration = 1000;
};
DA9EA7C31D0EC45F0021F650 = {
CreatedOnToolsVersion = 7.3;
- LastSwiftMigration = 0800;
+ LastSwiftMigration = 1000;
};
};
};
@@ -393,7 +393,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -413,7 +413,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Release;
};
@@ -425,7 +425,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -437,7 +437,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Release;
};
From ce243695571b79c6e337d12d8083963c0e357325 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sun, 30 Sep 2018 12:35:48 +0300
Subject: [PATCH 08/15] bump to swift 4.2, support xcode10
---
.swift-version | 2 +-
.travis.yml | 2 +-
.../Controllers/AutolayoutCellsController.swift | 2 +-
Demo/TableKitDemo.xcodeproj/project.pbxproj | 12 ++++++++----
.../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++
README.md | 6 +++---
TableKit.podspec | 2 +-
7 files changed, 23 insertions(+), 11 deletions(-)
create mode 100644 Demo/TableKitDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
diff --git a/.swift-version b/.swift-version
index 389f774..8012ebb 100644
--- a/.swift-version
+++ b/.swift-version
@@ -1 +1 @@
-4.0
\ No newline at end of file
+4.2
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 09c53af..b1416f2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
language: objective-c
-osx_image: xcode9
+osx_image: xcode10
branches:
only:
- master
diff --git a/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift b/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift
index 73c99ca..2ce3741 100644
--- a/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift
+++ b/Demo/Classes/Presentation/Controllers/AutolayoutCellsController.swift
@@ -65,6 +65,6 @@ class AutolayoutCellsController: UIViewController {
view.setNeedsLayout()
view.layoutIfNeeded()
- return view.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height
+ return view.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height
}
}
diff --git a/Demo/TableKitDemo.xcodeproj/project.pbxproj b/Demo/TableKitDemo.xcodeproj/project.pbxproj
index 21f4909..17885b9 100644
--- a/Demo/TableKitDemo.xcodeproj/project.pbxproj
+++ b/Demo/TableKitDemo.xcodeproj/project.pbxproj
@@ -233,13 +233,13 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
- LastUpgradeCheck = 0900;
+ LastUpgradeCheck = 1000;
ORGANIZATIONNAME = Tablet;
TargetAttributes = {
DAB7EB261BEF787300D2AD5E = {
CreatedOnToolsVersion = 7.0.1;
DevelopmentTeam = Z48R734SJX;
- LastSwiftMigration = 0800;
+ LastSwiftMigration = 1000;
};
};
};
@@ -338,12 +338,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -391,12 +393,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -439,7 +443,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.demo;
PRODUCT_NAME = TableKitDemo;
PROVISIONING_PROFILE = "";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -456,7 +460,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.demo;
PRODUCT_NAME = TableKitDemo;
PROVISIONING_PROFILE = "";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Release;
};
diff --git a/Demo/TableKitDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Demo/TableKitDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Demo/TableKitDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/README.md b/README.md
index 663a157..c13a629 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
-
+
-
+
@@ -237,7 +237,7 @@ Clone the repo and drag files from `Sources` folder into your Xcode project.
# Changelog
-Keep eye on [changes](CHANGELOG.md).
+Keep an eye on [changes](CHANGELOG.md).
# License
diff --git a/TableKit.podspec b/TableKit.podspec
index a6c3ab9..5d90f09 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 = '2.7.0'
+ s.version = '2.8.0'
s.homepage = 'https://github.com/maxsokolov/TableKit'
s.summary = 'Type-safe declarative table views with Swift.'
From 0c87f3ee88eb0ea684f3256b80c4615c7783c151 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sun, 30 Sep 2018 12:37:38 +0300
Subject: [PATCH 09/15] update changelog
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ad1533a..ebb1a04 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
+## [2.8.0](https://github.com/maxsokolov/TableKit/releases/tag/2.8.0)
+Released on 2018-09-30.
+- Swift 4.2 support.
+
## [2.5.0](https://github.com/maxsokolov/TableKit/releases/tag/2.5.0)
Released on 2017-09-24.
- Swift 4.0 support.
From b379ac62724d0967ed13dedb88863405a95f6465 Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sun, 30 Sep 2018 12:42:46 +0300
Subject: [PATCH 10/15] fix travis ci
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index b1416f2..22e199e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,7 @@ env:
global:
- LC_CTYPE=en_US.UTF-8
- LANG=en_US.UTF-8
- - IOS_SDK=iphonesimulator11.0
+ - IOS_SDK=iphonesimulator12.0
- SCHEME_IOS="TableKit"
- PROJECT_FRAMEWORK="TableKit.xcodeproj"
From f16a5a29c9ebc751d0ecd284a119fe4fb13ccaee Mon Sep 17 00:00:00 2001
From: Max Sokolov
Date: Sun, 30 Sep 2018 12:49:21 +0300
Subject: [PATCH 11/15] fix travis ci
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 22e199e..228c26b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,7 +17,7 @@ env:
- DESTINATION="OS=9.2,name=iPhone 6S" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK"
- DESTINATION="OS=9.3,name=iPhone 6S Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK"
- DESTINATION="OS=10.0,name=iPhone 5" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK"
- - DESTINATION="OS=10.0,name=iPhone 7 Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK"
+ - DESTINATION="OS=12.0,name=iPhone 7 Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK"
script:
- set -o pipefail
From 741627107688f100526d01e00991caf01b928883 Mon Sep 17 00:00:00 2001
From: Ivan Zinovyev
Date: Sun, 4 Nov 2018 08:18:06 +0300
Subject: [PATCH 12/15] Fix type
---
Sources/ConfigurableCell.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift
index 48748b5..5dd0152 100644
--- a/Sources/ConfigurableCell.swift
+++ b/Sources/ConfigurableCell.swift
@@ -35,7 +35,7 @@ public protocol ConfigurableCell {
public extension ConfigurableCell {
- func height(for _: T) -> CGFloat {
+ func height(for _: CellData) -> CGFloat {
return UITableViewAutomaticDimension
}
From 1c92c14a1a7bb30ee8e44b88d5d3760888e3f87b Mon Sep 17 00:00:00 2001
From: Ivan Zinovyev
Date: Sun, 4 Nov 2018 08:20:28 +0300
Subject: [PATCH 13/15] Fix for new swift
---
Sources/ConfigurableCell.swift | 2 +-
Sources/TableRow.swift | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Sources/ConfigurableCell.swift b/Sources/ConfigurableCell.swift
index 5dd0152..dee4db2 100644
--- a/Sources/ConfigurableCell.swift
+++ b/Sources/ConfigurableCell.swift
@@ -36,7 +36,7 @@ public protocol ConfigurableCell {
public extension ConfigurableCell {
func height(for _: CellData) -> CGFloat {
- return UITableViewAutomaticDimension
+ return UITableView.automaticDimension
}
}
diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift
index d2d3bd3..1c5eef0 100644
--- a/Sources/TableRow.swift
+++ b/Sources/TableRow.swift
@@ -62,7 +62,7 @@ open class TableRow: Row where CellType: UITableView
open func height(for cell: UITableViewCell) -> CGFloat {
- return (cell as? CellType)?.height(for: item) ?? UITableViewAutomaticDimension
+ return (cell as? CellType)?.height(for: item) ?? UITableView.automaticDimension
}
// MARK: - RowActionable -
From 86f07b8e7c61e2433fbec1945330d288d265109d Mon Sep 17 00:00:00 2001
From: Ivan Zinovyev
Date: Sun, 4 Nov 2018 08:28:50 +0300
Subject: [PATCH 14/15] Add AccurateCellHeightCalculator
---
Sources/AccurateCellHeightCalculator.swift | 45 ++++++++++++++++++++++
TableKit.xcodeproj/project.pbxproj | 4 ++
2 files changed, 49 insertions(+)
create mode 100644 Sources/AccurateCellHeightCalculator.swift
diff --git a/Sources/AccurateCellHeightCalculator.swift b/Sources/AccurateCellHeightCalculator.swift
new file mode 100644
index 0000000..e266790
--- /dev/null
+++ b/Sources/AccurateCellHeightCalculator.swift
@@ -0,0 +1,45 @@
+import UIKit
+
+class AccurateCellHeightCalculator: RowHeightCalculator {
+
+ private(set) weak var tableView: UITableView?
+ private var prototypes = [String: UITableViewCell]()
+ private var cachedHeights = [Int: CGFloat]()
+
+ public init(tableView: UITableView?) {
+ self.tableView = tableView
+ }
+
+ open func height(forRow row: Row, at indexPath: IndexPath) -> CGFloat {
+
+ guard let tableView = tableView else { return 0 }
+
+ let hash = row.hashValue ^ Int(tableView.bounds.size.width).hashValue
+
+ if let height = cachedHeights[hash] {
+ return height
+ }
+
+ var prototypeCell = prototypes[row.reuseIdentifier]
+ if prototypeCell == nil {
+
+ prototypeCell = tableView.dequeueReusableCell(withIdentifier: row.reuseIdentifier)
+ prototypes[row.reuseIdentifier] = prototypeCell
+ }
+
+ guard let cell = prototypeCell else { return 0 }
+ let height = row.height(for: cell)
+
+ cachedHeights[hash] = height
+
+ return height
+ }
+
+ open func estimatedHeight(forRow row: Row, at indexPath: IndexPath) -> CGFloat {
+ return height(forRow: row, at: indexPath)
+ }
+
+ open func invalidate() {
+ cachedHeights.removeAll()
+ }
+}
diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj
index 9afc02f..b30ee04 100644
--- a/TableKit.xcodeproj/project.pbxproj
+++ b/TableKit.xcodeproj/project.pbxproj
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ 320C5280218EB9A7004EAD1C /* AccurateCellHeightCalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 320C527F218EB9A7004EAD1C /* AccurateCellHeightCalculator.swift */; };
50CF6E6B1D6704FE004746FF /* TableCellRegisterer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CF6E6A1D6704FE004746FF /* TableCellRegisterer.swift */; };
50E858581DB153F500A9AA55 /* TableKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E858571DB153F500A9AA55 /* TableKit.swift */; };
DA9EA7AF1D0EC2C90021F650 /* ConfigurableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7A61D0EC2C90021F650 /* ConfigurableCell.swift */; };
@@ -32,6 +33,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
+ 320C527F218EB9A7004EAD1C /* AccurateCellHeightCalculator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccurateCellHeightCalculator.swift; sourceTree = ""; };
50CF6E6A1D6704FE004746FF /* TableCellRegisterer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableCellRegisterer.swift; sourceTree = ""; };
50E858571DB153F500A9AA55 /* TableKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableKit.swift; sourceTree = ""; };
DA9EA7561D0B679A0021F650 /* TableKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TableKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -100,6 +102,7 @@
DA9EA7A71D0EC2C90021F650 /* TablePrototypeCellHeightCalculator.swift */,
DA9EA7A61D0EC2C90021F650 /* ConfigurableCell.swift */,
DA9EA7A81D0EC2C90021F650 /* Operators.swift */,
+ 320C527F218EB9A7004EAD1C /* AccurateCellHeightCalculator.swift */,
);
path = Sources;
sourceTree = "";
@@ -233,6 +236,7 @@
50CF6E6B1D6704FE004746FF /* TableCellRegisterer.swift in Sources */,
DA9EA7AF1D0EC2C90021F650 /* ConfigurableCell.swift in Sources */,
DA9EA7B31D0EC2C90021F650 /* TableDirector.swift in Sources */,
+ 320C5280218EB9A7004EAD1C /* AccurateCellHeightCalculator.swift in Sources */,
DA9EA7B71D0EC2C90021F650 /* TableSection.swift in Sources */,
DA9EA7B01D0EC2C90021F650 /* TablePrototypeCellHeightCalculator.swift in Sources */,
DA9EA7B51D0EC2C90021F650 /* TableRowAction.swift in Sources */,
From 70e6addcd0435eafa7e78307a966f4db7f781df6 Mon Sep 17 00:00:00 2001
From: Ivan Zinovyev
Date: Sun, 4 Nov 2018 08:31:46 +0300
Subject: [PATCH 15/15] Make AccurateCellHeightCalculator public
---
Sources/AccurateCellHeightCalculator.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Sources/AccurateCellHeightCalculator.swift b/Sources/AccurateCellHeightCalculator.swift
index e266790..d4190fb 100644
--- a/Sources/AccurateCellHeightCalculator.swift
+++ b/Sources/AccurateCellHeightCalculator.swift
@@ -1,6 +1,6 @@
import UIKit
-class AccurateCellHeightCalculator: RowHeightCalculator {
+public class AccurateCellHeightCalculator: RowHeightCalculator {
private(set) weak var tableView: UITableView?
private var prototypes = [String: UITableViewCell]()