// My QBZ > Mixtapes — the index/landing grid of the user's mixtapes // (Tauri's MixtapesView.svelte). The grid DISPLAYS rows and routes from the // sidebar; the create CTA + card click run their wired callbacks. // // HOMOLOGATED to the app's index views (Favorites / LocalLibrary): NO per-view // back button (the shell owns the global < > nav), 32px L/R content padding so // the grid never rides under the ListScrollbar, Typography tokens, the app's // ExpandableSearch + QbzSelect toolbar controls and the shared ViewToggle, and // a surface-elevated "+ New" action (NewActionBtn) instead of a 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 MixtapesView inherits Rectangle { // Fixed grid geometry (208px columns, 20px gap, 12px-padded card -> 184 // mosaic). card-h matches MyQbzCard's computed height. property card-w: 208px; property grid-gap: 20px; property card-h: 184px + 12px + 12px + 18px + 2 * 20px + 18px + 12px; // Sort index for the QbzSelect (position / name / items / updated). property sort-index: MyQbzState.mix-sort == "name" ? 1 : MyQbzState.mix-sort == "items" ? 2 : MyQbzState.mix-sort == "updated" ? 3 : 0; background: Theme.surface-main; flick := Flickable { viewport-width: self.width; viewport-height: page.preferred-height; // Scroll-position restore on back/forward (see nav::scope_for). property sr-armed: NavState.restore-scope; function sr-restore() { if (NavState.restore-scope == "mixtapes" && 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; // Canonical content padding (Favorites / LocalLibrary): 32px L/R // (the 32px right pad is the scrollbar inset), 100px bottom clears // the player bar. padding-top: 16px; padding-right: 32px; padding-bottom: 100px; padding-left: 32px; spacing: 0px; alignment: start; // --- Header (.view-header) — no per-view back button ------- HorizontalLayout { height: 40px; spacing: 16px; VerticalLayout { alignment: center; horizontal-stretch: 1; Text { text: @tr("Mixtapes"); 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.mixtapes.length > 0 || MyQbzState.mix-search != "": VerticalLayout { alignment: center; NewActionBtn { clicked => { MyQbzActions.create-mixtape(); } } } } Rectangle { height: 16px; } // ====================== EMPTY STATE ======================== if MyQbzState.mixtapes.length == 0 && MyQbzState.mix-search == "": VerticalLayout { padding-top: 80px; padding-bottom: 80px; spacing: 16px; alignment: start; HorizontalLayout { alignment: center; CollectionMosaic { size: 160px; empty-kind: "mixtape"; } } HorizontalLayout { alignment: center; Text { text: @tr("No mixtapes yet"); color: Theme.text-secondary; font-size: Typography.section; font-weight: Typography.semibold; } } HorizontalLayout { alignment: center; NewActionBtn { clicked => { MyQbzActions.create-mixtape(); } } } } // ====================== POPULATED ========================== if MyQbzState.mixtapes.length > 0 || MyQbzState.mix-search != "": VerticalLayout { spacing: 0px; alignment: start; // --- Toolbar (.list-controls) -------------------------- HorizontalLayout { height: 30px; spacing: 8px; // Spacer floats the toolbar flush right (margin-left:auto). Rectangle { horizontal-stretch: 1; } VerticalLayout { alignment: center; ExpandableSearch { placeholder: @tr("Search"); sm: true; query <=> MyQbzState.mix-search; edited(q) => { MyQbzActions.mix-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.mix-set-sort( i == 1 ? "name" : i == 2 ? "items" : i == 3 ? "updated" : "position"); } } } VerticalLayout { alignment: center; ViewToggle { view: MyQbzState.mix-view; set-view(v) => { MyQbzActions.mix-set-view(v); } } } } Rectangle { height: 16px; } // --- Body: search-empty ------------------------------- if MyQbzState.mixtapes.length == 0 && MyQbzState.mix-search != "": 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.mixtapes.length > 0 && MyQbzState.mix-view == "grid": grid := Rectangle { property columns: Math.max(1, Math.floor((self.width + root.grid-gap) / (root.card-w + root.grid-gap))); property rows: Math.ceil(MyQbzState.mixtapes.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.mixtapes: 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.mixtapes.length > 0 && MyQbzState.mix-view == "list": VerticalLayout { spacing: 4px; for item in MyQbzState.mixtapes: 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; } }