Per the user's visual review. Replaces the reinvented MyQBZ controls with the app's existing primitives and resolves the per-item data left unresolved. Cross-cutting (all MyQBZ views): - Removed the per-view "Back" header (the app uses the global < > nav). - 32px L/R content padding so the ListScrollbar never rides over rows/cards. - Homologated page padding + Typography tokens to Favorites/LocalLibrary. - No more blue accent-filled pills / non-app colors. Component homologation (deleted the reinvented locals + dead code): - Grid/list + detail view-mode toggle -> the app ViewToggle (ToggleButton, surface-hover active, never accent). Builder ORDER-BY segmented de-blued too. - Sort/filter -> QbzSelect (sm); search -> ExpandableSearch (sm); "+ New" -> NewActionBtn (surface-elevated circle, single centered glyph). Header "+ New" hidden when empty so the empty-state CTA is the only one (no duplicate). - Deleted PrimaryCta / MyQbzSearch / ControlBtn / ViewSeg / ViewModeGroup / SortItem / ColMenuItem + the hand-rolled sort/filter popups + reset. Data (resolveItems, was deferred): - Quality column populated from the resolved tracks (QualityBadgeFull). - New ui/primitives/SourceGlyph.slint: full-color Qobuz/Plex glyphs + a text-muted local hard-drive -- distinguishes Local vs Plex, no accent blob. Reused in the detail + builder rows. - Type column shows the real release type (ALBUM/EP/SINGLE), not always ALBUM. - Local/Plex album art now loads in the detail rows (split artwork dispatch). - Collection grid card renders custom_artwork_path. - Builder rows: 44px + a hairline so quality badges read separated. Backend crates untouched. cargo check -p qbz-slint green. cc
238 lines
10 KiB
Plaintext
238 lines
10 KiB
Plaintext
// My QBZ > Collections — the index grid of the user's Collections + Artist
|
|
// Collections (Tauri's CollectionsView.svelte). Same vocabulary as Mixtapes
|
|
// plus the kind-filter (a second QbzSelect). The 3x3 mosaic appears only for a
|
|
// `collection` with >= 9 items (handled inside CollectionMosaic).
|
|
//
|
|
// HOMOLOGATED to the app's index views: NO per-view back button, 32px L/R
|
|
// content padding, Typography tokens, ExpandableSearch + QbzSelect + the shared
|
|
// ViewToggle, surface-elevated NewActionBtn (no blue pill).
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { MyQbzState, MyQbzActions, MixtapeCardItem, NavState } from "../state.slint";
|
|
import { ExpandableSearch } from "../primitives/ExpandableSearch.slint";
|
|
import { QbzSelect } from "../primitives/QbzSelect.slint";
|
|
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
|
|
import { CollectionMosaic } from "CollectionMosaic.slint";
|
|
import { NewActionBtn, ViewToggle, MyQbzCard, MyQbzListRow } from "MyQbzShared.slint";
|
|
|
|
export component CollectionsView inherits Rectangle {
|
|
property <length> card-w: 208px;
|
|
property <length> grid-gap: 20px;
|
|
property <length> card-h: 184px + 12px + 12px + 18px + 2 * 20px + 18px + 12px;
|
|
|
|
property <int> sort-index:
|
|
MyQbzState.col-sort == "name" ? 1
|
|
: MyQbzState.col-sort == "items" ? 2
|
|
: MyQbzState.col-sort == "updated" ? 3
|
|
: 0;
|
|
property <int> kind-index:
|
|
MyQbzState.col-kind-filter == "collection" ? 1
|
|
: MyQbzState.col-kind-filter == "artist_collection" ? 2
|
|
: 0;
|
|
|
|
background: Theme.surface-main;
|
|
|
|
flick := Flickable {
|
|
viewport-width: self.width;
|
|
viewport-height: page.preferred-height;
|
|
property <string> sr-armed: NavState.restore-scope;
|
|
function sr-restore() {
|
|
if (NavState.restore-scope == "collections" && 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-top: 16px;
|
|
padding-right: 32px;
|
|
padding-bottom: 100px;
|
|
padding-left: 32px;
|
|
spacing: 0px;
|
|
alignment: start;
|
|
|
|
// --- Header — no per-view back button ----------------------
|
|
HorizontalLayout {
|
|
height: 40px;
|
|
spacing: 16px;
|
|
VerticalLayout {
|
|
alignment: center;
|
|
horizontal-stretch: 1;
|
|
Text {
|
|
text: @tr("Collections");
|
|
color: Theme.text-primary;
|
|
font-size: Typography.section;
|
|
font-weight: Typography.bold;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
// Header "+ New" shows only when populated; when empty the
|
|
// empty-state CTA is the single call-to-action (no duplicate).
|
|
if MyQbzState.collections.length > 0 || MyQbzState.col-search != "" || MyQbzState.col-kind-filter != "all": VerticalLayout {
|
|
alignment: center;
|
|
NewActionBtn {
|
|
clicked => { MyQbzActions.create-collection(); }
|
|
}
|
|
}
|
|
}
|
|
Rectangle { height: 16px; }
|
|
|
|
// ====================== EMPTY STATE ========================
|
|
if MyQbzState.collections.length == 0 && MyQbzState.col-search == "" && MyQbzState.col-kind-filter == "all": VerticalLayout {
|
|
padding-top: 80px;
|
|
padding-bottom: 80px;
|
|
spacing: 16px;
|
|
alignment: start;
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
CollectionMosaic {
|
|
size: 160px;
|
|
empty-kind: "collection";
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
Text {
|
|
text: @tr("No collections yet");
|
|
color: Theme.text-secondary;
|
|
font-size: Typography.section;
|
|
font-weight: Typography.semibold;
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
NewActionBtn {
|
|
clicked => { MyQbzActions.create-collection(); }
|
|
}
|
|
}
|
|
}
|
|
|
|
// ====================== POPULATED ==========================
|
|
if MyQbzState.collections.length > 0 || MyQbzState.col-search != "" || MyQbzState.col-kind-filter != "all": VerticalLayout {
|
|
spacing: 0px;
|
|
alignment: start;
|
|
|
|
// --- Toolbar -------------------------------------------
|
|
HorizontalLayout {
|
|
height: 30px;
|
|
spacing: 8px;
|
|
Rectangle { horizontal-stretch: 1; }
|
|
VerticalLayout {
|
|
alignment: center;
|
|
ExpandableSearch {
|
|
placeholder: @tr("Search");
|
|
sm: true;
|
|
query <=> MyQbzState.col-search;
|
|
edited(q) => { MyQbzActions.col-search-changed(q); }
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
QbzSelect {
|
|
menu-width: 180px;
|
|
sm: true;
|
|
options: [
|
|
@tr("Position"),
|
|
@tr("Name"),
|
|
@tr("Items"),
|
|
@tr("Recently updated"),
|
|
];
|
|
current-index: root.sort-index;
|
|
selected(i) => {
|
|
MyQbzActions.col-set-sort(
|
|
i == 1 ? "name"
|
|
: i == 2 ? "items"
|
|
: i == 3 ? "updated"
|
|
: "position");
|
|
}
|
|
}
|
|
}
|
|
// Kind filter (group-by idiom, second QbzSelect).
|
|
VerticalLayout {
|
|
alignment: center;
|
|
QbzSelect {
|
|
menu-width: 200px;
|
|
sm: true;
|
|
options: [
|
|
@tr("All kinds"),
|
|
@tr("Collections"),
|
|
@tr("Artist Collections"),
|
|
];
|
|
current-index: root.kind-index;
|
|
selected(i) => {
|
|
MyQbzActions.col-set-kind-filter(
|
|
i == 1 ? "collection"
|
|
: i == 2 ? "artist_collection"
|
|
: "all");
|
|
}
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
ViewToggle {
|
|
view: MyQbzState.col-view;
|
|
set-view(v) => { MyQbzActions.col-set-view(v); }
|
|
}
|
|
}
|
|
}
|
|
Rectangle { height: 16px; }
|
|
|
|
// --- Body: search/filter-empty -------------------------
|
|
if MyQbzState.collections.length == 0: Rectangle {
|
|
height: 80px;
|
|
Text {
|
|
text: @tr("No results found");
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
}
|
|
}
|
|
|
|
// --- Body: GRID ---------------------------------------
|
|
if MyQbzState.collections.length > 0 && MyQbzState.col-view == "grid": grid := Rectangle {
|
|
property <int> columns: Math.max(1,
|
|
Math.floor((self.width + root.grid-gap) / (root.card-w + root.grid-gap)));
|
|
property <int> rows: Math.ceil(MyQbzState.collections.length / self.columns);
|
|
height: self.rows > 0
|
|
? self.rows * root.card-h + Math.max(0, self.rows - 1) * root.grid-gap
|
|
: 0px;
|
|
for item[i] in MyQbzState.collections: MyQbzCard {
|
|
x: Math.mod(i, grid.columns) * (root.card-w + root.grid-gap);
|
|
y: Math.floor(i / grid.columns) * (root.card-h + root.grid-gap);
|
|
item: item;
|
|
clicked => { MyQbzActions.open-card(item.id); }
|
|
}
|
|
}
|
|
|
|
// --- Body: LIST ---------------------------------------
|
|
if MyQbzState.collections.length > 0 && MyQbzState.col-view == "list": VerticalLayout {
|
|
spacing: 4px;
|
|
for item in MyQbzState.collections: MyQbzListRow {
|
|
item: item;
|
|
clicked => { MyQbzActions.open-card(item.id); }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ListScrollbar {
|
|
x: parent.width - self.width - 4px;
|
|
y: 0px;
|
|
width: 14px;
|
|
height: parent.height;
|
|
viewport-height: flick.viewport-height;
|
|
visible-height: flick.height;
|
|
viewport-y <=> flick.viewport-y;
|
|
}
|
|
}
|