Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AppleNugs/Theme/Components/ArtistTile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions AppleNugs/Views/FavoritesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand All @@ -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)],
Expand Down
58 changes: 31 additions & 27 deletions AppleNugs/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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 }
}
}
}
Expand Down Expand Up @@ -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 }
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading