// HOME AS A DECK (row C of the deck faces): Home's today is a deck of cards,// never a list — each of today's events and todos due today (the day read,// `TodayFeedModel`) and each unread conversation (the thread table's own// cards), then Home's notices, asked and done, each a card (`HomePartCard`).// A day's row is the framed cream card with its tool's picture, what it is// typed small (its table's name), its title typed heavy, where it is and the// people on it (its record's own card), and its time on the day by hand// ("4:30 pm", "due today"), struck through once done — drawn only for a row// whose table's own face is not (CottonUI's `HomeToday.drawn`): a row read as// its record draws its tool's face, as an unread thread draws its own// (`ThreadSlipsFace`). A tap opens the record. The tool's picture is the app's// (`object`, CottonUI's `ToolObject` at the side the face gives it); the// row's words are a plain `TodayItem`.importCottonPaperimportCottonValuesimportSwiftUIpublicenumTodayFaceKnobs {/// A title longer than this many characters draws the picture smaller.publicstaticlet longTitle = 48publicstaticlet pictureShareLong: CGFloat = 0.26publicstaticlet inset = EdgeInsets(top: 26, leading: 26, bottom: 22, trailing: 22)publicstaticlet pictureShare: CGFloat = 0.5publicstaticlet titleSize: CGFloat = 28publicstaticlet lineHand: CGFloat = 30publicstaticlet placeSize: CGFloat = 15publicstaticlet mount: CGFloat = 34}publicstructTodayFace<Object: View>: View {let today: TodayItem/// What the row is, in its table's own name ("Todo", "Event").let kind: String?/// The record's own card, once read: its place and people.var card: DeckCard? = nil/// The tool's picture, at the side the face gives it.let object: (_ side: CGFloat) -> Objectpublicinit(today: TodayItem, kind: String?, card: DeckCard? = nil, @ViewBuilder object: @escaping (_ side: CGFloat) -> Object) {self.today = todayself.kind = kindself.card = cardself.object = object }publicvar body: someView {GeometryReader { sheet in// A long title takes room from the picture, never the foot.let share = today.title.count > TodayFaceKnobs.longTitle ? TodayFaceKnobs.pictureShareLong : TodayFaceKnobs.pictureShare VStack(alignment: .leading, spacing: 0) {iflet kind { FaceKind(words: kind).facePart(.subtitle) } object(sheet.size.width * share) .frame(width: sheet.size.width * share, height: sheet.size.width * share) .facePart(.picture) .frame(maxWidth: .infinity) .padding(.top, 6) .accessibilityHidden(true)// A long title wraps on into the room below before it is cut.HeavyType(words: today.title, size: TodayFaceKnobs.titleSize) .lineLimit(5) .minimumScaleFactor(0.7) .strikethrough(today.done) .padding(.top, 12) .accessibilityIdentifier("deck-title") .facePart(.title)iflet place = card?.text("place") {Text(place) .font(CottonFonts.type(TodayFaceKnobs.placeSize)) .lineLimit(2) .faceInk(.ink) .padding(.top, 8) .facePart(.place) }let people = card?.entries("people") ?? []if !people.isEmpty { HStack(spacing: 8) {ForEach(Array(people.enumerated()), id: \.offset) { _, entry inFaceMount(name: entry["name"]?.text ?? "", picture: entry["picture"]?.text, size: TodayFaceKnobs.mount) }iflet more = card?.text("people_more") {Text(more) .font(CottonFonts.type(FacePartsKnobs.labelSize + 1)) .faceInk(.pencil) } } .padding(.top, 10) .facePart(.people) }Spacer(minLength: 8)iflet line = today.line {Text(HandRun.tail(line)) .font(CottonFonts.hand(TodayFaceKnobs.lineHand)) .lineLimit(1) .minimumScaleFactor(0.7) .faceInk(.ink) .rotationEffect(.degrees(-3)) .facePart(.when) } } .padding(TodayFaceKnobs.inset) .opacity(today.done ? 0.6 : 1) } .onCardPaper(TodayFaceCatalogue.stock.laid(card?.pace)) }}/// The day's row face, and the cards it is reviewed in. No card kind names/// it: Home draws a day's row with it (CottonUI's `HomeToday`) where no/// table's face can. From a card, its title, its line (`date`) and whether/// it is done (`check`), what it is (`subtitle`), its place and people.publicenumTodayFaceCatalogue {publicstaticlet stock: FaceStock = .framedpublicstaticlet ground: FaceGround = .paperpublicstaticlet face = Face(id: "cotton.today", specimens: [Specimen("dinner", dinner)]) { card, picture, _ inTodayFace(today: TodayItem(title: card.text("title") ?? "", done: card.checked == true, line: card.text("date")), kind: card.text("subtitle"), card: card) { side iniflet picture { picture.frame(width: side, height: side) } } }publicstaticlet dinner = DeckCard(face: .event, fields: ["title": .text("Dinner"),"subtitle": .text("Event"),"date": .text("8:00 pm"),"place": .text("12 Example Lane, Indiranagar"),"people": .list([ .object(["name": .text("Priya Example"), "picture": .text("guest-0")]), .object(["name": .text("Arjun Rao")]), ]), ])}