feat(slint): Blacklist Manager view (list/search/toggle/remove/clear)
cc
This commit is contained in:
7 files changed
+918
-2
No files matched your search
@@ -0,0 +1,581 @@
|
||||
// Artist Blacklist Manager — a faithful Slint port of Tauri's
|
||||
// BlacklistManagerView.svelte (consolidated review §7). The standalone
|
||||
// manage-blacklist surface reached from the Settings content-filtering row:
|
||||
// a header (Back + ban icon + title), a description line, a controls row
|
||||
// (enable/disable toggle / search-as-you-type with × clear / Clear-All /
|
||||
// total-count badge), an amber disabled-warning banner, and a 4-branch body
|
||||
// (loading / empty / no-search-results / list), plus a Clear-All confirm
|
||||
// modal overlaid above everything (ADR-009 — declared last so it stacks on
|
||||
// top; the manager itself has no other overlay).
|
||||
//
|
||||
// State + actions live in BlacklistState / BlacklistActions; the controller
|
||||
// (crate::blacklist_manager) precomputes the date string + has-notes flag and
|
||||
// pushes ONLY the search-filtered rows into `items`, while `count` stays the
|
||||
// FULL list count — so "empty" = count==0 and "no results" = count>0 with an
|
||||
// empty `items`. Rows show a generic blind-eye glyph (no artist image exists),
|
||||
// the name, "Added {date}", optional italic notes, and a per-row remove X
|
||||
// (optimistic, no confirm). The blacklist visual across the Slint port is
|
||||
// `blind-eye.svg` (TrackRow + ArtistPageView, T5/T9), used here too instead of
|
||||
// Tauri's lucide `Ban`.
|
||||
|
||||
import { ScrollView } from "std-widgets.slint";
|
||||
import { Theme } from "../foundation/semantic-colors.slint";
|
||||
import { Typography } from "../foundation/typography.slint";
|
||||
import { Radius } from "../foundation/radius.slint";
|
||||
import { BlacklistState, BlacklistActions } from "../state.slint";
|
||||
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||||
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
|
||||
import { NavButtons } from "../shell/NavButtons.slint";
|
||||
|
||||
// One blacklisted-artist row.
|
||||
component ArtistRow inherits Rectangle {
|
||||
in property <string> artist-name;
|
||||
in property <string> added-display;
|
||||
in property <string> notes;
|
||||
in property <bool> has-notes;
|
||||
callback select();
|
||||
callback remove();
|
||||
height: 64px;
|
||||
border-radius: Radius.md;
|
||||
background: ta.has-hover ? Theme.surface-elevated : Theme.surface-card;
|
||||
|
||||
HorizontalLayout {
|
||||
padding-left: 16px;
|
||||
padding-right: 8px;
|
||||
spacing: 12px;
|
||||
|
||||
// Clickable artist-info region — opens the artist page.
|
||||
Rectangle {
|
||||
horizontal-stretch: 1;
|
||||
ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.select();
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 12px;
|
||||
// Generic blind-eye avatar (no artist image data exists).
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Rectangle {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 22px;
|
||||
background: Theme.surface-elevated;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/blind-eye.svg");
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
tint: Theme.text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Name + meta (+ optional notes).
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 2px;
|
||||
Text {
|
||||
text: root.artist-name;
|
||||
color: Theme.text-primary;
|
||||
font-size: Typography.body;
|
||||
font-weight: Typography.medium;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: @tr("Added {}", root.added-display);
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
overflow: elide;
|
||||
}
|
||||
if root.has-notes: Text {
|
||||
text: root.notes;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
font-italic: true;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Per-row remove (optimistic, no confirm).
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Rectangle {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: Radius.sm;
|
||||
background: rm-ta.has-hover ? #ef444426 : transparent;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/x.svg");
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
tint: rm-ta.has-hover ? #ef4444 : Theme.text-muted;
|
||||
}
|
||||
rm-ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component BlacklistManagerView inherits Rectangle {
|
||||
background: Theme.surface-main;
|
||||
|
||||
// Local modal flag (Clear-All confirmation). Lives in the view; the
|
||||
// confirm only fires BlacklistActions.clear-all on the danger button.
|
||||
property <bool> confirm-clear-open: false;
|
||||
|
||||
VerticalLayout {
|
||||
padding: 24px;
|
||||
spacing: 14px;
|
||||
|
||||
// Top bar — Back (ADR-004 via NavButtons; routes through nav history).
|
||||
HorizontalLayout {
|
||||
vertical-stretch: 0;
|
||||
NavButtons { }
|
||||
}
|
||||
|
||||
// Header — blind-eye icon + title.
|
||||
HorizontalLayout {
|
||||
vertical-stretch: 0;
|
||||
spacing: 12px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/blind-eye.svg");
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
tint: Theme.text-muted;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("Artist Blacklist");
|
||||
color: Theme.text-primary;
|
||||
font-size: Typography.section;
|
||||
font-weight: Typography.bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Description.
|
||||
Text {
|
||||
vertical-stretch: 0;
|
||||
text: @tr("Blacklisted artists are hidden from search results, radio, suggestions, and similar artists.");
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.body;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
// Controls row.
|
||||
HorizontalLayout {
|
||||
vertical-stretch: 0;
|
||||
spacing: 12px;
|
||||
|
||||
// Enable/Disable toggle.
|
||||
Rectangle {
|
||||
width: toggle-row.preferred-width + 28px;
|
||||
height: 34px;
|
||||
border-radius: Radius.sm;
|
||||
background: toggle-ta.has-hover ? Theme.surface-hover : Theme.surface-elevated;
|
||||
toggle-row := HorizontalLayout {
|
||||
x: 14px;
|
||||
width: self.preferred-width;
|
||||
height: 100%;
|
||||
spacing: 8px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: BlacklistState.enabled
|
||||
? @image-url("../assets/icons/eye.svg")
|
||||
: @image-url("../assets/icons/eye-off.svg");
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
tint: BlacklistState.enabled ? Theme.accent : Theme.text-muted;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: BlacklistState.enabled ? @tr("Enabled") : @tr("Disabled");
|
||||
color: BlacklistState.enabled ? Theme.accent : Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
toggle-ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
BlacklistActions.toggle-enabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Search input (search-as-you-type) + clear (×).
|
||||
Rectangle {
|
||||
width: 280px;
|
||||
height: 34px;
|
||||
border-radius: Radius.sm;
|
||||
background: Theme.surface-elevated;
|
||||
border-width: 1px;
|
||||
border-color: search-in.has-focus ? Theme.accent : Theme.border-subtle;
|
||||
HorizontalLayout {
|
||||
padding-left: 10px;
|
||||
padding-right: 6px;
|
||||
spacing: 6px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/search.svg");
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
tint: Theme.text-muted;
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
horizontal-stretch: 1;
|
||||
search-in := TextInput {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
vertical-alignment: center;
|
||||
color: Theme.text-primary;
|
||||
font-size: Typography.legal;
|
||||
text: BlacklistState.search-query;
|
||||
// Search-as-you-type: every edit re-pushes the
|
||||
// controller-filtered rows. No debounce (Tauri parity).
|
||||
edited => {
|
||||
BlacklistActions.search-changed(self.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
if BlacklistState.search-query != "": VerticalLayout {
|
||||
alignment: center;
|
||||
Rectangle {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: Radius.sm;
|
||||
background: clear-ta.has-hover ? Theme.surface-hover : transparent;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/x.svg");
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
tint: clear-ta.has-hover ? Theme.text-primary : Theme.text-muted;
|
||||
}
|
||||
clear-ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
search-in.text = "";
|
||||
BlacklistActions.search-changed("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear-All — only when there is something to clear (full count).
|
||||
if BlacklistState.count > 0: Rectangle {
|
||||
width: clear-all-row.preferred-width + 28px;
|
||||
height: 34px;
|
||||
border-radius: Radius.sm;
|
||||
background: clear-all-ta.has-hover ? #ef444426 : Theme.surface-elevated;
|
||||
clear-all-row := HorizontalLayout {
|
||||
x: 14px;
|
||||
width: self.preferred-width;
|
||||
height: 100%;
|
||||
spacing: 8px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/trash-2.svg");
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
tint: #ef4444;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("Clear All");
|
||||
color: #ef4444;
|
||||
font-size: Typography.legal;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
clear-all-ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.confirm-clear-open = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spacer + count badge (FULL count, right-aligned).
|
||||
Rectangle {
|
||||
horizontal-stretch: 1;
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("{} artists", BlacklistState.count);
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disabled warning banner.
|
||||
if !BlacklistState.enabled: Rectangle {
|
||||
vertical-stretch: 0;
|
||||
height: warn-row.preferred-height + 24px;
|
||||
border-radius: Radius.md;
|
||||
background: #fbbf241a;
|
||||
border-width: 1px;
|
||||
border-color: #fbbf244d;
|
||||
warn-row := HorizontalLayout {
|
||||
padding: 12px;
|
||||
spacing: 10px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/circle-alert.svg");
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
tint: #fbbf24;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("Blacklist filtering is disabled. Blacklisted artists are shown everywhere until you re-enable it.");
|
||||
color: #fbbf24;
|
||||
font-size: Typography.legal;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Body — 4 mutually-exclusive branches (order is load-bearing).
|
||||
Rectangle {
|
||||
vertical-stretch: 1;
|
||||
|
||||
// 1) Loading.
|
||||
if BlacklistState.loading: VerticalLayout {
|
||||
alignment: center;
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
LoadingSpinner { }
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("Loading blacklist…");
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Empty blacklist.
|
||||
if !BlacklistState.loading && BlacklistState.count == 0: VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 12px;
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/blind-eye.svg");
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
tint: Theme.text-muted;
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("No blacklisted artists");
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.heading;
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("To hide an artist, go to their page and use the menu.");
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3) No search results (full list non-empty, filtered empty).
|
||||
if !BlacklistState.loading && BlacklistState.count > 0 && BlacklistState.items.length == 0: VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 12px;
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/search.svg");
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
tint: Theme.text-muted;
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: @tr("No results for \"{}\"", BlacklistState.search-query);
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.heading;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 4) The list (no virtualization — plain for over the filtered rows).
|
||||
if !BlacklistState.loading && BlacklistState.items.length > 0: ScrollView {
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
for item in BlacklistState.items: ArtistRow {
|
||||
artist-name: item.artist-name;
|
||||
added-display: item.added-display;
|
||||
notes: item.notes;
|
||||
has-notes: item.has-notes;
|
||||
select => {
|
||||
BlacklistActions.artist-select(item.artist-id);
|
||||
}
|
||||
remove => {
|
||||
BlacklistActions.remove(item.artist-id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear-All confirm modal — declared LAST so it stacks above the view
|
||||
// (ADR-009 ≥ 3000 satisfied by declaration order; mirrors
|
||||
// PlaylistDuplicateConfirmModal's scrim + centered card). Backdrop click
|
||||
// dismisses; Esc dismisses via the focus-scope key handler.
|
||||
if root.confirm-clear-open: Rectangle {
|
||||
background: #000000bf;
|
||||
// Scrim — click outside to dismiss.
|
||||
TouchArea {
|
||||
mouse-cursor: default;
|
||||
clicked => {
|
||||
root.confirm-clear-open = false;
|
||||
}
|
||||
}
|
||||
// Esc dismiss. Grab focus on mount so the key handler is live.
|
||||
esc-scope := FocusScope {
|
||||
init => {
|
||||
self.focus();
|
||||
}
|
||||
key-pressed(event) => {
|
||||
if (event.text == Key.Escape) {
|
||||
root.confirm-clear-open = false;
|
||||
return accept;
|
||||
}
|
||||
return reject;
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
width: Math.min(root.width - 80px, 400px);
|
||||
height: panel.preferred-height;
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
border-radius: Radius.md;
|
||||
background: Theme.surface-main;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border-subtle;
|
||||
drop-shadow-blur: 32px;
|
||||
drop-shadow-color: #00000080;
|
||||
// Swallow clicks so they don't reach the scrim.
|
||||
TouchArea { }
|
||||
|
||||
panel := VerticalLayout {
|
||||
padding: 24px;
|
||||
spacing: 16px;
|
||||
|
||||
Text {
|
||||
text: @tr("Clear Blacklist?");
|
||||
color: Theme.text-primary;
|
||||
font-size: Typography.heading;
|
||||
font-weight: Typography.semibold;
|
||||
}
|
||||
Text {
|
||||
text: @tr("This will remove all {} blacklisted artists. This cannot be undone.", BlacklistState.count);
|
||||
color: Theme.text-secondary;
|
||||
font-size: Typography.body;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: end;
|
||||
spacing: 10px;
|
||||
|
||||
// Cancel.
|
||||
Rectangle {
|
||||
width: cancel-lbl.preferred-width + 32px;
|
||||
height: 36px;
|
||||
border-radius: Radius.sm;
|
||||
background: cancel-ta.has-hover ? Theme.surface-hover : Theme.surface-elevated;
|
||||
cancel-lbl := Text {
|
||||
text: @tr("Cancel");
|
||||
color: Theme.text-primary;
|
||||
font-size: Typography.body;
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
}
|
||||
cancel-ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.confirm-clear-open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Danger Clear-All.
|
||||
Rectangle {
|
||||
width: danger-lbl.preferred-width + 32px;
|
||||
height: 36px;
|
||||
border-radius: Radius.sm;
|
||||
background: danger-ta.has-hover ? #dc2626 : #ef4444;
|
||||
danger-lbl := Text {
|
||||
text: @tr("Clear All");
|
||||
color: #ffffff;
|
||||
font-size: Typography.body;
|
||||
font-weight: Typography.medium;
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
}
|
||||
danger-ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
BlacklistActions.clear-all();
|
||||
root.confirm-clear-open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user