| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- // This file was generated using gyb. Do not edit it directly. Edit
- // TableRowContent.swift.gyb instead.
- // swiftformat:options --allow-partial-wrapping true
- %{
- maximum_column_count = 20
- }%
- public protocol TableRowContent<RowValue> {
- associatedtype RowValue
- associatedtype RowContent: View
- var labels: [String] { get }
- func content(for row: RowValue) -> RowContent
- }
- public struct EmptyTableRowContent<RowValue>: TableRowContent {
- public typealias RowContent = EmptyView
- public var labels: [String] {
- []
- }
- public init() {}
- public func content(for row: RowValue) -> EmptyView {
- EmptyView()
- }
- }
- %for i in range(1, maximum_column_count + 1):
- public struct TupleTableRowContent${i}<
- RowValue, ${", ".join("Content%d: View" % j for j in range(i))}
- >: TableRowContent {
- public typealias RowContent = TupleView${i}<
- ${", ".join("Content%d" % j for j in range(i))}
- >
- %for j in range(i):
- public var column${j}: TableColumn<RowValue, Content${j}>
- %end
- public var labels: [String] {
- [${", ".join("column%d.label" % j for j in range(i))}]
- }
- public init(
- ${", ".join("_ column%d: TableColumn<RowValue, Content%d>" % (j, j) for j in range(i))}
- ) {
- %for j in range(i):
- self.column${j} = column${j}
- %end
- }
- public func content(for row: RowValue) -> RowContent {
- TupleView${i}(
- ${", ".join("column%d.content(row)" % j for j in range(i))}
- )
- }
- }
- %end
|