// A studio's CLASS (Sharmila's boards, 23 Oct 2026; Codex round 2 and the // coordinator's review of aa7f6389e), drawn on the kinds the deck already // has, on the flavour's own card (`CardMaterial`: her theme's white card). // // A CLASS (syz-class-2): an event card with a picture (a yoga session, an // event, a booking) is its words down the left and its photograph tall down // the right, to the card's edge. The day spaced small, the time in large // figures with its am/pm small after them, the length by a clock (`subtitle`, // the start and its `also` joined by the core), a short coral rule, the class // heavy, its trainer on a round mount (`people`), a few lines of what it is // (`body`), the room by a pin (`source`), and the places — the core's words // (`place`: "7 of 12 places taken") over a coral bar of the places taken of // the room (`used` of `limit`). No Book button: acts live on the fan. // Every word is the core's (`DeckCard`); the face lays them out. A class is // an event card with a picture: the deck reaches this face through its event // adapter (CottonUI's `DeckFace`), its trainer's picture through the picture // hook (`FaceMount`). import CottonPaper import CottonValues import SwiftUI /// What the studio's class reads off a card: its time. extension StudioReading { /// The time large and what the core joined after it ("60 min"). public static func time(_ words: String?) -> (time: String, rest: String?)? { guard let words else { return nil } let parts = words.components(separatedBy: ShellLines.line("cards", "join")) .map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty } guard let first = parts.first else { return nil } let rest = parts.dropFirst().joined(separator: ShellLines.line("cards", "join")) return (first, rest.isEmpty ? nil : rest) } } /// A class: its words down the left, its photograph tall down the right. public struct ClassFace: View { let card: DeckCard var photo: Photo? public init(card: DeckCard, photo: Photo?) { self.card = card self.photo = photo } public var body: some View { GeometryReader { sheet in HStack(spacing: 0) { ClassWords(card: card) .padding(StudioFaceKnobs.inset) .frame(width: photo == nil ? sheet.size.width : sheet.size.width * StudioFaceKnobs.wordsShare, height: sheet.size.height, alignment: .topLeading) if let photo { photo .frame(width: sheet.size.width * (1 - StudioFaceKnobs.wordsShare), height: sheet.size.height) .clipped() .accessibilityIdentifier("face-photo") .facePart(.picture) } } .frame(width: sheet.size.width, height: sheet.size.height, alignment: .topLeading) .clipped() } .onCardPaper(ClassFaceCatalogue.stock.laid(card.pace)) } } /// The class's words: day, time, length, name, trainer, what it is, room, /// places. private struct ClassWords: View { let card: DeckCard @Environment(\.theme) private var theme var body: some View { VStack(alignment: .leading, spacing: 8) { if let day = card.text("date") { Text(day) .font(theme.type.title(StudioFaceKnobs.daySize)) .tracking(StudioFaceKnobs.dayTracking) .textCase(.uppercase) .lineLimit(1) .faceInk(.ink) .facePart(.when) } ClassTime(card: card) .facePart(.subtitle) Rectangle() .fill(theme.colors.accent.color) .frame(width: StudioFaceKnobs.ruleWidth, height: StudioFaceKnobs.ruleHeight) .padding(.vertical, 4) if let title = card.text("title") { Text(title) .font(theme.type.display(StudioFaceKnobs.titleSize)) .faceInk(.ink) .lineLimit(3) .minimumScaleFactor(0.6) .accessibilityIdentifier("deck-title") .facePart(.title) } ClassTrainer(card: card) .facePart(.people) if let about = card.text("body") { Text(about) .font(theme.type.body(StudioFaceKnobs.aboutSize)) .lineLimit(StudioFaceKnobs.aboutLines) .foregroundStyle(theme.colors.inkBody.color.opacity(StudioFaceKnobs.labelFaint)) .facePart(.body) } Spacer(minLength: 0) ClassPlaces(card: card) } } } /// The time in the large figures, its am/pm small after them, and the /// length under it; an event's kind, which is no clock, as a plain line. private struct ClassTime: View { let card: DeckCard @Environment(\.theme) private var theme var body: some View { if let when = StudioReading.time(card.text("subtitle")) { VStack(alignment: .leading, spacing: 2) { if let clock = StudioReading.clock(when.time) { HStack(alignment: .firstTextBaseline, spacing: 4) { Text(clock.figures) .font(theme.type.figure(StudioFaceKnobs.timeSize)) .lineLimit(1) .minimumScaleFactor(0.5) if let suffix = clock.suffix { Text(suffix) .font(theme.type.title(StudioFaceKnobs.suffixSize)) .textCase(.uppercase) .lineLimit(1) .fixedSize() } } .faceInk(.ink) } else { Text(when.time) .font(theme.type.title(StudioFaceKnobs.lengthSize)) .lineLimit(1) .faceInk(.ink) } if let rest = when.rest { StudioFact(symbol: "clock", said: rest, tint: theme.colors.ink.color, size: StudioFaceKnobs.lengthSize) } } .accessibilityElement(children: .combine) .accessibilityIdentifier("face-time") } } } /// The class's trainer on a round mount — their picture, or their initials. private struct ClassTrainer: View { let card: DeckCard @Environment(\.theme) private var theme var body: some View { if let entry = card.entries("people").first, let name = entry["name"]?.text { HStack(spacing: 8) { FaceMount(name: name, picture: entry["picture"]?.text, size: StudioFaceKnobs.personMount) Text(name) .font(theme.type.title(StudioFaceKnobs.lineSize)) .lineLimit(2) .minimumScaleFactor(0.8) .faceInk(.ink) } .accessibilityElement(children: .combine) .accessibilityIdentifier("face-trainer") } } } /// The room by a pin, the core's places words, and the places taken as a /// coral bar. private struct ClassPlaces: View { let card: DeckCard @Environment(\.theme) private var theme var body: some View { VStack(alignment: .leading, spacing: 8) { if let room = card.text("source") { StudioFact(symbol: "mappin", said: room, tint: theme.colors.accent.color, size: StudioFaceKnobs.lineSize + 1) } if let left = card.text("place") { Text(left) .font(theme.type.body(StudioFaceKnobs.lineSize)) .lineLimit(2) .faceInk(.ink) .facePart(.place) } if let seats = StudioReading.seats(card) { SeatRule(share: StudioReading.ringShare(taken: seats.taken, of: seats.of), color: theme.colors.accent.color) } } .accessibilityElement(children: .combine) .accessibilityIdentifier("face-seats") } } /// The class face, and the cards it is reviewed in. No card kind names it: a /// class is an event card with a picture, drawn so by the deck's event /// adapter (CottonUI's `DeckFace`). public enum ClassFaceCatalogue { public static let stock: FaceStock = .framed public static let ground: FaceGround = .paper public static let face = Face(id: "sharmila.class", specimens: [Specimen("flow", flow, picture: "verandah")]) { card, picture, _ in ClassFace(card: card, photo: picture) } public static let flow = DeckCard(face: .event, fields: [ "photo": .text("verandah"), "title": .text("Invented flow"), "subtitle": .text("7:00 am \u{00B7} 60 min"), "date": .text("Thu 29 Oct"), "body": .text("An invented class for an invented morning."), "source": .text("Invented room"), "place": .text("7 of 12 places taken"), "used": .number(7), "limit": .number(12), "people": .list([.object(["name": .text("Invented Trainer"), "picture": .text("portrait")])]), ]) }