DataSourceKit
DataSourceKit copied to clipboard
Introduce data structure for sections
Currently, declarations of contents of UITableView are expressed by [CellDeclaration]. One idea to support sections is expressing sections by some type like [TableViewSectionDeclaration<CellDeclaration>].
struct TableViewSectionDeclaration<CellDeclaration> {
let headerTitle: String?
let footerTitle: String?
let cellDeclarations: [CellDeclaration]
init(
headerTitle: String? = nil,
footerTitle: String? = nil,
declareCells: @escaping (@escaping (CellDeclaration) -> Void) -> Void) {
...
}
}
With TableViewSectionDeclaration<CellDeclaration>, a conformer may look like:
class ViewController: SectionsDeclarator {
enum CellDeclaration {
case a, b
}
func declareSections(_ section: (TableViewSectionDeclaration<CellDeclaration>) -> Void) {
section(TableViewSectionDeclaration(headerTitle: "A") { cell in
cell(.a)
})
section(TableViewSectionDeclaration(headerTitle: "B") { cell in
cell(.b)
cell(.b)
cell(.b)
})
}
}
Hey, thanks for sharing your thoughts. This proposal would add support for PR #9 and PR #10 right ? Any updates on this ? We are currently maintaining a fork for both of these features to work.