// A studio's PLACE in its own look (Codex round 2: syz-studio; the // coordinator's review of aa7f6389e), on the flavour's own card // (`CardMaterial`): the studio, or a class of its catalogue, on its // photograph (`sharmila.studio`) — its name spaced over the photograph, the headline heavy // (`subtitle`, the tagline), whoever the card names on a mount with the // core's label for them (`people`: the founder, her photograph, through the // picture hook, `FaceMount`), a hairline, and its place by a pin (`place`: // the address) beside its days by a calendar (`period`); its pages after it, // as every face turns them (`FaceTurns`, the pages on its card). // No action is drawn on the card. Every word is the core's. import CottonPaper import CottonValues import SwiftUI /// The studio, or a class of its catalogue: its name spaced over its /// photograph, the headline, the person it names, its place and days. public struct StudioPlaceFace: View { let card: DeckCard var photo: Photo? /// The pages its card turns to after it (`card.pages`), each a column's /// words under its label (`FaceTurns`). var pages: [CardPage] = [] @Environment(\.theme) private var theme public init(card: DeckCard, photo: Photo?, pages: [CardPage] = []) { self.card = card self.photo = photo self.pages = pages } public var body: some View { FaceTurns(pages: pages) { front } .onCardPaper(StudioPlaceFaceCatalogue.stock.laid(card.pace)) } /// The face itself, before the pages its card turns to. @ViewBuilder private var front: some View { GeometryReader { sheet in VStack(alignment: .leading, spacing: 12) { if let name = card.text("title") { Text(name) .font(theme.type.title(StudioBrandKnobs.wordmarkSize)) .tracking(StudioBrandKnobs.wordmarkTracking) .textCase(.uppercase) .lineLimit(1) .foregroundStyle(theme.colors.ink.color) .accessibilityIdentifier("deck-title") .facePart(.title) } if let photo { photo .frame(maxWidth: .infinity) .frame(height: sheet.size.height * StudioBrandKnobs.placeShare) .clipShape(RoundedRectangle(cornerRadius: StudioBrandKnobs.placeRadius, style: .continuous)) .accessibilityIdentifier("face-photo") .facePart(.picture) } StudioPlaceWords(card: card) Spacer(minLength: 0) } .padding(StudioBrandKnobs.inset) .frame(width: sheet.size.width, height: sheet.size.height, alignment: .topLeading) } } } private struct StudioPlaceWords: View { let card: DeckCard @Environment(\.theme) private var theme var body: some View { VStack(alignment: .leading, spacing: 12) { if let headline = card.text("subtitle") { Text(headline) .font(theme.type.display(StudioBrandKnobs.headlineSize)) .lineLimit(3) .minimumScaleFactor(0.7) .faceInk(.ink) .facePart(.subtitle) } StudioPerson(card: card) .facePart(.people) Rectangle() .fill(theme.colors.hairline.color.opacity(StudioBrandKnobs.hairlineFaint)) .frame(height: 1) HStack(alignment: .top, spacing: 12) { if let place = card.text("place") { StudioFact(symbol: "mappin", said: place, tint: theme.colors.accent.color, size: StudioBrandKnobs.factSize - 1) .facePart(.place) } if let days = card.text("period") { StudioFact(symbol: "calendar", said: days, tint: theme.colors.accent.color, size: StudioBrandKnobs.factSize - 1) } } if card.text("place") == nil, card.text("period") == nil, let about = card.text("body") { Text(about) .font(theme.type.body(StudioBrandKnobs.aboutSize)) .lineLimit(3) .foregroundStyle(theme.colors.inkBody.color.opacity(StudioFaceKnobs.labelFaint)) .facePart(.body) } } } } /// The person a card names (the studio's founder) on a mount — their /// picture or their initials — under the core's label for them on this face. private struct StudioPerson: 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: 14) { FaceMount(name: name, picture: entry["picture"]?.text, size: StudioBrandKnobs.founderMount) VStack(alignment: .leading, spacing: 2) { // The face's own label for this place only — the generic // one ("People") says nothing here. if let label = entry["label"]?.text ?? StudioReading.ownLabel(card.face, "people") { Text(label) .font(theme.type.body(StudioBrandKnobs.labelSize)) .foregroundStyle(theme.colors.inkBody.color.opacity(StudioFaceKnobs.labelFaint)) } Text(name) .font(theme.type.title(StudioBrandKnobs.lineSize + 1)) .lineLimit(1) .minimumScaleFactor(0.7) .faceInk(.ink) } } .accessibilityElement(children: .combine) .accessibilityIdentifier("face-person") } } } extension StudioReading { /// The core's label for a place on this face alone (`label.face..`), /// never the generic one every face shares. public static func ownLabel(_ face: String, _ slot: String) -> String? { let path = "label.face.\(face).\(slot)" let said = ShellLines.line("cards", path) return said == "cards.\(path)" ? nil : said } } /// The studio's place face, and the cards it is reviewed in. A studio's kit /// names it for its place and its catalogue's classes (`sharmila.studio`), /// with the pages its card turns to; one with no photograph is a note, as /// every note is drawn (`NoteCard`: its words cut into pages for the room). public enum StudioPlaceFaceCatalogue { public static let stock: FaceStock = .ornamented public static let ground: FaceGround = .paper public static let face = Face(id: "sharmila.studio", specimens: [Specimen("studio", studio, picture: "verandah-wide")]) { card, picture, _ in if card.text("photo") == nil { NoteCard(card: card) } else { StudioPlaceFace(card: card, photo: picture, pages: card.pages) } } public static let studio = DeckCard(face: .sharmilaStudio, fields: [ "photo": .text("verandah-wide"), "title": .text("Invented Studio"), "subtitle": .text("An invented tagline."), "people": .list([.object(["name": .text("Invented Founder"), "picture": .text("portrait")])]), "place": .text("Invented Road"), "period": .text("Mon\u{2013}Fri"), "body": .text("Invented words about the studio."), ]) }