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
Proposal: Add support for multiple cells types #390
Proposal: Add support for multiple cells types #390
Conversation
Hi @syatyo! Thank you so much for your PR. I have a few comments on your proposal.
pagingViewController.register(LoadingCell.self, for: LoadingItem.self)
pagingViewController.register(nib, for: LoadingItem.self) By default, What do you think about that? |
Thank you for your comments @rechsteiner !
I'll try them! |
193f864
to
27fb000
Compare
Replace new register api, and fix tests
Hi @rechsteiner ! I have just committed them following your comments. Please review them🙇 |
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.
Important changes. I've already checked that all tests are green
|
||
/// The class type for the menu item. Override this if you want | ||
/// your own custom menu items. _Default: PagingTitleCell.self_ | ||
public var menuItemSource: PagingMenuItemSource |
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.
I get rid of old API.
let cell = collectionView.dequeueReusableCell( | ||
withReuseIdentifier: PagingController.CellIdentifier, | ||
withReuseIdentifier: String(describing: type(of: pagingItem)), |
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.
I use Type
name of pagingItem
instance to decide proper cell identifier.
/// Register cell class for paging cell | ||
/// - Parameter cellClass: paging cell's class | ||
/// - Parameter pagingItemType: paging item type for specifying cell identifier | ||
public func register(_ cellClass: AnyClass?, forCellWithPagingItemType pagingItemType: PagingItem.Type) { |
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.
I've added a new API to PagingViewController
as register(_ cellClass: AnyClass?, forCellWithPagingItemType pagingItemType: PagingItem.Type)
. I tried to use similar argument name to UIKit.
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.
Can you rename forCellWithPagingItemType
to just for
?
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.
I completed to rename them!
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.
Great! One more thing, any reason AnyClass
/UINib
is optional?
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.
It's only for consistency to UIKit API.
Awesome, thank you so much for adding this 🙌 |
Proposal
Add support for multiple cells types