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
112 lines
3.0 KiB
Plaintext
112 lines
3.0 KiB
Plaintext
// Where the user is: the page, open dialogs, panel sizes. Any screen can
|
|
// navigate through these functions; Rust sets the same properties for the
|
|
// development switch VOELIN_OPEN (src/dev.rs).
|
|
|
|
import { Bridge, BookmarkForm, ShareForm } from "bridge.slint";
|
|
|
|
export enum Page {
|
|
// Welcome page: servers at a glance.
|
|
home,
|
|
// A server: channels, chat or the stream viewer, members and streams.
|
|
server,
|
|
settings,
|
|
}
|
|
|
|
// Sections of the settings page, in the order of its navigation.
|
|
export enum SettingsSection {
|
|
voice,
|
|
keybinds,
|
|
streaming,
|
|
privacy,
|
|
appearance,
|
|
}
|
|
|
|
// Tabs of the bottom navigation in the narrow (mobile) layout.
|
|
export enum MobileTab {
|
|
home,
|
|
servers,
|
|
chat,
|
|
activity,
|
|
you,
|
|
}
|
|
|
|
export global Nav {
|
|
in-out property <Page> page: Page.server;
|
|
in-out property <SettingsSection> settings-section: SettingsSection.voice;
|
|
in-out property <MobileTab> mobile-tab: MobileTab.chat;
|
|
// Narrow windows use the mobile layout; the breakpoint is the setting
|
|
// `ui.narrow_breakpoint`.
|
|
in-out property <bool> narrow: false;
|
|
in-out property <length> narrow-breakpoint: 800px;
|
|
in-out property <bool> right-panel-open: true;
|
|
in-out property <length> right-panel-width: 280px;
|
|
// Incremented to focus the search field (Ctrl+K).
|
|
in-out property <int> search-requests;
|
|
|
|
// Dialogs.
|
|
in-out property <bool> about-open;
|
|
in-out property <bool> share-open;
|
|
in-out property <bool> client-open;
|
|
in-out property <bool> bookmark-open;
|
|
// The emoji picker over the composer, and the composer's text.
|
|
in-out property <bool> emoji-open;
|
|
in-out property <string> draft;
|
|
in-out property <BookmarkForm> bookmark-form;
|
|
in-out property <ShareForm> share-form;
|
|
|
|
// Settings were opened (so leaving them tells Rust).
|
|
property <bool> settings-active;
|
|
|
|
public function show(p: Page) {
|
|
if p != Page.settings && settings-active {
|
|
settings-active = false;
|
|
Bridge.close-settings();
|
|
}
|
|
page = p;
|
|
}
|
|
|
|
public function open-settings(section: SettingsSection) {
|
|
if !settings-active {
|
|
settings-active = true;
|
|
Bridge.open-settings();
|
|
}
|
|
settings-section = section;
|
|
page = Page.settings;
|
|
}
|
|
|
|
public function close-settings() {
|
|
show(Page.server);
|
|
}
|
|
|
|
public function open-about() {
|
|
Bridge.open-about();
|
|
about-open = true;
|
|
}
|
|
|
|
public function open-share() {
|
|
share-form = Bridge.open-share();
|
|
share-open = true;
|
|
}
|
|
|
|
public function add-server() {
|
|
bookmark-form = Bridge.edit-bookmark(-1);
|
|
bookmark-open = true;
|
|
}
|
|
|
|
public function edit-server(id: int) {
|
|
bookmark-form = Bridge.edit-bookmark(id);
|
|
bookmark-open = true;
|
|
}
|
|
|
|
public function open-client(id: int) {
|
|
if Bridge.open-client(id) {
|
|
client-open = true;
|
|
}
|
|
}
|
|
|
|
public function select-server(id: int) {
|
|
show(Page.server);
|
|
Bridge.select-server(id);
|
|
}
|
|
}
|