refactor(slint): promote ToggleButton to a shared primitive
LabelReleasesView and DiscoverBrowseView each carried a verbatim copy of the 34px segmented/toolbar toggle. Move it to primitives/ToggleButton and import it in both. No visual change — same surface, one definition. cc
This commit is contained in:
3 files changed
+37
-59
No files matched your search
@@ -18,6 +18,7 @@ import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
|
||||
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
|
||||
import { NavButtons } from "../shell/NavButtons.slint";
|
||||
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||||
import { ToggleButton } from "../primitives/ToggleButton.slint";
|
||||
|
||||
// Search field — a leading magnifier, the input, and a trailing X that
|
||||
// clears (mirrors Tauri's .search-wrapper).
|
||||
@@ -144,35 +145,6 @@ component GenreButton inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
// One half of the grid/list segmented toggle.
|
||||
component ToggleButton inherits Rectangle {
|
||||
in property <image> icon;
|
||||
in property <bool> active: false;
|
||||
callback clicked();
|
||||
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
background: root.active
|
||||
? Theme.surface-hover
|
||||
: (ta.has-hover ? Theme.surface-elevated : transparent);
|
||||
|
||||
QbzIcon {
|
||||
source: root.icon;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
tint: root.active ? Theme.text-primary : Theme.text-muted;
|
||||
}
|
||||
|
||||
ta := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.clicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component DiscoverBrowseView inherits Rectangle {
|
||||
callback open-album(string);
|
||||
callback open-artist(string);
|
||||
|
||||
Reference in new issue
Block a user