The tiles still collapsed to the bottom-left even with per-tile horizontal-stretch: a HorizontalLayout nested in the rail's VerticalLayout was taking its preferred (content) width, not the rail width. Drop the wrapper, make the tile row an explicit width: root.width child with the hairline as an overlay, and the 6 tiles now spread evenly across the panel. cc
140 lines
4.2 KiB
Plaintext
140 lines
4.2 KiB
Plaintext
// Bottom NavRail — small-panel touch navigation (2.0.2 frente #3, Axis B).
|
|
//
|
|
// Six ~80px icon+label tiles (Radius.sm rectangles, NO pills — ADR-008)
|
|
// replacing the desktop Sidebar on the kiosk panel, driving the SAME NavState
|
|
// routes. Net-new component; tokens/accent/radii/icons from the existing set.
|
|
// Labels reuse existing `@tr` msgids so no new `.po` strings are introduced.
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { NavState, ContentView, ImmersiveState } from "../state.slint";
|
|
|
|
component NavTile inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <string> label;
|
|
in property <bool> active;
|
|
callback clicked;
|
|
|
|
horizontal-stretch: 1;
|
|
border-radius: Radius.sm;
|
|
background: root.active
|
|
? Theme.accent.with-alpha(0.12)
|
|
: ta.has-hover ? Theme.alpha-6 : transparent;
|
|
border-width: root.active ? 1px : 0px;
|
|
border-color: Theme.accent.with-alpha(0.30);
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
spacing: 5px;
|
|
Image {
|
|
source: root.icon;
|
|
colorize: root.active ? Theme.accent : Theme.text-muted;
|
|
width: 24px;
|
|
height: 24px;
|
|
horizontal-alignment: center;
|
|
}
|
|
Text {
|
|
text: root.label;
|
|
color: root.active ? Theme.accent : Theme.text-muted;
|
|
font-size: 11.5px;
|
|
font-weight: 600;
|
|
horizontal-alignment: center;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
|
|
ta := TouchArea {
|
|
clicked => {
|
|
root.clicked();
|
|
}
|
|
}
|
|
}
|
|
|
|
export component NavRail inherits Rectangle {
|
|
// One callback per destination; KioskShell maps each to the real route.
|
|
callback discover();
|
|
callback library();
|
|
callback search();
|
|
callback playing();
|
|
callback visualizer();
|
|
callback menu();
|
|
|
|
background: Theme.surface-main;
|
|
|
|
// Top hairline (overlay — kept out of the tile row).
|
|
Rectangle {
|
|
x: 0;
|
|
y: 0;
|
|
width: root.width;
|
|
height: 1px;
|
|
background: Theme.border-subtle;
|
|
}
|
|
|
|
// Tile row. EXPLICIT `width: root.width` — a HorizontalLayout nested inside
|
|
// a VerticalLayout was not filling the rail width, so the tiles collapsed to
|
|
// icon width packed on the left. Pinning the row to the rail's full width
|
|
// lets each tile's horizontal-stretch distribute them evenly across it.
|
|
HorizontalLayout {
|
|
x: 0;
|
|
y: 1px;
|
|
width: root.width;
|
|
height: root.height - 1px;
|
|
padding: 8px;
|
|
spacing: 6px;
|
|
|
|
NavTile {
|
|
horizontal-stretch: 1;
|
|
icon: @image-url("../assets/icons/compass.svg");
|
|
label: @tr("Discover");
|
|
active: NavState.view == ContentView.home;
|
|
clicked => {
|
|
root.discover();
|
|
}
|
|
}
|
|
NavTile {
|
|
horizontal-stretch: 1;
|
|
icon: @image-url("../assets/icons/library-big.svg");
|
|
label: @tr("Library");
|
|
active: NavState.view == ContentView.favorites;
|
|
clicked => {
|
|
root.library();
|
|
}
|
|
}
|
|
NavTile {
|
|
horizontal-stretch: 1;
|
|
icon: @image-url("../assets/icons/search.svg");
|
|
label: @tr("Search");
|
|
active: NavState.view == ContentView.search;
|
|
clicked => {
|
|
root.search();
|
|
}
|
|
}
|
|
NavTile {
|
|
horizontal-stretch: 1;
|
|
icon: @image-url("../assets/icons/play-fill.svg");
|
|
label: @tr("Now Playing");
|
|
active: ImmersiveState.open;
|
|
clicked => {
|
|
root.playing();
|
|
}
|
|
}
|
|
NavTile {
|
|
horizontal-stretch: 1;
|
|
icon: @image-url("../assets/icons/sliders-horizontal.svg");
|
|
label: @tr("Visualizer");
|
|
active: false;
|
|
clicked => {
|
|
root.visualizer();
|
|
}
|
|
}
|
|
NavTile {
|
|
horizontal-stretch: 1;
|
|
icon: @image-url("../assets/icons/settings.svg");
|
|
label: @tr("Settings");
|
|
active: NavState.view == ContentView.settings;
|
|
clicked => {
|
|
root.menu();
|
|
}
|
|
}
|
|
}
|
|
}
|