@@ -31,11 +31,13 @@ import UIKit
31
31
open class SPDiffableCollectionDataSource : UICollectionViewDiffableDataSource < SPDiffableSection , SPDiffableItem > {
32
32
33
33
private weak var collectionView : UICollectionView ?
34
-
34
+
35
35
// MARK: - Init
36
36
37
37
public init ( collectionView: UICollectionView , cellProviders: [ CellProvider ] , supplementaryViewProviders: [ SupplementaryViewProvider ] = [ ] ) {
38
38
39
+ self . collectionView = collectionView
40
+
39
41
super. init ( collectionView: collectionView) { ( collectionView, indexPath, item) -> UICollectionViewCell ? in
40
42
for provider in cellProviders {
41
43
if let cell = provider ( collectionView, indexPath, item) {
@@ -91,32 +93,25 @@ open class SPDiffableCollectionDataSource: UICollectionViewDiffableDataSource<SP
91
93
// In this case we shoudn't set header to section snapshot.
92
94
// For this case it condition only.
93
95
let headerAsFirstElement : Bool = {
94
- print ( " collectionView: \( collectionView) " )
95
96
if collectionView? . collectionViewLayout is UICollectionViewFlowLayout {
96
- print ( " return false " )
97
97
return false
98
98
}
99
99
if collectionView? . collectionViewLayout is UICollectionViewCompositionalLayout {
100
- print ( " return true " )
101
100
return true
102
101
}
103
- print ( " return true 2 " )
104
102
return true
105
103
} ( )
106
- print ( " headerAsFirstElement \( headerAsFirstElement) " )
107
104
108
105
for section in sections {
109
106
var sectionSnapshot = SPDiffableSectionSnapshot ( )
110
107
111
108
if headerAsFirstElement {
112
- print ( " call as headerAsFirstElement " )
113
109
let header = section. header
114
110
if let header = header {
115
111
sectionSnapshot. append ( [ header] )
116
112
}
117
113
sectionSnapshot. append ( section. items, to: header)
118
114
} else {
119
- print ( " call as DONT headerAsFirstElement " )
120
115
sectionSnapshot. append ( section. items)
121
116
}
122
117
0 commit comments