-
Notifications
You must be signed in to change notification settings - Fork 15
Description
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