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

Provide initialiser for custom TableBorderSelector #373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adJGraeser
Copy link

Currently there is no way to create a custom TableBorderSelector, since the initialiser of TableBorderSelector and TableBounds aren't exposed. This PR changes those to public. With that we can now create custom TableBorderSelector like this one:

extension TableBorderSelector {
    public static var firstHorizontalBorder: TableBorderSelector {
        TableBorderSelector { tableBounds, borderWidth in
            guard tableBounds.rowCount >= 1 else { return [] }

            return [
                tableBounds.bounds(forRow: 0)
                    .insetBy(dx: -borderWidth, dy: -borderWidth)
            ]
                .map {
                    CGRect(
                        origin: .init(x: $0.minX, y: $0.maxY - borderWidth),
                        size: .init(width: $0.width, height: borderWidth)
                    )
                }
        }
    }
}

…aliser of TableBorderSelector and TableBounds
@adJGraeser adJGraeser changed the title custom-tableborderselector: custom-tableborderselector: Provide initi… Provide initialiser for custom TableBorderSelector Dec 13, 2024
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

Successfully merging this pull request may close these issues.

1 participant