Cotton code
36 lines · 1.2 KB · SwiftRaw
// A raised sheet's title, drawn over the acts of the one thing it was raised for.import CottonKitimport SwiftUI/// A raised sheet's title: the thing it was raised for, and what it is asked/// of small under it.struct TrayTitle: View {    @Environment(\.theme) private var theme    let title: String    var subject: String? = nil    var body: some View {        VStack(alignment: .leading, spacing: TrayTitleKnobs.pickTitleStackGap) {            // The record's name as its page sets it: two lines, cut at a            // word — never one line cut mid-word ("INV/26…", walker294).            PaperTitleLines(title: title) {                $0.font(theme.type.title(theme.scale.titleSize + 5))                    .foregroundStyle(theme.print(.ink))            }            if let subject {                Text(subject)                    .font(theme.type.hand(theme.scale.handSize + 1))                    .foregroundStyle(theme.print(.pencil))                    .lineLimit(1)            }        }        .accessibilityElement(children: .combine)        .accessibilityAddTraits(.isHeader)    }}/// The gaps TrayTitle draws with: Swift's own, beside their reader.enum TrayTitleKnobs {    static let pickTitleStackGap: CGFloat = 2}