// The BIRTHDAY face (reference `birthdays.png` and its cases) — the face of// a tool that reads another tool's table (Birthdays reads people). The// person in a round mount at the top with a sprig beside it, the name typed// heavy under it, their place in pencil and the corner's "why now" written in// red over a stroke of the pen when the core says one, a rule, then the cake// at the left and the facts at the right, filling the card's foot — the// birthday by hand under its label, the age it turns, whether wishes are// sent, when last wished. Every word is the core's (`DeckCard`).importCottonPaperimportCottonValuesimportSwiftUIenumBirthdayFaceKnobs {staticlet inset = EdgeInsets(top: 22, leading: 22, bottom: 20, trailing: 20)staticlet mountShare: CGFloat = 0.42staticlet nameSize: CGFloat = 25staticlet placeSize: CGFloat = 13staticlet cornerHand: CGFloat = 25staticlet swash: CGSize = CGSize(width: 150, height: 7)staticlet factSize: CGFloat = 15.5staticlet factGap: CGFloat = 7staticlet dateHand: CGFloat = 29staticlet cakeShare: CGFloat = 0.43staticlet wishMark: CGFloat = 30}publicstructBirthdayFace<Photo: View>: View {let card: DeckCard/// The person's photograph filling its frame; nil draws their initials.var photo: Photo? @Environment(\.theme) privatevar themepublicinit(card: DeckCard, photo: Photo? = nil) {self.card = cardself.photo = photo }publicvar body: someView {GeometryReader { sheet inlet mount = sheet.size.width * BirthdayFaceKnobs.mountShare VStack(spacing: 0) { ZStack {Group {iflet photo {MountedPrint(photo: photo) } else {InitialsMount(name: card.text("title") ?? "") } } .frame(width: mount, height: mount) .clipShape(Circle()) .overlay(Circle().stroke(theme.print(.pencil).opacity(0.6), lineWidth: 1)) .padding(4) .overlay(Circle().stroke(theme.print(.pencil).opacity(0.35), lineWidth: 0.8)) .facePart(.picture)FaceArt(name: "face-art-sprig") .frame(height: mount * 0.95) .offset(x: mount * 0.72) }iflet name = card.text("title") {HeavyType(words: name, size: BirthdayFaceKnobs.nameSize) .lineLimit(1) .minimumScaleFactor(0.7) .padding(.top, 10) .accessibilityIdentifier("deck-title") .facePart(.title) }iflet place = card.text("subtitle") {Text(place) .font(CottonFonts.type(BirthdayFaceKnobs.placeSize)) .lineLimit(1) .faceInk(.pencil) .padding(.top, 2) .facePart(.subtitle) }// The corner's "why now" ("Birthday in 3 days") written in red// with a stroke of the pen under it, when the core says one.iflet corner = card.corner {Text(HandRun.tail(corner)) .font(CottonFonts.hand(BirthdayFaceKnobs.cornerHand)) .lineLimit(1) .minimumScaleFactor(0.7) .faceInk(.red) .overlay(alignment: .bottom) {PenSwash() .stroke(theme.print(.red), style: StrokeStyle(lineWidth: 1.3, lineCap: .round)) .frame(width: BirthdayFaceKnobs.swash.width, height: BirthdayFaceKnobs.swash.height) .offset(y: BirthdayFaceKnobs.swash.height) .blendMode(theme.printBlend) } .rotationEffect(.degrees(-3)) .padding(.top, 2) .accessibilityIdentifier("face-corner") .facePart(.when) }FaceHairline() .padding(.top, 8) HStack(alignment: .center, spacing: 10) {FaceArt(name: "face-art-cake") .frame(width: sheet.size.width * BirthdayFaceKnobs.cakeShare) VStack(alignment: .leading, spacing: BirthdayFaceKnobs.factGap) {iflet date = card.text("date") { VStack(alignment: .leading, spacing: 0) {iflet label = card.label("date") { FaceLabel(words: label) }Text(HandRun.tail(date)) .font(CottonFonts.hand(BirthdayFaceKnobs.dateHand)) .lineLimit(1) .minimumScaleFactor(0.7) .faceInk(.ink) .fixedSize(horizontal: false, vertical: true) } .facePart(.when) .layoutPriority(1) }// The age it comes round to ("turns 35", said whole),// then when they were last wished under its label.iflet turns = card.text("turns") {FaceHairline()FaceFact(value: turns, size: BirthdayFaceKnobs.factSize) }// Wishes are sent: the words, the inked envelope after them.if card.fields["wishes"] == .bool(true) {FaceHairline() HStack(spacing: 8) {iflet label = card.label("wishes") {Text(label) .font(CottonFonts.type(BirthdayFaceKnobs.factSize)) .lineLimit(1) .minimumScaleFactor(0.7) .faceInk(.ink) }FaceArt(name: "act-bubble") .frame(height: BirthdayFaceKnobs.wishMark) } .accessibilityElement(children: .combine) }iflet wished = card.text("last_wished") {FaceHairline()FaceFact(label: card.label("last_wished"), value: wished, size: BirthdayFaceKnobs.factSize) } } } .padding(.vertical, 8) .frame(maxHeight: .infinity) } .padding(BirthdayFaceKnobs.inset) } .onCardPaper(BirthdayFaceCatalogue.stock.laid(card.pace)) }}/// The birthday face, by the kind's name, and the cards it is reviewed in.publicenumBirthdayFaceCatalogue {publicstaticlet stock: FaceStock = .creampublicstaticlet ground: FaceGround = .paperpublicstaticlet face = Face(id: "birthday", specimens: [Specimen("birthday", birthday, picture: "portrait")]) { card, picture, _ inBirthdayFace(card: card, photo: picture) }publicstaticlet birthday = DeckCard(face: .birthday, fields: ["title": .text("Ravi Example"),"date": .text("Thu 29 Oct"),"turns": .text("turns 52"),"wishes": .bool(true),"last_wished": .text("a year ago"),"photo": .text("portrait"), ])}