Skip to content

Commit a87f402

Browse files
committed
Fixed headerAsFirstCell flag.
1 parent f1cc8e4 commit a87f402

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
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.3.0'
4+
s.version = '1.3.1'
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
3737

3838
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.
3939
*/
40-
public var headerAsFirstElement: Bool = true
40+
public let headerAsFirstCell: Bool
4141

4242
// MARK: - Init
4343

44-
public init(collectionView: UICollectionView, cellProviders: [CellProvider], supplementaryViewProviders: [SupplementaryViewProvider] = []) {
44+
public init(collectionView: UICollectionView, cellProviders: [CellProvider], supplementaryViewProviders: [SupplementaryViewProvider] = [], headerAsFirstCell: Bool = true) {
4545

46+
self.headerAsFirstCell = headerAsFirstCell
4647
self.collectionView = collectionView
4748

4849
super.init(collectionView: collectionView) { (collectionView, indexPath, item) -> UICollectionViewCell? in
@@ -97,7 +98,7 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
9798
for section in sections {
9899
var sectionSnapshot = SPDiffableSectionSnapshot()
99100

100-
if headerAsFirstElement {
101+
if headerAsFirstCell {
101102
let header = section.header
102103
if let header = header {
103104
sectionSnapshot.append([header])

0 commit comments

Comments
 (0)