fix(kiosk): position NavRail tiles manually so they distribute

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
This commit is contained in:
vicrodh committed 2026-07-10 19:49:50 -06:00
1 parent 45cbe24206
commit 172dbf8eb6
1 file changed
+37 -25
+37 -25
View File
@@ -1,9 +1,14 @@
// Bottom NavRail — small-panel touch navigation (2.0.2 frente #3, Axis B). // 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) // Six ~80px icon+label tiles (Radius.sm rectangles, NO pills — ADR-008)
// replacing the desktop Sidebar on the kiosk panel, driving the SAME NavState // replacing the desktop Sidebar, driving the SAME NavState routes.
// routes. Net-new component; tokens/accent/radii/icons from the existing set. //
// Labels reuse existing `@tr` msgids so no new `.po` strings are introduced. // 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 { Theme } from "../foundation/semantic-colors.slint";
import { Radius } from "../foundation/radius.slint"; import { Radius } from "../foundation/radius.slint";
import { NavState, ContentView, ImmersiveState } from "../state.slint"; import { NavState, ContentView, ImmersiveState } from "../state.slint";
@@ -14,7 +19,6 @@ component NavTile inherits Rectangle {
in property <bool> active; in property <bool> active;
callback clicked; callback clicked;
horizontal-stretch: 1;
border-radius: Radius.sm; border-radius: Radius.sm;
background: root.active background: root.active
? Theme.accent.with-alpha(0.12) ? Theme.accent.with-alpha(0.12)
@@ -50,7 +54,6 @@ component NavTile inherits Rectangle {
} }
export component NavRail inherits Rectangle { export component NavRail inherits Rectangle {
// One callback per destination; KioskShell maps each to the real route.
callback discover(); callback discover();
callback library(); callback library();
callback search(); callback search();
@@ -60,7 +63,11 @@ export component NavRail inherits Rectangle {
background: Theme.surface-main; background: Theme.surface-main;
// Top hairline (overlay — kept out of the tile row). // 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 { Rectangle {
x: 0; x: 0;
y: 0; y: 0;
@@ -69,20 +76,11 @@ export component NavRail inherits Rectangle {
background: Theme.border-subtle; 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 { NavTile {
horizontal-stretch: 1; x: 8px + 0 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/compass.svg"); icon: @image-url("../assets/icons/compass.svg");
label: @tr("Discover"); label: @tr("Discover");
active: NavState.view == ContentView.home; active: NavState.view == ContentView.home;
@@ -91,7 +89,10 @@ export component NavRail inherits Rectangle {
} }
} }
NavTile { NavTile {
horizontal-stretch: 1; x: 8px + 1 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/library-big.svg"); icon: @image-url("../assets/icons/library-big.svg");
label: @tr("Library"); label: @tr("Library");
active: NavState.view == ContentView.favorites; active: NavState.view == ContentView.favorites;
@@ -100,7 +101,10 @@ export component NavRail inherits Rectangle {
} }
} }
NavTile { NavTile {
horizontal-stretch: 1; x: 8px + 2 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/search.svg"); icon: @image-url("../assets/icons/search.svg");
label: @tr("Search"); label: @tr("Search");
active: NavState.view == ContentView.search; active: NavState.view == ContentView.search;
@@ -109,7 +113,10 @@ export component NavRail inherits Rectangle {
} }
} }
NavTile { NavTile {
horizontal-stretch: 1; x: 8px + 3 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/play-fill.svg"); icon: @image-url("../assets/icons/play-fill.svg");
label: @tr("Now Playing"); label: @tr("Now Playing");
active: ImmersiveState.open; active: ImmersiveState.open;
@@ -118,7 +125,10 @@ export component NavRail inherits Rectangle {
} }
} }
NavTile { NavTile {
horizontal-stretch: 1; x: 8px + 4 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/sliders-horizontal.svg"); icon: @image-url("../assets/icons/sliders-horizontal.svg");
label: @tr("Visualizer"); label: @tr("Visualizer");
active: false; active: false;
@@ -127,7 +137,10 @@ export component NavRail inherits Rectangle {
} }
} }
NavTile { NavTile {
horizontal-stretch: 1; x: 8px + 5 * (root.tw + 6px);
y: 9px;
width: root.tw;
height: root.th;
icon: @image-url("../assets/icons/settings.svg"); icon: @image-url("../assets/icons/settings.svg");
label: @tr("Settings"); label: @tr("Settings");
active: NavState.view == ContentView.settings; active: NavState.view == ContentView.settings;
@@ -135,5 +148,4 @@ export component NavRail inherits Rectangle {
root.menu(); root.menu();
} }
} }
}
} }