// The two built-in themes: `paper`, which is Cotton as it draws today, and // `plain`, the flat family's own — each its shipped row, as the core handed it // over (`ShippedThemes`), laid over a base. The row is the truth: it carries every key the app reads, the acts, // the cards and every knob of the scale (`ThemeScaleKeyTests`). The bases hold // the family's palette and faces as the constants they were measured from // (`ThemeDefaultTests`) and nothing of the look the row adds. import SwiftUI extension Theme { /// Cotton's own look: the `paper` family with today's palette, faces and /// geometry. The theme a database is seeded with. public static let paper = shipped(.paper, row: ShippedThemes.rows[ThemeFamily.paper.rawValue]) /// The flat family's own theme, as Cotton ships it. public static let plain = shipped(.plain, row: ShippedThemes.rows[ThemeFamily.plain.rawValue]) /// A shipped theme: its row as the core handed it over /// (`ShippedThemes.rows`) laid /// over the family's palette and faces. The row carries every key the app /// reads (`ThemeScaleKeyTests`), so nothing below draws a value of its own; /// a build whose core handed over no row draws the base, visibly bare. static func shipped(_ family: ThemeFamily, row data: Data?) -> Theme { let base = base(family) guard let data, let row = try? JSONDecoder().decode(ThemeRowForm.self, from: data) else { return base } // The theme keeps the base's id and name: `default`, the row a // database is seeded with, is Cotton's own theme by that name. var theme = row.theme(over: base) theme.id = base.id theme.name = base.name return theme } /// The family's palette and faces, before its shipped row. static func base(_ family: ThemeFamily) -> Theme { switch family { case .paper: return paperBase case .plain: return plainBase } } static let paperBase = Theme( id: "default", name: "Cotton", family: .paper, palette: ThemePalettes(light: .paper, dark: .paper), type: ThemeType( display: .frauncesTitle, title: .frauncesText, body: .courier, meta: .courierItalic, hand: .caveat, figure: .courier, cap: .instrumentItalic, interface: .system, script: .courierNew ), scale: .unread, texture: ThemeTexture(grain: true, shadow: .soft, tilt: true), cap: ThemeCap(colour: nil, texture: .enamel), acts: .unread, cards: .unread ) /// The flat family's base: Cotton's palette on flat white cards, the /// system face, a fixed corner, no grain, no lift, no tilt. static let plainBase = Theme( id: "plain", name: "Plain", family: .plain, palette: ThemePalettes(light: .plain, dark: .plain), type: ThemeType( display: .systemSemibold, title: .systemSemibold, body: .system, meta: .system, hand: .systemItalic, figure: .systemMonospaced, cap: .systemSemibold, interface: .system, script: .courierNew ), scale: .unread, texture: ThemeTexture(grain: false, shadow: .none, tilt: false), cap: ThemeCap(colour: nil, texture: .flat), acts: .unread, cards: .unread ) } extension ThemePalette { /// `Palettes.paper` and its status colours, with the ribbon and the pencil /// that `PaperInk` typed with. public static let paper = ThemePalette( ground: ThemeColor(Palettes.paper.ground), groundMuted: ThemeColor(Palettes.paper.groundMuted), groundElevated: ThemeColor(Palettes.paper.groundElevated), ink: ThemeColor(Palettes.paper.ink), inkBody: ThemeColor(Palettes.paper.inkBody), inkSecondary: ThemeColor(Palettes.paper.inkSecondary), inkTertiary: ThemeColor(Palettes.paper.inkTertiary), hairline: ThemeColor(Palettes.paper.hairline), accent: ThemeColor(Palettes.paper.accent), accentContrast: ThemeColor(Palettes.paper.accentContrast), chipGround: ThemeColor(Palettes.paper.chipGround), highlight: ThemeColor(Palettes.paper.highlight), selection: ThemeColor(Palettes.paper.selection), success: ThemeColor(Palettes.status.success), successLight: ThemeColor(Palettes.status.successLight), error: ThemeColor(Palettes.status.error), errorLight: ThemeColor(Palettes.status.errorLight), warning: ThemeColor(Palettes.status.warning), warningLight: ThemeColor(Palettes.status.warningLight), // The typewriter's ribbon: dark warm ink, the todo card's since // 2026-09-13, kept as the channels it was written in. print: ThemeColor(red: 0.18, green: 0.16, blue: 0.145), pencil: 0.55, paper: ThemeColor(Palettes.paper.ground), shadow: ThemeColor(red: 0, green: 0, blue: 0), tags: ThemeTags(fill: ThemeColor(Palettes.paper.chipGround), ink: ThemeColor(Palettes.paper.ink)) ) /// Plain's: the same roles, a white card on the plaster, and the ink the /// palette sets text in rather than a ribbon. public static let plain: ThemePalette = { var palette = ThemePalette.paper palette.print = palette.ink palette.paper = ThemeColor(Palettes.paper.groundElevated) palette.ground = ThemeColor(Palettes.paper.chipGround) palette.groundMuted = ThemeColor(Palettes.paper.chipGround) palette.tags = ThemeTags(fill: ThemeColor(Palettes.paper.ink), ink: ThemeColor(Palettes.paper.ground)) return palette }() } extension ThemeActs { /// No stock read yet: the base a shipped row is laid over, never drawn — /// the shipped themes name every class. static let unread = ThemeActs( completes: .cream, times: .cream, moves: .cream, destroys: .cream, putsAway: .cream, unnamed: .cream, unnamedHeld: .cream ) } extension ThemeCards { /// Nothing read yet: the base a shipped row is laid over, never drawn. static let unread = ThemeCards( fieldDefaultStock: .cream, overdueStock: .cream, trayStackStocks: [], emptyOutlineDash: [], emptyOutlineOpacity: 0, faintObjectOpacity: 0, offObjectOpacity: 0, objects: [:] ) } extension ThemeScale { /// No knob read yet: the base a shipped row is laid over, never drawn — /// the shipped themes carry every knob. static let unread = ThemeScale( radius: 0, radiusMin: 0, radiusFraction: 0, spacing: 0, insetFraction: 0, insetMin: 0, insetMax: 0, stroke: 0, hairline: 0, navCircle: 0, navRowTop: 0, navRowAir: 0, titleSize: 0, bodySize: 0, metaSize: 0, handSize: 0, sectionTitleSize: 0, screenTitleSize: 0 ) } extension ThemeFamily { /// The family's shipped theme — for code that WRITES a theme row (a reset /// or a family switch needs the family's own values) or draws where no /// database is shown (the Mac's menu bar). Everything that draws a /// database reads the worn theme from `\.theme` (`WornThemeGuardTests`). public var shipped: Theme { Theme.standard(self) } }