// The TODO as an INDEX CARD in a TRAY (the coordinator's pick for Todos, // owner, 29 Oct 2026: "most of your things look good"; the todo picture // `objects-2/todos/3-punched-card`): a ruled cream index card standing at the // front of a worn green-grey steel card tray, the cards behind it showing // their coloured tabs, the tray bare on the todos' dark teal baize // (`FaceGround.baizeTeal`) with no paper and no rule of the deck's. The tray, its // stack, its front wall, its shadow, the card with its rules and the blank // tabs are PAINTED (`Media.xcassets`, cut and imported by // `scripts/import-todos-materials.py`); the face draws live only what the // card decides, typed on the painted rules in Courier Prime: // // the title on the first rule under the red head rule, one line or two // and no further — a title that wants a third stops at the second's last // whole word, with no ellipsis: a card just stops. // the description's opening on the rules after it, as many whole lines as // the card holds above the tray's lip, stopping at the last whole word // that fits: nothing scrolls, no pages, no "and more". // "made " on the last rule the lip leaves showing: the card's own // label for its made place and the day the core says. // the due date on a tab standing up behind the card's top right — the // card's date words typed in capitals, the tab as long as they need; a red // tab once the day is behind (the card's `pressing`); no tab at all for a // todo with no date. // the completed card's word rubber-stamped across its head in worn ink, // the title struck through in pencil; an open card's head stays bare. // // Tagged parts: the title, the description (body), the tab (when), the stamp // (done, the face's own toggle) and, for a todo with no date, the bare place // where the tab would stand (corner), so a date is given from the card. The // day it was made is no part: nothing writes it. Tap steps keep the card // in place so the stamp lands and lifts. // // Every word is the core's (`DeckCard`): the face only types them on the // rules. import CottonPaper import CottonValues import CoreText import SwiftUI enum TodoCardFaceKnobs { // THE TRAY, as painted (`todo-tray`, cut from 1388 by 1003 pixels): its // width over its height; the lip's top edge and the front wall's layer // (`todo-tray-front`, 1140 by 276) as shares of its height; the stack's // front card's left and right edges as shares of its width, which the // front card covers; how far its shadow (`todo-tray-shadow`, 804 by // 612) reaches past it on every side, as a share of its width — // measured off the painting by the cut that made the layers (`cut.py` // beside them), so a repainted tray owes new knobs. static let trayAspect: CGFloat = 1388.0 / 1003.0 static let lip: CGFloat = 0.667 static let frontTop: CGFloat = 0.665 static let frontAspect: CGFloat = 1140.0 / 276.0 static let stackLeft: CGFloat = 0.0857 static let stackRight: CGFloat = 0.9222 static let shadowReach: CGFloat = 0.0793 static let shadowAspect: CGFloat = 804.0 / 612.0 /// The tray in the card's room: the most of its width it takes, and of /// its height. static let fillWidth: CGFloat = 0.96 static let fillHeight: CGFloat = 0.96 // THE CARD, as painted (`todo-card`, cut from 1462 by 786): its width // over its height, the red head rule's and each blue rule's height as // shares of it. static let cardAspect: CGFloat = 1462.0 / 786.0 static let head: CGFloat = 0.1833 static let rules: [CGFloat] = [0.3007, 0.4189, 0.5368, 0.6604, 0.7834, 0.9098] /// The card stands this far past the stack's card on either side, as a /// share of the tray's width, and its top this far down the tray, as a /// share of the tray's height: proud of the cards behind it, under their /// tabs, five of its rules showing above the lip. static let overhang: CGFloat = 0.006 static let top: CGFloat = 0.13 /// The rules showing above the lip: the title's, the description's and /// the made day's. static let shown = 5 // THE TAB (`todo-tab`, 720 by 102; `todo-tab-late`, 720 by 71): its // height as a share of the card's width, the share of it hidden behind // the card, its right end's distance in from the card's right edge; // each painting's tapered ends, as shares of its own height, which keep // their painted size while the tab stretches between them to its words. static let tabHeight: CGFloat = 0.09 static let tabBuried: CGFloat = 0.2 static let tabInset: CGFloat = 0.03 static let tabAspect: CGFloat = 720.0 / 102.0 static let tabEnds: CGFloat = 0.7225 static let lateTabAspect: CGFloat = 720.0 / 71.0 static let lateTabEnds: CGFloat = 0.59 /// The tab's words, as a share of its height, and the room either side /// of them inside the tapered ends, as a share of its height; the /// shortest and the longest a tab may be, as shares of the card's width. static let tabSize: CGFloat = 0.5 static let tabPad: CGFloat = 0.25 static let tabShortest: CGFloat = 0.3 static let tabLongest: CGFloat = 0.64 // THE TYPE, as shares of the card's height (at a phone's card, about // 16 and 14 points on rules 18 apart): print on an object scales with // the object, never with Dynamic Type. static let titleSize: CGFloat = 0.108 static let bodySize: CGFloat = 0.092 /// The writing's room: from this far in from the card's left edge to /// this far in from its right, as shares of its width. static let lead: CGFloat = 0.065 static let trail: CGFloat = 0.05 static let titleLines = 2 /// Pencil strike through a completed title. static let pencilLine: CGFloat = 0.011 } /// A todo's card as the index card types it: the title's lines, the /// description's, the made day and the rule each stands on, the tab and the /// stamp. public struct IndexCard: Equatable, Sendable { public var title: [TornLine] public var body: [TornLine] public var made: String? /// The due date, as typed on the tab; nil, no tab. public var tab: String? /// The tab is the red one: the day is behind. public var late: Bool /// The stamp is printed and the title struck through. public var done: Bool /// The card’s own word printed by the stamp. public var stampWord: String? public var titleRules: Range { 0.. { bodyRule..<(bodyRule + body.count) } public var madeRule: Int? { made.map { _ in TodoCardFaceKnobs.shown - 1 } } } /// How a todo's card is typed on the index card. public enum IndexCardSetting { /// The card's own label for its place `slot` (`labels`), nil when it /// has none. static func label(_ card: DeckCard, _ slot: String) -> String? { guard let label = card.labels[slot: slot], !label.isEmpty else { return nil } return label } /// The made day under its label ("made Thu 22 Oct"), nil when the card /// carries no made place. public static func made(_ card: DeckCard) -> String? { guard let day = card.text("made")?.trimmingCharacters(in: .whitespacesAndNewlines), !day.isEmpty else { return nil } return label(card, "made").map { "\($0) \(day)" } ?? day } /// The type the card is written in, at a card `height` points tall. static func fonts(height: CGFloat) -> (title: CTFont, body: CTFont) { let knobs = TodoCardFaceKnobs.self // Asked of CottonFonts first, so the bundled faces are registered // before CoreText is asked for them by name. _ = CottonFonts.type(1) return ( CTFontCreateWithName(CottonFonts.typeFace as CFString, drawable(knobs.titleSize * height), nil), CTFontCreateWithName(CottonFonts.typeFace as CFString, drawable(knobs.bodySize * height), nil) ) } /// The writing's room across a card `size` points: where it starts and /// how wide it is. static func column(_ size: CGSize) -> (lead: CGFloat, width: CGFloat) { let knobs = TodoCardFaceKnobs.self let lead = knobs.lead * size.width return (lead, size.width * (1 - knobs.trail) - lead) } /// `card` typed on an index card `size` points: the title on the first /// rules, the description on the rules after it, the made day on the /// last rule showing. public static func set(_ card: DeckCard, size: CGSize) -> IndexCard { let knobs = TodoCardFaceKnobs.self let faces = fonts(height: size.height) let column = column(size) let flat = (card.text("title") ?? "").split(whereSeparator: \.isNewline).joined(separator: " ") let title = TornPageSetting.lines(flat, font: faces.title, width: column.width, limit: knobs.titleLines) let made = made(card) let room = knobs.shown - title.count - (made == nil ? 0 : 1) let body = TornPageSetting.lines( card.text("body")?.trimmingCharacters(in: .whitespacesAndNewlines) ?? "", font: faces.body, width: column.width, limit: max(0, room)) let done = card.checked == true && card.text("state") == nil return IndexCard( title: title, body: body, made: made, tab: card.dated?.uppercased(), late: card.pressing && !done, done: done, stampWord: label(card, "check")?.uppercased()) } } /// The size CottonFonts draws a face at, which a font measured by name must /// match: never under a point. private func drawable(_ points: CGFloat) -> CGFloat { points.isFinite ? max(points, 1) : 1 } /// A painted layer, by its catalogue name, at the scale it was painted for; /// nil where this build carries no pictures. private func painted(_ name: String) -> Image? { CottonMedia.image(name, scale: 3) } public struct TodoCardFace: View { @Environment(\.faceOpened) private var opened let card: DeckCard let toggle: () -> Void public init(card: DeckCard, toggle: @escaping () -> Void = {}) { self.card = card self.toggle = toggle } public var body: some View { let knobs = TodoCardFaceKnobs.self if opened { LiftedIndexCard(card: card, toggle: toggle) } else { GeometryReader { box in let width = min(box.size.width * knobs.fillWidth, box.size.height * knobs.fillHeight * knobs.trayAspect) let size = CGSize(width: width, height: width / knobs.trayAspect) CardTray(card: card, toggle: toggle, size: size) .frame(width: size.width, height: size.height) .frame(width: box.size.width, height: box.size.height) } } } } /// The tray standing on the steel: its shadow, the tray and its stack, the /// tab, the front card and what is typed on it, and the front wall over the /// card's foot. private struct CardTray: View { let card: DeckCard let toggle: () -> Void let size: CGSize var body: some View { let knobs = TodoCardFaceKnobs.self let w = size.width let h = size.height let reach = knobs.shadowReach * w let cardWidth = (knobs.stackRight - knobs.stackLeft + 2 * knobs.overhang) * w let cardSize = CGSize(width: cardWidth, height: cardWidth / knobs.cardAspect) let cardOrigin = CGPoint(x: (knobs.stackLeft - knobs.overhang) * w, y: knobs.top * h) let typed = IndexCardSetting.set(card, size: cardSize) ZStack(alignment: .topLeading) { if let shadow = painted("todo-tray-shadow") { shadow.resizable().interpolation(.high) .frame(width: w + 2 * reach, height: (w + 2 * reach) / knobs.shadowAspect) .offset(x: -reach, y: -reach) .accessibilityHidden(true) } if let tray = painted("todo-tray") { tray.resizable().interpolation(.high) .frame(width: w, height: h) .accessibilityHidden(true) } else { StandInTray(size: size) } DueTab(typed: typed, cardSize: cardSize) .offset(x: cardOrigin.x, y: cardOrigin.y) IndexCardSheet(typed: typed, checked: card.checked, title: card.text("title") ?? "", toggle: toggle, size: cardSize) .frame(width: cardSize.width, height: cardSize.height) .offset(x: cardOrigin.x, y: cardOrigin.y) if let front = painted("todo-tray-front") { front.resizable().interpolation(.high) .frame(width: w, height: w / knobs.frontAspect) .offset(y: knobs.frontTop * h) .accessibilityHidden(true) } else { TodosMaterial.enamel.colour .frame(width: w, height: h * (1 - knobs.lip)) .offset(y: knobs.lip * h) .accessibilityHidden(true) } } .frame(width: w, height: h, alignment: .topLeading) .accessibilityElement(children: .contain) .accessibilityIdentifier("todo-card") } } /// The tab behind the card's top right with the due date typed on it, the /// red one once the day is behind; for a todo with no date, no tab, and its /// bare place the corner a date is given from. private struct DueTab: View { let typed: IndexCard let cardSize: CGSize var body: some View { let knobs = TodoCardFaceKnobs.self let height = knobs.tabHeight * cardSize.width let showing = height * (1 - knobs.tabBuried) let size = knobs.tabSize * height let ends = (typed.late ? knobs.lateTabEnds : knobs.tabEnds) * height let words = typed.tab.map { tabWords($0, size: size) } let width = min( knobs.tabLongest * cardSize.width, max(knobs.tabShortest * cardSize.width, (words?.width ?? 0) + 2 * (ends + knobs.tabPad * height))) let x = cardSize.width * (1 - knobs.tabInset) - width if let tab = typed.tab, let words { // The words centred on the showing part, their capitals' middle // on its middle; squeezed to the room inside the ends when they // outrun the longest tab. let room = max(1, width - 2 * (ends + knobs.tabPad * height)) let typedWidth = min(room, words.width + 1) let baseline = showing / 2 + size * 0.3 ZStack(alignment: .topLeading) { TabStock(late: typed.late, ends: ends) .frame(width: width, height: height) Typed(lines: [TornLine(tab)], rules: [baseline], font: CottonFonts.type(size), size: size, ink: TodosMaterial.ink.colour, width: typedWidth, fits: true) .blendMode(.multiply) .accessibilityRepresentation { Text(tab) } .accessibilityIdentifier("todo-card-tab") .offset(x: (width - typedWidth) / 2, y: baseline - size * 1.1) } .frame(width: width, height: height, alignment: .topLeading) .facePart(.when) .pencilRinged(.when, reach: EdgeInsets(top: 2, leading: 2, bottom: -height * knobs.tabBuried, trailing: 2)) .offset(x: x, y: -showing) } else { Color.clear .frame(width: width, height: showing) .contentShape(Rectangle()) .accessibilityIdentifier("todo-card-corner") .facePart(.corner) .offset(x: x, y: -showing) } } private func tabWords(_ words: String, size: CGFloat) -> (words: String, width: CGFloat) { _ = CottonFonts.type(1) let font = CTFontCreateWithName(CottonFonts.typeFace as CFString, drawable(size), nil) let set = NSAttributedString(string: words, attributes: [NSAttributedString.Key(kCTFontAttributeName as String): font]) return (words, CGFloat(CTLineGetTypographicBounds(CTLineCreateWithAttributedString(set), nil, nil, nil))) } } /// The tab's painted stock, stretched between its tapered ends; flat where /// this build carries no pictures. private struct TabStock: View { let late: Bool /// Each tapered end's width, in points. let ends: CGFloat var body: some View { let knobs = TodoCardFaceKnobs.self let name = late ? "todo-tab-late" : "todo-tab" let aspect = late ? knobs.lateTabAspect : knobs.tabAspect GeometryReader { room in // The painting's pixels a point at the tab's height, so its ends // keep their painted shape. let pixels = 720 / aspect / max(room.size.height, 1) if let image = CottonMedia.image(name, scale: pixels) { image .resizable(capInsets: EdgeInsets(top: 0, leading: ends, bottom: 0, trailing: ends), resizingMode: .stretch) .interpolation(.high) .accessibilityHidden(true) } else { UnevenRoundedRectangle(topLeadingRadius: ends / 2, topTrailingRadius: ends / 2) .fill((late ? TodosMaterial.tabLate : TodosMaterial.tab).colour) .accessibilityHidden(true) } } } } /// The painted card, its writing and the stamp overprinting its head. private struct IndexCardSheet: View { let typed: IndexCard let checked: Bool? let title: String let toggle: () -> Void let size: CGSize var body: some View { let knobs = TodoCardFaceKnobs.self let w = size.width let h = size.height let column = IndexCardSetting.column(size) let rule = { (index: Int) in knobs.rules[min(max(0, index), knobs.rules.count - 1)] * h } let titleSize = knobs.titleSize * h let bodySize = knobs.bodySize * h ZStack(alignment: .topLeading) { if let paper = painted("todo-card") { paper.resizable().interpolation(.high) .frame(width: w, height: h) .cardPaperLaid() .accessibilityHidden(true) } else { StandInCard(size: size) } Group { if !typed.title.isEmpty { Typed( lines: typed.title, rules: typed.titleRules.map(rule), font: CottonFonts.type(titleSize), size: titleSize, ink: TodosMaterial.ink.colour, width: column.width, struck: typed.done ? TodosMaterial.pencil.colour : nil, strike: knobs.pencilLine * h) .accessibilityRepresentation { Text(typed.title.map(\.words).joined(separator: " ")) } .accessibilityIdentifier("deck-title") .facePart(.title) .pencilRinged(.title, reach: EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4)) .offset(x: column.lead, y: rule(typed.titleRules.lowerBound) - titleSize * 1.1) } if !typed.body.isEmpty { Typed( lines: typed.body, rules: typed.bodyRules.map(rule), font: CottonFonts.type(bodySize), size: bodySize, ink: TodosMaterial.ink.colour, width: column.width) .accessibilityRepresentation { Text(typed.body.map(\.words).joined(separator: " ")) } .accessibilityIdentifier("todo-card-body") .facePart(.body) .pencilRinged(.body, reach: EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4)) .offset(x: column.lead, y: rule(typed.bodyRule) - bodySize * 1.1) } if let made = typed.made, let at = typed.madeRule { Typed( lines: [TornLine(made)], rules: [rule(at)], font: CottonFonts.type(bodySize), size: bodySize, ink: TodosMaterial.ink.colour, width: column.width, fits: true) .accessibilityRepresentation { Text(made) } .accessibilityIdentifier("todo-card-made") .offset(x: column.lead, y: rule(at) - bodySize * 1.1) } } // A typewriter's ink sits in the card's stock. .blendMode(.multiply) DoneStamp(typed: typed, checked: checked, title: title, toggle: toggle, cardSize: size) .offset(x: column.lead, y: h * 0.08) .blendMode(.multiply) } .frame(width: w, height: h, alignment: .topLeading) } } /// The bare landing place stays a toggle; completed cards carry its worn ink. private struct DoneStamp: View { let typed: IndexCard let checked: Bool? let title: String let toggle: () -> Void let cardSize: CGSize @Environment(\.accessibilityReduceMotion) private var reduceMotion private var arrival: AnyTransition { reduceMotion ? .identity : .asymmetric( insertion: .scale(scale: 1.6).combined(with: .offset(y: -cardSize.height * 0.24)) .combined(with: .modifier(active: StampSettle(turn: -3), identity: StampSettle(turn: 0))), removal: .scale(scale: 1.15).combined(with: .offset(y: -cardSize.height * 0.12)).combined(with: .opacity)) } var body: some View { let width = cardSize.width / 3 let height = cardSize.height * 0.24 let drawn = ZStack { Color.clear if typed.done, let word = typed.stampWord { RubberStamp(words: word, size: cardSize.height * 0.13, turn: -5) .frame(width: width, height: height) .transition(arrival) } } .frame(width: width, height: height) .contentShape(Rectangle()) .animation(reduceMotion ? nil : (typed.done ? .timingCurve(0.16, 1, 0.3, 1, duration: 0.18) : .easeOut(duration: 0.12)), value: typed.done) if let checked { Button(action: toggle) { drawn } .buttonStyle(.plain) .accessibilityLabel(title) .accessibilityAddTraits(checked ? .isSelected : []) .accessibilityIdentifier("deck-check") .facePart(.done) .pencilRinged(.done, reach: EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) } else { drawn.accessibilityHidden(true) } } } private struct StampSettle: ViewModifier { let turn: Double func body(content: Content) -> some View { content.rotationEffect(.degrees(turn)) } } /// Lines typed on the card's rules: each line's baseline on its rule, drawn /// into a room from just above the first line's letters to just under the /// last's; struck through in pencil when a finished todo's title. private struct Typed: View { let lines: [TornLine] /// Each line's rule, from the card's top. let rules: [CGFloat] let font: Font let size: CGFloat let ink: Color let width: CGFloat /// One line squeezed to the room rather than cut: a date. var fits = false /// The pencil a line is struck through in; nil, none. var struck: Color? var strike: CGFloat = 1 var body: some View { let top = (rules.first ?? 0) - size * 1.1 let height = (rules.last ?? 0) - top + size * 0.4 Canvas { context, room in for (line, rule) in zip(lines, rules) { let text = context.resolve(Text(line.words).font(font).foregroundStyle(ink)) let ideal = text.measure(in: CGSize(width: 10_000, height: 10_000)) let base = text.firstBaseline(in: CGSize(width: 10_000, height: 10_000)) let scale = fits && ideal.width > room.width ? room.width / ideal.width : 1 var drawn = context drawn.translateBy(x: 0, y: rule - top) drawn.scaleBy(x: scale, y: scale) drawn.draw(text, at: CGPoint(x: 0, y: -base), anchor: .topLeading) if let struck { // A ruler-less pencil line through the letters' middle, // a touch past either end and a little uphill. let y = -size * 0.3 var line = Path() line.move(to: CGPoint(x: -size * 0.2, y: y + size * 0.04)) line.addLine(to: CGPoint(x: ideal.width + size * 0.25, y: y - size * 0.05)) drawn.stroke(line, with: .color(struck), style: StrokeStyle(lineWidth: strike, lineCap: .round)) } } } .frame(width: width, height: max(height, 1)) } } /// The tray where this build carries no pictures: its enamel, the stack's /// cream, flat. private struct StandInTray: View { let size: CGSize var body: some View { let knobs = TodoCardFaceKnobs.self Canvas { context, room in context.fill(Path(roundedRect: CGRect(origin: .zero, size: room), cornerRadius: room.width * 0.04), with: .color(TodosMaterial.enamel.colour)) let inside = CGRect( x: knobs.stackLeft * room.width, y: room.height * 0.05, width: (knobs.stackRight - knobs.stackLeft) * room.width, height: room.height * (knobs.lip - 0.05)) context.fill(Path(inside), with: .color(TodosMaterial.card.colour.opacity(0.8))) } .frame(width: size.width, height: size.height) .accessibilityHidden(true) } } /// The card where this build carries no pictures: its cream, its head rule /// and its rules, flat. private struct StandInCard: View { let size: CGSize var body: some View { let knobs = TodoCardFaceKnobs.self Canvas { context, room in context.fill(Path(roundedRect: CGRect(origin: .zero, size: room), cornerRadius: room.width * 0.01), with: .color(TodosMaterial.card.colour)) let ruling = [(knobs.head, TodosMaterial.head.colour)] + knobs.rules.map { ($0, TodosMaterial.rule.colour) } for (share, colour) in ruling { let y = share * room.height context.stroke(Path { $0.move(to: CGPoint(x: 0, y: y)); $0.addLine(to: CGPoint(x: room.width, y: y)) }, with: .color(colour), lineWidth: 0.6) } } .frame(width: size.width, height: size.height) .accessibilityHidden(true) } } /// The index card, by its id beside the todo's own face, and the todos it /// is reviewed in: invented words only. The specimen world's today is /// Thursday 29 October 2026; a todo's date and its corner as the core says /// them (`weekday_date`, `late`), the day it was made under the card's own /// label for it. public enum TodoCardFaceCatalogue { public static let stock: FaceStock = .own public static let ground: FaceGround = .baizeTeal public static var opened: DeckCard { var card = long card.fields["check"] = .bool(true) card.fields["started"] = .text("Thu 22 Oct") card.fields["expires"] = .text("Thu 29 Oct") card.fields["repeats"] = .text("Every week") return card } public static let face = Face(id: "todo.card", specimens: [ Specimen("opened", opened, opened: true), Specimen("open", open), Specimen("done", done), Specimen("overdue", overdue), Specimen("no-date", noDate), Specimen("long", long), ], steps: .inPlace) { card, _, taps in TodoCardFace(card: card, toggle: taps.toggle ?? {}) } /// The labels a todo's card carries for its check and its made place. static let labels = CardLabels(bySlot: ["check": "Done", "made": "made"]) static func todo(corner: String?, pressing: Bool = false, pace: DeckPace?, _ fields: [String: RecordValue]) -> DeckCard { var card = DeckCard(face: "todo.card", corner: corner, pressing: pressing, pace: pace, plate: nil, fields: fields) card.labels = labels return card } /// The reference's todo: due tomorrow, Friday. public static let open = todo(corner: "Tomorrow", pace: .soon, [ "check": .bool(false), "title": .text("Renew the car insurance"), "body": .text("Policy ends 3 Nov; ask for the no-claims letter"), "date": .text("Fri 30 Oct"), "made": .text("Thu 22 Oct"), ]) /// The same todo, done today: stamped, the title struck through. public static let done = todo(corner: "Done today", pace: .done, [ "check": .bool(true), "title": .text("Renew the car insurance"), "body": .text("Policy ends 3 Nov; ask for the no-claims letter"), "date": .text("Fri 30 Oct"), "made": .text("Thu 22 Oct"), ]) /// Two days past its day: the red tab. public static let overdue = todo(corner: "2 days late", pressing: true, pace: .late, [ "check": .bool(false), "title": .text("Pay the building maintenance"), "body": .text("The society office takes cheques only, and shuts at noon on Saturday."), "date": .text("Tue 27 Oct"), "made": .text("Mon 12 Oct"), ]) /// No date: no tab. public static let noDate = todo(corner: nil, pace: .someday, [ "check": .bool(false), "title": .text("Sort the old photographs"), "body": .text("The shoebox under the bed first. The wedding ones can wait for Amma's visit."), "date": .text(ShellLines.line("cards", "date.add")), "made": .text("Sun 4 Oct"), ]) /// A title on two lines over a long description, due on Saturday evening. public static let long = todo(corner: "in 2 days", pace: .soon, [ "check": .bool(false), "title": .text("Call the insurance agent about the scratch on the rear door"), "body": .text(""" The policy number is on the renewal letter in the blue folder. Ask whether the surveyor can come on Saturday morning before ten, and whether the garage by the station is on their list or we have to take it all the way to the one on the ring road. """), "date": .text("Sat 31 Oct\(EventWhen.join)6:00 pm"), "group": .text("Car"), "made": .text("Tue 27 Oct"), ]) } /// The same ruled stock lifted clear of the tray's front wall. private struct LiftedIndexCard: View { let card: DeckCard let toggle: () -> Void var body: some View { GeometryReader { room in let width = room.size.width * 0.88 ScrollView { VStack(alignment: .leading, spacing: 18) { if let title = card.text("title") { Text(title).font(CottonFonts.type(width * 0.062)) .strikethrough(card.checked == true).facePart(.title) } if card.checked == true { Text(IndexCardSetting.label(card, "check")?.uppercased() ?? "") .foregroundStyle(TodosMaterial.tabLate.colour).rotationEffect(.degrees(-8)) .onTapGesture(perform: toggle) } if let notes = card.text("body") { Text(notes).font(CottonFonts.type(width * 0.05)) .lineSpacing(7).fixedSize(horizontal: false, vertical: true).facePart(.body) } let history = [ card.text("started").map { ShellLines.line("cards", "opened.made") + " " + EventWhen.parted($0).day }, card.checked == true ? card.text("expires").map { ShellLines.line("cards", "opened.done") + " " + EventWhen.parted($0).day } : nil, card.text("repeats").map { ShellLines.line("cards", "opened.repeats") + " " + $0 } ].compactMap { $0 }.joined(separator: " · ") if !history.isEmpty { Text(history).font(CottonFonts.type(width * 0.035)) .lineLimit(1).minimumScaleFactor(0.5).accessibilityIdentifier("todo-card-history") } } .foregroundStyle(TodosMaterial.ink.colour) .padding(width * 0.07) .padding(.top, width * 0.06) .frame(width: width, alignment: .leading) .background { if let paper = painted("todo-card") { paper.resizable().cardPaperLaid() } else { TodosMaterial.card.colour } } .shadow(color: .black.opacity(0.25), radius: 8, x: 2, y: 8) .padding(.vertical, 20) .frame(maxWidth: .infinity) } .accessibilityIdentifier("todo-card-opened") } } }