// The TRACK face (card kind `track`, 66a451ec1; the Codex album-2 card, 23// Oct 2026): one song kept as a file, on the cream card, over its own art// faded into the stock — or, while it has none, its sleeve printed with its// title and artist, stood a little turned at the head where the art would// be. The title typed heavy at the head, its place on the album by hand// under it (`number`, "Track 3"), the artist and the album typed in pencil// and its length typed; at the foot the scrubber — the playhead// running while this track is the one the player holds, a still line from// nought to its length while it is not — and the dark disc that plays it.// The track's place in its album is the deck's to say, never the card's.// Every word is the core's (`DeckCard`); the file is the `play` place's. The// player is the app's: it says where it stands with this track (`TrackPlay`)// and plays, pauses and seeks it (the player the app installs, `faceTrackPlayer`: CottonUI's `DeckTrackPlaying`); the art is the// picture it hands in.importCottonPaperimportCottonValuesimportSwiftUIenumTrackFaceKnobs {staticlet inset = EdgeInsets(top: 28, leading: 26, bottom: 22, trailing: 24)/// The art across the card: where its fade is centred, as shares of the/// card, and how far out it has faded to nothing, as a share of its/// longer side.staticlet artCentre = UnitPoint(x: 0.66, y: 0.58)staticlet artReach: CGFloat = 0.78staticlet artSaturation: CGFloat = 0.85/// The sleeve kept without art, at the head of the card where the art/// would be: its side, of the card's width; its turn; and the room/// between it and the title.staticlet sleeveShare: CGFloat = 0.36staticlet sleeveTurn: Double = 3staticlet sleeveGap: CGFloat = 18/// The head's share of the card's width: the art shows past it.staticlet headWidth: CGFloat = 0.8staticlet titleSize: CGFloat = 27staticlet handSize: CGFloat = 25staticlet subtitleSize: CGFloat = 13.5staticlet lengthSize: CGFloat = 15staticlet disc: CGFloat = 46staticlet noticeHand: CGFloat = 16staticlet stillKnob: CGFloat = 10}publicstructTrackFace<Art: View>: View {let card: DeckCard/// The track's art filling its frame, when the card names one.var art: Art?/// Where the player stands with this track.var play: TrackPlay = .still/// Plays or pauses the track; nil for a card with no file to play.var toggle: (() -> Void)?/// Moves the playhead of the track the player holds.var seek: (TimeInterval) -> Void = { _ in }publicinit( card: DeckCard, art: Art?, play: TrackPlay = .still, toggle: (() -> Void)?, seek: @escaping (TimeInterval) -> Void = { _ in } ) {self.card = cardself.art = artself.play = playself.toggle = toggleself.seek = seek }/// This card's track is the one the player holds.privatevar held: Bool { play.held }privatevar playing: Bool { held && play.playing }publicvar body: someView {GeometryReader { sheet in ZStack(alignment: .topLeading) {iflet art {FadedArt(art: art) .frame(width: sheet.size.width, height: sheet.size.height) } VStack(alignment: .leading, spacing: 0) {// Without art, its sleeve stands at the head where the// art would be, and the words go under it.if card.text("photo") == nil {let side = sheet.size.width * TrackFaceKnobs.sleeveShareTypeSleeve(title: card.text("title"), artist: card.text("subtitle")) .frame(width: side, height: side) .rotationEffect(.degrees(TrackFaceKnobs.sleeveTurn)) .frame(maxWidth: .infinity) .padding(.bottom, TrackFaceKnobs.sleeveGap) } head .frame(width: sheet.size.width * TrackFaceKnobs.headWidth, alignment: .leading)Spacer(minLength: 8) foot } .padding(TrackFaceKnobs.inset) } .frame(width: sheet.size.width, height: sheet.size.height, alignment: .topLeading) .clipped() } .onCardPaper(TrackFaceCatalogue.stock.laid(card.pace)) }/// The title, its place by hand, the artist and album, the length.privatevar head: someView { VStack(alignment: .leading, spacing: 0) {iflet title = card.text("title") {HeavyType(words: title, size: TrackFaceKnobs.titleSize) .lineLimit(2) .minimumScaleFactor(0.7) .accessibilityIdentifier("deck-title") .facePart(.title) }iflet number = card.text("number") {Text(number) .font(CottonFonts.hand(TrackFaceKnobs.handSize)) .lineLimit(1) .minimumScaleFactor(0.7) .faceInk(.ink) .padding(.top, 4) .accessibilityIdentifier("face-number") }iflet subtitle = card.text("subtitle") {Text(subtitle) .font(CottonFonts.type(TrackFaceKnobs.subtitleSize)) .lineLimit(2) .minimumScaleFactor(0.8) .faceInk(.pencil) .padding(.top, 6) .accessibilityIdentifier("face-byline") .facePart(.subtitle) }iflet length = card.text("length") {Text(length) .font(CottonFonts.type(TrackFaceKnobs.lengthSize)) .monospacedDigit() .faceInk(.ink) .padding(.top, 8) } } }/// The scrubber, or the still line, and the disc; what went wrong, by/// hand, over them.privatevar foot: someView { VStack(alignment: .leading, spacing: 6) {if held, let fault = play.fault {Text(HandRun.tail(ShellLines.line("faces", fault == .unavailable ? "media.could_not_fetch" : "recording.none"))) .font(CottonFonts.hand(TrackFaceKnobs.noticeHand)) .lineLimit(2) .faceInk(.pencil) } HStack(alignment: .center, spacing: 14) {if held, play.duration > 0 {TrackScrubber(elapsed: play.elapsed, duration: play.duration, title: card.text("title"), seek: seek) } else {StillRule(length: card.text("length")) }iflet toggle {Button(action: toggle) {TrackDisc(playing: playing, size: TrackFaceKnobs.disc) .opacity(held && play.loading ? 0.5 : 1) } .buttonStyle(MotionButtonStyle()) .accessibilityLabel(ShellLines.line("faces", playing ? "media.pause" : "media.play")) .accessibilityValue(card.text("title") ?? "") .accessibilityIdentifier("track-play") .facePart(.play) } } } }}/// The track's art across the whole card, printed into the stock and faded/// out toward its edges and the head.privatestructFadedArt<Art: View>: View {let art: Art @Environment(\.theme) privatevar themevar body: someView {GeometryReader { box inColor.clear .overlay(art) .clipped() .saturation(TrackFaceKnobs.artSaturation) .mask {RadialGradient( colors: [.black, .black.opacity(0.85), .clear], center: TrackFaceKnobs.artCentre, startRadius: 0, endRadius: max(box.size.width, box.size.height) * TrackFaceKnobs.artReach) } .blendMode(theme.printBlend) } .accessibilityHidden(true) }}/// The scrubber's line while the track is not the one playing: nothing/// played, the knob at its start, nought and the length under it.privatestructStillRule: View {let length: String? @Environment(\.theme) privatevar themevar body: someView { VStack(spacing: 4) { ZStack(alignment: .leading) {Capsule().fill(theme.print(.pencil).opacity(0.35)).frame(height: MusicPartsKnobs.line)Circle().fill(theme.print(.ink)).frame(width: TrackFaceKnobs.stillKnob, height: TrackFaceKnobs.stillKnob) } .frame(height: MusicPartsKnobs.height) HStack {Text(TrackClock.said(0))Spacer(minLength: 8)iflet length { Text(length) } } .font(CottonFonts.type(MusicPartsKnobs.clockSize)) .monospacedDigit() .faceInk(.pencil) } .accessibilityHidden(true) }}/// The track face, by the kind's name, and the cards it is reviewed in:/// under the player the app installs (`faceTrackPlayer`), else still.publicenumTrackFaceCatalogue {publicstaticlet stock: FaceStock = .creampublicstaticlet ground: FaceGround = .paperpublicstaticlet face = Face(id: "track", specimens: [Specimen("lantern", lantern), Specimen("tide", tide)]) { card, picture, _ inTrackPlaying(card: card) { player inTrackFace(card: card, art: picture, play: player.play, toggle: player.toggle, seek: player.seek) } }publicstaticlet lantern = DeckCard(face: .track, fields: ["title": .text("Lantern Weather"),"number": .text("Track 1"),"subtitle": .text("The Example Quartet \u{00B7} Harbour Lights"),"length": .text("3:41"),"play": .text("media/track-1"), ])publicstaticlet tide = DeckCard(face: .track, fields: ["title": .text("Slow Tide"),"number": .text("Track 2"),"subtitle": .text("The Example Quartet \u{00B7} Harbour Lights"),"length": .text("5:02"),"play": .text("media/track-2"), ])}