Files
qbz/crates/qbz-ui/ui/discover/ForYouView.slint
T
vicrodh 9e7d574be0 feat(discover): Most Played Albums View-all page with search + play count
Full-page listing opened from the rail's View all (both tabs now wire show-view-all -> HomeActions.open-most-played-albums). New MostPlayedAlbumsView (mirrors RecentAlbumsView) with a search box; AlbumCardItem gains a plays field shown ONLY here (a gated line in AlbumCard). Rust: navigate_most_played_albums loads all_albums(), caches the ranked rows, renders the grid + fires artwork (MostPlayedAlbumsPage target, Qobuz vs Plex/local split); the search box re-filters the cached rows by title/artist and re-renders (mirrors the Qobuz-playlists filter). NavEntry::MostPlayedAlbums + AppShell mount + ContentView variant. Count label in 8 locales. slintcheck green; qbz-crate Rust pending a full build (30GB wall).

cc
2026-07-14 01:21:36 -06:00

201 lines
7.9 KiB
Plaintext

// Discover > For You — ordered, heterogeneous layout for the For You tab.
// Unlike Home / Editor's Picks (uniform album carousels), For You mixes album
// carousels, a track carousel, artist carousels, radio tiles, Qobuz Mixes, and
// the Spotlight, so each row is a different component.
//
// Slice 5: the order + visibility are driven by the prefs configurator. Rust
// pushes DiscoverState.foryou-sections (the ordered ENABLED descriptor ids); a
// single repeater iterates them and an if-chain delegate mounts the right
// component, reading the matching ForYouState field by id. Each arm keeps its
// own data `length > 0` self-hide gate (qobuzMixes excepted — always rendered).
//
// essentialsByGenre is Slice-2c-blocked (no ForYouState.essentials field yet);
// Rust drops it from the descriptor list, so there is intentionally no arm for
// it here. It returns automatically once Slice 2c adds the field + an arm.
//
// Reuses the shared cards/carousels — no new card components here.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { ForYouState, RadioStationItem, DiscoverState, HomeActions } from "../state.slint";
import { Carousel } from "Carousel.slint";
import { SlimCarousel } from "SlimCarousel.slint";
import { ArtistCarousel } from "ArtistCarousel.slint";
import { Spotlight } from "Spotlight.slint";
import { QobuzMixesRow } from "QobuzMixesRow.slint";
import { RadioCarousel } from "RadioCarousel.slint";
import { HomeSkeleton } from "HomeSkeleton.slint";
export component ForYouView inherits VerticalLayout {
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
callback play-track(string);
callback play-top-tracks(string);
callback start-radio(string);
callback start-radio-album(string);
callback open-mix(string);
// Progressive load: while the first lazy load is in flight, show the
// skeleton Home uses (the Qobuz Mixes tiles stay — they're static). It hides
// as soon as ANY content paints. Static, order-independent (top while empty).
property <bool> show-skeleton:
ForYouState.loading
&& ForYouState.release-watch.albums.length == 0
&& ForYouState.top-artists.length == 0
&& ForYouState.recent-albums.albums.length == 0
&& ForYouState.recent-tracks.length == 0;
spacing: 40px;
alignment: start;
if root.show-skeleton: HomeSkeleton { }
// Prefs-driven loop. DiscoverState.foryou-sections = enabled ids in pref
// order (recomputed in Rust). Delegate = single-root VerticalLayout whose
// inner if-chain mounts the right component + binds the matching global;
// exactly one inner `if` matches per descriptor id, so each row resolves to
// one visible child (or none, when its data is empty and it self-hides).
for desc in DiscoverState.foryou-sections: VerticalLayout {
spacing: 0px;
// qobuzMixes — static navigation tiles, ALWAYS rendered (no data gate).
if desc.id == "qobuzMixes": QobuzMixesRow {
open-mix(which) => {
root.open-mix(which);
}
}
// releaseWatch — album carousel.
if desc.id == "releaseWatch" && ForYouState.release-watch.albums.length > 0: Carousel {
section: ForYouState.release-watch;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// radioStations — album-seeded radio tiles (paged carousel w/ nav buttons).
if desc.id == "radioStations" && ForYouState.radio-stations.length > 0: RadioCarousel {
title: @tr("Radio Stations");
stations: ForYouState.radio-stations;
start-radio-album(id) => {
root.start-radio-album(id);
}
}
// continueListening — recently-played tracks slim carousel.
if desc.id == "continueListening" && ForYouState.recent-tracks.length > 0: SlimCarousel {
title: @tr("Recently Played Tracks");
items: ForYouState.recent-tracks;
item-clicked(id) => {
root.play-track(id);
}
}
// recentlyPlayedAlbums — album carousel.
if desc.id == "recentlyPlayedAlbums" && ForYouState.recent-albums.albums.length > 0: Carousel {
section: ForYouState.recent-albums;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// topArtists — artist carousel.
if desc.id == "topArtists" && ForYouState.top-artists.length > 0: ArtistCarousel {
title: @tr("Your Top Artists");
artists: ForYouState.top-artists;
artist-clicked(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// favoriteAlbums — album carousel.
if desc.id == "favoriteAlbums" && ForYouState.favorite-albums.albums.length > 0: Carousel {
section: ForYouState.favorite-albums;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// mostPlayedAlbums — album carousel ranked by local play count.
if desc.id == "mostPlayedAlbums" && ForYouState.most-played-albums.albums.length > 0: Carousel {
section: ForYouState.most-played-albums;
show-view-all: true;
view-all-clicked => {
HomeActions.open-most-played-albums();
}
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// similarAlbums — "More From Your Library" album carousel.
if desc.id == "similarAlbums" && ForYouState.more-from-library.albums.length > 0: Carousel {
section: ForYouState.more-from-library;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// rediscoverLibrary — album carousel.
if desc.id == "rediscoverLibrary" && ForYouState.rediscover.albums.length > 0: Carousel {
section: ForYouState.rediscover;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// artistsToFollow — artist carousel.
if desc.id == "artistsToFollow" && ForYouState.artists-to-follow.length > 0: ArtistCarousel {
title: @tr("Artists to Follow");
artists: ForYouState.artists-to-follow;
artist-clicked(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// artistSpotlight — the Spotlight panel.
if desc.id == "artistSpotlight" && ForYouState.spotlight-visible: Spotlight {
open-artist(id) => {
root.open-artist(id);
}
open-album(id) => {
root.open-album(id);
}
play-top-tracks(id) => {
root.play-top-tracks(id);
}
start-radio(id) => {
root.start-radio(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}