The results view was bare text rows — nothing like the Tauri search. Rebuilt it from the components the successful views already use: - Albums: a Carousel of AlbumCard cover cards (All tab) and an AlbumCard grid (Albums tab). - Artists: new ArtistCard (circular portrait) + ArtistCarousel; an ArtistCard grid on the Artists tab. - Tracks: SearchTrackRow with a position number. - The history nav pair (NavButtons) added to the view toolbar. cc
136 lines
4.3 KiB
Plaintext
136 lines
4.3 KiB
Plaintext
// Artist carousel — a title, prev/next page controls, and a clipped,
|
|
// sliding track of artist cards. Same paging mechanism as Carousel, but
|
|
// for artists (circular cards). Used by the search results All tab.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { SlimItem } from "../state.slint";
|
|
import { ArtistCard } from "ArtistCard.slint";
|
|
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
|
|
|
component NavButton inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <bool> enabled: true;
|
|
callback clicked();
|
|
|
|
width: 28px;
|
|
height: 28px;
|
|
border-radius: 14px;
|
|
opacity: root.enabled ? 1.0 : 0.4;
|
|
background: ta.has-hover && root.enabled
|
|
? Theme.surface-hover
|
|
: Theme.surface-elevated;
|
|
|
|
QbzIcon {
|
|
source: root.icon;
|
|
width: 15px;
|
|
height: 15px;
|
|
x: (parent.width - self.width) / 2;
|
|
y: (parent.height - self.height) / 2;
|
|
tint: root.enabled ? Theme.text-primary : Theme.text-muted;
|
|
}
|
|
|
|
ta := TouchArea {
|
|
enabled: root.enabled;
|
|
mouse-cursor: root.enabled ? pointer : default;
|
|
clicked => {
|
|
root.clicked();
|
|
}
|
|
}
|
|
}
|
|
|
|
export component ArtistCarousel inherits VerticalLayout {
|
|
in property <string> title;
|
|
in property <[SlimItem]> artists;
|
|
callback artist-clicked(string);
|
|
|
|
property <length> card-width: 160px;
|
|
property <length> card-height: 200px;
|
|
property <length> gap: 24px;
|
|
|
|
property <int> count: root.artists.length;
|
|
property <int> per-page: Math.max(
|
|
1,
|
|
Math.floor((viewport.width + root.gap) / (root.card-width + root.gap)));
|
|
property <int> page-count: Math.max(1, Math.ceil(root.count / root.per-page));
|
|
property <int> page: 0;
|
|
property <int> current-page: Math.min(Math.max(0, root.page), root.page-count - 1);
|
|
property <length> step: root.per-page * (root.card-width + root.gap);
|
|
property <length> content-width:
|
|
root.count * root.card-width + Math.max(0, root.count - 1) * root.gap;
|
|
|
|
spacing: 12px;
|
|
|
|
HorizontalLayout {
|
|
Text {
|
|
text: root.title;
|
|
color: Theme.text-primary;
|
|
font-size: 18px;
|
|
font-weight: Typography.semibold;
|
|
vertical-alignment: center;
|
|
horizontal-stretch: 1;
|
|
}
|
|
HorizontalLayout {
|
|
spacing: 4px;
|
|
VerticalLayout {
|
|
alignment: center;
|
|
NavButton {
|
|
icon: @image-url("../assets/icons/chevron-left.svg");
|
|
enabled: root.current-page > 0;
|
|
clicked => {
|
|
root.page = root.current-page - 1;
|
|
}
|
|
}
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
NavButton {
|
|
icon: @image-url("../assets/icons/chevron-right.svg");
|
|
enabled: root.current-page < root.page-count - 1;
|
|
clicked => {
|
|
root.page = root.current-page + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
viewport := Rectangle {
|
|
height: root.card-height;
|
|
clip: true;
|
|
|
|
Rectangle {
|
|
x: -root.current-page * root.step;
|
|
y: 0px;
|
|
width: root.content-width;
|
|
height: root.card-height;
|
|
animate x { duration: 220ms; easing: ease-in-out; }
|
|
|
|
HorizontalLayout {
|
|
spacing: root.gap;
|
|
for artist in root.artists: ArtistCard {
|
|
artist: artist;
|
|
clicked(id) => {
|
|
root.artist-clicked(id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
x: 0px;
|
|
width: 56px;
|
|
background: @linear-gradient(90deg, Theme.surface-main 0%, transparent 100%);
|
|
opacity: root.current-page > 0 ? 1.0 : 0.0;
|
|
animate opacity { duration: 150ms; }
|
|
}
|
|
Rectangle {
|
|
x: parent.width - self.width;
|
|
width: 56px;
|
|
background: @linear-gradient(90deg, transparent 0%, Theme.surface-main 100%);
|
|
opacity: root.current-page < root.page-count - 1 ? 1.0 : 0.0;
|
|
animate opacity { duration: 150ms; }
|
|
}
|
|
}
|
|
}
|