Files
VoelinClient/crates/voelin-ui/ui/shells/desktop.slint
T
Claude e40bce40e8 voelin-ui: design system, shells and view models for the new design
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
2026-09-28 02:22:25 +00:00

287 lines
9.6 KiB
Plaintext

// The desktop frame: the server rail at the far left, the top bar, and the
// page's panels (@children: a sidebar, the main area, a right panel). The
// window keeps its native decorations.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, ServerItem } from "../bridge.slint";
import { Nav, Page, SettingsSection } from "../nav.slint";
import { Icon, IconButton, Avatar, Status, CountBadge, SearchBox, ScrollView, Tooltip } from "../components/index.slint";
import { Panel, VoiceCard, UserCard } from "common.slint";
// A server in the rail: its icon (initials), the selection pill, state and
// unread marks.
component RailServer inherits Rectangle {
in property <ServerItem> server;
in property <bool> selected;
callback clicked();
callback edit();
width: Theme.rail-width;
height: 56px;
accessible-role: AccessibleRole.list-item;
accessible-label: server.name;
accessible-description: server.address;
accessible-item-selectable: true;
accessible-item-selected: selected;
accessible-action-default => { clicked(); }
// Selection pill.
Rectangle {
x: 0;
width: 4px;
height: selected ? 36px : touch.has-hover ? 18px : 0px;
border-radius: 2px;
background: Theme.text;
animate height { duration: Theme.fast; }
}
// Ring of the selected server.
if selected: Rectangle {
width: 52px;
height: 52px;
border-radius: Theme.radius-lg + 2px;
border-width: 2px;
border-color: Theme.accent;
background: Theme.glow.transparentize(0.6);
}
Avatar {
size: 46px;
square: true;
initials: server.initials;
tint: server.tint;
label: server.name;
status: server.status == "connected" ? Status.online : server.status == "observing" ? Status.info : server.status == "connecting" ? Status.idle : Status.none;
}
if server.unread > 0: CountBadge {
x: min(parent.width - self.width - 4px, 50px);
y: 0px;
count: server.unread;
}
if server.live && server.unread == 0: Rectangle {
x: parent.width - 20px;
y: 4px;
width: 12px;
height: 12px;
border-radius: 6px;
background: Theme.live;
border-width: 2px;
border-color: Theme.bg-rail;
}
touch := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => { root.clicked(); }
double-clicked => { root.edit(); }
}
}
// The column of servers.
export component ServerRail inherits Rectangle {
width: Theme.rail-width;
background: Theme.bg-rail.transparentize(0.1);
accessible-role: AccessibleRole.list;
accessible-label: @tr("Servers");
Rectangle {
x: parent.width - 1px;
width: 1px;
background: Theme.border;
}
VerticalLayout {
padding-top: Theme.space-3;
padding-bottom: Theme.space-3;
spacing: Theme.space-2;
// App mark: home.
HorizontalLayout {
alignment: center;
Rectangle {
width: 48px;
height: 48px;
border-radius: Theme.radius-lg;
background: Nav.page == Page.home ? Theme.accent-soft : logo-touch.has-hover ? Theme.surface-3 : Theme.surface-2;
border-width: 1px;
border-color: Nav.page == Page.home ? Theme.accent : Theme.border;
accessible-role: AccessibleRole.button;
accessible-label: @tr("Home");
accessible-action-default => { Nav.show(Page.home); }
Image {
width: 30px;
height: 30px;
source: Icons.logo;
}
logo-touch := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => { Nav.show(Page.home); }
}
}
}
HorizontalLayout {
alignment: center;
padding-top: Theme.space-2;
padding-bottom: Theme.space-2;
Rectangle {
width: 32px;
height: 2px;
border-radius: 1px;
background: Theme.border-strong;
}
}
ScrollView {
vertical-stretch: 1;
VerticalLayout {
alignment: start;
spacing: Theme.space-2;
for server in Bridge.servers: RailServer {
server: server;
selected: Nav.page == Page.server && Bridge.current-server == server.id;
clicked => { Nav.select-server(server.id); }
edit => { Nav.edit-server(server.id); }
}
HorizontalLayout {
alignment: center;
padding-top: Theme.space-2;
IconButton {
icon: Icons.plus;
label: @tr("Add server");
round: true;
filled: true;
size: 46px;
tint: Theme.success;
clicked => { Nav.add-server(); }
}
}
}
}
HorizontalLayout {
alignment: center;
IconButton {
icon: Icons.settings;
label: @tr("Settings");
round: true;
size: 46px;
checked: Nav.page == Page.settings;
clicked => { Nav.open-settings(SettingsSection.voice); }
}
}
}
}
// The bar at the top: the app name and page, search, notifications.
export component TopBar inherits Rectangle {
in property <string> context;
height: Theme.topbar-height;
accessible-role: AccessibleRole.banner;
HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-4;
spacing: Theme.space-4;
HorizontalLayout {
width: Theme.sidebar-width - Theme.space-4;
spacing: Theme.space-3;
Image {
width: 30px;
height: 30px;
y: (parent.height - self.height) / 2;
source: Icons.logo;
}
Text {
text: Bridge.app-name;
color: Theme.text;
font-size: Theme.font-xl;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
}
if root.context != "": Text {
text: root.context;
color: Theme.accent-text;
font-size: Theme.font-md;
vertical-alignment: center;
overflow: elide;
}
}
HorizontalLayout {
horizontal-stretch: 1;
alignment: center;
search := SearchBox {
max-width: 680px;
height: 40px;
y: (parent.height - self.height) / 2;
placeholder: Bridge.current-server >= 0 ? @tr("Search channels and people in {}…", Bridge.server-title) : @tr("Search channels and people…");
label: @tr("Search");
edited(text) => { Bridge.search(text); }
}
}
IconButton {
icon: Icons.bell;
label: Bridge.share-requests > 0 ? @tr("{} requests to watch your stream", Bridge.share-requests) : @tr("Notifications");
dot: Bridge.share-requests > 0 || Bridge.crash-notice != "";
y: (parent.height - self.height) / 2;
clicked => {
if Bridge.share-requests > 0 {
Nav.open-share();
}
}
}
IconButton {
icon: Icons.users;
label: @tr("Members and streams");
checked: Nav.right-panel-open && Nav.page == Page.server;
y: (parent.height - self.height) / 2;
clicked => {
Nav.show(Page.server);
Nav.right-panel-open = !Nav.right-panel-open;
}
}
Rectangle {
width: 1px;
height: 24px;
y: (parent.height - self.height) / 2;
background: Theme.border-strong;
}
IconButton {
icon: Icons.help;
label: @tr("About {}", Bridge.app-name);
y: (parent.height - self.height) / 2;
clicked => { Nav.open-about(); }
}
}
// Ctrl+K focuses the search.
property <int> requests: Nav.search-requests;
changed requests => { search.focus(); }
}
// A sidebar panel: the page's navigation (@children) above the voice card
// and the user card.
export component Sidebar inherits Panel {
width: Theme.sidebar-width;
horizontal-stretch: 0;
VerticalLayout {
padding: Theme.space-3;
spacing: Theme.space-3;
VerticalLayout {
vertical-stretch: 1;
spacing: Theme.space-3;
@children
}
if Bridge.voice-connected || Bridge.voice-connecting: VoiceCard { }
UserCard { }
}
}
// The frame: rail | (top bar / panels).
export component DesktopShell inherits Rectangle {
in property <string> context;
background: Theme.backdrop;
HorizontalLayout {
ServerRail { }
VerticalLayout {
TopBar {
context: root.context;
}
HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
padding-bottom: Theme.space-3;
spacing: Theme.space-3;
@children
}
}
}
}