From 31eddcedb950fa5e35844489d5676086cad8f67f Mon Sep 17 00:00:00 2001 From: Apptek Studios Date: Tue, 22 Oct 2019 22:34:17 +1000 Subject: [PATCH] Remove ASCollectionLayoutFlow in favour of UICollectionViewFlowLayout --- .../ASCollectionViewDemo/Screens/Tags/TagsScreen.swift | 4 ++-- Sources/ASCollectionView/ASCollectionViewLayout.swift | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Demo/ASCollectionViewDemo/Screens/Tags/TagsScreen.swift b/Demo/ASCollectionViewDemo/Screens/Tags/TagsScreen.swift index 1f7c2e4..2e62090 100644 --- a/Demo/ASCollectionViewDemo/Screens/Tags/TagsScreen.swift +++ b/Demo/ASCollectionViewDemo/Screens/Tags/TagsScreen.swift @@ -18,11 +18,11 @@ struct TagsScreen: View { .font(.title) ASCollectionView( data: store.items, - layout: .init(layout: { + layout: ASCollectionViewLayout(customLayout: { let fl = AlignedFlowLayout() fl.estimatedItemSize = UICollectionViewFlowLayout.automaticSize return fl - }()) + }) ) { item in Text(item.displayString) .fixedSize() diff --git a/Sources/ASCollectionView/ASCollectionViewLayout.swift b/Sources/ASCollectionView/ASCollectionViewLayout.swift index a1bded5..acb3d63 100644 --- a/Sources/ASCollectionView/ASCollectionViewLayout.swift +++ b/Sources/ASCollectionView/ASCollectionViewLayout.swift @@ -29,9 +29,9 @@ public struct ASCollectionViewLayout self.layout = .compositional({ _ in layout }, interSectionSpacing: interSectionSpacing, scrollDirection: scrollDirection) // ignore section ID -> all have same layout } - public init(layout: UICollectionViewLayout) + public init(customLayout: (() -> UICollectionViewLayout)) { - self.layout = .custom(layout) + self.layout = .custom(customLayout()) } public func makeLayout(withCoordinator coordinator: ASCollectionView.Coordinator) -> UICollectionViewLayout @@ -134,7 +134,9 @@ public struct ASCollectionViewLayoutList: ASCollectionViewLayoutSection return section } } - +/* + //It is recommended to use UICollectionViewFlowLayout instead (see demo project). The new CompositionalLayout doesn't yet handle flow layouts well. + public struct ASCollectionViewLayoutFlow: ASCollectionViewLayoutSection { var itemSpacing: CGFloat @@ -192,7 +194,7 @@ public struct ASCollectionViewLayoutFlow: ASCollectionViewLayoutSection return section } } - +*/ public struct ASCollectionViewLayoutGrid: ASCollectionViewLayoutSection { var layoutMode: LayoutMode