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

Introduce data structure for sections #18

Open
ishkawa opened this issue Oct 14, 2018 · 1 comment
Open

Introduce data structure for sections #18

ishkawa opened this issue Oct 14, 2018 · 1 comment

Comments

@ishkawa
Copy link
Owner

ishkawa commented Oct 14, 2018

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)
        })
    }
}
@dehlen
Copy link
Contributor

dehlen commented Nov 23, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants