// 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.importCottonPaperimportCottonValuesimportSwiftUIenumDishFaceKnobs {staticlet inset = EdgeInsets(top: 24, leading: 24, bottom: 20, trailing: 22)staticlet titleSize: CGFloat = 22staticlet sumSize: CGFloat = 30staticlet bodySize: CGFloat = 13staticlet bodyLines = 3staticlet pageSize: CGFloat = 14staticlet gap: CGFloat = 12/// A plate's width, of the card's inside.staticlet plateShare: CGFloat = 0.56staticlet plateRim: CGFloat = 5staticlet plateShadow = 0.12staticlet plateShadowRadius: CGFloat = 4staticlet plateShadowDrop: CGFloat = 2staticlet chipSize: CGFloat = 12staticlet chipPad = EdgeInsets(top: 4, leading: 9, bottom: 4, trailing: 10)staticlet chipMark: CGFloat = 8staticlet countSize: CGFloat = 13staticlet dot: CGFloat = 5/// A page not shown, its dot.staticlet dotFaint = 0.4/// How far a swipe travels before it turns a page.staticlet turn: CGFloat = 40}extensionDeckCard {/// A plain card with a picture and a sum is a dish.publicvar isDish: Bool { text("photo") != nil && text("amount") != nil }}/// The ink a dish's kind is marked in; any other kind unmarked.publicenumDishKindMark {publicstaticfunc ink(_ kind: String?) -> PaperInk? {switch kind {case"veg": .greencase"non_veg": .reddefault: nil } }}publicstructDishFace<Picture: View>: View {let card: DeckCardvar 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) privatevar passOn @State privatevar page = 0publicinit( card: DeckCard, picture: Picture?, pages: [CardPage] = [], rating: Double? = nil, mark: PaperInk? = nil, kitchen: CardLabels? = nil ) {self.card = cardself.picture = pictureself.pages = pagesself.rating = ratingself.mark = markself.kitchen = kitchen }publicvar body: someView {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 inlet next = page + (forward ? 1 : -1)if (0..<count).contains(next) { page = next } else { passOn?(forward) } } .animation(.easeOut(duration: 0.18), value: page) .onCardPaper((kitchen == nil ? DishFaceCatalogue.stock : KitchenDishFaceCatalogue.stock).laid(card.pace)) } @ViewBuilder privatevar front: someView {iflet kitchen {KitchenDishFront(card: card, picture: picture, rating: rating, mark: mark, labels: kitchen) } else { plate } }privatevar plate: someView {GeometryReader { room inlet edge = room.size.width * DishFaceKnobs.plateShare VStack(alignment: .leading, spacing: DishFaceKnobs.gap) { HStack {Spacer(minLength: 0)PlateMount(picture: picture) .frame(width: edge, height: edge) .facePart(.picture)Spacer(minLength: 0) }iflet title = card.text("title") {HeavyType(words: title, size: DishFaceKnobs.titleSize) .lineLimit(3) .minimumScaleFactor(0.7) .accessibilityIdentifier("deck-title") .facePart(.title) }let chips = DeckCard.chips(card.text("subtitle"))if !chips.isEmpty { HStack(spacing: 6) {ForEach(Array(chips.enumerated()), id: \.offset) { index, chip inFaceChip(words: chip, mark: index == 0 ? mark : nil) } } .accessibilityElement(children: .combine) .accessibilityIdentifier("face-chips") .facePart(.subtitle) } HStack(alignment: .lastTextBaseline, spacing: 8) {iflet rating { StarRow(rating: rating) }iflet reviews = card.text("count") {Text(reviews) .font(CottonFonts.type(DishFaceKnobs.countSize)) .faceInk(.pencil) .accessibilityIdentifier("face-count") }Spacer(minLength: 0)iflet sum = card.text("amount") {Text(sum) .font(CottonFonts.type(DishFaceKnobs.sumSize)) .lineLimit(1) .minimumScaleFactor(0.6) .faceInk(.ink) .accessibilityIdentifier("face-sum") .facePart(.amount) } }iflet body = card.text("body") {FaceFact(value: body, size: DishFaceKnobs.bodySize, lines: DishFaceKnobs.bodyLines) }Spacer(minLength: 0) } } }privatefunc turned(_ shown: CardPage, count: Int) -> someView { 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 inlet next = page + (forward ? 1 : -1)if (0..<count).contains(next) { page = next } else { passOn?(forward) } }) } .accessibilityIdentifier("face-page-\(page)") }privatefunc dots(_ count: Int) -> someView { HStack(spacing: 6) {Spacer(minLength: 0)ForEach(0..<count, id: \.self) { index inCircle() .frame(width: DishFaceKnobs.dot, height: DishFaceKnobs.dot) .faceInk(index == page ? .ink : .pencil) .opacity(index == page ? 1 : DishFaceKnobs.dotFaint) }Spacer(minLength: 0) } .padding(.top, 8) .accessibilityHidden(true) }privatefunc turning(count: Int) -> someGesture {DragGesture(minimumDistance: 16) .onEnded { end inlet dx = end.translation.widthguard abs(dx) > DishFaceKnobs.turn, abs(dx) > abs(end.translation.height) else { return }let next = page + (dx < 0 ? 1 : -1)if (0..<count).contains(next) { page = next } else { passOn?(dx < 0) } } }}/// A dish's picture on its plate: round, a paper rim around it; with no/// picture, the empty plate.structPlateMount<Picture: View>: View {let picture: Picture? @Environment(\.theme) privatevar themevar body: someView { ZStack {Circle().fill(theme.sheet(.cream))iflet 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.structFaceChip: View {let words: Stringvar mark: PaperInk? @Environment(\.theme) privatevar themevar body: someView { HStack(spacing: 5) {iflet 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.publicenumDishFaceCatalogue {publicstaticlet stock: FaceStock = .framedpublicstaticlet ground: FaceGround = .paperpublicstaticlet face = Face(id: "plain.dish", specimens: [Specimen("dal", dal)]) { card, picture, _ inDishFace(card: card, picture: picture) }publicstaticlet 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."), ])}