From f5ad500ba46f230875ebaa3b522dd57c67a526b9 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Thu, 4 Apr 2019 23:26:15 +0300 Subject: [PATCH 01/22] support swift 5.0, bump to 2.9.0 --- .swift-version | 2 +- .travis.yml | 2 +- CHANGELOG.md | 4 ++++ Demo/TableKitDemo.xcodeproj/project.pbxproj | 9 +++++---- README.md | 2 +- Sources/TableRow.swift | 2 +- TableKit.podspec | 2 +- TableKit.xcodeproj/project.pbxproj | 13 +++++++------ 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.swift-version b/.swift-version index 8012ebb..6e63660 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2 \ No newline at end of file +5.0 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 228c26b..dfd5f4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10 +osx_image: xcode10.1 branches: only: - master diff --git a/CHANGELOG.md b/CHANGELOG.md index ebb1a04..9bf4ad6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [2.9.0](https://github.com/maxsokolov/TableKit/releases/tag/2.9.0) +Released on 2019-04-04. +- Swift 5.0 support. + ## [2.8.0](https://github.com/maxsokolov/TableKit/releases/tag/2.8.0) Released on 2018-09-30. - Swift 4.2 support. diff --git a/Demo/TableKitDemo.xcodeproj/project.pbxproj b/Demo/TableKitDemo.xcodeproj/project.pbxproj index 17885b9..eef710e 100644 --- a/Demo/TableKitDemo.xcodeproj/project.pbxproj +++ b/Demo/TableKitDemo.xcodeproj/project.pbxproj @@ -248,6 +248,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -377,7 +378,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -425,7 +426,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -443,7 +444,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.demo; PRODUCT_NAME = TableKitDemo; PROVISIONING_PROFILE = ""; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -460,7 +461,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.demo; PRODUCT_NAME = TableKitDemo; PROVISIONING_PROFILE = ""; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/README.md b/README.md index a4583c0..aeb1e11 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

Build Status - Swift 4.2 compatible + Swift 5.0 compatible Carthage compatible CocoaPods compatible Platform iOS diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 411f5aa..b04382d 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -113,7 +113,7 @@ open class TableRow: Row where CellType: UITableView open func removeAction(forActionId actionId: String) { for (key, value) in actions { - if let actionIndex = value.index(where: { $0.id == actionId }) { + if let actionIndex = value.firstIndex(where: { $0.id == actionId }) { actions[key]?.remove(at: actionIndex) } } diff --git a/TableKit.podspec b/TableKit.podspec index 0a92cd7..9c30c24 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.8.1' + s.version = '2.9.0' s.homepage = 'https://github.com/maxsokolov/TableKit' s.summary = 'Type-safe declarative table views with Swift.' diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj index 9afc02f..d20f8ba 100644 --- a/TableKit.xcodeproj/project.pbxproj +++ b/TableKit.xcodeproj/project.pbxproj @@ -195,6 +195,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = DA9EA74C1D0B679A0021F650; @@ -315,7 +316,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -368,7 +369,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -393,7 +394,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -413,7 +414,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKit; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -425,7 +426,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.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -437,7 +438,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.2; + SWIFT_VERSION = 5.0; }; name = Release; }; From 1d4fdaad0d0ca842738aa41b28c28ae3fdd5ac66 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Thu, 4 Apr 2019 23:27:25 +0300 Subject: [PATCH 02/22] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aeb1e11..dabf33b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Build Status Swift 5.0 compatible Carthage compatible - CocoaPods compatible + CocoaPods compatible Platform iOS License: MIT

From 603264a6d1fedf1162f80ba1fab712afc2252f95 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Thu, 4 Apr 2019 23:31:40 +0300 Subject: [PATCH 03/22] fix travis ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dfd5f4c..9812d00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10.1 +osx_image: xcode10.2 branches: only: - master From a4bacd2c16e0edcd53539802cc386f0fe2317eb9 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Thu, 4 Apr 2019 23:40:25 +0300 Subject: [PATCH 04/22] fix travis ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9812d00..4e7d59b 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=iphonesimulator12.0 + - IOS_SDK=iphonesimulator12.2 - SCHEME_IOS="TableKit" - PROJECT_FRAMEWORK="TableKit.xcodeproj" From 337175c507abc79fc9c955de170de3efab4952b5 Mon Sep 17 00:00:00 2001 From: Bogdan Kurpakov Date: Thu, 9 May 2019 11:10:31 +0200 Subject: [PATCH 05/22] added: willDeselect --- Sources/TableDirector.swift | 8 ++++++++ Sources/TableKit.swift | 1 + 2 files changed, 9 insertions(+) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index aa6473b..e6f16c7 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -309,6 +309,14 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return indexPath } + open func tableView(_ tableView: UITableView, willDeselectRowAt indexPath: IndexPath) -> IndexPath? { + if hasAction(.willDeselect, atIndexPath: indexPath) { + return invoke(action: .willDeselect, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? IndexPath + } + + return indexPath + } + // MARK: - Row editing open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath) diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 5d554d5..3eb96a4 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -69,6 +69,7 @@ public enum TableRowActionType { case select case deselect case willSelect + case willDeselect case willDisplay case didEndDisplaying case shouldHighlight From 959032a03f1b28be567e6b408148d7701b3b9b9a Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 27 May 2019 11:01:35 +0300 Subject: [PATCH 06/22] Add accessoryButton action support --- Sources/TableDirector.swift | 5 +++++ Sources/TableKit.swift | 1 + 2 files changed, 6 insertions(+) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index e6f16c7..4a77708 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -355,6 +355,11 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { open func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) { invoke(action: .move, cell: tableView.cellForRow(at: sourceIndexPath), indexPath: sourceIndexPath, userInfo: [TableKitUserInfoKeys.CellMoveDestinationIndexPath: destinationIndexPath]) } + + open func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) { + let cell = tableView.cellForRow(at: indexPath) + invoke(action: .accessoryButtonTap, cell: cell, indexPath: indexPath) + } } // MARK: - Sections manipulation diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 3eb96a4..9202180 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -80,6 +80,7 @@ public enum TableRowActionType { case canMove case canMoveTo case move + case accessoryButtonTap case custom(String) var key: String { From 402757c41f6802289a18f19127ac645774376f83 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Tue, 25 Jun 2019 14:36:47 +0300 Subject: [PATCH 07/22] drop iOS 9 checks on ci --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e7d59b..09bf830 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,8 @@ env: - PROJECT_FRAMEWORK="TableKit.xcodeproj" matrix: - - DESTINATION="OS=9.0,name=iPhone 6" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - - DESTINATION="OS=9.1,name=iPhone 6 Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - - 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=11.0,name=iPhone 6" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - DESTINATION="OS=12.0,name=iPhone 7 Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" script: From dc1a924a8045902d0bc118abc4461381e4b73ea7 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Tue, 25 Jun 2019 14:45:02 +0300 Subject: [PATCH 08/22] drop iOS 9 checks on ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 09bf830..79275fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ env: matrix: - DESTINATION="OS=10.0,name=iPhone 5" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - - DESTINATION="OS=11.0,name=iPhone 6" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" + - DESTINATION="OS=11.1,name=iPhone 6" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - DESTINATION="OS=12.0,name=iPhone 7 Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" script: From f39e7ac602e5dc079b2b945e5290e6408226bacb Mon Sep 17 00:00:00 2001 From: bellebethcooper Date: Sat, 7 Sep 2019 15:49:07 +1000 Subject: [PATCH 09/22] Updated Swift tools version and added missing requirements --- Package.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 35ee9ed..5ce7c3d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,5 +1,20 @@ +// swift-tools-version:5.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + import PackageDescription let package = Package( - name: "TableKit" -) \ No newline at end of file + name: "TableKit", + + products: [ + .library( + name: "TableKit", + targets: ["TableKit"]), + ], + + targets: [ + .target( + name: "TableKit", + path: "Sources") + ] +) From 01bf1e01e3e569f190e9dbd94c3b79ccf66b5f03 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sun, 29 Sep 2019 09:50:40 -0400 Subject: [PATCH 10/22] support swift 5.1 and xcode 11 --- .travis.yml | 5 +++-- CHANGELOG.md | 4 ++++ README.md | 4 ++-- Tests/TableKitTests.swift | 5 ++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 79275fb..f1d55d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10.2 +osx_image: xcode11.0 branches: only: - master @@ -7,7 +7,7 @@ env: global: - LC_CTYPE=en_US.UTF-8 - LANG=en_US.UTF-8 - - IOS_SDK=iphonesimulator12.2 + - IOS_SDK=iphonesimulator13.0 - SCHEME_IOS="TableKit" - PROJECT_FRAMEWORK="TableKit.xcodeproj" @@ -15,6 +15,7 @@ env: - DESTINATION="OS=10.0,name=iPhone 5" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - DESTINATION="OS=11.1,name=iPhone 6" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - DESTINATION="OS=12.0,name=iPhone 7 Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" + - DESTINATION="OS=13.0,name=iPhone 11" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" script: - set -o pipefail diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bf4ad6..3eca5a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [2.10.0](https://github.com/maxsokolov/TableKit/releases/tag/2.10.0) +Released on 2019-09-29. +- Swift 5.1 support. + ## [2.9.0](https://github.com/maxsokolov/TableKit/releases/tag/2.9.0) Released on 2019-04-04. - Swift 5.0 support. diff --git a/README.md b/README.md index dabf33b..b565112 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@

Build Status - Swift 5.0 compatible + Swift 5.1 compatible Carthage compatible - CocoaPods compatible + CocoaPods compatible Platform iOS License: MIT

diff --git a/Tests/TableKitTests.swift b/Tests/TableKitTests.swift index ded9bd6..d9d5b11 100644 --- a/Tests/TableKitTests.swift +++ b/Tests/TableKitTests.swift @@ -74,7 +74,10 @@ class TableKitTests: XCTestCase { super.setUp() testController = TestController() - testController.view.isHidden = false + testController.tableView.frame = UIScreen.main.bounds + testController.tableView.isHidden = false + testController.tableView.setNeedsLayout() + testController.tableView.layoutIfNeeded() } override func tearDown() { From c3652eec6fb21bdca240c2f6c3394439d0473179 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sun, 29 Sep 2019 09:51:33 -0400 Subject: [PATCH 11/22] bump podspec --- TableKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TableKit.podspec b/TableKit.podspec index 9c30c24..7b9a0e0 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.9.0' + s.version = '2.10.0' s.homepage = 'https://github.com/maxsokolov/TableKit' s.summary = 'Type-safe declarative table views with Swift.' From 065cd9ace3445c7d1195a8e94190920332ac44b0 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sun, 29 Sep 2019 09:56:11 -0400 Subject: [PATCH 12/22] fix travis-ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f1d55d2..dabee0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode11.0 +osx_image: xcode11 branches: only: - master From a0658f0b2e8e0442c5a0deab131476cbd36e7891 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sun, 29 Sep 2019 10:03:45 -0400 Subject: [PATCH 13/22] fix travis-ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dabee0a..570d984 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: - PROJECT_FRAMEWORK="TableKit.xcodeproj" matrix: - - DESTINATION="OS=10.0,name=iPhone 5" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" + - DESTINATION="OS=10.3.1,name=iPhone 5" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - DESTINATION="OS=11.1,name=iPhone 6" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - DESTINATION="OS=12.0,name=iPhone 7 Plus" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" - DESTINATION="OS=13.0,name=iPhone 11" SCHEME="$SCHEME_IOS" SDK="$IOS_SDK" From efe99eeb46d0f9439a40e24f39661edbba6472b4 Mon Sep 17 00:00:00 2001 From: Dmitry Frishbuter Date: Sat, 5 Oct 2019 21:57:35 +0600 Subject: [PATCH 14/22] Fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b565112..6b9766c 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ tableDirector += rows Done, your table is ready. ## Automatic cell registration -TableKit can register your cells in a table view automatically. In case if your reusable cell id mathces cell's xib name: +TableKit can register your cells in a table view automatically. In case if your reusable cell id matches cell's xib name: ```ruby MyTableViewCell.swift From eb93fe253c6862d39ba3752d9ce60c0ef35461ee Mon Sep 17 00:00:00 2001 From: mrtokii Date: Sun, 3 May 2020 16:25:30 +0300 Subject: [PATCH 15/22] Add multiple selection actions & context menu action --- Sources/TableDirector.swift | 25 +++++++++++++++++++++++++ Sources/TableKit.swift | 4 ++++ 2 files changed, 29 insertions(+) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 4a77708..2ffc99d 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -317,6 +317,31 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return indexPath } + @available(iOS 13.0, *) + open func tableView( + _ tableView: UITableView, + shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool + { + invoke(action: .shouldBeginMultipleSelection, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) as? Bool ?? false + } + + @available(iOS 13.0, *) + open func tableView( + _ tableView: UITableView, + didBeginMultipleSelectionInteractionAt indexPath: IndexPath) + { + invoke(action: .didBeginMultipleSelection, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath) + } + + @available(iOS 13.0, *) + open func tableView( + _ tableView: UITableView, + contextMenuConfigurationForRowAt indexPath: IndexPath, + point: CGPoint) -> UIContextMenuConfiguration? + { + invoke(action: .showContextMenu, cell: tableView.cellForRow(at: indexPath), indexPath: indexPath, userInfo: [TableKitUserInfoKeys.ContextMenuInvokePoint: point]) as? UIContextMenuConfiguration + } + // MARK: - Row editing open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath) diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 9202180..526b378 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -27,6 +27,7 @@ struct TableKitNotifications { public struct TableKitUserInfoKeys { public static let CellMoveDestinationIndexPath = "TableKitCellMoveDestinationIndexPath" public static let CellCanMoveProposedIndexPath = "CellCanMoveProposedIndexPath" + public static let ContextMenuInvokePoint = "ContextMenuInvokePoint" } public protocol RowConfigurable { @@ -73,6 +74,8 @@ public enum TableRowActionType { case willDisplay case didEndDisplaying case shouldHighlight + case shouldBeginMultipleSelection + case didBeginMultipleSelection case height case canEdit case configure @@ -80,6 +83,7 @@ public enum TableRowActionType { case canMove case canMoveTo case move + case showContextMenu case accessoryButtonTap case custom(String) From 8bf4840d9d0475a92352f02f368f88b74eced447 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Mon, 4 May 2020 08:11:57 -0400 Subject: [PATCH 16/22] bump to 2.11.0 --- README.md | 2 +- TableKit.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b9766c..626274c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Build Status Swift 5.1 compatible Carthage compatible - CocoaPods compatible + CocoaPods compatible Platform iOS License: MIT

diff --git a/TableKit.podspec b/TableKit.podspec index 7b9a0e0..2db6237 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.10.0' + s.version = '2.11.0' s.homepage = 'https://github.com/maxsokolov/TableKit' s.summary = 'Type-safe declarative table views with Swift.' From 37482d3b69206b8de1b82dfd27906f6735b8364b Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 26 Dec 2020 10:31:38 +0300 Subject: [PATCH 17/22] Replace UITableViewRowAction with UIContextualAction --- Sources/TableDirector.swift | 12 +++++++++++- Sources/TableKit.swift | 4 +++- Sources/TableRow.swift | 18 ++++++++++++++---- TableKit.xcodeproj/project.pbxproj | 4 ++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 2ffc99d..10e6390 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -348,7 +348,17 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { } open func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { - return sections[indexPath.section].rows[indexPath.row].editingActions + return nil + } + + open func tableView(_ tableView: UITableView, + leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { + return .init(actions: sections[indexPath.section].rows[indexPath.row].leadingContextualActions) + } + + open func tableView(_ tableView: UITableView, + trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { + return .init(actions: sections[indexPath.section].rows[indexPath.row].trailingContextualActions) } open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 0615871..97b48ec 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -38,7 +38,9 @@ public protocol RowConfigurable { public protocol RowActionable { - var editingActions: [UITableViewRowAction]? { get } + var leadingContextualActions: [UIContextualAction] { get } + var trailingContextualActions: [UIContextualAction] { get } + func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool func invoke( diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 662b4dd..467dfec 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -24,7 +24,9 @@ open class TableRow: Row where CellType: UITableView public let item: CellType.CellData private lazy var actions = [String: [TableRowAction]]() - private(set) open var editingActions: [UITableViewRowAction]? + + private(set) open var leadingContextualActions: [UIContextualAction] = [] + private(set) open var trailingContextualActions: [UIContextualAction] = [] open var hashValue: Int { return ObjectIdentifier(self).hashValue @@ -50,10 +52,15 @@ open class TableRow: Row where CellType: UITableView return CellType.self } - public init(item: CellType.CellData, actions: [TableRowAction]? = nil, editingActions: [UITableViewRowAction]? = nil) { + public init(item: CellType.CellData, + actions: [TableRowAction]? = nil, + leadingContextualActions: [UIContextualAction] = [], + trailingContextualActions: [UIContextualAction] = []) { self.item = item - self.editingActions = editingActions + self.leadingContextualActions = leadingContextualActions + self.trailingContextualActions = trailingContextualActions + actions?.forEach { on($0) } } @@ -81,7 +88,10 @@ open class TableRow: Row where CellType: UITableView if actions[TableRowActionType.canEdit.key] != nil { return invoke(action: .canEdit, cell: nil, path: indexPath) as? Bool ?? false } - return editingActions?.isEmpty == false || actions[TableRowActionType.clickDelete.key] != nil + + return !leadingContextualActions.isEmpty + || !trailingContextualActions.isEmpty + || actions[TableRowActionType.clickDelete.key] != nil } // MARK: - actions - diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj index 990d148..d097f6a 100644 --- a/TableKit.xcodeproj/project.pbxproj +++ b/TableKit.xcodeproj/project.pbxproj @@ -412,7 +412,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Configs/TableKit.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKit; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -433,7 +433,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Configs/TableKit.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKit; PRODUCT_NAME = "$(TARGET_NAME)"; From 49b3f868f3a2ab6dc88468ca0e0a4d35dc387b78 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 26 Dec 2020 10:36:32 +0300 Subject: [PATCH 18/22] Return IPHONEOS_DEPLOYMENT_TARGET --- TableKit.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TableKit.xcodeproj/project.pbxproj b/TableKit.xcodeproj/project.pbxproj index d097f6a..990d148 100644 --- a/TableKit.xcodeproj/project.pbxproj +++ b/TableKit.xcodeproj/project.pbxproj @@ -412,7 +412,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Configs/TableKit.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKit; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -433,7 +433,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Configs/TableKit.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tablekit.TableKit; PRODUCT_NAME = "$(TARGET_NAME)"; From d87a23587ed0d3b94764980f5c994fea07cdfc98 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 26 Dec 2020 10:52:06 +0300 Subject: [PATCH 19/22] Add backward capability to editingActions --- Sources/Expandable.swift | 2 +- Sources/TableDirector.swift | 5 ++++- Sources/TableKit.swift | 6 ++++++ Sources/TableRow.swift | 43 +++++++++++++++++++++++++++---------- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/Sources/Expandable.swift b/Sources/Expandable.swift index 6553e9c..e3cb3a1 100644 --- a/Sources/Expandable.swift +++ b/Sources/Expandable.swift @@ -40,7 +40,7 @@ extension Expandable where Self: UITableViewCell & ConfigurableCell { animationDuration: TimeInterval = .defaultExpandableAnimationDuration) { guard let viewModel = viewModel, - let stateIndex = viewModel.availableStates.index(where: { $0 == viewModel.expandableState }) else { + let stateIndex = viewModel.availableStates.firstIndex(where: { $0 == viewModel.expandableState }) else { return } diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index 10e6390..cc99f16 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -347,15 +347,18 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath) } + @available(iOS, obsoleted: 11, message: "Use leadingSwipeActionsConfigurationForRowAt(:_) and trailingSwipeActionsConfigurationForRowAt(:_) instead") open func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { - return nil + return sections[indexPath.section].rows[indexPath.row].editingActions } + @available(iOS 11, *) open func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { return .init(actions: sections[indexPath.section].rows[indexPath.row].leadingContextualActions) } + @available(iOS 11, *) open func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { return .init(actions: sections[indexPath.section].rows[indexPath.row].trailingContextualActions) diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 97b48ec..e3f25f4 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -38,9 +38,15 @@ public protocol RowConfigurable { public protocol RowActionable { + @available(iOS 11, *) var leadingContextualActions: [UIContextualAction] { get } + + @available(iOS 11, *) var trailingContextualActions: [UIContextualAction] { get } + @available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead") + var editingActions: [UITableViewRowAction]? { get } + func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool func invoke( diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 467dfec..bf44619 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -21,12 +21,21 @@ import UIKit open class TableRow: Row where CellType: UITableViewCell { - + public let item: CellType.CellData private lazy var actions = [String: [TableRowAction]]() - private(set) open var leadingContextualActions: [UIContextualAction] = [] - private(set) open var trailingContextualActions: [UIContextualAction] = [] + open private(set) var editingActions: [UITableViewRowAction]? + + @available(iOS 11, *) + public var leadingContextualActions: [UIContextualAction] { + [] + } + + @available(iOS 11, *) + public var trailingContextualActions: [UIContextualAction] { + [] + } open var hashValue: Int { return ObjectIdentifier(self).hashValue @@ -52,14 +61,22 @@ open class TableRow: Row where CellType: UITableView return CellType.self } + @available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead") public init(item: CellType.CellData, actions: [TableRowAction]? = nil, - leadingContextualActions: [UIContextualAction] = [], - trailingContextualActions: [UIContextualAction] = []) { + editingActions: [UITableViewRowAction]? = nil) { + + self.item = item + self.editingActions = editingActions + + actions?.forEach { on($0) } + } + + @available(iOS 11, *) + public init(item: CellType.CellData, + actions: [TableRowAction]? = nil) { self.item = item - self.leadingContextualActions = leadingContextualActions - self.trailingContextualActions = trailingContextualActions actions?.forEach { on($0) } } @@ -88,10 +105,14 @@ open class TableRow: Row where CellType: UITableView if actions[TableRowActionType.canEdit.key] != nil { return invoke(action: .canEdit, cell: nil, path: indexPath) as? Bool ?? false } - - return !leadingContextualActions.isEmpty - || !trailingContextualActions.isEmpty - || actions[TableRowActionType.clickDelete.key] != nil + + if #available(iOS 11, *) { + return !leadingContextualActions.isEmpty + || !trailingContextualActions.isEmpty + || actions[TableRowActionType.clickDelete.key] != nil + } else { + return editingActions?.isEmpty == false || actions[TableRowActionType.clickDelete.key] != nil + } } // MARK: - actions - From 94c40faa636d93676f27f69650fc3cc6d2b353fb Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 26 Dec 2020 11:05:20 +0300 Subject: [PATCH 20/22] Code correction --- Sources/TableRow.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index bf44619..356693e 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -25,15 +25,16 @@ open class TableRow: Row where CellType: UITableView public let item: CellType.CellData private lazy var actions = [String: [TableRowAction]]() + @available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead") open private(set) var editingActions: [UITableViewRowAction]? @available(iOS 11, *) - public var leadingContextualActions: [UIContextualAction] { + open var leadingContextualActions: [UIContextualAction] { [] } @available(iOS 11, *) - public var trailingContextualActions: [UIContextualAction] { + open var trailingContextualActions: [UIContextualAction] { [] } From efc03d7c223623ef1f38d2a606bac5eceb64ed05 Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 26 Dec 2020 11:24:59 +0300 Subject: [PATCH 21/22] Add performsFirstActionWithFullSwipe --- Sources/TableDirector.swift | 14 ++++++++++++-- Sources/TableKit.swift | 3 +++ Sources/TableRow.swift | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index cc99f16..e5e2564 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -355,13 +355,23 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { @available(iOS 11, *) open func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { - return .init(actions: sections[indexPath.section].rows[indexPath.row].leadingContextualActions) + let currentRow = sections[indexPath.section].rows[indexPath.row] + let configuration = UISwipeActionsConfiguration(actions: currentRow.leadingContextualActions) + + configuration.performsFirstActionWithFullSwipe = currentRow.performsFirstActionWithFullSwipe + + return configuration } @available(iOS 11, *) open func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { - return .init(actions: sections[indexPath.section].rows[indexPath.row].trailingContextualActions) + let currentRow = sections[indexPath.section].rows[indexPath.row] + let configuration = UISwipeActionsConfiguration(actions: currentRow.trailingContextualActions) + + configuration.performsFirstActionWithFullSwipe = currentRow.performsFirstActionWithFullSwipe + + return configuration } open func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index e3f25f4..65ae26d 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -44,6 +44,9 @@ public protocol RowActionable { @available(iOS 11, *) var trailingContextualActions: [UIContextualAction] { get } + @available(iOS 11, *) + var performsFirstActionWithFullSwipe: Bool { get } + @available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead") var editingActions: [UITableViewRowAction]? { get } diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index 356693e..f78a4b3 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -38,6 +38,11 @@ open class TableRow: Row where CellType: UITableView [] } + @available(iOS 11, *) + open var performsFirstActionWithFullSwipe: Bool { + false + } + open var hashValue: Int { return ObjectIdentifier(self).hashValue } From caec2dd10e1ce96f5f0a869e11b5158b9e18eb3f Mon Sep 17 00:00:00 2001 From: Vlad Date: Sat, 26 Dec 2020 15:22:00 +0300 Subject: [PATCH 22/22] Return deprecated --- Sources/TableDirector.swift | 2 +- Sources/TableKit.swift | 2 +- Sources/TableRow.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index e5e2564..e269398 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -347,7 +347,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath) } - @available(iOS, obsoleted: 11, message: "Use leadingSwipeActionsConfigurationForRowAt(:_) and trailingSwipeActionsConfigurationForRowAt(:_) instead") + @available(iOS, deprecated: 11, message: "Use leadingSwipeActionsConfigurationForRowAt(:_) and trailingSwipeActionsConfigurationForRowAt(:_) instead") open func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { return sections[indexPath.section].rows[indexPath.row].editingActions } diff --git a/Sources/TableKit.swift b/Sources/TableKit.swift index 65ae26d..1aba0bd 100644 --- a/Sources/TableKit.swift +++ b/Sources/TableKit.swift @@ -47,7 +47,7 @@ public protocol RowActionable { @available(iOS 11, *) var performsFirstActionWithFullSwipe: Bool { get } - @available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead") + @available(iOS, deprecated: 11, message: "Use leadingContextualActions, trailingContextualActions instead") var editingActions: [UITableViewRowAction]? { get } func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool diff --git a/Sources/TableRow.swift b/Sources/TableRow.swift index f78a4b3..6679595 100644 --- a/Sources/TableRow.swift +++ b/Sources/TableRow.swift @@ -25,7 +25,7 @@ open class TableRow: Row where CellType: UITableView public let item: CellType.CellData private lazy var actions = [String: [TableRowAction]]() - @available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead") + @available(iOS, deprecated: 11, message: "Use leadingContextualActions, trailingContextualActions instead") open private(set) var editingActions: [UITableViewRowAction]? @available(iOS 11, *) @@ -67,7 +67,7 @@ open class TableRow: Row where CellType: UITableView return CellType.self } - @available(iOS, obsoleted: 11, message: "Use leadingContextualActions, trailingContextualActions instead") + @available(iOS, deprecated: 11, message: "Use leadingContextualActions, trailingContextualActions instead") public init(item: CellType.CellData, actions: [TableRowAction]? = nil, editingActions: [UITableViewRowAction]? = nil) {