Add the missing For You "Favorite Albums" carousel (Tauri's
favoriteAlbums), the user's favorited albums capped at 18 in favorite
order, self-hiding when empty. Reuses the album fav-fetch already done in
albums_branch — no new endpoint.
- state.slint: ForYouState.favorite-albums: DiscoverSection.
- foryou.rs: build_favorite_albums (cap 18, unfiltered) + apply_favorite_albums
(mirrors apply_rediscover); wired into albums_branch right after fav_albums
resolves, painting in the same layer as rediscover/radio.
- artwork.rs: ForYouFavoriteAlbum { index } variant + apply arm.
- ForYouView.slint: mount the Carousel after Your Top Artists, before More
From Your Library, gated on favorite-albums.albums.length > 0.
Titled "Favorite Albums" (not Tauri's literal "More From Your Library")
to avoid the label collision with similarAlbums.
cc
201 lines
6.6 KiB
Plaintext
201 lines
6.6 KiB
Plaintext
// Discover > For You — dedicated, ordered layout for the For You tab.
|
|
// Unlike Home / Editor's Picks (uniform album carousels from
|
|
// HomeState.sections), For You mixes album carousels, a track
|
|
// carousel, and artist carousels, so it renders from ForYouState.
|
|
// Sections hide themselves when empty.
|
|
//
|
|
// Reuses the shared cards/carousels — no new card components here.
|
|
// Qobuz Mixes, Radio Stations, Spotlight, and the reco-DB sections
|
|
// (More from library, Rediscover) are later increments.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { ForYouState, RadioStationItem } 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 { RadioCard } from "RadioCard.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 — the recently-played sections
|
|
// render first (local, instant), the rest fill in via each section's own
|
|
// `if length > 0` gate. The page-level `loading` latch only keeps the
|
|
// skeleton up while every backing section is still 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;
|
|
|
|
// 0. Qobuz Mixes (static navigation tiles).
|
|
QobuzMixesRow {
|
|
open-mix(which) => {
|
|
root.open-mix(which);
|
|
}
|
|
}
|
|
|
|
if root.show-skeleton: HomeSkeleton { }
|
|
|
|
// 1. Release Watch.
|
|
if 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);
|
|
}
|
|
}
|
|
|
|
// 1b. Radio Stations — album-seeded radio tiles.
|
|
if ForYouState.radio-stations.length > 0: VerticalLayout {
|
|
spacing: 12px;
|
|
Text {
|
|
text: @tr("Radio Stations");
|
|
color: Theme.text-primary;
|
|
font-size: 18px;
|
|
font-weight: Typography.semibold;
|
|
}
|
|
Rectangle {
|
|
height: 234px;
|
|
clip: true;
|
|
radio-flick := Flickable {
|
|
width: 100%;
|
|
height: parent.height;
|
|
viewport-width: ForYouState.radio-stations.length * (200px + 32px);
|
|
viewport-height: self.height;
|
|
HorizontalLayout {
|
|
spacing: 32px;
|
|
alignment: start;
|
|
for st in ForYouState.radio-stations: RadioCard {
|
|
seed-title: st.title;
|
|
seed-subtitle: st.artist;
|
|
label: "RADIO";
|
|
artwork: st.artwork;
|
|
clicked => {
|
|
root.start-radio-album(st.album-id);
|
|
}
|
|
play => {
|
|
root.start-radio-album(st.album-id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 2. Recently Played Tracks.
|
|
if ForYouState.recent-tracks.length > 0: SlimCarousel {
|
|
title: @tr("Recently Played Tracks");
|
|
items: ForYouState.recent-tracks;
|
|
item-clicked(id) => {
|
|
root.play-track(id);
|
|
}
|
|
}
|
|
|
|
// 3. Recently Played Albums.
|
|
if 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);
|
|
}
|
|
}
|
|
|
|
// 4. Your Top Artists.
|
|
if 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);
|
|
}
|
|
}
|
|
|
|
// 6. Favorite Albums.
|
|
if 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);
|
|
}
|
|
}
|
|
|
|
// 5. More From Your Library.
|
|
if 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);
|
|
}
|
|
}
|
|
|
|
// 6. Rediscover Your Library.
|
|
if 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);
|
|
}
|
|
}
|
|
|
|
// 6. Artists to Follow.
|
|
if 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);
|
|
}
|
|
}
|
|
|
|
// 6. Spotlight.
|
|
if 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);
|
|
}
|
|
}
|
|
}
|