// Nancy's Naga Kitchen's ORDER going out (Codex round 2, nan-order): a // delivery — its name and slot on a dark band, the total large, the plan tag // while it is a meal on one, the address, the day due and when it went out, // and Delivered and Paid stamped once its columns hold them. Delivered and // Paid are the table's acts, on the fan. Every word is the core's. import CottonPaper import CottonValues import SwiftUI /// An order going out: its name on the dark band, the total, the plan tag, /// where and when, and the states its columns hold, stamped. public struct KitchenDeliveryFace: View { let card: DeckCard let state: KitchenDeliveryState var labels = CardLabels() var planTag: String? @Environment(\.theme) private var theme public init(card: DeckCard, state: KitchenDeliveryState, labels: CardLabels = CardLabels(), planTag: String? = nil) { self.card = card self.state = state self.labels = labels self.planTag = planTag } public var body: some View { VStack(alignment: .leading, spacing: 14) { KitchenDeliveryBand(card: card) HStack(alignment: .bottom, spacing: 10) { if let total = card.text("amount") { KitchenFigure(label: labels[slot: "amount"], words: total, ink: theme.colors.accent.color) .accessibilityIdentifier("face-sum") .facePart(.amount) } Spacer(minLength: 0) if let planTag { KitchenPlanTag(words: planTag) } } .padding(.horizontal, KitchenKnobs.side) KitchenDeliveryFacts(card: card, labels: labels).padding(.horizontal, KitchenKnobs.side) Spacer(minLength: 0) HStack(spacing: 18) { Spacer(minLength: 0) ForEach(Array(state.stamps(labels).enumerated()), id: \.offset) { index, words in KitchenStamp(words: words, turn: index == 0 ? -7 : 5, ink: index == 0 ? theme.colors.accent.color : theme.colors.ink.color) } } .padding(.horizontal, KitchenKnobs.side) .padding(.bottom, KitchenKnobs.foot) } .padding(KitchenKnobs.inset) .onCardPaper(KitchenDeliveryFaceCatalogue.stock.laid(card.pace)) } } /// Where it goes, the day it is due and the facts past them, each under its /// label by its symbol: the states are stamped, never said twice. private struct KitchenDeliveryFacts: View { let card: DeckCard let labels: CardLabels var body: some View { let skip = Set([labels[slot: "amount"], labels[column: KitchenColumns.delivered], labels[column: KitchenColumns.paid]] .compactMap { $0 }) VStack(alignment: .leading, spacing: 12) { if let address = card.text("body") { KitchenFact(label: labels[slot: "body"], said: address, symbol: "mappin.and.ellipse") .facePart(.body) } if let day = card.text("date") { KitchenFact(label: labels[slot: "date"], said: day, symbol: "calendar").facePart(.when) } ForEach(Array(card.kitchenFacts(except: skip, saying: Set([card.text("date")].compactMap { $0 })).prefix(2).enumerated()), id: \.offset) { _, fact in KitchenFact(label: fact.label, said: fact.said, symbol: "clock") } } } } private struct KitchenDeliveryBand: View { let card: DeckCard @Environment(\.theme) private var theme var body: some View { let cream = theme.colors.paper.color VStack(alignment: .leading, spacing: 4) { if let name = card.text("title") { KitchenHeading(words: name, size: 40, ink: cream) .textCase(.uppercase).lineLimit(2).minimumScaleFactor(0.5).accessibilityIdentifier("deck-title") .facePart(.title) } if let slot = card.text("subtitle") { Text(slot).font(theme.type.body.font(KitchenKnobs.body + 4, weight: .semibold)).foregroundStyle(cream) .facePart(.subtitle) } } .padding(.horizontal, 32) .padding(.vertical, 22) .frame(maxWidth: .infinity, alignment: .leading) .background(KitchenBand(fill: theme.colors.inkBody.color, weave: theme.colors.accent.color)) } } /// The plan tag: the plan column's label on a green capsule. struct KitchenPlanTag: View { let words: String @Environment(\.theme) private var theme var body: some View { HStack(spacing: 8) { Image(systemName: "leaf.fill") Text(words).lineLimit(1) } .font(theme.type.body.font(KitchenKnobs.chip + 1, weight: .semibold)) .foregroundStyle(theme.colors.paper.color) .padding(KitchenKnobs.chipPad) .background(Capsule().fill(theme.colors.ink.color)) .accessibilityIdentifier("kitchen-plan-tag") } } /// The kitchen's delivery face, and the cards it is reviewed in. The /// kitchen's kit names it for its deliveries (`nancy.delivery`), its state as /// its columns hold it (`delivery`; with none, nothing stamped). public enum KitchenDeliveryFaceCatalogue { public static let stock: FaceStock = .framed public static let ground: FaceGround = .paper public static let face = Face(id: "nancy.delivery", specimens: [Specimen("lunch", lunch.reading { $0.delivery = KitchenDeliveryState(delivered: true, paid: false, onPlan: true) $0.labels = CardLabels(bySlot: ["body": "Address", "amount": "Total"], byColumn: ["delivered": "Delivered", "paid": "Paid", "subscription": "Plan"]) })]) { card, _, _ in let state = card.delivery ?? KitchenDeliveryState(delivered: false, paid: false, onPlan: false) KitchenDeliveryFace(card: card, state: state, labels: card.labels, planTag: state.planTag(card.labels)) } public static let lunch = DeckCard(face: .plain, fields: [ "title": .text("Invented lunch"), "subtitle": .text("Lunch"), "body": .text("Invented flat"), "amount": .text("₹598"), ]) }