From b04cb6e4fbdb288343802a7181d4acdf0a3aeae4 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 16 Nov 2026 15:24:33 -0500 Subject: [PATCH 1/2] feat: Home's favorite artists are photo tiles The Favorites strip's text chips become one scrolling shelf of ArtistTile (photo in a circle, name below, never cut off for ~98% of the catalog), as in the crate and on the Favorites page. Photos share Home's avatar table, now merged rather than replaced so the crate's lookup can't wipe them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VriHZgxEZZHunPFyTvTmjt --- AppleNugs/Theme/Components/ArtistTile.swift | 3 +- AppleNugs/Views/HomeView.swift | 58 +++++++++++---------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/AppleNugs/Theme/Components/ArtistTile.swift b/AppleNugs/Theme/Components/ArtistTile.swift index 7319b62..0032e5b 100644 --- a/AppleNugs/Theme/Components/ArtistTile.swift +++ b/AppleNugs/Theme/Components/ArtistTile.swift @@ -2,7 +2,8 @@ import SwiftUI /// An artist as a tile: the photo in a circle (Apple Music's shape for an /// artist, so it reads apart from square show covers), the name centered below, -/// on a raised shelf. Home's crate (iOS) and the Favorites page use it. +/// on a raised shelf. Home's crate (iOS), Home's favorites shelf and the +/// Favorites page use it. /// /// Names are never cut off for ~98% of the catalog: up to three lines, /// shrinking to 85% before truncating (median name 14 characters, 1 in 10 past diff --git a/AppleNugs/Views/HomeView.swift b/AppleNugs/Views/HomeView.swift index fcb15ee..87954cc 100644 --- a/AppleNugs/Views/HomeView.swift +++ b/AppleNugs/Views/HomeView.swift @@ -17,8 +17,9 @@ struct HomeView: View { @State private var artistCount = 0 @State private var appeared = false @State private var sampleError: String? - /// The crate artists' photos, by artist id. Empty until the lookup lands - /// (and for good if it fails) — tiles show the monogram meanwhile. + /// Artist photos for the crate and the favorites shelf, by artist id. + /// Empty until a lookup lands (and for good if it fails) — tiles show the + /// monogram meanwhile. @State private var avatars: [String: URL] = [:] /// Starts true: the fetch is already coming, and a one-frame "nothing in /// the crate" is a worse lie than a spinner nobody sees. @@ -265,6 +266,9 @@ struct HomeView: View { /// Section headers: `.sec h3`'s heavy 22. private var sectionSize: CGFloat { 22 } + /// A favorite artist's tile on the shelf. + private var favoriteTileWidth: CGFloat { 100 } + // --- favorites strip ---------------------------------------------------- private var favoritesStrip: some View { @@ -281,31 +285,30 @@ struct HomeView: View { } if !app.favorites.artists.isEmpty { - LazyVGrid(columns: [GridItem(.adaptive(minimum: 150, maximum: 240), spacing: 10)], - alignment: .leading, spacing: 10) { - ForEach(app.favorites.artists.prefix(8)) { fav in - NavigationLink(value: Route.artist(ArtistEntry(id: fav.id, name: fav.name))) { - HStack { - Text(fav.name) - .font(theme.type.body(13.5).weight(.bold)) - .foregroundStyle(theme.palette.textPrimary) - .lineLimit(1) - Spacer(minLength: 0) - } - .padding(.horizontal, 12) - .padding(.vertical, 9) - .background { - RoundedRectangle(cornerRadius: 9, style: .continuous) - .fill(theme.palette.raised) - // `.chips span`: shelf with a frost keyline. - .overlay { - RoundedRectangle(cornerRadius: 9, style: .continuous) - .strokeBorder(theme.palette.hairline, lineWidth: 1) - } + // One scrolling shelf of photo tiles (`ArtistTile`, as in the + // crate and on the Favorites page), the artist circles above + // the square show covers below. One row, not a grid: eight + // tiles in a grid were three rows on a phone. 100pt leaves a + // peek of the fourth tile across a portrait phone, so the row + // reads as scrollable; the Mac's ~800pt Home shows about seven. + ScrollView(.horizontal, showsIndicators: false) { + HStack(alignment: .top, spacing: ArtistTile.spacing) { + ForEach(app.favorites.artists.prefix(8)) { fav in + NavigationLink(value: Route.artist(ArtistEntry(id: fav.id, name: fav.name))) { + ArtistTile(name: fav.name, photo: avatars[fav.id]) + .frame(width: favoriteTileWidth) } - .contentShape(RoundedRectangle(cornerRadius: 9, style: .continuous)) + .buttonStyle(.plain) } - .buttonStyle(.plain) + } + // Tiles stretch to the tallest name, so the row lines up. + .fixedSize(horizontal: false, vertical: true) + } + .task(id: app.favorites.artists.prefix(8).map(\.id)) { + let ids = app.favorites.artists.prefix(8).map(\.id) + // A failure leaves the monograms, and reports nothing. + if let found = try? await app.artistAvatars(ids: Array(ids)) { + avatars.merge(found) { _, new in new } } } } @@ -339,8 +342,9 @@ struct HomeView: View { } // Photos are a nicety on top of a crate that already works: a failure // leaves the monograms, and reports nothing. - if !sample.isEmpty { - avatars = (try? await app.artistAvatars(ids: sample.map(\.id))) ?? [:] + // Merged, not assigned: the favorites shelf shares this table. + if !sample.isEmpty, let found = try? await app.artistAvatars(ids: sample.map(\.id)) { + avatars.merge(found) { _, new in new } } } } From 6c3ab844f5b756ef43412286bfd85d6d3503eec7 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 16 Nov 2026 15:34:27 -0500 Subject: [PATCH 2/2] fix: the Favorites page shows artist photos once they load The photo table was read only inside the LazyVGrid's cells, so it never registered as a dependency of the page's body: a photo that landed after the grid was built never redrew the tile, and Goose stayed a monogram on Tim's Duo. The body now reads the table and hands it to the section. CLAUDE.md records the rule. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VriHZgxEZZHunPFyTvTmjt --- AppleNugs/Views/FavoritesView.swift | 9 +++++++-- CLAUDE.md | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/AppleNugs/Views/FavoritesView.swift b/AppleNugs/Views/FavoritesView.swift index 1237f89..15f74c6 100644 --- a/AppleNugs/Views/FavoritesView.swift +++ b/AppleNugs/Views/FavoritesView.swift @@ -20,7 +20,12 @@ struct FavoritesView: View { .frame(maxWidth: .infinity, minHeight: 360) } else { VStack(alignment: .leading, spacing: 26) { - if !favorites.artists.isEmpty { artistsSection } + // `avatars` is read HERE, in body, and handed down. Read only + // inside the LazyVGrid's cells, it never registered as a + // dependency of this body, so a photo landing after the + // grid was built never redrew the tile (Goose stayed a + // monogram on Tim's Duo, 2026-11-16). + if !favorites.artists.isEmpty { artistsSection(avatars) } if !favorites.shows.isEmpty { showsSection } if !favorites.videos.isEmpty { videosSection } } @@ -45,7 +50,7 @@ struct FavoritesView: View { .foregroundStyle(theme.palette.textPrimary) } - private var artistsSection: some View { + private func artistsSection(_ avatars: [String: URL]) -> some View { VStack(alignment: .leading, spacing: 12) { sectionTitle("Artists") LazyVGrid(columns: [GridItem(ArtistTile.column, spacing: ArtistTile.spacing)], diff --git a/CLAUDE.md b/CLAUDE.md index f4bd774..ef0d111 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -91,6 +91,11 @@ or release notes for design changes, but keep his own data safe. networking); the now-playing counter reads "Track 3 of 24"; the Mac Home resume card is a FLAT cover (the Mac's bubble belongs to the dashboard miniplayer and the Now Playing window); "Sign out" app-wide; all clear-queue paths confirm. +- **Artist photos** (`ArtistPortrait`, `ArtistTile`) come from `AppModel.artistAvatars(ids:)` into a + view's `@State` table that lands AFTER the grid is built. **Read that table in `body`** and hand it + 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. ### Platforms and layout - **macOS vs iOS:** `AppleNugs/macOS/` and `AppleNugs/iOS/` are per-platform (excluded from the other