From ff1882279ded929d391ed74ef12107b41cac30a8 Mon Sep 17 00:00:00 2001 From: Taras Nikulin Date: Tue, 28 May 2019 10:40:06 +0200 Subject: [PATCH 1/8] Default implementation for isContentEqual --- Sources/Shared/Protocols/ElementRepresentable.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Shared/Protocols/ElementRepresentable.swift b/Sources/Shared/Protocols/ElementRepresentable.swift index 02e0637..176a0de 100644 --- a/Sources/Shared/Protocols/ElementRepresentable.swift +++ b/Sources/Shared/Protocols/ElementRepresentable.swift @@ -31,6 +31,12 @@ public protocol Differentiable { func isContentEqual(to other: Differentiable) -> Bool } +public extension Differentiable { + func isContentEqual(to other: Differentiable) -> Bool { + return self.differenceIdentifier == other.differenceIdentifier + } +} + // MARK: - ElementRepresentable - public protocol ElementRepresentable: Differentiable { From f8bf4bc345f1fd10c1dbd26baeff3a1dba52fae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Topi=C4=8D?= Date: Thu, 31 Oct 2019 18:49:30 +0100 Subject: [PATCH 2/8] Fix SPM to support iOS 10+ only --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index aef9c2b..3e021d4 100644 --- a/Package.swift +++ b/Package.swift @@ -5,6 +5,7 @@ import PackageDescription let package = Package( name: "Owl", + platforms: .iOS(.v10), products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( From 1caf1878243ed7e6fc99345f35b1f379fd671b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Topi=C4=8D?= Date: Thu, 31 Oct 2019 18:53:15 +0100 Subject: [PATCH 3/8] Fix Package.swift --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 3e021d4..2099822 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "Owl", - platforms: .iOS(.v10), + platforms: [.iOS(.v10)], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( From 42ccfca94e7d9b06f3fb7bb7c0e1579ca21c98f7 Mon Sep 17 00:00:00 2001 From: Ciprian Redinciuc Date: Thu, 14 Nov 2019 20:47:57 +0200 Subject: [PATCH 4/8] Change CollectionHeaderFooterAdapter, TableSection and TableHeaderFooterAdapter classes from public to open for inherintance purposes --- .../HeaderFooter Adapter/CollectionHeaderFooterAdapter.swift | 2 +- .../Owl/Table/Header Adapter/TableHeaderFooterAdapter.swift | 2 +- Sources/Owl/Table/TableSection.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Owl/Collection/HeaderFooter Adapter/CollectionHeaderFooterAdapter.swift b/Sources/Owl/Collection/HeaderFooter Adapter/CollectionHeaderFooterAdapter.swift index 7c17daf..6e5655f 100644 --- a/Sources/Owl/Collection/HeaderFooter Adapter/CollectionHeaderFooterAdapter.swift +++ b/Sources/Owl/Collection/HeaderFooter Adapter/CollectionHeaderFooterAdapter.swift @@ -30,7 +30,7 @@ public extension CollectionHeaderFooterAdapterProtocol { } -public class CollectionHeaderFooterAdapter: CollectionHeaderFooterAdapterProtocol { +open class CollectionHeaderFooterAdapter: CollectionHeaderFooterAdapterProtocol { /// This is the cell type used to dequeue the model. You should not alter it. public var modelCellType: Any.Type = View.self diff --git a/Sources/Owl/Table/Header Adapter/TableHeaderFooterAdapter.swift b/Sources/Owl/Table/Header Adapter/TableHeaderFooterAdapter.swift index dee16c3..521cd25 100644 --- a/Sources/Owl/Table/Header Adapter/TableHeaderFooterAdapter.swift +++ b/Sources/Owl/Table/Header Adapter/TableHeaderFooterAdapter.swift @@ -34,7 +34,7 @@ public extension TableHeaderFooterAdapterProtocol { // MARK: - TableHeaderFooterAdapter - -public class TableHeaderFooterAdapter: TableHeaderFooterAdapterProtocol { +open class TableHeaderFooterAdapter: TableHeaderFooterAdapterProtocol { // MARK: - Public Properties - diff --git a/Sources/Owl/Table/TableSection.swift b/Sources/Owl/Table/TableSection.swift index 64ae303..8813b39 100644 --- a/Sources/Owl/Table/TableSection.swift +++ b/Sources/Owl/Table/TableSection.swift @@ -12,7 +12,7 @@ import UIKit -public class TableSection: Equatable, Copying, DifferentiableSection { +open class TableSection: Equatable, Copying, DifferentiableSection { // MARK: - Public Properties - @@ -95,7 +95,7 @@ public class TableSection: Equatable, Copying, DifferentiableSection { // MARK: - Initialization - - required init(original: TableSection) { + required public init(original: TableSection) { self.allElements = original.allElements self.identifier = original.identifier self.headerTitle = original.headerTitle From 37a5a2702d6b3c094434236a7ff0eab067a78e55 Mon Sep 17 00:00:00 2001 From: daniele margutti Date: Sun, 24 Nov 2019 18:12:11 +0100 Subject: [PATCH 5/8] #38 Fixed crash with didEndDisplayCell both for Collection and Table directors. For these events model cannot be sent because it's not valid anymore (when removed its not part of the data source anymore). So these events are sent to the cell type without the model itself. --- .../xcode/package.xcworkspace/contents.xcworkspacedata | 7 +++++++ Sources/Owl/Collection/CollectionDirector.swift | 6 ++++-- Sources/Owl/Table/TableDirector.swift | 7 ++++--- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Sources/Owl/Collection/CollectionDirector.swift b/Sources/Owl/Collection/CollectionDirector.swift index 72f04ac..77f447d 100644 --- a/Sources/Owl/Collection/CollectionDirector.swift +++ b/Sources/Owl/Collection/CollectionDirector.swift @@ -391,8 +391,10 @@ public extension CollectionDirector { } func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { - let (model, adapter) = context(forItemAt: indexPath) - let _ = adapter.dispatchEvent(.endDisplay, model: model, cell: cell, path: indexPath, params: nil) + guard let adapter = adapterForCell(cell) else { + return + } + let _ = adapter.dispatchEvent(.endDisplay, model: nil, cell: cell, path: indexPath, params: nil) } private func adapterForCellClass(_ cell: UICollectionViewCell?) -> CollectionCellAdapterProtocol? { diff --git a/Sources/Owl/Table/TableDirector.swift b/Sources/Owl/Table/TableDirector.swift index 9c1c66f..044dfa9 100644 --- a/Sources/Owl/Table/TableDirector.swift +++ b/Sources/Owl/Table/TableDirector.swift @@ -703,9 +703,10 @@ extension TableDirector: UITableViewDataSource, UITableViewDelegate { } public func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) { - //let adapter = adapterForCellClass(tableView.cellForRow(at: indexPath)) - let (model, adapter) = context(forItemAt: indexPath) - let _ = adapter.dispatchEvent(.endDisplay, model: model, cell: cell, path: indexPath, params: nil) + guard let adapter = adapterForCellClass(cell) else { + return + } + let _ = adapter.dispatchEvent(.endDisplay, model: nil, cell: cell, path: indexPath, params: nil) } public func tableView(_ tableView: UITableView, shouldShowMenuForRowAt indexPath: IndexPath) -> Bool { From 1a362e3e2ae3d5e08f2b35e762012105ef824c47 Mon Sep 17 00:00:00 2001 From: daniele margutti Date: Sun, 24 Nov 2019 18:14:16 +0100 Subject: [PATCH 6/8] #38 model property of the event (both for collection and cells) is now optional because it may be nil in certain situations (ie. didEndDisplayCell events) --- .../Cell Adapter/CollectionCellAdapter+Events.swift | 4 ++-- Sources/Owl/Table/Cell Adapters/TableCellAdapter+Events.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Owl/Collection/Cell Adapter/CollectionCellAdapter+Events.swift b/Sources/Owl/Collection/Cell Adapter/CollectionCellAdapter+Events.swift index d5e9816..d9449e5 100644 --- a/Sources/Owl/Collection/Cell Adapter/CollectionCellAdapter+Events.swift +++ b/Sources/Owl/Collection/Cell Adapter/CollectionCellAdapter+Events.swift @@ -20,7 +20,7 @@ public extension CollectionCellAdapter { public let indexPath: IndexPath? /// Represented model instance - public let element: Model + public let element: Model? /// Managed source collection public var collection: UICollectionView? { @@ -50,7 +50,7 @@ public extension CollectionCellAdapter { /// - path: cell's path /// - collection: parent cell's collection instance internal init(element: Any?, cell: Any?, path: IndexPath?) { - self.element = element as! Model + self.element = element as? Model self.cell = cell as? Cell self.indexPath = path } diff --git a/Sources/Owl/Table/Cell Adapters/TableCellAdapter+Events.swift b/Sources/Owl/Table/Cell Adapters/TableCellAdapter+Events.swift index c2438c2..a23d466 100644 --- a/Sources/Owl/Table/Cell Adapters/TableCellAdapter+Events.swift +++ b/Sources/Owl/Table/Cell Adapters/TableCellAdapter+Events.swift @@ -51,14 +51,14 @@ public extension TableCellAdapter { public let indexPath: IndexPath? // Target element of the event. - public let element: Model + public let element: Model? // Target static typed cell if available. // This value maybe `nil` if, at the time of the request, no cell is contextually associable with the event. public var cell: Cell? internal init(item: Any? = nil, cell: Any? = nil, indexPath: IndexPath? = nil) { - self.element = item as! Model + self.element = item as? Model self.cell = cell as? Cell self.indexPath = indexPath } From 3a4e87d329ad35204ca3fc352a8d4683acc15b05 Mon Sep 17 00:00:00 2001 From: daniele margutti Date: Sun, 24 Nov 2019 18:21:46 +0100 Subject: [PATCH 7/8] Added .DSStore to ignored items --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d534044..a4b4a49 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ fastlane/report.xml fastlane/Preview.html fastlane/screenshots fastlane/test_output +.DS_Store From dc8b5fb72af5b99f483d68602de4368723c26582 Mon Sep 17 00:00:00 2001 From: daniele margutti Date: Sun, 24 Nov 2019 18:21:53 +0100 Subject: [PATCH 8/8] Bump to 1.1.1 --- Configs/Owl.plist | 2 +- Owl.xcodeproj/project.pbxproj | 4 ++++ OwlKit.podspec | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Configs/Owl.plist b/Configs/Owl.plist index 42063e9..5eb0141 100644 --- a/Configs/Owl.plist +++ b/Configs/Owl.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.4 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion diff --git a/Owl.xcodeproj/project.pbxproj b/Owl.xcodeproj/project.pbxproj index 3341838..44d0f06 100644 --- a/Owl.xcodeproj/project.pbxproj +++ b/Owl.xcodeproj/project.pbxproj @@ -898,6 +898,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CURRENT_PROJECT_VERSION = 0; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -906,6 +907,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 1.1.1; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.Owl.Owl-iOS"; PRODUCT_NAME = Owl; @@ -921,6 +923,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CURRENT_PROJECT_VERSION = 0; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -929,6 +932,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 1.1.1; PRODUCT_BUNDLE_IDENTIFIER = "com.Owl.Owl-iOS"; PRODUCT_NAME = Owl; SKIP_INSTALL = YES; diff --git a/OwlKit.podspec b/OwlKit.podspec index 3cc54a7..b91f898 100644 --- a/OwlKit.podspec +++ b/OwlKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "OwlKit" - s.version = "1.1.0" + s.version = "1.1.1" s.summary = "A declarative type-safe framework for building fast and flexible list with Tables & Collections" s.description = <<-DESC Owl offers a data-driven declarative approach for building fast & flexible list in iOS. It supports both UICollectionView & UITableView; UIStackView is on the way!.