// The SEASON as its CREAM SEASON CARD, laid on the Picture House's// curtain-red velvet under its one warm house light (`FaceGround.velvet`;// Cinemas leftovers, 7 Nov 2026: a season's own page stood on plain cream// paper with a generic face while its series wore the one-sheet and its// episodes the lobby card). The card is the Round 14 season card// (`cinemas14-materials`, `season-card`, the tab a series' frame fans behind// its top edge), PAINTED (`Media.xcassets`, imported by// `scripts/import-cinemas-materials.py`) and laid whole in its 1565 x 663// box, scaled by the drawn width over 1565; the progress strip and the// ticket stub are the lobby card's (`CinemaParts.swift`). The face draws// live only what the card decides://// the POSTER is the series' own picture, laid in a rounded window at the// card's left; a series kept without one shows the velvet through a dark// field there, the season's number typed large on it in the cream.// the TAB says the season ("SEASON 2", the film's season line from its// number) in the typewriter face across the card's top.// the TITLE is the season's own in Libre Caslon, on one line taken down// until it fits, then on two balanced lines, past the least size cut; a// title that only repeats the tab's words gives way to the series' title.// the FACTS under it: the year it aired and its episodes, as the core// counted and said them ("2019 · 8 episodes").// the WATCHED line and the PROGRESS STRIP at the card's foot once any// episode is watched: "3 of 8 watched", the strip filled as far.// the STUB at the card's upper right corner once every episode is// watched: stamped WATCHED, no day (a season is watched over many).//// Tagged: the poster (`picture`), the title (`title`), the facts (`body`),// the strip (`state`), the stub (`done`). Stepped by a tap, it cuts. Print// on an object scales with the object, never with Dynamic Type.//// What the card holds (the slots the Cinemas kit fills on `film_season`):// `photo` (the series' poster), `title`, `number` (the season's number, the// figure alone), `year`, `subtitle` (its episodes, said in their count words),// `limit` (its episodes, the number), `used` (its episodes watched, the// number), `source` (the series' title). Every word is the core's or a// line: the face only sets them.importCottonPaperimportCottonValuesimportCoreTextimportSwiftUIenumSeasonCardFaceKnobs {// THE CARD'S BOX every placement is in, in the painting's pixels// (`layout.json`'s `season-card`, 1565 x 663): the face draws the card// at most `widest` points wide, and every place below is scaled by the// drawn width over the box's.staticlet box = CGSize(width: 1565, height: 663)staticlet widest: CGFloat = 340/// The most of the card's room the card and what it carries take.staticlet fillWidth: CGFloat = 0.96staticlet fillHeight: CGFloat = 0.94/// The card's shadow on the velvet: its reach and how far it falls, in/// the box's pixels, and how dark it lies (the painting carries none).staticlet shadowRadius: CGFloat = 28staticlet shadowDrop: CGFloat = 18staticlet shadowStrength: Double = 0.55/// What the shadow reaches past the card on every side.staticlet shadowReach: CGFloat = 64// THE POSTER: its window on the card's left, the series' one-sheet// proportion (two across, three down), and its rounding; a poster laid a// hair past it. Where none is kept: how strongly the dark is laid over// the velvet and the season's number typed on it, its size.staticlet poster = CGRect(x: 78, y: 104, width: 324, height: 486)staticlet posterRadius: CGFloat = 24staticlet posterBleed: CGFloat = 4staticlet screenStrength: Double = 0.5staticlet numeralSize: CGFloat = 260// THE WORDS, right of the poster: the tab across the card's top, the// title under it, the facts, the watched line and the strip at the foot.staticlet tab = CGRect(x: 450, y: 70, width: 1040, height: 80)staticlet tabSize: CGFloat = 60staticlet title = CGRect(x: 450, y: 170, width: 1040, height: 200)staticlet titleSize: CGFloat = 92staticlet titleLeast: CGFloat = 60staticlet titleShrink: CGFloat = 0.94staticlet titleStep: CGFloat = 1.08staticlet titleLines = 2staticlet facts = CGRect(x: 450, y: 384, width: 1040, height: 60)staticlet factsSize: CGFloat = 42staticlet watched = CGRect(x: 450, y: 470, width: 1040, height: 56)staticlet watchedSize: CGFloat = 38staticlet progress = CGRect(x: 450, y: 548, width: 1000, height: 16)// THE STUB, over the card's upper right corner (the one-sheet's tuck,// at the season card's scale), in the card's box.staticlet stub = CGRect(x: 1180, y: -72, width: 380, height: 241.1)}/// How the season's card is set.publicenumSeasonCardSetting {/// The tab's words, the season said from its number ("SEASON 2"); nil,/// no number kept.publicstaticfunc tab(_ card: DeckCard) -> String? {guardlet number = card.text("number") else { returnnil }returnShellLines.line("cards", "film.season", ["n": number]).uppercased() }/// The title set in Caslon: the season's own, unless it only repeats/// the tab's words, then the series'; nil, neither kept.publicstaticfunc title(_ card: DeckCard) -> String? {let own = card.text("title")?.split(whereSeparator: \.isWhitespace).joined(separator: " ")iflet own, own.uppercased() != tab(card) { return own }return card.text("source")?.split(whereSeparator: \.isWhitespace).joined(separator: " ") ?? own }/// The title set: on one line at its own size, taken down a step at a/// time to the least; then on two balanced lines from its size down/// again; past the least size cut with an ellipsis. In the card's pixels.publicstaticfunc titleLines(_ card: DeckCard) -> (lines: [String], size: CGFloat) {let knobs = SeasonCardFaceKnobs.selfguardlet title = title(card) else { return ([], knobs.titleSize) }let room = knobs.titlefunc fits(_ size: CGFloat, lines count: Int) -> Bool {let lines = HighlightPassageSetting.lines(title, font: FilmPosterSetting.caslon(size), width: room.width, limit: .max)return lines.count <= count && CGFloat(lines.count) * size * knobs.titleStep <= room.height }for count in1...knobs.titleLines {var size = knobs.titleSizewhile !fits(size, lines: count), size * knobs.titleShrink >= knobs.titleLeast { size *= knobs.titleShrink }if fits(size, lines: count) {return (BookHardbackSetting.balanced(title, font: FilmPosterSetting.caslon(size), width: room.width, limit: count), size) } }var size = knobs.titleSizewhile size * knobs.titleShrink >= knobs.titleLeast { size *= knobs.titleShrink }return (HighlightPassageSetting.lines(title, font: FilmPosterSetting.caslon(size), width: room.width, limit: knobs.titleLines), size) }/// The facts under the title: the year it aired and its episodes as the/// core said them, joined as the cards join words; nil, neither kept.publicstaticfunc facts(_ card: DeckCard) -> String? {let facts = [card.text("year"), card.text("subtitle")].compactMap { $0 }return facts.isEmpty ? nil : facts.joined(separator: ShellLines.line("cards", "join")) }/// Its episodes, and those watched, as the core counted them.staticfunc episodes(_ card: DeckCard) -> (watched: Int, of: Int)? {guardlet of = card.number("limit"), of > 0else { returnnil }let watched = min(of, max(0, card.number("used") ?? 0))return (Int(watched.rounded()), Int(of.rounded())) }/// The watched line ("3 of 8 watched"), once any episode is watched.publicstaticfunc watched(_ card: DeckCard) -> String? {guardlet counted = episodes(card), counted.watched > 0else { returnnil }returnShellLines.line("cards", "film.season_watched", ["n": "\(counted.watched)", "of": "\(counted.of)"]) }/// How far the strip is filled, nought to one: the episodes watched of/// its episodes; nil, none watched.publicstaticfunc share(_ card: DeckCard) -> Double? {guardlet counted = episodes(card), counted.watched > 0else { returnnil }returnDouble(counted.watched) / Double(counted.of) }/// The stub's stamp once every episode is watched, with no day; nil/// otherwise.publicstaticfunc stub(_ card: DeckCard) -> String? {guardlet counted = episodes(card), counted.watched == counted.of else { returnnil }returnShellLines.line("cards", "film.stub").uppercased() }/// The season's number, typed on a posterless window; nil, none kept.publicstaticfunc numeral(_ card: DeckCard) -> String? { card.text("number") }/// The typewriter face as CoreText measures it.staticfunc type(_ size: CGFloat) -> CTFont {EpisodeLobbySetting.type(size) }/// What the face reaches, in the card's box: the card, its shadow, its/// stub (always kept room for, so a season's card is the same size/// watched or not).staticvar reach: CGRect {let knobs = SeasonCardFaceKnobs.selflet card = CGRect(origin: .zero, size: knobs.box)return card.insetBy(dx: -knobs.shadowReach, dy: -knobs.shadowReach).union(knobs.stub) }}publicstructSeasonCardFace<Poster: View>: View {let card: DeckCard/// The series' poster laid in the window; nil shows the dark field.var poster: Poster?publicinit(card: DeckCard, poster: Poster? = nil) {self.card = cardself.poster = poster }publicvar body: someView {let knobs = SeasonCardFaceKnobs.selflet reach = SeasonCardSetting.reachGeometryReader { room inlet across = 2 * max(knobs.box.width / 2 - reach.minX, reach.maxX - knobs.box.width / 2)let s = min(knobs.widest / knobs.box.width, room.size.width * knobs.fillWidth / across, room.size.height * knobs.fillHeight / reach.height)SeasonCard(card: card, poster: poster, s: s) .frame(width: knobs.box.width * s, height: knobs.box.height * s, alignment: .topLeading) .offset(x: (room.size.width - knobs.box.width * s) / 2, y: (room.size.height - reach.height * s) / 2 - reach.minY * s) .frame(width: room.size.width, height: room.size.height, alignment: .topLeading) } .accessibilityElement(children: .contain) .accessibilityIdentifier("season-card") }}/// The card in its box, scaled by `s`: the card on its shadow, the poster/// or the dark field, the tab, the title, the facts, the watched line and/// the strip, the stub.privatestructSeasonCard<Poster: View>: View {let card: DeckCardlet poster: Poster?let s: CGFloatvar body: someView {let knobs = SeasonCardFaceKnobs.self ZStack(alignment: .topLeading) {CinemaPainted(name: "season-card") .cinemaLaid(CGRect(origin: .zero, size: knobs.box), s) .shadow(color: CinemasMaterial.screen.colour.opacity(knobs.shadowStrength), radius: knobs.shadowRadius * s, y: knobs.shadowDrop * s)Window(card: card, poster: poster, s: s)iflet tab = SeasonCardSetting.tab(card) { typed(tab, size: knobs.tabSize, in: knobs.tab) .accessibilityHidden(true) .offset(x: knobs.tab.minX * s, y: knobs.tab.minY * s) }Title(card: card, s: s)iflet facts = SeasonCardSetting.facts(card) { typed(facts, size: knobs.factsSize, in: knobs.facts) .contentShape(Rectangle()) .accessibilityElement() .accessibilityLabel(facts) .accessibilityIdentifier("season-card-facts") .facePart(.body) .offset(x: knobs.facts.minX * s, y: knobs.facts.minY * s) }iflet watched = SeasonCardSetting.watched(card) { typed(watched, size: knobs.watchedSize, in: knobs.watched) .accessibilityHidden(true) .offset(x: knobs.watched.minX * s, y: knobs.watched.minY * s) }iflet share = SeasonCardSetting.share(card) {CinemaStrip(rect: knobs.progress, share: share, said: SeasonCardSetting.watched(card) ?? "", identifier: "season-card-progress", s: s) }iflet stamp = SeasonCardSetting.stub(card) {CinemaStub(rect: knobs.stub, stamp: stamp, day: nil, identifier: "season-card-stub", s: s) } } .frame(width: knobs.box.width * s, height: knobs.box.height * s, alignment: .topLeading) }/// `words` in the typewriter at `size`, set from the leading edge of a/// room `rect`'s size on one line, taken down to fit it; placed by the/// caller, after it is tagged.privatefunc typed(_ words: String, size: CGFloat, in rect: CGRect) -> someView {Text(words) .font(CottonFonts.type(size * s)) .foregroundStyle(CinemasMaterial.ink.colour) .lineLimit(1) .minimumScaleFactor(0.5) .frame(width: rect.width * s, height: rect.height * s, alignment: .leading) }}/// The poster's window on the card: the series' poster, or the velvet/// through a dark field with the season's number on it; tagged as the/// card's picture.privatestructWindow<Poster: View>: View {let card: DeckCardlet poster: Poster?let s: CGFloatvar body: someView {let knobs = SeasonCardFaceKnobs.selflet shape = RoundedRectangle(cornerRadius: knobs.posterRadius * s, style: .continuous)let bled = knobs.poster.insetBy(dx: -knobs.posterBleed, dy: -knobs.posterBleed) ZStack {iflet poster { poster .frame(width: bled.width * s, height: bled.height * s) .clipped() .clipShape(shape) } else {CinemasMaterial.velvet.colour .overlay { CottonMedia.image(FaceGround.velvet.tile ?? "", scale: 3)?.resizable(resizingMode: .tile) } .clipShape(shape) shape.fill(CinemasMaterial.screen.colour.opacity(knobs.screenStrength))iflet numeral = SeasonCardSetting.numeral(card) {Text(numeral) .font(CottonFonts.type(knobs.numeralSize * s)) .foregroundStyle(CinemasMaterial.cream.colour) .lineLimit(1) .minimumScaleFactor(0.3) } } } .frame(width: bled.width * s, height: bled.height * s) .contentShape(shape) .accessibilityElement(children: .ignore) .accessibilityLabel(SeasonCardSetting.tab(card) ?? "") .accessibilityIdentifier("season-card-poster") .facePart(.picture) .offset(x: bled.minX * s, y: bled.minY * s) }}/// The title in Caslon, set from the words' leading edge.privatestructTitle: View {let card: DeckCardlet s: CGFloatvar body: someView {let knobs = SeasonCardFaceKnobs.selflet (lines, size) = SeasonCardSetting.titleLines(card) VStack(alignment: .leading, spacing: 0) {ForEach(Array(lines.enumerated()), id: \.offset) { _, line inText(line) .font(CottonFonts.caslon(size * s)) .lineLimit(1) .fixedSize() .frame(height: size * knobs.titleStep * s) } } .foregroundStyle(CinemasMaterial.ink.colour) .frame(width: knobs.title.width * s, height: knobs.title.height * s, alignment: .leading) .contentShape(Rectangle()) .accessibilityElement() .accessibilityLabel([SeasonCardSetting.tab(card), lines.isEmpty ? nil : lines.joined(separator: " ")] .compactMap { $0 }.joined(separator: ShellLines.line("cards", "join"))) .accessibilityAddTraits(.isHeader) .accessibilityIdentifier("deck-title") .facePart(.title) .offset(x: knobs.title.minX * s, y: knobs.title.minY * s) }}/// The season's card, by its id beside the series' one-sheet and the/// episode's lobby card, and the seasons it is reviewed in: invented titles,/// an invented poster. An episode count is said as the core says it (the/// column's count words).publicenumSeasonCardFaceCatalogue {publicstaticlet stock: FaceStock = .ownpublicstaticlet ground: FaceGround = .velvetpublicstaticlet face = Face(id: "season.card", specimens: [Specimen("poster", poster, picture: "poster-ferry"), Specimen("no-poster", noPoster),Specimen("part-watched", partWatched, picture: "poster-ferry"), Specimen("watched", watched, picture: "poster-ferry"),Specimen("longest-title", longestTitle), Specimen("largest", largest, picture: "poster-ferry"), ], steps: .cut) { card, picture, _ inSeasonCardFace(card: card, poster: picture) }staticfunc season(_ fields: [String: RecordValue]) -> DeckCard {DeckCard(face: "season.card", corner: nil, pressing: false, pace: nil, plate: nil, fields: fields) }/// None watched yet, the series' poster kept; its title its own.publicstaticlet poster = season(["title": .text("The Winter Crossings"),"number": .text("2"),"year": .text("2021"),"subtitle": .text("8 episodes"),"limit": .number(8),"used": .number(0),"photo": .text("poster-ferry"),"source": .text("Night Ferry"), ])/// No poster kept: the dark field and the season's number on it; its/// title only repeats the tab, so the series' title is set.publicstaticlet noPoster = season(["title": .text("Season 1"),"number": .text("1"),"year": .text("2019"),"subtitle": .text("6 episodes"),"limit": .number(6),"used": .number(0),"source": .text("The Fog Bell"), ])/// Three of eight watched: the watched line and the strip.publicstaticlet partWatched = season(["title": .text("The Winter Crossings"),"number": .text("2"),"year": .text("2021"),"subtitle": .text("8 episodes"),"limit": .number(8),"used": .number(3),"photo": .text("poster-ferry"),"source": .text("Night Ferry"), ])/// Every episode watched: the strip full and the stub at the corner.publicstaticlet watched = season(["title": .text("The Winter Crossings"),"number": .text("2"),"year": .text("2021"),"subtitle": .text("8 episodes"),"limit": .number(8),"used": .number(8),"photo": .text("poster-ferry"),"source": .text("Night Ferry"), ])/// The longest title: on two lines, cut; no poster, no year.publicstaticlet longestTitle = season(["title": .text("The Lamp-Keeper's Daughter Rows Out Past the Breakwater on the Longest Night of the Year"),"number": .text("12"),"subtitle": .text("104 episodes"),"limit": .number(104),"used": .number(40),"source": .text("The Lantern Coast"), ])/// The fullest card, drawn at every text size Loom has, the largest/// among them: watched through, a long title, a long count.publicstaticlet largest = season(["title": .text("The Lantern Coast and the Harbour Towns"),"number": .text("10"),"year": .text("2014"),"subtitle": .text("68 episodes"),"limit": .number(68),"used": .number(68),"photo": .text("poster-ferry"),"source": .text("The Lantern Coast"), ])}