The single 1700-line app.slint becomes a design system and screens that later waves can compose: - theme.slint: colour, radius, spacing and type tokens (dark and light, a runtime font scale); icons.slint: Lucide icons as tintable images. - components/: Button, IconButton, TextField, SearchBox, Select, Toggle, Slider, SegmentedTabs, Avatar, badges, Card, Meter, NavItem, ListItem, PopupMenu, Tooltip, Modal, Toast, ResizeHandle, Spinner, RichText and the EmojiPicker. - shells/: the desktop frame (server rail, top bar, sidebar with the user card) and the phone frame with a bottom navigation, switched at a breakpoint from the settings. - screens/: today's screens re-skinned (channels, chat, streams panel and viewer, settings page, home, dialogs, phone pages); all callbacks and properties keep their behaviour. Navigation state is the Nav global. On the Rust side app.rs keeps setup and event glue; servers.rs, chat.rs, settings_page.rs and appearance.rs hold the logic, vm/ the pure view models, bind/ the callbacks, dev.rs the development switches. Models are created once and updated row by row (vm::list::sync); each chat tab owns its lines model, so a message appends one row. Emoji come from the bundled Twemoji archive through a size-bounded image cache, split into runs that wrap with the text. New settings ui.theme, ui.font_scale, ui.narrow_breakpoint and ui.image_cache_mb apply live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
159 lines
5.5 KiB
Plaintext
159 lines
5.5 KiB
Plaintext
import { Theme } from "../theme.slint";
|
|
import { Icons } from "../icons.slint";
|
|
import { Icon } from "icon.slint";
|
|
|
|
// A navigation entry: icon, title, optional subtitle and count; the
|
|
// selected one filled with the accent and ringed (settings navigation,
|
|
// sidebar links).
|
|
export component NavItem inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <string> text;
|
|
in property <string> subtitle;
|
|
in property <bool> selected;
|
|
in property <int> badge;
|
|
// Show a chevron at the right (mobile lists).
|
|
in property <bool> chevron;
|
|
callback clicked();
|
|
|
|
min-height: subtitle != "" ? 52px * Theme.font-scale : 40px * Theme.font-scale;
|
|
border-radius: Theme.radius-md;
|
|
background: selected ? Theme.accent-soft : touch.has-hover ? Theme.surface-3 : transparent;
|
|
border-width: selected ? 1px : 0px;
|
|
border-color: Theme.accent;
|
|
animate background { duration: Theme.fast; }
|
|
accessible-role: AccessibleRole.list-item;
|
|
accessible-label: text;
|
|
accessible-description: subtitle;
|
|
accessible-item-selectable: true;
|
|
accessible-item-selected: selected;
|
|
accessible-action-default => { clicked(); }
|
|
|
|
touch := TouchArea {
|
|
mouse-cursor: MouseCursor.pointer;
|
|
clicked => { root.clicked(); }
|
|
}
|
|
HorizontalLayout {
|
|
padding-left: Theme.space-4;
|
|
padding-right: Theme.space-3;
|
|
spacing: Theme.space-4;
|
|
if root.icon.width > 0: Icon {
|
|
source: root.icon;
|
|
size: root.subtitle != "" ? Theme.icon-lg : Theme.icon-md;
|
|
tint: root.selected ? Theme.text : Theme.icon;
|
|
y: (parent.height - self.height) / 2;
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
horizontal-stretch: 1;
|
|
Text {
|
|
text: root.text;
|
|
color: root.selected ? Theme.text : Theme.text;
|
|
font-weight: root.selected ? Theme.weight-semibold : Theme.weight-medium;
|
|
font-size: Theme.font-body;
|
|
overflow: elide;
|
|
}
|
|
if root.subtitle != "": Text {
|
|
text: root.subtitle;
|
|
color: root.selected ? Theme.text-secondary : Theme.text-muted;
|
|
font-size: Theme.font-sm;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
if root.badge > 0: VerticalLayout {
|
|
alignment: center;
|
|
Rectangle {
|
|
min-width: 18px;
|
|
height: 18px;
|
|
border-radius: 9px;
|
|
background: Theme.live;
|
|
HorizontalLayout {
|
|
padding-left: 5px;
|
|
padding-right: 5px;
|
|
Text {
|
|
text: root.badge > 99 ? "99+" : root.badge;
|
|
color: #ffffff;
|
|
font-size: Theme.font-xs;
|
|
font-weight: Theme.weight-bold;
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if root.chevron: Icon {
|
|
source: Icons.chevron-right;
|
|
size: Theme.icon-sm;
|
|
tint: Theme.text-muted;
|
|
y: (parent.height - self.height) / 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
// A list row: a leading slot (@children, e.g. an Avatar), title and
|
|
// subtitle, and trailing text. For lists of people, conversations, sources.
|
|
export component ListItem inherits Rectangle {
|
|
in property <string> title;
|
|
in property <string> subtitle;
|
|
in property <color> title-color: Theme.text;
|
|
in property <color> subtitle-color: Theme.text-muted;
|
|
in property <string> trailing;
|
|
in property <bool> selected;
|
|
in property <bool> interactive: true;
|
|
in property <length> leading-width: 36px;
|
|
callback clicked();
|
|
callback double-clicked();
|
|
|
|
min-height: 44px * Theme.font-scale;
|
|
border-radius: Theme.radius-md;
|
|
background: selected ? Theme.accent-soft : touch.has-hover && interactive ? Theme.surface-3 : transparent;
|
|
border-width: selected ? 1px : 0px;
|
|
border-color: Theme.accent;
|
|
accessible-role: AccessibleRole.list-item;
|
|
accessible-label: title;
|
|
accessible-description: subtitle;
|
|
accessible-item-selectable: interactive;
|
|
accessible-item-selected: selected;
|
|
accessible-action-default => { clicked(); }
|
|
|
|
touch := TouchArea {
|
|
enabled: root.interactive;
|
|
mouse-cursor: MouseCursor.pointer;
|
|
clicked => { root.clicked(); }
|
|
double-clicked => { root.double-clicked(); }
|
|
}
|
|
HorizontalLayout {
|
|
padding-left: Theme.space-3;
|
|
padding-right: Theme.space-3;
|
|
padding-top: Theme.space-2;
|
|
padding-bottom: Theme.space-2;
|
|
spacing: Theme.space-4;
|
|
VerticalLayout {
|
|
alignment: center;
|
|
width: root.leading-width;
|
|
@children
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
horizontal-stretch: 1;
|
|
Text {
|
|
text: root.title;
|
|
color: root.title-color;
|
|
font-weight: Theme.weight-medium;
|
|
overflow: elide;
|
|
}
|
|
if root.subtitle != "": Text {
|
|
text: root.subtitle;
|
|
color: root.subtitle-color;
|
|
font-size: Theme.font-sm;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
if root.trailing != "": Text {
|
|
text: root.trailing;
|
|
color: Theme.text-muted;
|
|
font-size: Theme.font-xs;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
}
|