@@ -34,44 +34,44 @@ public enum SPDiffableCollectionCellProviders {
34
34
35
35
@available ( iOS 14 , * )
36
36
public static var sideBarItem : SPDiffableCollectionCellProvider {
37
+ let cellRegistration = UICollectionView . CellRegistration < UICollectionViewListCell , SPDiffableSideBarItem > { ( cell, indexPath, item) in
38
+ var content = UIListContentConfiguration . sidebarCell ( )
39
+ content. text = item. title
40
+ content. image = item. image
41
+ cell. contentConfiguration = content
42
+ cell. accessories = item. accessories
43
+ }
37
44
let cellProvider : SPDiffableCollectionCellProvider = { ( collectionView, indexPath, item) -> UICollectionViewCell ? in
38
45
guard let item = item as? SPDiffableSideBarItem else { return nil }
39
- let cellRegistration = UICollectionView . CellRegistration < UICollectionViewListCell , SPDiffableSideBarItem > { ( cell, indexPath, item) in
40
- var content = UIListContentConfiguration . sidebarCell ( )
41
- content. text = item. title
42
- content. image = item. image
43
- cell. contentConfiguration = content
44
- cell. accessories = item. accessories
45
- }
46
46
return collectionView. dequeueConfiguredReusableCell ( using: cellRegistration, for: indexPath, item: item)
47
47
}
48
48
return cellProvider
49
49
}
50
50
51
51
@available ( iOS 14 , * )
52
52
public static var sideBarButton : SPDiffableCollectionCellProvider {
53
+ let cellRegistration = UICollectionView . CellRegistration < SPDiffableSideBarButtonCollectionViewListCell , SPDiffableSideBarButton > { ( cell, indexPath, item) in
54
+ cell. updateWithItem ( item)
55
+ cell. accessories = item. accessories
56
+ }
53
57
let cellProvider : SPDiffableCollectionCellProvider = { ( collectionView, indexPath, item) -> UICollectionViewCell ? in
54
58
guard let item = item as? SPDiffableSideBarButton else { return nil }
55
- let cellRegistration = UICollectionView . CellRegistration < SPDiffableSideBarButtonCollectionViewListCell , SPDiffableSideBarButton > { ( cell, indexPath, item) in
56
- cell. updateWithItem ( item)
57
- cell. accessories = item. accessories
58
- }
59
59
return collectionView. dequeueConfiguredReusableCell ( using: cellRegistration, for: indexPath, item: item)
60
60
}
61
61
return cellProvider
62
62
}
63
63
64
64
@available ( iOS 14 , * )
65
65
public static var sideBarHeader : SPDiffableCollectionCellProvider {
66
+ let cellRegistration = UICollectionView . CellRegistration < UICollectionViewListCell , SPDiffableSideBarHeader > { ( cell, indexPath, item) in
67
+ var content = UIListContentConfiguration . sidebarHeader ( )
68
+ content. text = item. text
69
+ content. image = nil
70
+ cell. contentConfiguration = content
71
+ cell. accessories = item. accessories
72
+ }
66
73
let cellProvider : SPDiffableCollectionCellProvider = { ( collectionView, indexPath, item) -> UICollectionViewCell ? in
67
74
guard let item = item as? SPDiffableSideBarHeader else { return nil }
68
- let cellRegistration = UICollectionView . CellRegistration < UICollectionViewListCell , SPDiffableSideBarHeader > { ( cell, indexPath, item) in
69
- var content = UIListContentConfiguration . sidebarHeader ( )
70
- content. text = item. text
71
- content. image = nil
72
- cell. contentConfiguration = content
73
- cell. accessories = item. accessories
74
- }
75
75
return collectionView. dequeueConfiguredReusableCell ( using: cellRegistration, for: indexPath, item: item)
76
76
}
77
77
return cellProvider
0 commit comments