Skip to content
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

Fix model for table view headers/footers #100

Open
jessesquires opened this issue Jan 28, 2018 · 1 comment
Open

Fix model for table view headers/footers #100

jessesquires opened this issue Jan 28, 2018 · 1 comment

Comments

@jessesquires
Copy link
Collaborator

jessesquires commented Jan 28, 2018

We have:

public protocol ReusableSupplementaryViewProtocol {
    var viewInfo: SupplementaryViewInfo? { get }
}

This should be not optional.

This works fine for collections (CollectionViewSupplementaryViewModel) ✅

This will break tables (TableViewSectionHeaderFooterViewModel), which also have a var title: String?. Tables can provide strings to get the default table view headers, or register views. Right now we model this as two optionals:

public protocol TableViewSectionHeaderFooterViewModel: ReusableSupplementaryViewProtocol {
    var title: String? { get }

    // comes from ReusableSupplementaryViewProtocol
    // var viewInfo: SupplementaryViewInfo? { get }

This should probably be an enum instead (essentially: Either<String, SupplementaryViewInfo>).

However, that introduces problems for ReusableSupplementaryViewProtocol, which must be adopted by both tables and collections.

Unless: we provide default "label-only" collection view headers in the library, such that you can just provide a String title for collections too. I'm leaning toward this. If the header just has a UILabel, clients can configure it however they want (fonts, colors, etc.) This is the approach I used in JSQDataSourcesKit: https://github.com/jessesquires/JSQDataSourcesKit/blob/develop/Source/TitledSupplementaryView.swift

@jessesquires jessesquires added this to the Initial Release milestone Jan 28, 2018
@jessesquires
Copy link
Collaborator Author

cc @anayini

This what we discussed yesterday afternoon.

@anayini anayini modified the milestones: Initial Release, Next Release Feb 2, 2018
@jessesquires jessesquires modified the milestone: 0.2.0 Feb 7, 2018
@jessesquires jessesquires self-assigned this Feb 7, 2018
@benasher44 benasher44 modified the milestones: 0.2.0, 0.3.0 Sep 11, 2018
@benasher44 benasher44 modified the milestones: 0.3.0, 0.4.0 Sep 20, 2018
@jessesquires jessesquires removed their assignment Jan 7, 2019
@jessesquires jessesquires modified the milestones: 0.4.0, Next Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants