Files
qbz/crates/qbz-slint/ui/award/AwardView.slint
T
vicrodh 9ccfbd3845 feat(slint): port Awards pages (landing + albums listing + follow)
Port Tauri's AwardView/AwardAlbumsView to Slint: the award landing
(hero + acclaimed-releases preview grid + other-awards rail + follow
heart), the paginated albums listing with client-side search, and
clickable album-sidebar laurels that open the award page (resolving the
award id by name when /album/get omits it).

- AwardState/AwardActions globals + AwardEntry; AlbumState.awards now
  carries award ids
- award controller (src/award.rs): /award/page hero (never page.releases),
  /award/getAlbums grid, /award/explore other-awards + name->id resolver;
  follow via the shared favorite_awards cache (plural-read/singular-write
  favType, skip-if-remote, login seed)
- nav registration: NavEntry::Award/AwardAlbums, ContentView arms,
  navigate_award/navigate_award_albums, AppShell mounts, app.slint exports
- ArtworkTarget::AwardAlbum/AwardOther

cc
2026-06-19 02:41:12 -06:00

341 lines
15 KiB
Plaintext

// Award landing page — a 1:1 port of Tauri's AwardView.svelte: a circular
// laurel/gold hero with the award name + magazine + a Follow heart, a
// section header ("Acclaimed Releases" + count + "See all" when more
// exist), a bounded PREVIEW grid of award-winning releases (loading /
// error+retry / empty / grid branches), and an "Other awards" carousel.
//
// Faithful composition from existing primitives — the scaffold (Flickable
// + NavButtons + 32px page padding + shared ListScrollbar + NavState
// scroll restore) mirrors LabelPageView; the hero laurel uses the album
// sidebar's gold gradient; the preview grid reuses AlbumCollectionView
// (the DiscoverBrowse/Label grid); the "Other awards" rail reuses the
// SlimItem ArtistCarousel (LabelPageView's "More labels" precedent). No
// new widgets — only this composition.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { AwardState, AwardActions, NavState, DragState } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { CircleAction } from "../primitives/CircleAction.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { NavButtons } from "../shell/NavButtons.slint";
import { AlbumCollectionView } from "../discover/AlbumCollectionView.slint";
import { ArtistCarousel } from "../discover/ArtistCarousel.slint";
component SectionTitle inherits Text {
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
}
export component AwardView inherits Rectangle {
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
background: Theme.surface-main;
page-flickable := Flickable {
// Don't scroll while a track is being dragged out (keeps the row's
// pointer grab so drag-end fires) — matches the other content views.
interactive: !DragState.active;
viewport-width: self.width;
viewport-height: page.preferred-height;
// Scroll-position restore on back/forward (see nav::scope_for).
property <string> sr-armed: NavState.restore-scope;
function sr-restore() {
if (NavState.restore-scope == "award" && self.viewport-height > self.height) {
self.viewport-y = NavState.scroll-restore;
NavState.restore-scope = "";
}
}
init => { self.sr-restore(); }
changed sr-armed => { self.sr-restore(); }
changed viewport-height => { self.sr-restore(); }
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
page := VerticalLayout {
width: parent.width;
padding-left: 32px;
padding-right: 32px;
padding-top: 11px;
padding-bottom: 100px;
spacing: 0px;
alignment: start;
// --- History navigation --------------------------------------
HorizontalLayout {
alignment: start;
NavButtons { }
}
Rectangle { height: 22px; }
// --- Award hero header ---------------------------------------
HorizontalLayout {
spacing: 32px;
alignment: start;
// Circular 180px hero — the award/magazine image when set,
// otherwise a white laurel on the gold gradient (matches the
// album sidebar AWARDS avatar styling).
Rectangle {
width: 180px;
height: 180px;
border-radius: 90px;
background: @linear-gradient(135deg, #b45309 0%, #eab308 100%);
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
drop-shadow-offset-y: 8px;
clip: true;
if AwardState.image-url == "": QbzIcon {
source: @image-url("../assets/laurels.svg");
width: 84px;
height: 84px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: #ffffff;
}
if AwardState.image-url != "": Image {
width: 100%;
height: 100%;
source: AwardState.image;
image-fit: cover;
}
}
VerticalLayout {
alignment: start;
padding-top: 8px;
spacing: 0px;
horizontal-stretch: 1;
Text {
text: @tr("Award");
color: Theme.text-muted;
font-size: 10px;
font-weight: Typography.semibold;
letter-spacing: 1.5px;
}
Rectangle { height: 6px; }
Text {
text: AwardState.name;
color: Theme.text-primary;
font-size: Typography.section;
font-weight: Typography.bold;
overflow: elide;
}
// Magazine line — only when present (server text, untranslated).
if AwardState.magazine-name != "": Rectangle { height: 10px; }
if AwardState.magazine-name != "": Text {
text: AwardState.magazine-name;
color: Theme.text-secondary;
font-size: Typography.body;
overflow: elide;
}
Rectangle { height: 18px; }
// Follow heart — three states: not-following / following /
// toggling (disabled while the API call is in flight). The
// filled heart + accent tint marks the followed state; the
// disabled state dims (CircleAction enabled=false).
HorizontalLayout {
alignment: start;
CircleAction {
primary: false;
diameter: 44px;
active: AwardState.is-following;
enabled: !AwardState.following-toggling;
icon: AwardState.is-following
? @image-url("../assets/icons/heart-filled.svg")
: @image-url("../assets/icons/heart.svg");
tooltip: AwardState.is-following
? @tr("Unfollow award")
: @tr("Follow award");
clicked => {
AwardActions.toggle-follow(AwardState.id);
}
}
}
}
}
Rectangle { height: 32px; }
// --- Section header: title + count + "See all" ---------------
HorizontalLayout {
spacing: 12px;
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
HorizontalLayout {
spacing: 10px;
VerticalLayout {
alignment: center;
SectionTitle {
text: @tr("Acclaimed Releases");
}
}
// Count badge — shown only when the total hint is > 0.
if AwardState.total > 0: VerticalLayout {
alignment: center;
Text {
text: "\{AwardState.total}";
color: Theme.text-muted;
font-size: Typography.body;
font-weight: Typography.medium;
}
}
}
}
// "See all" — only when there are more albums than the preview.
if AwardState.has-more: VerticalLayout {
alignment: center;
see-all := Rectangle {
width: see-all-text.preferred-width + 16px;
height: 26px;
border-radius: 4px;
background: see-all-ta.has-hover ? Theme.surface-hover : transparent;
see-all-text := Text {
// "See All" is the contract i18n value; the arrow
// glyph is decoration appended outside the msgid.
text: @tr("See All") + " →";
color: see-all-ta.has-hover ? Theme.text-primary : Theme.text-secondary;
font-size: 14px;
font-weight: Typography.medium;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
see-all-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
AwardActions.open-albums();
}
}
}
}
}
Rectangle { height: 16px; }
// --- Body: loading / error+retry / empty / grid (exclusive) --
if AwardState.loading: Rectangle {
height: 280px;
VerticalLayout {
alignment: center;
spacing: 18px;
HorizontalLayout {
alignment: center;
LoadingSpinner { size: 36px; }
}
Text {
text: @tr("Loading…");
color: Theme.text-muted;
font-size: 13px;
horizontal-alignment: center;
}
}
}
if !AwardState.loading && AwardState.load-error: Rectangle {
height: 240px;
VerticalLayout {
alignment: center;
spacing: 16px;
Text {
text: @tr("Failed to load Library");
color: Theme.text-muted;
font-size: 14px;
horizontal-alignment: center;
}
HorizontalLayout {
alignment: center;
retry-btn := Rectangle {
width: retry-text.preferred-width + 32px;
height: 34px;
border-radius: 6px;
background: retry-ta.has-hover
? Theme.surface-hover
: Theme.surface-elevated;
border-width: 1px;
border-color: Theme.border-subtle;
retry-text := Text {
text: @tr("Retry");
color: Theme.text-primary;
font-size: 13px;
font-weight: Typography.medium;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
retry-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
AwardActions.retry();
}
}
}
}
}
}
if !AwardState.loading && !AwardState.load-error
&& AwardState.albums.length == 0: Rectangle {
height: 200px;
VerticalLayout {
alignment: center;
Text {
text: @tr("No award-winning releases yet.");
color: Theme.text-muted;
font-size: 14px;
horizontal-alignment: center;
}
}
}
// The PREVIEW grid (reuses the DiscoverBrowse/Label grid).
if !AwardState.loading && !AwardState.load-error
&& AwardState.albums.length > 0: AlbumCollectionView {
albums: AwardState.albums;
view-mode: "grid";
is-grouped: false;
show-source: false;
open-album(id) => { root.open-album(id); }
open-artist(id) => { root.open-artist(id); }
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// --- Other awards carousel -----------------------------------
// Reuses the SlimItem ArtistCarousel (LabelPageView's "More
// labels" precedent): circular cards, title = award name,
// subtitle = magazine. No follow chip here.
if AwardState.other-awards.length > 0: Rectangle { height: 32px; }
if AwardState.other-awards.length > 0: ArtistCarousel {
title: @tr("Other awards");
artists: AwardState.other-awards;
card-follow-mode: "none";
artist-clicked(id) => {
AwardActions.open-award(id, "");
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
// Shared scrollbar in the right gutter (homologated cross-view).
ListScrollbar {
x: parent.width - self.width - 4px;
width: 14px;
height: 100%;
viewport-height: page-flickable.viewport-height;
visible-height: page-flickable.height;
viewport-y <=> page-flickable.viewport-y;
}
}