@@ -34,44 +34,44 @@ public enum SPDiffableCollectionCellProviders {
3434
3535 @available ( iOS 14 , * )
3636 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+ }
3744 let cellProvider : SPDiffableCollectionCellProvider = { ( collectionView, indexPath, item) -> UICollectionViewCell ? in
3845 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- }
4646 return collectionView. dequeueConfiguredReusableCell ( using: cellRegistration, for: indexPath, item: item)
4747 }
4848 return cellProvider
4949 }
5050
5151 @available ( iOS 14 , * )
5252 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+ }
5357 let cellProvider : SPDiffableCollectionCellProvider = { ( collectionView, indexPath, item) -> UICollectionViewCell ? in
5458 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- }
5959 return collectionView. dequeueConfiguredReusableCell ( using: cellRegistration, for: indexPath, item: item)
6060 }
6161 return cellProvider
6262 }
6363
6464 @available ( iOS 14 , * )
6565 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+ }
6673 let cellProvider : SPDiffableCollectionCellProvider = { ( collectionView, indexPath, item) -> UICollectionViewCell ? in
6774 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- }
7575 return collectionView. dequeueConfiguredReusableCell ( using: cellRegistration, for: indexPath, item: item)
7676 }
7777 return cellProvider
0 commit comments