Files
VoelinClient/crates/voelin-ui/ui/nav.slint
T
selikhovandClaude Opus 5.5 55267f88bd Merge the server screens into the Stream Studio branch
Both sides added to Nav (the studio's open-studio next to the drawers and
the voice view), to App (the studio's state next to the uploads) and to
the development switches (studio[:...] next to voice, pins, topics,
watch); all of them are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 07:14:20 +03:00

178 lines
5.1 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";
import { StudioBridge } from "studio-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,
// The Stream Studio (scenes, preview, mixer, going live).
studio,
}
// 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;
// The voice channel we are in (people, streams, its chat) instead of
// the plain chat.
in-out property <bool> voice-view: false;
// Drawers in place of the members panel (gateway features).
in-out property <bool> pins-open;
in-out property <bool> topics-open;
// The message the emoji picker reacts to; 0: it fills the composer.
in-out property <int> react-key;
// "Start a topic" asks for a title first.
in-out property <bool> topic-form-open;
in-out property <int> topic-form-key;
in-out property <string> topic-form-title;
// 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;
}
}
// The Stream Studio: its page, or its window when it has one.
public function open-studio() {
if StudioBridge.status.detached {
StudioBridge.open();
} else {
show(Page.studio);
}
}
// The pins and the topics share the drawer, so opening one closes the
// other.
public function show-pins(on: bool) {
pins-open = on;
if on {
topics-open = false;
Bridge.open-pins();
}
}
public function show-topics(on: bool) {
topics-open = on;
if on {
pins-open = false;
Bridge.open-topics();
}
}
// The members button: back from a drawer, or the panel on and off.
public function toggle-members() {
if pins-open || topics-open {
pins-open = false;
topics-open = false;
right-panel-open = true;
} else {
right-panel-open = !right-panel-open;
}
}
// The voice channel view, or back to the chat (Rust opens the
// channel's chat and puts the people in it first in the panel).
public function show-voice(on: bool) {
voice-view = on;
Bridge.show-voice-view(on);
}
public function start-topic(key: int) {
topic-form-key = key;
topic-form-title = "";
topic-form-open = true;
}
public function select-server(id: int) {
show(Page.server);
Bridge.select-server(id);
}
}