-
Notifications
You must be signed in to change notification settings - Fork 45
SupplementaryViewFactory for section headers and footers #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That addition makes a lot of sense, as supplementary view support is currently lacking. I left a couple of small question for you, and thanks for the PR
@@ -97,6 +100,10 @@ public class CollectionViewItemsController<CollectionType>: NSObject, UICollecti | |||
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |||
cellFactory(self, collectionView, indexPath, collection[indexPath.section][indexPath.row]) | |||
} | |||
|
|||
public func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { | |||
return configureSupplementaryView!(self, collectionView, kind, indexPath, collection[indexPath.section]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configureSupplementaryView is optional, right? do you need to force unwrap it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes because the collection view delegate method requires a returned supplementary view. Unless we were to guard it and cause a fatal error with a message saying the property must not be nil
@@ -31,6 +32,8 @@ public class CollectionViewItemsController<CollectionType>: NSObject, UICollecti | |||
|
|||
/// A fallback data source to implement custom logic like indexes, dragging, etc. | |||
public var dataSource: UICollectionViewDataSource? | |||
|
|||
open var configureSupplementaryView: SupplementaryViewFactory? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a specific reason this property needs to be open
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, will change this to public
@icanzilb Updated the PR |
Looks good thank you! Will go about merging it when I have a moment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@alexjameslittle I'm sorry but I merged this by mistake. There were no tests for the new code - could you create a separate PR with those? |
No description provided.