// The DISH face (Nancy's kitchen, 23 Oct 2026): a plain card (`PlainFace`) // with a picture and a sum is a dish on its plate — the picture round in the // middle, the title typed heavy, the kind and the spice as chips (`subtitle` // and its `also`, cut where the core joined them; the kind marked green for // vegetarian, red for meat, as an Indian menu marks them), the rating in // stars beside the number of reviews (`count`), the price large, and the // start of the description (`body`). The columns its card turns to // (`card.pages`: the description, then what buyers say) are the pages after // it, each under its column's label and cut to the room as a note's. Every // word is the core's (`DeckCard`); the face lays them out. The app reads the // rating, the kind and the pages off the dish's table (CottonUI's // `DeckCardFill`) and hands them in on its card. In Nancy's app the kitchen's // own front is drawn instead (`KitchenDishFront`), with the same pages. import CottonPaper import CottonValues import SwiftUI enum DishFaceKnobs { static let inset = EdgeInsets(top: 24, leading: 24, bottom: 20, trailing: 22) static let titleSize: CGFloat = 22 static let sumSize: CGFloat = 30 static let bodySize: CGFloat = 13 static let bodyLines = 3 static let pageSize: CGFloat = 14 static let gap: CGFloat = 12 /// A plate's width, of the card's inside. static let plateShare: CGFloat = 0.56 static let plateRim: CGFloat = 5 static let plateShadow = 0.12 static let plateShadowRadius: CGFloat = 4 static let plateShadowDrop: CGFloat = 2 static let chipSize: CGFloat = 12 static let chipPad = EdgeInsets(top: 4, leading: 9, bottom: 4, trailing: 10) static let chipMark: CGFloat = 8 static let countSize: CGFloat = 13 static let dot: CGFloat = 5 /// A page not shown, its dot. static let dotFaint = 0.4 /// How far a swipe travels before it turns a page. static let turn: CGFloat = 40 } extension DeckCard { /// A plain card with a picture and a sum is a dish. public var isDish: Bool { text("photo") != nil && text("amount") != nil } } /// The ink a dish's kind is marked in; any other kind unmarked. public enum DishKindMark { public static func ink(_ kind: String?) -> PaperInk? { switch kind { case "veg": .green case "non_veg": .red default: nil } } } public struct DishFace: View { let card: DeckCard var picture: Picture? var pages: [CardPage] = [] var rating: Double? var mark: PaperInk? /// In Nancy's app the kitchen's own front (`KitchenDishFront`), its /// facts under the package's labels; the pages after it are the same. var kitchen: CardLabels? @Environment(\.deckPassOn) private var passOn @State private var page = 0 public init( card: DeckCard, picture: Picture?, pages: [CardPage] = [], rating: Double? = nil, mark: PaperInk? = nil, kitchen: CardLabels? = nil ) { self.card = card self.picture = picture self.pages = pages self.rating = rating self.mark = mark self.kitchen = kitchen } public var body: some View { let count = 1 + pages.count VStack(alignment: .leading, spacing: 0) { Group { if page == 0 { front } else { turned(pages[page - 1], count: count) } } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) if count > 1 { dots(count) } } .padding(kitchen == nil ? DishFaceKnobs.inset : KitchenKnobs.dishInset) .contentShape(Rectangle()) // A tap turns to the next page, the last back to the first; a swipe // turns either way, and past either end moves card. .onTapGesture { if count > 1 { page = (page + 1) % count } } .facePages(count > 1 ? turning(count: count) : nil, at: "\(page)/\(count)") { forward in let next = page + (forward ? 1 : -1) if (0.. some View { VStack(alignment: .leading, spacing: 10) { FaceLabel(words: shown.label) // The column's words cut to the room as a note's; past its last // page the card turns on, past its first back. FacePages(text: shown.text, size: DishFaceKnobs.pageSize) .environment(\.deckPassOn, { forward in let next = page + (forward ? 1 : -1) if (0.. some View { HStack(spacing: 6) { Spacer(minLength: 0) ForEach(0.. some Gesture { DragGesture(minimumDistance: 16) .onEnded { end in let dx = end.translation.width guard abs(dx) > DishFaceKnobs.turn, abs(dx) > abs(end.translation.height) else { return } let next = page + (dx < 0 ? 1 : -1) if (0..: View { let picture: Picture? @Environment(\.theme) private var theme var body: some View { ZStack { Circle().fill(theme.sheet(.cream)) if let picture { picture .clipShape(Circle()) .padding(DishFaceKnobs.plateRim) } Circle().stroke(theme.colors.hairline.color, lineWidth: 1) } .shadow(color: .black.opacity(DishFaceKnobs.plateShadow), radius: DishFaceKnobs.plateShadowRadius, y: DishFaceKnobs.plateShadowDrop) .accessibilityIdentifier("face-plate") } } /// One of a card's parts as a chip: its words in a hairline capsule, marked /// in an ink when it has one. struct FaceChip: View { let words: String var mark: PaperInk? @Environment(\.theme) private var theme var body: some View { HStack(spacing: 5) { if let mark { Circle() .frame(width: DishFaceKnobs.chipMark, height: DishFaceKnobs.chipMark) .faceInk(mark) } Text(words) .font(CottonFonts.type(DishFaceKnobs.chipSize)) .lineLimit(1) .faceInk(.ink) } .padding(DishFaceKnobs.chipPad) .overlay(Capsule().stroke(theme.colors.hairline.color, lineWidth: 1)) } } /// The dish face: a plain card with a picture and a sum, on its plate. No /// card kind names it; the plain face draws it for a dish (`isDish`). /// The fixtures hold no dish, so the specimen's plate is empty. public enum DishFaceCatalogue { public static let stock: FaceStock = .framed public static let ground: FaceGround = .paper public static let face = Face(id: "plain.dish", specimens: [Specimen("dal", dal)]) { card, picture, _ in DishFace(card: card, picture: picture) } public static let dal = DeckCard(face: .plain, fields: [ "title": .text("Invented dal"), "amount": .text("\u{20B9}180"), "subtitle": .text("Veg \u{00B7} Mild"), "count": .text("23 reviews"), "body": .text("An invented dish."), ]) }