95 lines · 4.0 KB · SwiftRaw
// Nancy's Naga KITCHEN itself (Codex round 2, nan-kitchen): its name and// address on the band, its photograph (its words large without one), and// its facts. Every word is the core's.import CottonPaperimport CottonValuesimport SwiftUI/// The kitchen itself: its name on the band, its photograph, its facts.public struct KitchenPlaceFace<Photo: View>: View { let card: DeckCard var photo: Photo? var labels = CardLabels() @Environment(\.theme) private var theme /// The facts' symbols, in the order the core says them. static var symbols: [String] { ["scooter", "signpost.right", "mappin.and.ellipse"] } public init(card: DeckCard, photo: Photo? = nil, labels: CardLabels = CardLabels()) { self.card = card self.photo = photo self.labels = labels } public var body: some View { let facts = card.kitchenFacts(saying: Set([card.text("subtitle")].compactMap { $0 })) VStack(alignment: .leading, spacing: 14) { KitchenNameBand(card: card) if let photo { photo .frame(maxWidth: .infinity, maxHeight: .infinity) .clipShape(RoundedRectangle(cornerRadius: KitchenKnobs.radius, style: .continuous)) .padding(.horizontal, KitchenKnobs.side - 8) .accessibilityIdentifier("face-photo") .facePart(.picture) } else if let about = card.text("body") { KitchenHeading(words: about, size: 34) .minimumScaleFactor(0.5) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) .padding(.horizontal, KitchenKnobs.side) .facePart(.body) } ForEach(Array(facts.prefix(3).enumerated()), id: \.offset) { index, fact in KitchenFact(label: fact.label, said: fact.said, symbol: Self.symbols[index % Self.symbols.count]) } .padding(.horizontal, KitchenKnobs.side) if photo != nil, let about = card.text("body") { Text(about).font(theme.type.body(KitchenKnobs.body)).foregroundStyle(theme.colors.inkBody.color) .lineLimit(3).padding(.horizontal, KitchenKnobs.side) .facePart(.body) } } .padding(.bottom, KitchenKnobs.foot) .onCardPaper(KitchenPlaceFaceCatalogue.stock.laid(card.pace)) }}private struct KitchenNameBand: 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: 36, ink: cream) .lineLimit(2).minimumScaleFactor(0.6).accessibilityIdentifier("deck-title") .facePart(.title) } if let address = card.text("subtitle") { Text(address).font(theme.type.body.font(KitchenKnobs.body + 1, weight: .medium)) .foregroundStyle(cream.opacity(KitchenKnobs.faint)).lineLimit(2) .facePart(.subtitle) } } .padding(.horizontal, 32) .padding(.vertical, 20) .frame(maxWidth: .infinity, alignment: .leading) .background(KitchenBand()) }}/// The kitchen's own face, and the cards it is reviewed in. The kitchen's/// kit names it for its place (`nancy.place`), with its table's labels.public enum KitchenPlaceFaceCatalogue { public static let stock: FaceStock = .framed public static let ground: FaceGround = .paper public static let face = Face(id: "nancy.place", specimens: [Specimen("kitchen", kitchen)]) { card, picture, _ in KitchenPlaceFace(card: card, photo: picture, labels: card.labels) } public static let kitchen = DeckCard(face: .plain, fields: [ "title": .text("Invented kitchen"), "subtitle": .text("Invented street"), "body": .text("Invented about."), ])}