Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Sources/MarkdownUI/Views/Blocks/TableBorderSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import SwiftUI
///
/// You use a table border selector to select the visible borders when creating a ``TableBorderStyle``.
public struct TableBorderSelector {
var rectangles: (_ tableBounds: TableBounds, _ borderWidth: CGFloat) -> [CGRect]
public var rectangles: (_ tableBounds: TableBounds, _ borderWidth: CGFloat) -> [CGRect]

public init(rectangles: @escaping (_: TableBounds, _: CGFloat) -> [CGRect]) {
self.rectangles = rectangles
}
}

extension TableBorderSelector {
Expand Down
14 changes: 7 additions & 7 deletions Sources/MarkdownUI/Views/Blocks/TableBounds.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import SwiftUI

struct TableBounds {
var rowCount: Int {
public struct TableBounds {
public var rowCount: Int {
self.rows.count
}

var columnCount: Int {
public var columnCount: Int {
self.columns.count
}

let bounds: CGRect
public let bounds: CGRect

private let rows: [(minY: CGFloat, height: CGFloat)]
private let columns: [(minX: CGFloat, width: CGFloat)]
Expand Down Expand Up @@ -50,20 +50,20 @@ struct TableBounds {
self.columns = columns
}

func bounds(forRow row: Int, column: Int) -> CGRect {
public func bounds(forRow row: Int, column: Int) -> CGRect {
CGRect(
origin: .init(x: self.columns[column].minX, y: self.rows[row].minY),
size: .init(width: self.columns[column].width, height: self.rows[row].height)
)
}

func bounds(forRow row: Int) -> CGRect {
public func bounds(forRow row: Int) -> CGRect {
(0..<self.columnCount)
.map { self.bounds(forRow: row, column: $0) }
.reduce(.null, CGRectUnion)
}

func bounds(forColumn column: Int) -> CGRect {
public func bounds(forColumn column: Int) -> CGRect {
(0..<self.rowCount)
.map { self.bounds(forRow: $0, column: column) }
.reduce(.null, CGRectUnion)
Expand Down