// Nancy's Naga Kitchen's DISH (Codex round 2, nan-dish-2; the coordinator's // bar: every fact under its words by its symbol, the face filling its card, // no act drawn on it), wherever a card names it (drawn from Loom's registry): // her terracotta band with the woven strips, the dish on her dark plate // across it, the name heavy and narrow, the kind (marked veg or meat), the // spice and the rating as chips, the start of the description, and the price // a plate and the reviews large at the foot. This is the dish face's front // in her app (`DishFace` with her labels); the pages after it are the dish // face's, with its page dots. Order is the dish's act, on the long-press fan. // No tool name on the card, no logo (none is in the repository). import CottonPaper import CottonValues import SwiftUI public struct KitchenDishFront: View { let card: DeckCard let picture: Picture? var rating: Double? var mark: PaperInk? var labels = CardLabels() public init(card: DeckCard, picture: Picture?, rating: Double? = nil, mark: PaperInk? = nil, labels: CardLabels = CardLabels()) { self.card = card self.picture = picture self.rating = rating self.mark = mark self.labels = labels } public var body: some View { GeometryReader { room in let edge = min(room.size.width * 0.62, room.size.height * 0.37) VStack(spacing: 10) { ZStack(alignment: .top) { KitchenBand().frame(height: edge * 0.72 + 14) KitchenPlate(card: card, picture: picture).frame(width: edge, height: edge).padding(.top, 14) .facePart(.picture) } .frame(height: edge + 14) KitchenDishWords(card: card, rating: rating, mark: mark) Spacer(minLength: 0) KitchenDishFoot(card: card, labels: labels) } } } } /// The dish on her dark plate; with no picture, its name's letters. struct KitchenPlate: View { let card: DeckCard let picture: Picture? @Environment(\.theme) private var theme var body: some View { ZStack { Circle().fill(theme.colors.inkBody.color) if let picture { picture.frame(maxWidth: .infinity, maxHeight: .infinity).clipShape(Circle()).padding(10) } else if case .monogram(let letters)? = KitchenPortrait.of(card) { KitchenInitials(letters: letters).padding(10) } } .shadow(color: .black.opacity(KitchenKnobs.shadow), radius: KitchenKnobs.shadowRadius, y: KitchenKnobs.shadowDrop) .accessibilityIdentifier("face-plate") } } private struct KitchenDishWords: View { let card: DeckCard var rating: Double? var mark: PaperInk? @Environment(\.theme) private var theme var body: some View { VStack(spacing: 8) { if let title = card.text("title") { KitchenHeading(words: title, size: KitchenKnobs.heading - 4) .textCase(.uppercase) .multilineTextAlignment(.center) .lineLimit(2) .minimumScaleFactor(0.6) .fixedSize(horizontal: false, vertical: true) .accessibilityIdentifier("deck-title") .facePart(.title) } HStack(spacing: 6) { ForEach(Array(DeckCard.chips(card.text("subtitle")).enumerated()), id: \.offset) { index, chip in KitchenChip(words: chip, mark: index == 0 ? mark : nil) .facePart(.subtitle) } if let rating { KitchenChip(words: rating.formatted(.number.precision(.fractionLength(1))), symbol: "star.fill") .accessibilityIdentifier("face-rating") } } .accessibilityElement(children: .combine) .accessibilityIdentifier("face-chips") if let body = card.text("body") { Text(body) .font(theme.type.body(KitchenKnobs.body)) .foregroundStyle(theme.colors.inkBody.color) .multilineTextAlignment(.center) .lineLimit(2) .fixedSize(horizontal: false, vertical: true) .facePart(.body) } } .frame(maxWidth: .infinity) .padding(.horizontal, KitchenKnobs.side) } } /// The price a plate and the reviews, each large under its label. private struct KitchenDishFoot: View { let card: DeckCard let labels: CardLabels @Environment(\.theme) private var theme var body: some View { VStack(spacing: 8) { Rectangle().fill(theme.colors.hairline.color).frame(height: 1) HStack(alignment: .bottom, spacing: 12) { if let sum = card.text("amount") { KitchenFigure(label: labels[slot: "amount"], words: sum) .accessibilityIdentifier("face-sum") .facePart(.amount) } Spacer(minLength: 0) if let reviews = card.text("count") { KitchenFigure(label: labels[slot: "count"], words: reviews, size: KitchenKnobs.headingSmall + 4, trailing: true) .accessibilityIdentifier("face-count") } } } .padding(.horizontal, KitchenKnobs.side) } } /// The dish in Nancy's look, and the cards it is reviewed in. The kitchen's /// kit names it for its dishes (`nancy.dish`), with its rating, its kind's /// mark, its pages and its table's labels. The fixtures hold no dish, so the /// plate shows its name's letters. public enum KitchenDishFaceCatalogue { public static let stock: FaceStock = .framed public static let ground: FaceGround = .paper public static let face = Face(id: "nancy.dish", specimens: [Specimen("dish", dish.reading { $0.stars = 4.5 $0.stored = ["subtitle": "veg"] $0.labels = CardLabels(bySlot: ["amount": "Price a plate", "count": "Reviews"]) })]) { card, picture, _ in DishFace(card: card, picture: picture, pages: card.pages, rating: card.stars, mark: DishKindMark.ink(card.stored["subtitle"]), kitchen: card.labels) } public static let dish = DeckCard(face: .plain, fields: [ "title": .text("Invented dal"), "amount": .text("\u{20B9}180"), "subtitle": .text("Veg \u{00B7} Mild"), "count": .text("23"), "body": .text("An invented dish, cooked the morning it leaves."), ]) }