// Cotton Story's look (contract, 17 Nov 2026): typographic, flat and calm.// A near-white ground in light and a near-black one in dark, following the// phone; one ink each; one accent, a warm red, for the current thing, the// caret and the Plus, never for decoration. Every Story surface (its faces,// the writer, the script reader) takes its colours from here and nowhere// else, so the two themes are one decision.//// Unlike the other apps' materials these flip with the phone's appearance:// Story is the one app whose owner asked for both themes. Built with// `UIColor(red:green:blue:alpha:)` inside a dynamic provider, the one// constructor this file is exempt from (`swift-sweep-palette-guard`).importSwiftUI#if canImport(UIKit)import UIKit#endifpublicenumStoryMaterial: CaseIterable, Sendable {/// The ground every Story surface lies on: the paper, #F4ECDE / #121212.case ground/// A card or a page laid on the ground: a soft tone step off it.case sheet/// The script reader's page: white in light, the sheet's tone in dark.case page/// The words: #161616 / #ECECE6.case ink/// Words that step back: a count, a status, a scene number.case quiet/// Words further back still: the hint in an empty field.case faint/// The hairline round a card and under a heading.case hairline/// One speaker's bubble in the chat face, the left side.case bubble/// The other speaker's bubble, the right side: the ink itself.case bubbleOther/// The words in the right side's bubble.case bubbleOtherInk/// The one accent: #E5482D. The current thing, the caret, the Plus.case accent/// Light and dark, as 0...1 channels.privatevar channels: (light: (Double, Double, Double, Double), dark: (Double, Double, Double, Double)) {switchself {case .ground: ((0.957, 0.925, 0.871, 1), (0.071, 0.071, 0.071, 1))case .sheet: ((1, 1, 1, 1), (0.110, 0.110, 0.106, 1))case .page: ((1, 1, 1, 1), (0.110, 0.110, 0.106, 1))case .ink: ((0.086, 0.086, 0.086, 1), (0.925, 0.925, 0.902, 1))case .quiet: ((0.086, 0.086, 0.086, 0.58), (0.925, 0.925, 0.902, 0.6))case .faint: ((0.086, 0.086, 0.086, 0.34), (0.925, 0.925, 0.902, 0.36))case .hairline: ((0.086, 0.086, 0.086, 0.12), (0.925, 0.925, 0.902, 0.14))case .bubble: ((0.925, 0.925, 0.906, 1), (0.165, 0.165, 0.161, 1))case .bubbleOther: ((0.086, 0.086, 0.086, 1), (0.925, 0.925, 0.902, 1))case .bubbleOtherInk: ((0.980, 0.980, 0.969, 1), (0.071, 0.071, 0.071, 1))case .accent: ((0.898, 0.282, 0.176, 1), (0.937, 0.341, 0.239, 1)) } } #if canImport(UIKit)/// The colour for UIKit (the writer's text view), following the trait./// One instance per material, so the same material is the same colour/// wherever it is asked for (a fresh dynamic colour never equals another).publicvar uiColour: UIColor { Self.uiColours[self]! }privatestaticlet uiColours: [StoryMaterial: UIColor] = Dictionary(uniqueKeysWithValues: allCases.map { material inlet (light, dark) = material.channelsreturn (material, UIColor { traits inlet c = traits.userInterfaceStyle == .dark ? dark : lightreturn UIColor(red: c.0, green: c.1, blue: c.2, alpha: c.3) }) })/// The colour, following the phone's appearance.publicvar colour: Color { Color(uiColor: uiColour) } #elsepublicvar colour: Color {let c = channels.lightreturnColor(.sRGB, red: c.0, green: c.1, blue: c.2, opacity: c.3) } #endif/// The light colour alone, for what is measured rather than drawn (a/// ground's luminance) and for the PDF, which is always paper.publicvar lightColour: Color {let c = channels.lightreturnColor(.sRGB, red: c.0, green: c.1, blue: c.2, opacity: c.3) }}/// Story's type: the script in Courier Prime, the interface in the system's/// own sans. Both grow with the phone's text size (`relativeTo:`), and both/// fall back to the system's fonts for a script Courier Prime does not/// carry (Telugu draws in the system's Telugu face beside the Latin).publicenumStoryType {/// Script text: a scene's body, a heading, the reader's page.publicstaticfunc script(_ size: CGFloat, relativeTo style: Font.TextStyle = .body) -> Font { _ = CottonFonts.type(size)return .custom(CottonFonts.typeFace, size: size, relativeTo: style) }/// Interface text in the system sans.publicstaticfunc sans(_ style: Font.TextStyle, weight: Font.Weight = .regular) -> Font { .system(style, design: .default, weight: weight) }}