diff --git a/AppleNugs/Views/DownloadsView.swift b/AppleNugs/Views/DownloadsView.swift index 626df6e..8d9beb2 100644 --- a/AppleNugs/Views/DownloadsView.swift +++ b/AppleNugs/Views/DownloadsView.swift @@ -55,7 +55,8 @@ struct DownloadsView: View { play(show) } label: { HStack(spacing: 12) { - MonogramTile(text: show.artist ?? show.title ?? "?", size: 44) + DownloadCover(path: show.artworkPath, + fallback: show.artist ?? show.title ?? "?") VStack(alignment: .leading, spacing: 2) { Text(show.title ?? "Untitled show") @@ -114,3 +115,44 @@ struct DownloadsView: View { app.player.play(queue) } } + +/// A downloaded show's square cover — a show reads as its cover everywhere +/// else, not as its artist's initials. The monogram stands in while the +/// cover loads and when it can't (offline: the download keeps the cover's +/// address, not the image). +private struct DownloadCover: View { + @Environment(\.theme) private var theme + + let path: String? + let fallback: String + + private static let side: CGFloat = 44 + + var body: some View { + Group { + if let url = path.flatMap({ NugsConstants.imageURL(path: $0) }) { + AsyncImage(url: url) { phase in + if case .success(let image) = phase { + image.resizable().aspectRatio(contentMode: .fill) + } else { + monogram + } + } + } else { + monogram + } + } + .frame(width: Self.side, height: Self.side) + .clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous)) + // Flat on the shelf with a frost keyline, like `CoverArt`. + .overlay { + RoundedRectangle(cornerRadius: 6, style: .continuous) + .strokeBorder(theme.palette.hairline, lineWidth: 1) + } + .accessibilityHidden(true) + } + + private var monogram: some View { + MonogramTile(text: fallback, size: Self.side) + } +} diff --git a/AppleNugs/Views/ListeningLedger.swift b/AppleNugs/Views/ListeningLedger.swift index 2033f7d..2af2c4d 100644 --- a/AppleNugs/Views/ListeningLedger.swift +++ b/AppleNugs/Views/ListeningLedger.swift @@ -19,7 +19,8 @@ import SwiftUI /// pinned by tests rather than by this body. Do not format here. /// /// It is "the nice list": a sentence-case section header, one totals line -/// ("112 hours listened · 9 artists"), and rows of a checked box, the name +/// ("112 hours listened · 9 artists"), and rows of a checked box, the +/// artist's photo in a circle, the name /// (which truncates first) and plays / hours in two right-aligned columns; the /// split numbers come from `LedgerSummary`. /// @@ -37,12 +38,21 @@ struct ListeningLedger: View { /// clickable on one launch and not the next. @State private var resolved: [String: ArtistEntry] = [:] + /// The resolved rows' photos, by catalog id. Empty until the lookup lands + /// (and for good if it fails) — rows show the monogram meanwhile. + @State private var avatars: [String: URL] = [:] + var body: some View { let tallies = Self.tallies(from: app.listening.stats) let rows = LedgerSummary.top(tallies) let totals = LedgerSummary.totals(tallies) + // Each row's photo, worked out HERE so body reads `resolved` and + // `avatars` and redraws when they land (the CLAUDE.md artist-photo rule). + let photos = rows.reduce(into: [String: URL]()) { out, row in + if let id = resolved[row.key]?.id, let url = avatars[id] { out[row.key] = url } + } - niceList(rows: rows, totals: totals) + niceList(rows: rows, totals: totals, photos: photos) .task(id: rows.map(\.key).joined(separator: "|")) { await resolveNames(rows) } @@ -77,16 +87,19 @@ struct ListeningLedger: View { /// `.nice.ledger-wide` (72/48). Minimum widths, so the columns line up at /// the default text size and grow rather than clip at larger ones. #if os(macOS) + private static let photoSide: CGFloat = 28 private static let playsColumn: CGFloat = 72 private static let hoursColumn: CGFloat = 48 private static let rowPadding: CGFloat = 9 #else + private static let photoSide: CGFloat = 28 private static let playsColumn: CGFloat = 62 private static let hoursColumn: CGFloat = 40 private static let rowPadding: CGFloat = 11 #endif - private func niceList(rows: [LedgerSummary.Row], totals: LedgerSummary.Totals) -> some View { + private func niceList(rows: [LedgerSummary.Row], totals: LedgerSummary.Totals, + photos: [String: URL]) -> some View { VStack(alignment: .leading, spacing: 0) { // `.sec h3`: heavy 22, sentence case. Text(theme.copy.ledgerTitle) @@ -107,16 +120,21 @@ struct ListeningLedger: View { VStack(spacing: 0) { ForEach(rows) { row in hairline - linked(row) { niceRow(row) } + linked(row) { niceRow(row, photo: photos[row.key]) } } if !rows.isEmpty { hairline } } } } - private func niceRow(_ row: LedgerSummary.Row) -> some View { + private func niceRow(_ row: LedgerSummary.Row, photo: URL?) -> some View { HStack(spacing: 12) { CheckedBox() + // The artist's photo, beside the box rather than instead of it: + // the check is the nice list's joke (Tim, 2026-11-16). A name that + // doesn't resolve to the catalog keeps the monogram. + ArtistPortrait(url: photo, name: row.displayName) + .frame(width: Self.photoSide, height: Self.photoSide) Text(row.displayName) .font(theme.type.title(16)) .foregroundStyle(theme.palette.textPrimary) @@ -160,6 +178,12 @@ struct ListeningLedger: View { } } resolved = found + // Photos are a nicety on top of a list that already works: a failure + // leaves the monograms, and reports nothing. + let ids = found.values.map(\.id) + if !ids.isEmpty, let photos = try? await app.artistAvatars(ids: ids) { + avatars = photos + } } } diff --git a/CLAUDE.md b/CLAUDE.md index ef0d111..ef42c78 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -96,6 +96,9 @@ or release notes for design changes, but keep his own data safe. down: read only inside a `LazyVGrid`/`List` cell, it isn't a dependency of the body, and the tiles keep their monograms (the Favorites page did exactly that until 2026-11-16). Home's crate and the Artists list get away with it only because a `defer { loading = false }` lands in the same update. + **Where photos go (audited 2026-11-16):** every artist LIST — Home's crate, favorites shelf and nice + list, the Favorites page, the Artists list, search — plus the artist page header. Deliberately NOT on + show/video pages, now playing, the pill or the Mac miniplayer: there the artist is a name on a cover. ### Platforms and layout - **macOS vs iOS:** `AppleNugs/macOS/` and `AppleNugs/iOS/` are per-platform (excluded from the other @@ -184,7 +187,7 @@ or release notes for design changes, but keep his own data safe. (4) Backgrounded iOS has no tick, so credit is SETTLED (`ListeningCredit.span`), reading `creditPosition` — nil, never the stale `currentTime`, when the head isn't our item; paused → playing re-anchors without crediting. Don't add a wake or background tick for stats. Deliberate scope cuts: artists only, all-time - only, Home only, typographic ledger, audio only. Reset lives in the account menu. + only, Home only, typographic ledger (no cards or tiles; each row has a 28pt artist photo beside its check, 2026-11-16), audio only. Reset lives in the account menu. - **Compliance (nugs.net Terms):** identity is honest everywhere — `NugsIdentity.current` = `Yeti/ (unofficial; +github; )`, no Referer; the old Android UA strings exist ONLY as the DEBUG Network Probe's control. Streams try tier 7 (ALAC 16) first and other tiers ONE AT A TIME