Cotton code
93 lines · 3.9 KB · SwiftRaw
// Nancy's Naga Kitchen's meal PLAN (Codex round 2, nan-plan): the band with// the plan's name and what it is, then the meals and the price large under// their labels, and its days and slot. Every word is the core's.import CottonPaperimport CottonValuesimport SwiftUI/// A meal plan: the band with its name and words, its meals and price large/// under their labels, its days and slot by their symbols.public struct KitchenPlanFace: View {    let card: DeckCard    var labels = CardLabels()    @Environment(\.theme) private var theme    public init(card: DeckCard, labels: CardLabels = CardLabels()) {        self.card = card        self.labels = labels    }    public var body: some View {        let parts = DeckCard.chips(card.text("subtitle"))        VStack(spacing: 18) {            KitchenPlanBand(card: card)            HStack(alignment: .bottom, spacing: 14) {                if let meals = parts.first { KitchenFigure(label: labels[slot: "subtitle"], words: meals, size: 58).facePart(.subtitle) }                Spacer(minLength: 0)                Rectangle().fill(theme.colors.hairline.color).frame(width: 1, height: 56)                Spacer(minLength: 0)                if let price = card.text("price") {                    KitchenFigure(label: labels[slot: "price"], words: price, size: 58, ink: theme.colors.accent.color, trailing: true)                        .accessibilityIdentifier("face-sum")                }            }            .padding(.horizontal, KitchenKnobs.side)            HStack(alignment: .top, spacing: 12) {                if let period = card.text("period") {                    KitchenFact(label: labels[slot: "period"], said: period, symbol: "calendar")                }                if let slot = parts.dropFirst().first {                    KitchenFact(label: labels[column: "slot"], said: slot, symbol: "fork.knife")                }            }            .padding(.horizontal, KitchenKnobs.side)            .padding(.bottom, KitchenKnobs.foot)        }        .padding(KitchenKnobs.inset)        .onCardPaper(KitchenPlanFaceCatalogue.stock.laid(card.pace))    }}private struct KitchenPlanBand: View {    let card: DeckCard    var slot: String?    @Environment(\.theme) private var theme    var body: some View {        let cream = theme.colors.paper.color        VStack(spacing: 12) {            if let slot { KitchenLabel(words: slot, ink: cream.opacity(KitchenKnobs.faint)) }            if let title = card.text("title") {                KitchenHeading(words: title, size: 50, ink: cream)                    .multilineTextAlignment(.center).lineLimit(3).minimumScaleFactor(0.55)                    .accessibilityIdentifier("deck-title")                    .facePart(.title)            }            if let body = card.text("body") {                Text(body).font(theme.type.body(KitchenKnobs.body + 4)).foregroundStyle(cream.opacity(KitchenKnobs.faint))                    .multilineTextAlignment(.center).lineLimit(4)                    .facePart(.body)            }        }        .padding(.horizontal, 34)        .padding(.vertical, 24)        .frame(maxWidth: .infinity, maxHeight: .infinity)        .background(KitchenBand())    }}/// The kitchen's plan face, and the cards it is reviewed in. The kitchen's/// kit names it for its plans (`nancy.plan`), with its table's labels.public enum KitchenPlanFaceCatalogue {    public static let stock: FaceStock = .framed    public static let ground: FaceGround = .paper    public static let face = Face(id: "nancy.plan", specimens: [Specimen("plan", plan)]) { card, _, _ in        KitchenPlanFace(card: card, labels: card.labels)    }    public static let plan = DeckCard(face: .subscription, fields: [        "title": .text("Invented plan"), "subtitle": .text("10 meals · Lunch"), "price": .text("₹2,299"),        "period": .text("Weekdays"), "body": .text("Invented lunches."),    ])}