-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
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)
})
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels