All is no longer a flat album grid: a polymorphic most-popular hero (artist/album/track) plus Artists/Albums/Tracks(6)/Playlists previews, each with a View all that jumps to that tab. Reads SearchState verbatim, mirroring the desktop hierarchy. cc
447 lines
20 KiB
Plaintext
447 lines
20 KiB
Plaintext
// KioskSearch — lightweight kiosk Search results (2.0.2 frente #3).
|
|
//
|
|
// Reads the SAME SearchState the desktop SearchResultsView reads (albums,
|
|
// tracks, artists, playlists + tab int), rendered with the simple kiosk cards.
|
|
// The query is entered in the KioskShell back-bar field (SearchActions.submit);
|
|
// this view is the tabbed results. Covers are push-only, so binding the shared
|
|
// arrays is enough.
|
|
import { ListView } from "std-widgets.slint";
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { SearchState, SearchActions } from "../state.slint";
|
|
import { KioskAlbumGrid } from "KioskAlbumGrid.slint";
|
|
import { KioskArtistCard } from "KioskArtistCard.slint";
|
|
import { KioskTrackRow } from "KioskTrackRow.slint";
|
|
import { KioskCard } from "KioskCard.slint";
|
|
|
|
component SearchTab inherits Rectangle {
|
|
in property <string> label;
|
|
in property <int> index;
|
|
callback picked(int);
|
|
property <bool> active: SearchState.tab == root.index;
|
|
horizontal-stretch: 0;
|
|
HorizontalLayout {
|
|
padding-left: 2px;
|
|
padding-right: 2px;
|
|
VerticalLayout {
|
|
Text {
|
|
text: root.label;
|
|
color: root.active ? Theme.text-primary : Theme.text-muted;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
vertical-alignment: center;
|
|
}
|
|
Rectangle {
|
|
height: 2px;
|
|
background: root.active ? Theme.accent : transparent;
|
|
border-radius: 2px;
|
|
}
|
|
}
|
|
}
|
|
ta := TouchArea {
|
|
clicked => {
|
|
root.picked(root.index);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Section header for the All dashboard — title on the left, an optional
|
|
// "View all" affordance on the right that jumps to that type's tab.
|
|
component SectionHeader inherits Rectangle {
|
|
in property <string> title;
|
|
in property <bool> show-all: true;
|
|
callback view-all;
|
|
height: 34px;
|
|
HorizontalLayout {
|
|
Text {
|
|
text: root.title;
|
|
color: Theme.text-primary;
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
vertical-alignment: center;
|
|
}
|
|
Rectangle {
|
|
horizontal-stretch: 1;
|
|
}
|
|
if root.show-all: Rectangle {
|
|
width: 74px;
|
|
Text {
|
|
text: @tr("View all");
|
|
color: Theme.accent;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
horizontal-alignment: right;
|
|
vertical-alignment: center;
|
|
}
|
|
va-ta := TouchArea {
|
|
clicked => {
|
|
root.view-all();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export component KioskSearch inherits Rectangle {
|
|
callback open-album(string);
|
|
callback open-artist(string);
|
|
callback media-action(string, string, string);
|
|
|
|
property <length> pad: 16px;
|
|
|
|
VerticalLayout {
|
|
spacing: 0px;
|
|
|
|
// Tabs — All / Albums / Tracks / Artists / Playlists.
|
|
Rectangle {
|
|
height: 48px;
|
|
background: Theme.surface-main;
|
|
HorizontalLayout {
|
|
padding-left: root.pad;
|
|
padding-right: root.pad;
|
|
spacing: 22px;
|
|
alignment: start;
|
|
SearchTab { label: @tr("All"); index: 0; picked(i) => { SearchActions.tab-changed(i); } }
|
|
SearchTab { label: @tr("Albums"); index: 1; picked(i) => { SearchActions.tab-changed(i); } }
|
|
SearchTab { label: @tr("Tracks"); index: 2; picked(i) => { SearchActions.tab-changed(i); } }
|
|
SearchTab { label: @tr("Artists"); index: 3; picked(i) => { SearchActions.tab-changed(i); } }
|
|
SearchTab { label: @tr("Playlists"); index: 4; picked(i) => { SearchActions.tab-changed(i); } }
|
|
}
|
|
Rectangle {
|
|
y: parent.height - 1px;
|
|
height: 1px;
|
|
background: Theme.border-subtle;
|
|
}
|
|
}
|
|
|
|
// Content.
|
|
content := Rectangle {
|
|
vertical-stretch: 1;
|
|
clip: true;
|
|
|
|
// All — a dashboard (NOT a flat album grid): Most-popular hero +
|
|
// per-type previews, each with "View all" jumping to that tab.
|
|
// Mirrors the desktop SearchResultsView hierarchy; reads SearchState
|
|
// verbatim (no local re-ranking — the hero order is Qobuz's own
|
|
// most_popular block, same as desktop).
|
|
if SearchState.tab == 0: Flickable {
|
|
viewport-width: self.width;
|
|
viewport-height: dash.preferred-height;
|
|
dash := VerticalLayout {
|
|
padding: root.pad;
|
|
spacing: 26px;
|
|
alignment: start;
|
|
|
|
// Most-popular hero — polymorphic on most-popular-kind.
|
|
if SearchState.most-popular-kind != "": VerticalLayout {
|
|
spacing: 10px;
|
|
HorizontalLayout {
|
|
alignment: start;
|
|
spacing: 8px;
|
|
Image {
|
|
source: @image-url("../assets/icons/crown.svg");
|
|
colorize: #ffd24a;
|
|
width: 18px;
|
|
height: 18px;
|
|
}
|
|
Text {
|
|
text: @tr("Most popular");
|
|
color: Theme.text-secondary;
|
|
font-size: 14px;
|
|
font-weight: 700;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
alignment: start;
|
|
if SearchState.most-popular-kind == "artist": KioskArtistCard {
|
|
size: 150px;
|
|
id: SearchState.most-popular-artist.id;
|
|
name: SearchState.most-popular-artist.title;
|
|
avatar: SearchState.most-popular-artist.artwork;
|
|
clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
}
|
|
if SearchState.most-popular-kind == "album": KioskCard {
|
|
art-size: 150px;
|
|
album: SearchState.most-popular-album;
|
|
clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
}
|
|
if SearchState.most-popular-kind == "track": Rectangle {
|
|
width: 380px;
|
|
height: 96px;
|
|
border-radius: Radius.md;
|
|
background: Theme.surface-card;
|
|
HorizontalLayout {
|
|
padding: 8px;
|
|
spacing: 12px;
|
|
Rectangle {
|
|
width: 80px;
|
|
height: 80px;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
clip: true;
|
|
if SearchState.most-popular-track.artwork.width > 0: Image {
|
|
width: 100%;
|
|
height: 100%;
|
|
source: SearchState.most-popular-track.artwork;
|
|
image-fit: cover;
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
spacing: 3px;
|
|
Text {
|
|
text: SearchState.most-popular-track.title;
|
|
color: Theme.text-primary;
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
overflow: elide;
|
|
wrap: no-wrap;
|
|
}
|
|
Text {
|
|
text: SearchState.most-popular-track.artist;
|
|
color: Theme.text-secondary;
|
|
font-size: 13px;
|
|
overflow: elide;
|
|
wrap: no-wrap;
|
|
}
|
|
if SearchState.most-popular-quality-label != "": Text {
|
|
text: SearchState.most-popular-quality-label;
|
|
color: Theme.text-muted;
|
|
font-size: 11px;
|
|
}
|
|
}
|
|
}
|
|
hero-track-ta := TouchArea {
|
|
clicked => {
|
|
root.media-action("track", SearchState.most-popular-track.id, "play");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Artists preview (hero-deduped list).
|
|
if SearchState.artists-carousel.length > 0: VerticalLayout {
|
|
spacing: 10px;
|
|
SectionHeader {
|
|
title: @tr("Artists");
|
|
view-all => {
|
|
SearchActions.tab-changed(3);
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
spacing: 0px;
|
|
alignment: start;
|
|
for artist[i] in SearchState.artists-carousel: HorizontalLayout {
|
|
if i < 6: HorizontalLayout {
|
|
padding-right: 14px;
|
|
KioskArtistCard {
|
|
size: 120px;
|
|
id: artist.id;
|
|
name: artist.title;
|
|
avatar: artist.artwork;
|
|
clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Albums preview.
|
|
if SearchState.albums.length > 0: VerticalLayout {
|
|
spacing: 10px;
|
|
SectionHeader {
|
|
title: @tr("Albums");
|
|
view-all => {
|
|
SearchActions.tab-changed(1);
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
spacing: 0px;
|
|
alignment: start;
|
|
for album[i] in SearchState.albums: HorizontalLayout {
|
|
if i < 6: HorizontalLayout {
|
|
padding-right: 14px;
|
|
KioskCard {
|
|
art-size: 140px;
|
|
album: album;
|
|
clicked(id) => {
|
|
root.open-album(id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Tracks preview (capped at 6).
|
|
if SearchState.tracks.length > 0: VerticalLayout {
|
|
spacing: 6px;
|
|
SectionHeader {
|
|
title: @tr("Tracks");
|
|
show-all: SearchState.tracks-total > 6;
|
|
view-all => {
|
|
SearchActions.tab-changed(2);
|
|
}
|
|
}
|
|
for track[i] in SearchState.tracks: VerticalLayout {
|
|
if i < 6: KioskTrackRow {
|
|
track: track;
|
|
play(id) => {
|
|
root.media-action("track", id, "play");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Playlists preview.
|
|
if SearchState.playlists.length > 0: VerticalLayout {
|
|
spacing: 10px;
|
|
SectionHeader {
|
|
title: @tr("Playlists");
|
|
view-all => {
|
|
SearchActions.tab-changed(4);
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
spacing: 0px;
|
|
alignment: start;
|
|
for pl[i] in SearchState.playlists: HorizontalLayout {
|
|
if i < 6: HorizontalLayout {
|
|
padding-right: 14px;
|
|
Rectangle {
|
|
width: 140px;
|
|
VerticalLayout {
|
|
alignment: start;
|
|
spacing: 7px;
|
|
Rectangle {
|
|
width: 140px;
|
|
height: 140px;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
clip: true;
|
|
Image {
|
|
width: 100%;
|
|
height: 100%;
|
|
source: pl.cover1;
|
|
image-fit: cover;
|
|
}
|
|
}
|
|
Text {
|
|
text: pl.title;
|
|
color: Theme.text-primary;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
overflow: elide;
|
|
wrap: no-wrap;
|
|
}
|
|
}
|
|
pl-prev-ta := TouchArea {
|
|
clicked => {
|
|
root.media-action("playlist", pl.id, "open");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Albums tab — full grid.
|
|
if SearchState.tab == 1: KioskAlbumGrid {
|
|
albums: SearchState.albums;
|
|
open(id) => {
|
|
root.open-album(id);
|
|
}
|
|
}
|
|
|
|
// Tracks — windowed list (ListView mounts only the visible band).
|
|
if SearchState.tab == 2: ListView {
|
|
for track in SearchState.tracks: KioskTrackRow {
|
|
track: track;
|
|
play(id) => {
|
|
root.media-action("track", id, "play");
|
|
}
|
|
}
|
|
}
|
|
|
|
// Artists — round-card wrapping grid.
|
|
if SearchState.tab == 3: agrid := Flickable {
|
|
property <int> cols: 7;
|
|
property <length> gap: 14px;
|
|
property <length> cell: (self.width - 2 * root.pad - (self.cols - 1) * self.gap) / self.cols;
|
|
viewport-width: self.width;
|
|
viewport-height: Math.ceil(SearchState.artists.length / self.cols) * (self.cell + 26px + self.gap) + root.pad;
|
|
Rectangle {
|
|
for artist[i] in SearchState.artists: KioskArtistCard {
|
|
x: root.pad + Math.mod(i, agrid.cols) * (agrid.cell + agrid.gap);
|
|
y: root.pad + Math.floor(i / agrid.cols) * (agrid.cell + 26px + agrid.gap);
|
|
size: agrid.cell;
|
|
id: artist.id;
|
|
name: artist.title;
|
|
avatar: artist.artwork;
|
|
clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Playlists — square cover grid (uses the first collage cover).
|
|
if SearchState.tab == 4: pgrid := Flickable {
|
|
property <int> cols: 6;
|
|
property <length> gap: 16px;
|
|
property <length> cell: (self.width - 2 * root.pad - (self.cols - 1) * self.gap) / self.cols;
|
|
viewport-width: self.width;
|
|
viewport-height: Math.ceil(SearchState.playlists.length / self.cols) * (self.cell + 42px + self.gap) + root.pad;
|
|
Rectangle {
|
|
for pl[i] in SearchState.playlists: Rectangle {
|
|
x: root.pad + Math.mod(i, pgrid.cols) * (pgrid.cell + pgrid.gap);
|
|
y: root.pad + Math.floor(i / pgrid.cols) * (pgrid.cell + 42px + pgrid.gap);
|
|
width: pgrid.cell;
|
|
VerticalLayout {
|
|
alignment: start;
|
|
spacing: 7px;
|
|
Rectangle {
|
|
width: parent.width;
|
|
height: parent.width;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
clip: true;
|
|
Image {
|
|
width: 100%;
|
|
height: 100%;
|
|
source: pl.cover1;
|
|
image-fit: cover;
|
|
}
|
|
}
|
|
Text {
|
|
text: pl.title;
|
|
color: Theme.text-primary;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
overflow: elide;
|
|
wrap: no-wrap;
|
|
}
|
|
}
|
|
pl-ta := TouchArea {
|
|
clicked => {
|
|
root.media-action("playlist", pl.id, "open");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|