Layout-based attempts (child stretch, mount stretch, explicit HL width) all left the tiles collapsed to icon width packed on the left. Position the 6 tiles by absolute x + explicit width derived from root.width instead; the rail width comes from the KioskShell VerticalLayout, so the tiles now span the panel evenly. cc
152 lines
4.3 KiB
Plaintext
152 lines
4.3 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, driving the SAME NavState routes.
|
|
//
|
|
// The tiles are positioned MANUALLY (absolute x + explicit width from
|
|
// root.width) instead of a HorizontalLayout: every layout-based attempt left
|
|
// them collapsed to icon width packed on the left (a stretch factor on a custom
|
|
// component child was not honored / the nested layout took its preferred width).
|
|
// Absolute positioning removes all of that ambiguity — width comes straight from
|
|
// the rail width, which the KioskShell VerticalLayout stretches to the panel.
|
|
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;
|
|
|
|
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 {
|
|
callback discover();
|
|
callback library();
|
|
callback search();
|
|
callback playing();
|
|
callback visualizer();
|
|
callback menu();
|
|
|
|
background: Theme.surface-main;
|
|
|
|
// 6 tiles, 8px outer padding, 6px gaps.
|
|
property <length> tw: (root.width - 16px - 5 * 6px) / 6;
|
|
property <length> th: root.height - 18px;
|
|
|
|
// Top hairline overlay.
|
|
Rectangle {
|
|
x: 0;
|
|
y: 0;
|
|
width: root.width;
|
|
height: 1px;
|
|
background: Theme.border-subtle;
|
|
}
|
|
|
|
NavTile {
|
|
x: 8px + 0 * (root.tw + 6px);
|
|
y: 9px;
|
|
width: root.tw;
|
|
height: root.th;
|
|
icon: @image-url("../assets/icons/compass.svg");
|
|
label: @tr("Discover");
|
|
active: NavState.view == ContentView.home;
|
|
clicked => {
|
|
root.discover();
|
|
}
|
|
}
|
|
NavTile {
|
|
x: 8px + 1 * (root.tw + 6px);
|
|
y: 9px;
|
|
width: root.tw;
|
|
height: root.th;
|
|
icon: @image-url("../assets/icons/library-big.svg");
|
|
label: @tr("Library");
|
|
active: NavState.view == ContentView.favorites;
|
|
clicked => {
|
|
root.library();
|
|
}
|
|
}
|
|
NavTile {
|
|
x: 8px + 2 * (root.tw + 6px);
|
|
y: 9px;
|
|
width: root.tw;
|
|
height: root.th;
|
|
icon: @image-url("../assets/icons/search.svg");
|
|
label: @tr("Search");
|
|
active: NavState.view == ContentView.search;
|
|
clicked => {
|
|
root.search();
|
|
}
|
|
}
|
|
NavTile {
|
|
x: 8px + 3 * (root.tw + 6px);
|
|
y: 9px;
|
|
width: root.tw;
|
|
height: root.th;
|
|
icon: @image-url("../assets/icons/play-fill.svg");
|
|
label: @tr("Now Playing");
|
|
active: ImmersiveState.open;
|
|
clicked => {
|
|
root.playing();
|
|
}
|
|
}
|
|
NavTile {
|
|
x: 8px + 4 * (root.tw + 6px);
|
|
y: 9px;
|
|
width: root.tw;
|
|
height: root.th;
|
|
icon: @image-url("../assets/icons/sliders-horizontal.svg");
|
|
label: @tr("Visualizer");
|
|
active: false;
|
|
clicked => {
|
|
root.visualizer();
|
|
}
|
|
}
|
|
NavTile {
|
|
x: 8px + 5 * (root.tw + 6px);
|
|
y: 9px;
|
|
width: root.tw;
|
|
height: root.th;
|
|
icon: @image-url("../assets/icons/settings.svg");
|
|
label: @tr("Settings");
|
|
active: NavState.view == ContentView.settings;
|
|
clicked => {
|
|
root.menu();
|
|
}
|
|
}
|
|
}
|