From 33685abb16b5b7b5dc0d2d36b212d4977d88184c Mon Sep 17 00:00:00 2001 From: Calvin Chang Date: Fri, 19 Apr 2024 16:59:00 +0200 Subject: [PATCH 1/3] make the layout provider nonoptional --- .../Names/NamesSectionController.swift | 2 +- ...istCollectionViewAdapter+Convenience.swift | 4 +- ...ionCollectionViewAdapter+Convenience.swift | 4 +- .../Generic/BaseSectionController.swift | 2 +- .../SectionController/SectionController.swift | 7 +- ...ollectionViewDelegateFlowLayoutTests.swift | 70 +++++++++---------- ...lDefaultValuesSectionControllerTests.swift | 3 +- .../TestUtilities/MockSectionController.swift | 5 +- 8 files changed, 48 insertions(+), 49 deletions(-) diff --git a/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift b/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift index b14881d6..06a2f97c 100644 --- a/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift +++ b/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift @@ -5,7 +5,7 @@ final class NamesSectionController: ListSectionController< NamesSectionViewModelType, String > { - override var layoutProvider: SectionLayoutProvider? { + override var layoutProvider: SectionLayoutProvider { let layoutSize = NSCollectionLayoutSize( widthDimension: .fractionalWidth(1), heightDimension: .estimated(50) diff --git a/SectionKit/Sources/CollectionViewAdapter/ListCollectionViewAdapter/ListCollectionViewAdapter+Convenience.swift b/SectionKit/Sources/CollectionViewAdapter/ListCollectionViewAdapter/ListCollectionViewAdapter+Convenience.swift index 2ddbd2d7..65398091 100644 --- a/SectionKit/Sources/CollectionViewAdapter/ListCollectionViewAdapter/ListCollectionViewAdapter+Convenience.swift +++ b/SectionKit/Sources/CollectionViewAdapter/ListCollectionViewAdapter/ListCollectionViewAdapter+Convenience.swift @@ -59,7 +59,7 @@ extension ListCollectionViewAdapter { @inlinable public func flowDelegate(at indexPath: IndexPath) -> SectionFlowDelegate? { if #available(iOS 13.0, *) { - return controller(at: indexPath)?.layoutProvider?.flowLayoutProvider + return controller(at: indexPath)?.layoutProvider.flowLayoutProvider } else { return controller(at: indexPath)?.flowDelegate } @@ -68,7 +68,7 @@ extension ListCollectionViewAdapter { @inlinable public func flowDelegate(at index: Int) -> SectionFlowDelegate? { if #available(iOS 13.0, *) { - return controller(at: index)?.layoutProvider?.flowLayoutProvider + return controller(at: index)?.layoutProvider.flowLayoutProvider } else { return controller(at: index)?.flowDelegate } diff --git a/SectionKit/Sources/CollectionViewAdapter/SingleSectionCollectionViewAdapter/SingleSectionCollectionViewAdapter+Convenience.swift b/SectionKit/Sources/CollectionViewAdapter/SingleSectionCollectionViewAdapter/SingleSectionCollectionViewAdapter+Convenience.swift index d6666281..a4140864 100644 --- a/SectionKit/Sources/CollectionViewAdapter/SingleSectionCollectionViewAdapter/SingleSectionCollectionViewAdapter+Convenience.swift +++ b/SectionKit/Sources/CollectionViewAdapter/SingleSectionCollectionViewAdapter/SingleSectionCollectionViewAdapter+Convenience.swift @@ -59,7 +59,7 @@ extension SingleSectionCollectionViewAdapter { @inlinable public func flowDelegate(at indexPath: IndexPath) -> SectionFlowDelegate? { if #available(iOS 13.0, *) { - return controller(at: indexPath)?.layoutProvider?.flowLayoutProvider + return controller(at: indexPath)?.layoutProvider.flowLayoutProvider } else { return controller(at: indexPath)?.flowDelegate } @@ -68,7 +68,7 @@ extension SingleSectionCollectionViewAdapter { @inlinable public func flowDelegate(at index: Int) -> SectionFlowDelegate? { if #available(iOS 13.0, *) { - return controller(at: index)?.layoutProvider?.flowLayoutProvider + return controller(at: index)?.layoutProvider.flowLayoutProvider } else { return controller(at: index)?.flowDelegate } diff --git a/SectionKit/Sources/SectionController/Generic/BaseSectionController.swift b/SectionKit/Sources/SectionController/Generic/BaseSectionController.swift index 475d538f..7ef4035b 100644 --- a/SectionKit/Sources/SectionController/Generic/BaseSectionController.swift +++ b/SectionKit/Sources/SectionController/Generic/BaseSectionController.swift @@ -37,7 +37,7 @@ open class BaseSectionController: SectionController, open var dropDelegate: SectionDropDelegate? { self } @available(iOS 13.0, *) - open var layoutProvider: SectionLayoutProvider? { .flowLayout(self) } + open var layoutProvider: SectionLayoutProvider { .flowLayout(self) } open func didUpdate(model: Any) { } diff --git a/SectionKit/Sources/SectionController/SectionController.swift b/SectionKit/Sources/SectionController/SectionController.swift index b49bb6fd..7af145c9 100644 --- a/SectionKit/Sources/SectionController/SectionController.swift +++ b/SectionKit/Sources/SectionController/SectionController.swift @@ -28,7 +28,7 @@ public protocol SectionController: AnyObject { var dropDelegate: SectionDropDelegate? { get } @available(iOS 13.0, *) - var layoutProvider: SectionLayoutProvider? { get } + var layoutProvider: SectionLayoutProvider { get } /// The model of this section controller changed. func didUpdate(model: Any) @@ -47,14 +47,11 @@ extension SectionController { @available(iOS 11.0, *) public var dropDelegate: SectionDropDelegate? { nil } - - @available(iOS 13.0, *) - public var layoutProvider: SectionLayoutProvider? { nil } } @available(iOS 13.0, *) public enum SectionLayoutProvider { - case flowLayout(FlowLayoutProvider) + case flowLayout(FlowLayoutProvider?) case compositionalLayout(CompositionalLayoutProvider) } diff --git a/SectionKit/Tests/CollectionViewAdapter/UICollectionViewDelegateFlowLayout/BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests.swift b/SectionKit/Tests/CollectionViewAdapter/UICollectionViewDelegateFlowLayout/BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests.swift index ace37e1c..ab29f68c 100644 --- a/SectionKit/Tests/CollectionViewAdapter/UICollectionViewDelegateFlowLayout/BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests.swift +++ b/SectionKit/Tests/CollectionViewAdapter/UICollectionViewDelegateFlowLayout/BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests.swift @@ -2,19 +2,19 @@ import UIKit import XCTest -internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: XCTestCase { +class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: XCTestCase { override func setUpWithError() throws { try super.setUpWithError() continueAfterFailure = false try skipIfNeeded() } - internal func skipIfNeeded() throws { + func skipIfNeeded() throws { guard Self.self === BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests.self else { return } throw XCTSkip("Tests from base class are skipped") } - internal func createCollectionView( + func createCollectionView( frame: CGRect = .zero, collectionViewLayout layout: UICollectionViewLayout? = nil ) -> UICollectionView { @@ -22,7 +22,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func createCollectionViewAdapter( + func createCollectionViewAdapter( collectionView: UICollectionView, sections: [Section] = [], viewController: UIViewController? = nil, @@ -34,7 +34,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: // MARK: - sizeForItem @MainActor - internal func testSizeForItemWithDelegate() throws { + func testSizeForItemWithDelegate() throws { let testExpectation = expectation(description: "Should invoke flow layout delegate") let mockLayout = UICollectionViewFlowLayout() let collectionView = createCollectionView(collectionViewLayout: mockLayout) @@ -67,7 +67,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testSizeForItemWithoutDelegateButWithFlowLayout() throws { + func testSizeForItemWithoutDelegateButWithFlowLayout() throws { let itemSize = CGSize(width: 1, height: 2) let layout = UICollectionViewFlowLayout() layout.itemSize = itemSize @@ -78,7 +78,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -90,8 +90,8 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testSizeForItemWithoutDelegateAndFlowLayout() throws { - let layout = UICollectionViewLayout() + func testSizeForItemWithoutDelegateAndFlowLayout() throws { + let layout = UICollectionViewFlowLayout() let collectionView = createCollectionView(collectionViewLayout: layout) let itemIndexPath = IndexPath(item: 0, section: 0) let adapter = try createCollectionViewAdapter( @@ -99,7 +99,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -113,7 +113,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: // MARK: - inset @MainActor - internal func testInsetWithDelegate() throws { + func testInsetWithDelegate() throws { let testExpectation = expectation(description: "Should invoke flow layout delegate") let mockLayout = UICollectionViewFlowLayout() let collectionView = createCollectionView(collectionViewLayout: mockLayout) @@ -144,7 +144,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testInsetWithoutDelegateButWithFlowLayout() throws { + func testInsetWithoutDelegateButWithFlowLayout() throws { let sectionInset = UIEdgeInsets(top: 1, left: 2, bottom: 4, right: 8) let layout = UICollectionViewFlowLayout() layout.sectionInset = sectionInset @@ -154,7 +154,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -166,7 +166,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testInsetWithoutDelegateAndFlowLayout() throws { + func testInsetWithoutDelegateAndFlowLayout() throws { let layout = UICollectionViewLayout() let collectionView = createCollectionView(collectionViewLayout: layout) let adapter = try createCollectionViewAdapter( @@ -174,7 +174,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -188,7 +188,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: // MARK: - minimumLineSpacing @MainActor - internal func testMinimumLineSpacingWithDelegate() throws { + func testMinimumLineSpacingWithDelegate() throws { let testExpectation = expectation(description: "Should invoke flow layout delegate") let mockLayout = UICollectionViewFlowLayout() let collectionView = createCollectionView(collectionViewLayout: mockLayout) @@ -219,7 +219,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testMinimumLineSpacingWithoutDelegateButWithFlowLayout() throws { + func testMinimumLineSpacingWithoutDelegateButWithFlowLayout() throws { let lineSpacing: CGFloat = 1 let layout = UICollectionViewFlowLayout() layout.minimumLineSpacing = lineSpacing @@ -229,7 +229,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -241,7 +241,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testMinimumLineSpacingWithoutDelegateAndFlowLayout() throws { + func testMinimumLineSpacingWithoutDelegateAndFlowLayout() throws { let layout = UICollectionViewLayout() let collectionView = createCollectionView(collectionViewLayout: layout) let adapter = try createCollectionViewAdapter( @@ -249,7 +249,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -263,7 +263,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: // MARK: - minimumInteritemSpacing @MainActor - internal func testMinimumInteritemSpacingWithDelegate() throws { + func testMinimumInteritemSpacingWithDelegate() throws { let testExpectation = expectation(description: "Should invoke flow layout delegate") let mockLayout = UICollectionViewFlowLayout() let collectionView = createCollectionView(collectionViewLayout: mockLayout) @@ -294,7 +294,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testMinimumInteritemSpacingWithoutDelegateButWithFlowLayout() throws { + func testMinimumInteritemSpacingWithoutDelegateButWithFlowLayout() throws { let interitemSpacing: CGFloat = 1 let layout = UICollectionViewFlowLayout() layout.minimumInteritemSpacing = interitemSpacing @@ -304,7 +304,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -316,7 +316,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testMinimumInteritemSpacingWithoutDelegateAndFlowLayout() throws { + func testMinimumInteritemSpacingWithoutDelegateAndFlowLayout() throws { let layout = UICollectionViewLayout() let collectionView = createCollectionView(collectionViewLayout: layout) let adapter = try createCollectionViewAdapter( @@ -324,7 +324,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -338,7 +338,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: // MARK: - referenceSizeForHeader @MainActor - internal func testReferenceSizeForHeaderWithDelegate() throws { + func testReferenceSizeForHeaderWithDelegate() throws { let testExpectation = expectation(description: "Should invoke flow layout delegate") let mockLayout = UICollectionViewFlowLayout() let collectionView = createCollectionView(collectionViewLayout: mockLayout) @@ -369,7 +369,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testReferenceSizeForHeaderWithoutDelegateButWithFlowLayout() throws { + func testReferenceSizeForHeaderWithoutDelegateButWithFlowLayout() throws { let headerSize = CGSize(width: 1, height: 2) let layout = UICollectionViewFlowLayout() layout.headerReferenceSize = headerSize @@ -379,7 +379,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -391,7 +391,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testReferenceSizeForHeaderWithoutDelegateAndFlowLayout() throws { + func testReferenceSizeForHeaderWithoutDelegateAndFlowLayout() throws { let layout = UICollectionViewLayout() let collectionView = createCollectionView(collectionViewLayout: layout) let adapter = try createCollectionViewAdapter( @@ -399,7 +399,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -413,7 +413,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: // MARK: - referenceSizeForFooter @MainActor - internal func testReferenceSizeForFooterWithDelegate() throws { + func testReferenceSizeForFooterWithDelegate() throws { let testExpectation = expectation(description: "Should invoke flow layout delegate") let mockLayout = UICollectionViewFlowLayout() let collectionView = createCollectionView(collectionViewLayout: mockLayout) @@ -444,7 +444,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testReferenceSizeForFooterWithoutDelegateButWithFlowLayout() throws { + func testReferenceSizeForFooterWithoutDelegateButWithFlowLayout() throws { let footerSize = CGSize(width: 1, height: 2) let layout = UICollectionViewFlowLayout() layout.footerReferenceSize = footerSize @@ -454,7 +454,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] @@ -466,7 +466,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: } @MainActor - internal func testReferenceSizeForFooterWithoutDelegateAndFlowLayout() throws { + func testReferenceSizeForFooterWithoutDelegateAndFlowLayout() throws { let layout = UICollectionViewLayout() let collectionView = createCollectionView(collectionViewLayout: layout) let adapter = try createCollectionViewAdapter( @@ -474,7 +474,7 @@ internal class BaseCollectionViewAdapterUICollectionViewDelegateFlowLayoutTests: sections: [ Section(id: "", model: "", controller: { let sectionController = MockSectionController() - sectionController.layoutProvider = nil + sectionController.layoutProvider = .flowLayout(nil) return sectionController }) ] diff --git a/SectionKit/Tests/SectionController/ProtocolDefaultValuesSectionControllerTests.swift b/SectionKit/Tests/SectionController/ProtocolDefaultValuesSectionControllerTests.swift index d01408be..dde22eac 100644 --- a/SectionKit/Tests/SectionController/ProtocolDefaultValuesSectionControllerTests.swift +++ b/SectionKit/Tests/SectionController/ProtocolDefaultValuesSectionControllerTests.swift @@ -9,7 +9,8 @@ final class ProtocolDefaultValuesSectionControllerTests: XCTestCase { super.setUp() class DefaultSectionController: SectionController { var context: CollectionViewContext? - var dataSource: SectionDataSource = MockSectionDataSource() + let dataSource: SectionDataSource = MockSectionDataSource() + let layoutProvider: SectionLayoutProvider = .flowLayout(nil) func didUpdate(model: Any) { } } sut = DefaultSectionController() diff --git a/SectionKit/Tests/TestUtilities/MockSectionController.swift b/SectionKit/Tests/TestUtilities/MockSectionController.swift index 23ab185b..f5ffef42 100644 --- a/SectionKit/Tests/TestUtilities/MockSectionController.swift +++ b/SectionKit/Tests/TestUtilities/MockSectionController.swift @@ -42,9 +42,10 @@ internal class MockSectionController: SectionController { return MockErrorHandler() }() - internal lazy var layoutProvider: SectionLayoutProvider? = { + @available(iOS 13.0, *) + internal lazy var layoutProvider: SectionLayoutProvider = { XCTFail("layoutProvider is not set") - return nil + return .flowLayout(nil) }() // MARK: - didUpdate From 255b2f4728b86bafaa441cb47259214bea6fd6d3 Mon Sep 17 00:00:00 2001 From: Calvin Chang Date: Fri, 19 Apr 2024 17:14:11 +0200 Subject: [PATCH 2/3] update better naming --- .../VanillaSwiftExamples/Names/NamesSectionController.swift | 2 +- .../Sources/SectionController/SectionController.swift | 6 +++--- .../CompositionalLayout/SectionKitCompositionalLayout.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift b/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift index 06a2f97c..5830afa3 100644 --- a/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift +++ b/Example/VanillaSwiftExamples/Sources/VanillaSwiftExamples/Names/NamesSectionController.swift @@ -36,7 +36,7 @@ final class NamesSectionController: ListSectionController< layout.boundarySupplementaryItems = [] } return .compositionalLayout( - .init(layoutSection: { _ in layout }) + .init { _ in layout } ) } diff --git a/SectionKit/Sources/SectionController/SectionController.swift b/SectionKit/Sources/SectionController/SectionController.swift index 7af145c9..88cd4834 100644 --- a/SectionKit/Sources/SectionController/SectionController.swift +++ b/SectionKit/Sources/SectionController/SectionController.swift @@ -64,12 +64,12 @@ public struct CompositionalLayoutProvider { /// - Parameters: /// - layoutEnvironment: the environment value for the layout /// - Returns: The layout for the section - var layoutSection: (_ layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection + var layoutSectionProvider: (_ layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection public init( - layoutSection: @escaping (any NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection + layoutSectionProvider: @escaping (any NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection ) { - self.layoutSection = layoutSection + self.layoutSectionProvider = layoutSectionProvider } } diff --git a/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift b/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift index 71aa453d..d5d081e8 100644 --- a/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift +++ b/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift @@ -23,7 +23,7 @@ final public class SectionKitCompositionalLayout: UICollectionViewCompositionalL assertionFailure("Please set the layout provider with `CompositionalLayoutProvider`") return .empty } - return provider.layoutSection(environment) + return provider.layoutSectionProvider(environment) } sections = { [weak self] in self?.sections?() ?? [] From 23a7a128078d973700dc76329a5cbe21d2bd3759 Mon Sep 17 00:00:00 2001 From: Calvin Chang Date: Fri, 19 Apr 2024 17:41:26 +0200 Subject: [PATCH 3/3] make better assertion --- .../CompositionalLayout/SectionKitCompositionalLayout.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift b/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift index d5d081e8..d507b952 100644 --- a/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift +++ b/SectionKit/Sources/Utility/CompositionalLayout/SectionKitCompositionalLayout.swift @@ -20,7 +20,8 @@ final public class SectionKitCompositionalLayout: UICollectionViewCompositionalL return .empty } guard case .compositionalLayout(let provider) = sections[index].controller.layoutProvider else { - assertionFailure("Please set the layout provider with `CompositionalLayoutProvider`") + let sectionType = String(describing: type(of: sections[index].controller)) + assertionFailure("Please set the layout provider with `CompositionalLayoutProvider` in \(sectionType)") return .empty } return provider.layoutSectionProvider(environment)