// Segmented tab navigator — the SAME design Discovery's HomeView uses (a // small-radius rectangle group, ADR-008-compliant: NOT a capsule pill), // promoted to a shared, data-driven primitive so Local Library and Library // (Favorites) read identically. Each tab carries an optional count rendered // as a compact badge with smaller-but-legible type inside the tab item. import { Theme } from "../foundation/semantic-colors.slint"; import { Typography } from "../foundation/typography.slint"; // One entry in the navigator. `count <= 0` hides the badge. export struct SegTab { id: string, label: string, count: int, } // A single segment: fills with surface-main when active (Discovery's Tab), // hover surface-hover, transparent otherwise. The count sits in a rounded // badge to the right of the label. component Segment inherits Rectangle { in property label; in property count; in property active; callback clicked(); border-radius: 4px; background: root.active ? Theme.surface-main : ta.has-hover ? Theme.surface-hover : transparent; // HC-only: a 1px strong border makes the active/inactive distinction // survive a flattened High-Contrast palette where the fill alone reads // weakly. Gated so the 31 normal themes keep their clean borderless look. border-width: (Theme.is-high-contrast && root.active) ? 1px : 0px; border-color: Theme.border-strong; HorizontalLayout { padding-left: 12px; padding-right: root.count > 0 ? 8px : 12px; padding-top: 6px; padding-bottom: 6px; spacing: 7px; Text { text: root.label; color: root.active ? Theme.text-primary : Theme.text-muted; // Discovery's tab type: 13px medium. font-size: Typography.legal; font-weight: Typography.medium; vertical-alignment: center; } // Count badge — smaller (11px) but legible. min-width keeps single // digits balanced; the layout grows the chip for 2–3 digit counts. if root.count > 0: VerticalLayout { alignment: center; Rectangle { min-width: 18px; height: 16px; border-radius: 8px; // Alpha-token badge fill follows theme polarity (black-on-light // in light themes) instead of a fixed white wash. background: root.active ? Theme.alpha-15 : Theme.alpha-8; HorizontalLayout { alignment: center; padding-left: 5px; padding-right: 5px; Text { text: root.count; color: root.active ? Theme.text-primary : Theme.text-secondary; font-size: 11px; font-weight: Typography.medium; vertical-alignment: center; } } } } } // Redundant non-color shape cue for the active segment (Radix/Spotify // underline equivalent): a 2px accent bar pinned to the segment's bottom // edge, shown only when active. Drawn as a non-layout overlay (positioned // off the Segment root's own geometry, never a sibling .height reference) // so toggling it never reflows the row. Reads as polish in all 33 themes, // not just High-Contrast. if root.active: Rectangle { x: 4px; width: root.width - 8px; height: 2px; y: root.height - self.height; border-radius: 1px; background: Theme.accent; } ta := TouchArea { mouse-cursor: pointer; clicked => { root.clicked(); } } } export component SegmentedTabBar inherits Rectangle { in property <[SegTab]> tabs; in property active-id; callback selected(string); width: row.preferred-width; height: row.preferred-height; background: Theme.surface-elevated; border-radius: 6px; row := HorizontalLayout { padding: 3px; spacing: 4px; for tab in root.tabs: Segment { label: tab.label; count: tab.count; active: root.active-id == tab.id; clicked => { root.selected(tab.id); } } } }