@@ -18,6 +18,7 @@ public class CollectionViewItemsController<CollectionType>: NSObject, UICollecti
1818
1919 public typealias Element = CollectionType . Element . Element
2020 public typealias CellFactory < Element: Equatable > = ( CollectionViewItemsController < CollectionType > , UICollectionView , IndexPath , Element ) -> UICollectionViewCell
21+ public typealias SupplementaryViewFactory = ( CollectionViewItemsController < CollectionType > , UICollectionView , String , CollectionType . Element ) -> UICollectionReusableView
2122 public typealias CellConfig < Element, Cell> = ( Cell , IndexPath , Element ) -> Void
2223
2324 private let cellFactory : CellFactory < Element >
@@ -31,6 +32,8 @@ public class CollectionViewItemsController<CollectionType>: NSObject, UICollecti
3132
3233 /// A fallback data source to implement custom logic like indexes, dragging, etc.
3334 public var dataSource : UICollectionViewDataSource ?
35+
36+ open var configureSupplementaryView : SupplementaryViewFactory ?
3437
3538 // MARK: - Init
3639
@@ -97,6 +100,10 @@ public class CollectionViewItemsController<CollectionType>: NSObject, UICollecti
97100 public func collectionView( _ collectionView: UICollectionView , cellForItemAt indexPath: IndexPath ) -> UICollectionViewCell {
98101 cellFactory ( self , collectionView, indexPath, collection [ indexPath. section] [ indexPath. row] )
99102 }
103+
104+ public func collectionView( _ collectionView: UICollectionView , viewForSupplementaryElementOfKind kind: String , at indexPath: IndexPath ) -> UICollectionReusableView {
105+ return configureSupplementaryView!( self , collectionView, kind, collection [ indexPath. section] )
106+ }
100107
101108 // MARK: - Fallback data source object
102109 override public func forwardingTarget( for aSelector: Selector ! ) -> Any ? {
0 commit comments