Skip to content

Commit

Permalink
Fixed cell registration bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Sep 30, 2021
1 parent 985302e commit d533dea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion SPDiffable.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'SPDiffable'
s.version = '1.4.2'
s.version = '1.5.0'
s.summary = 'Extenshion of Diffable API which allow not duplicate code and use less models.'
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,44 @@ public enum SPDiffableCollectionCellProviders {

@available(iOS 14, *)
public static var sideBarItem: SPDiffableCollectionCellProvider {
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, SPDiffableSideBarItem> { (cell, indexPath, item) in
var content = UIListContentConfiguration.sidebarCell()
content.text = item.title
content.image = item.image
cell.contentConfiguration = content
cell.accessories = item.accessories
}
let cellProvider: SPDiffableCollectionCellProvider = { (collectionView, indexPath, item) -> UICollectionViewCell? in
guard let item = item as? SPDiffableSideBarItem else { return nil }
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, SPDiffableSideBarItem> { (cell, indexPath, item) in
var content = UIListContentConfiguration.sidebarCell()
content.text = item.title
content.image = item.image
cell.contentConfiguration = content
cell.accessories = item.accessories
}
return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
}
return cellProvider
}

@available(iOS 14, *)
public static var sideBarButton: SPDiffableCollectionCellProvider {
let cellRegistration = UICollectionView.CellRegistration<SPDiffableSideBarButtonCollectionViewListCell, SPDiffableSideBarButton> { (cell, indexPath, item) in
cell.updateWithItem(item)
cell.accessories = item.accessories
}
let cellProvider: SPDiffableCollectionCellProvider = { (collectionView, indexPath, item) -> UICollectionViewCell? in
guard let item = item as? SPDiffableSideBarButton else { return nil }
let cellRegistration = UICollectionView.CellRegistration<SPDiffableSideBarButtonCollectionViewListCell, SPDiffableSideBarButton> { (cell, indexPath, item) in
cell.updateWithItem(item)
cell.accessories = item.accessories
}
return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
}
return cellProvider
}

@available(iOS 14, *)
public static var sideBarHeader: SPDiffableCollectionCellProvider {
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, SPDiffableSideBarHeader> { (cell, indexPath, item) in
var content = UIListContentConfiguration.sidebarHeader()
content.text = item.text
content.image = nil
cell.contentConfiguration = content
cell.accessories = item.accessories
}
let cellProvider: SPDiffableCollectionCellProvider = { (collectionView, indexPath, item) -> UICollectionViewCell? in
guard let item = item as? SPDiffableSideBarHeader else { return nil }
let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, SPDiffableSideBarHeader> { (cell, indexPath, item) in
var content = UIListContentConfiguration.sidebarHeader()
content.text = item.text
content.image = nil
cell.contentConfiguration = content
cell.accessories = item.accessories
}
return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
}
return cellProvider
Expand Down

0 comments on commit d533dea

Please sign in to comment.