Home could be on screen while the bar marked Chats and the top bar named the server: opening Home other than by its tab (the desktop's logo before the window narrowed, VOELIN_OPEN=home) left the phone's tab where it was. Nav.show now keeps the tab and the page together, also while the window is wide, so the tab is right when it narrows. The tabs go through Nav.show-tab, which also closes the pins, topics or members page that was over the last tab, instead of leaving it over the next one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
205 lines
6.2 KiB
Plaintext
205 lines
6.2 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;
|
|
|
|
// The phone layout (narrow windows).
|
|
// The server's members as a page of their own (the desktop shows them
|
|
// beside the chat).
|
|
in-out property <bool> members-open;
|
|
// The voice channel screen (design mockup 02) instead of a tab: the
|
|
// voice channel view, or a stream we watch.
|
|
out property <bool> phone-voice: narrow && page == Page.server && Bridge.voice-connected && (voice-view || Bridge.viewer-open);
|
|
|
|
// 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();
|
|
}
|
|
// The phone shows Home on its own tab: a server goes to Servers,
|
|
// and Home from anywhere (the desktop's logo, a switch) is that tab.
|
|
// Also while wide, so the tab is right when the window narrows.
|
|
if p == Page.server && mobile-tab == MobileTab.home {
|
|
mobile-tab = MobileTab.servers;
|
|
}
|
|
if p == Page.home {
|
|
mobile-tab = MobileTab.home;
|
|
}
|
|
page = p;
|
|
}
|
|
|
|
// A tab of the phone's bottom navigation, without the pages that were
|
|
// over the last one (pins, topics, members).
|
|
public function show-tab(tab: MobileTab) {
|
|
pins-open = false;
|
|
topics-open = false;
|
|
members-open = false;
|
|
show(tab == MobileTab.home ? Page.home : Page.server);
|
|
mobile-tab = tab;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|