Skip to content

Commit f1cc8e4

Browse files
committed
Fixed headerAsFirstElement flag.
1 parent 7a664e2 commit f1cc8e4

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

SPDiffable.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPDiffable'
4-
s.version = '1.2.9'
4+
s.version = '1.3.0'
55
s.summary = 'Extenshion of Diffable API which allow not duplicate code and use less models.'
66
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }

Sources/SPDiffable/DataSource/SPDiffableCollectionDataSource.swift

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
3232

3333
private weak var collectionView: UICollectionView?
3434

35+
/**
36+
SPDiffable: Make section and use header model like first cell.
37+
38+
If you don't use composition layout, no way say to collection system about header elements. Its using random, sometimes its cell provider call, sometimes it call supplementary. In this case we shoudn't set header to section snapshot. For this case it condition only.
39+
*/
40+
public var headerAsFirstElement: Bool = true
41+
3542
// MARK: - Init
3643

3744
public init(collectionView: UICollectionView, cellProviders: [CellProvider], supplementaryViewProviders: [SupplementaryViewProvider] = []) {
@@ -86,22 +93,7 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
8693
}
8794

8895
// Update current sections.
89-
90-
// If you don't use composition layout, no way say to collection system
91-
// about header elements. Its using random, sometimes its
92-
// cell provider call, sometimes it call supplementary.
93-
// In this case we shoudn't set header to section snapshot.
94-
// For this case it condition only.
95-
let headerAsFirstElement: Bool = {
96-
if collectionView?.collectionViewLayout is UICollectionViewCompositionalLayout {
97-
return true
98-
}
99-
if collectionView?.collectionViewLayout is UICollectionViewFlowLayout {
100-
return false
101-
}
102-
return true
103-
}()
104-
96+
10597
for section in sections {
10698
var sectionSnapshot = SPDiffableSectionSnapshot()
10799

0 commit comments

Comments
 (0)