Files
VoelinClient/crates/voelin-ui/ui/app.slint
T
Claude d0cd3f6cfd ui: the Servers tab is titled Servers, and the voice card names only the channel
On the phone's Servers tab the top bar showed the server's name and counts,
which the server card right below it shows too, and the voice card named
the server again ("Chill Zone / Nightfall Guild"). The top bar now says
Servers, as the Activity and You tabs say their names; the server card
stays the one place for the name, the counts, the banner and its Edit
server / Add a server menu. The voice card shows only the channel, on
desktop too; while connecting, before there is a channel, it shows
Connecting… alone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
2026-10-08 18:53:08 +00:00

472 lines
21 KiB
Plaintext

// The main window: picks the desktop or the mobile shell and puts the
// current page's screens into it. See docs/ui.md for the structure and how
// to add a screen.
import "assets/fonts/Inter-Regular.ttf";
import "assets/fonts/Inter-Medium.ttf";
import "assets/fonts/Inter-SemiBold.ttf";
import "assets/fonts/Inter-Bold.ttf";
import "assets/fonts/Inter-Italic.ttf";
import { Palette } from "std-widgets.slint";
import { LoginPage } from "screens/account.slint";
import { Theme } from "theme.slint";
import { Icons } from "icons.slint";
import { Bridge } from "bridge.slint";
import { Nav, Page, MobileTab, SettingsSection } from "nav.slint";
import { EmojiPicker, Toast, ResizeHandle } from "components/index.slint";
import { DesktopShell, Sidebar } from "shells/desktop.slint";
import { MobileShell } from "shells/mobile.slint";
import { Panel } from "shells/common.slint";
import { ServerHeader, ConnectActions, ChannelTree } from "screens/channels.slint";
import { ChatView } from "screens/chat.slint";
import { PinsDrawer, TopicsDrawer, TopicDialog } from "screens/drawers.slint";
import { MemberCardPopup, MembersPanel } from "screens/members.slint";
import { VoiceView } from "screens/voice.slint";
import { StreamViewer } from "screens/streams.slint";
import { SettingsNav, SettingsPage } from "screens/settings.slint";
import { HomeNav, HomePage, HomeAside, LibraryPage } from "screens/home.slint";
import { FriendsPage, ContactPanel } from "screens/friends.slint";
import { MessagesPage, ConversationList, Conversation, DmProfile, OfflineDialog } from "screens/messages.slint";
import { ServerLinks, EventsPage, EventDialog } from "screens/events.slint";
import { NotificationsPanel, SearchPalette, Lightbox } from "screens/overlays.slint";
import { MobileServers, ActivityPage, YouPage, PhoneSheet } from "screens/mobile.slint";
import { MobileVoice, PhoneVoice } from "screens/mobile-voice.slint";
import { BookmarkDialog, ShareDialog, ClientAudioDialog, ChannelPasswordDialog, PokeDialog, LinkDialog, AboutDialog } from "screens/dialogs.slint";
import { StudioBridge } from "studio-bridge.slint";
import { StudioPage, MobileStudio } from "screens/studio.slint";
// Rust reaches the globals and structs through this file.
export * from "bridge.slint";
export { Theme } from "theme.slint";
export { Nav, Page, MobileTab, SettingsSection } from "nav.slint";
// The Stream Studio: its data, and its own window (src/studio.rs).
export { StudioBridge, StudioNav, StudioScene, StudioSource, StudioAudio, StudioLayer, StudioViewer, StudioPick, StudioStatus, StudioForm, StudioSourceForm, StudioSettingsForm } from "studio-bridge.slint";
export { StudioWindow } from "studio-window.slint";
// The stream we watch in a window of its own (src/popout.rs).
export { ViewerWindow } from "viewer-window.slint";
export component MainWindow inherits Window {
title: Bridge.app-name;
preferred-width: 1280px;
preferred-height: 820px;
min-width: 360px;
min-height: 480px;
background: Theme.bg-app;
default-font-family: "Inter";
default-font-size: Theme.font-body;
// Set from change handlers: a binding on `width` would loop through the
// layout.
property <length> breakpoint: Nav.narrow-breakpoint;
changed width => {
Nav.narrow = self.width < Nav.narrow-breakpoint;
Nav.wide = self.width > 1180px;
}
changed breakpoint => { Nav.narrow = self.width < Nav.narrow-breakpoint; }
changed height => { Nav.short = self.height < 800px; }
init => {
Nav.narrow = self.width < Nav.narrow-breakpoint;
Nav.wide = self.width > 1180px;
Nav.short = self.height < 800px;
Theme.system-dark = Palette.color-scheme != ColorScheme.light;
}
// Android: the space under the on-screen keyboard (the window is not
// resized for it). Zero on desktop.
property <length> keyboard-inset: 0;
changed virtual-keyboard-size => {
keyboard-inset = self.virtual-keyboard-size.height > 0 ? self.height - self.virtual-keyboard-position.y : 0;
}
// The viewer takes the whole window in full screen and in theatre mode
// (a narrow window keeps the phone layout).
property <bool> chrome: !(Bridge.viewer-open && (Bridge.viewer-fullscreen || (Nav.theatre && !Nav.narrow)));
// Theatre mode ends with the viewer here, which is also when it moves
// into a window of its own (Rust sets viewer-open false meanwhile).
property <bool> viewer-open: Bridge.viewer-open;
changed viewer-open => {
if !viewer-open {
Nav.theatre = false;
}
}
// The viewer moves to the whole window, or loses its chat for full
// screen, and what had the focus goes with it: the keys take it, so
// Escape works.
changed chrome => {
if !chrome {
keys.focus();
}
}
// Back from full screen to theatre mode, the player's button that was
// clicked goes as well.
property <bool> fullscreen: Bridge.viewer-fullscreen;
changed fullscreen => {
if fullscreen || !chrome {
keys.focus();
}
}
// The standard widgets follow the theme. In "system" mode the palette
// is left alone (it tracks the system) unless an explicit mode was
// set before; then the scheme seen at start is used.
property <string> theme-mode: Theme.mode;
property <bool> scheme-set;
changed theme-mode => { apply-color-scheme(); }
function apply-color-scheme() {
if Theme.mode == "dark" {
Palette.color-scheme = ColorScheme.dark;
} else if Theme.mode == "light" {
Palette.color-scheme = ColorScheme.light;
} else if Theme.mode == "system" && scheme-set {
Palette.color-scheme = Theme.system-dark ? ColorScheme.dark : ColorScheme.light;
}
scheme-set = scheme-set || Theme.mode == "dark" || Theme.mode == "light";
}
// Status messages show as a toast.
property <string> status: Bridge.status-text;
changed status => { toast.shown = status != ""; }
// The right column: members, pins or topics.
property <bool> side-panel: Nav.right-panel-open || Nav.pins-open || Nav.topics-open;
// Dragging the members panel stores its width (`ui.members_width`).
property <length> panel-width: Nav.right-panel-width;
changed panel-width => { Bridge.panel-resized(panel-width / 1px); }
// Messages are read while the chat is on screen.
property <bool> chat-shown: Nav.chat-shown;
changed chat-shown => { Bridge.chat-shown-changed(); }
// Compatibility with callers from before the navigation global.
public function open-share-dialog() {
Nav.open-share();
}
keys := FocusScope {
// Ctrl+K: search.
capture-key-pressed(event) => {
if event.modifiers.control && (event.text == "k" || event.text == "K") && root.chrome && !Bridge.myts.prompt {
Nav.open-search("");
return accept;
}
reject
}
// Escape leaves full screen, then theatre mode (after the focused
// field had its turn).
key-pressed(event) => {
if event.text == Key.Escape && Bridge.viewer-fullscreen {
Bridge.toggle-fullscreen();
return accept;
}
if event.text == Key.Escape && Nav.theatre && Bridge.viewer-open {
Nav.theatre = false;
return accept;
}
reject
}
VerticalLayout {
// Android draws the window under the status and navigation bars.
padding-top: root.safe-area-insets.top;
padding-left: root.safe-area-insets.left;
padding-right: root.safe-area-insets.right;
padding-bottom: max(root.safe-area-insets.bottom, root.keyboard-inset);
if Bridge.myts.prompt: LoginPage { }
if !Bridge.myts.prompt && !root.chrome: StreamViewer { }
if !Bridge.myts.prompt && !Nav.narrow && root.chrome: DesktopShell {
if Nav.page == Page.home: Sidebar {
HomeNav { }
}
if Nav.page == Page.home: Panel {
horizontal-stretch: 1;
HomePage { }
}
if Nav.page == Page.home && Nav.wide: Panel {
width: 300px;
horizontal-stretch: 0;
HomeAside { }
}
// Friends, direct messages and the Library share the home
// sidebar.
if Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library: Sidebar {
HomeNav { }
}
if Nav.page == Page.friends: Panel {
horizontal-stretch: 1;
FriendsPage { }
}
if Nav.page == Page.friends && Bridge.contact.uid != "": Panel {
width: 320px;
horizontal-stretch: 0;
ContactPanel { }
}
if Nav.page == Page.messages: Panel {
horizontal-stretch: 1;
MessagesPage { }
}
if Nav.page == Page.messages && Bridge.dm.open && !Bridge.dm.mail && Nav.wide: Panel {
width: 300px;
horizontal-stretch: 0;
DmProfile { }
}
if Nav.page == Page.library: Panel {
horizontal-stretch: 1;
LibraryPage { }
}
if Nav.page == Page.server || Nav.page == Page.events: Sidebar {
ServerHeader { }
ServerLinks { }
if !Bridge.voice-connected && !Bridge.voice-connecting: ConnectActions { }
ChannelTree {
vertical-stretch: 1;
}
}
if Nav.page == Page.server: Panel {
horizontal-stretch: 1;
if Bridge.viewer-open: StreamViewer { }
if !Bridge.viewer-open && Nav.voice-view && Bridge.voice-connected: VoiceView { }
if !Bridge.viewer-open && !(Nav.voice-view && Bridge.voice-connected): ChatView { }
}
// The members panel, or the pins or the topics in its place.
if Nav.page == Page.server && root.side-panel: ResizeHandle {
size <=> Nav.right-panel-width;
minimum: Theme.right-panel-min;
// As wide as the window allows, leaving the chat 400 px.
maximum: max(Theme.right-panel-min, root.width - Theme.rail-width - Theme.sidebar-width - 400px);
left: false;
}
if Nav.page == Page.server && root.side-panel: Panel {
width: Nav.right-panel-width;
horizontal-stretch: 0;
if Nav.pins-open: PinsDrawer { }
if Nav.topics-open && !Nav.pins-open: TopicsDrawer { }
if !Nav.pins-open && !Nav.topics-open: MembersPanel { }
}
if Nav.page == Page.events: Panel {
horizontal-stretch: 1;
EventsPage { }
}
if Nav.page == Page.settings: Sidebar {
SettingsNav { }
}
if Nav.page == Page.settings: Panel {
horizontal-stretch: 1;
SettingsPage { }
}
if Nav.page == Page.studio && !StudioBridge.status.detached: StudioPage {
horizontal-stretch: 1;
}
}
if !Bridge.myts.prompt && Nav.narrow && root.chrome: MobileShell {
property <bool> channel-chat: Nav.page == Page.server && !Nav.phone-voice
&& Nav.mobile-tab == MobileTab.chat && !Bridge.viewer-open
&& Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length
&& Bridge.tabs[Bridge.current-tab].kind == 1;
banner: Nav.phone-voice ? Bridge.own-channel-banner : self.channel-chat ? Bridge.tabs[Bridge.current-tab].banner : @image-url("");
// The page's or the tab's name (on the Servers tab the server
// card below names the server); on the Chats tab the server,
// with the chat below it.
title: Nav.page == Page.settings ? @tr("Settings")
: Nav.page == Page.friends ? @tr("Friends")
: Nav.page == Page.messages ? @tr("Messages")
: Nav.page == Page.library ? @tr("Library")
: Nav.page == Page.events ? @tr("Events")
: Nav.phone-voice ? Bridge.own-channel
: Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? Bridge.app-name
: Nav.mobile-tab == MobileTab.servers ? @tr("Servers")
: Nav.mobile-tab == MobileTab.you ? @tr("You")
: Nav.mobile-tab == MobileTab.activity ? @tr("Activity")
: Bridge.server-title;
subtitle: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library ? ""
: Nav.page == Page.events || Nav.phone-voice ? Bridge.server-title
: Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? ""
: Nav.mobile-tab == MobileTab.chat && Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].title : "";
back: Nav.phone-voice || Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || Nav.page == Page.events;
unread: Bridge.unread-total;
voice: Nav.phone-voice;
// The voice channel and the studio bring their own controls.
navigation: !Nav.phone-voice && Nav.page != Page.studio;
go-back => {
if Nav.phone-voice {
PhoneVoice.back();
} else if Nav.page == Page.messages && Bridge.dm.open {
Bridge.open-conversation(-1);
} else if Nav.page == Page.events || Nav.page == Page.settings {
Nav.show(Page.server);
} else {
Nav.show(Page.home);
Nav.mobile-tab = MobileTab.home;
}
}
if Nav.page == Page.settings: SettingsPage {
compact: true;
}
if !Nav.phone-voice && (Nav.page == Page.home || (Nav.page == Page.server && Nav.mobile-tab == MobileTab.home)): HomePage {
compact: true;
}
if Nav.page == Page.friends: FriendsPage {
compact: true;
}
if Nav.page == Page.messages && !Bridge.dm.open: ConversationList { }
if Nav.page == Page.messages && Bridge.dm.open: Conversation {
compact: true;
}
if Nav.page == Page.library: LibraryPage {
compact: true;
}
if Nav.page == Page.events: EventsPage {
compact: true;
}
if Nav.phone-voice: MobileVoice { }
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.servers: MobileServers { }
// Watching without voice (the local test stream): the player.
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.chat && Bridge.viewer-open: StreamViewer { }
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.chat && !Bridge.viewer-open: ChatView {
header: false;
}
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.activity: ActivityPage { }
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.you: YouPage { }
if Nav.page == Page.studio && !StudioBridge.status.detached: MobileStudio { }
// Pins, topics or the members, over the page.
if Nav.page == Page.server && (Nav.pins-open || Nav.topics-open || Nav.members-open): PhoneSheet { }
}
}
}
// The member card of the members panel, over everything. Like the emoji
// picker and the bell's panel below, it dims the window a little, and a
// click outside it closes it.
if !Bridge.myts.prompt && (Bridge.member-card.open): Rectangle {
background: Theme.scrim-light;
TouchArea {
clicked => { Bridge.open-member(-1); }
}
MemberCardPopup {
x: max(8px, parent.width - self.width - (Nav.narrow ? 8px : root.side-panel && Nav.page == Page.server ? Nav.right-panel-width + 24px : 32px));
y: max(8px, min(parent.height - self.height - 8px, 120px));
}
}
if !Bridge.myts.prompt && (Nav.emoji-open): Rectangle {
background: Theme.scrim-light;
// Clicks outside the picker close it.
TouchArea {
clicked => { Nav.emoji-open = false; }
}
EmojiPicker {
x: max(8px, parent.width - self.width - (Nav.narrow ? 8px : root.side-panel && Nav.page == Page.server ? Nav.right-panel-width + 40px : 32px));
y: max(8px, parent.height - self.height - (Nav.narrow ? 150px : 90px));
// Picked for a message: a reaction; otherwise the composer.
picked(cell) => {
if Nav.react-key != 0 {
Bridge.react(Nav.react-key, cell.text);
Nav.react-key = 0;
Nav.emoji-open = false;
} else {
Nav.draft = Nav.draft + cell.text;
}
}
close => {
Nav.react-key = 0;
Nav.emoji-open = false;
}
}
}
// The bell's panel, under the bell (the phone: the whole width), as
// tall as its notices up to 560 px.
if !Bridge.myts.prompt && (Nav.notifications-open): Rectangle {
background: Theme.scrim-light;
TouchArea {
clicked => { Nav.notifications-open = false; }
}
NotificationsPanel {
x: Nav.narrow ? 8px : parent.width - self.width - Theme.space-4;
y: Nav.narrow ? 64px : Theme.topbar-height;
width: Nav.narrow ? parent.width - 16px : 400px;
height: min(parent.height - self.y - 16px, 560px, self.preferred-height);
}
}
// Nav.copy: Slint copies only what is selected in a text field, so the
// text goes through this hidden one. Rust confirms it in the toast,
// shown again even when its text is the last one's.
property <int> clip-requests: Nav.clip-requests;
changed clip-requests => {
clipboard.text = Nav.clip-text;
clipboard.select-all();
clipboard.copy();
Bridge.copied();
toast.shown = true;
}
clipboard := TextInput {
visible: false;
width: 0;
height: 0;
}
// Over the pop-ups, so their scrim does not dim it (a poke from the
// member card says so here); under the dialogs.
toast := Toast {
x: (parent.width - self.width) / 2;
y: parent.height - self.height - (Nav.narrow ? 140px : 96px);
text: Bridge.status-text;
visible: self.shown && !Bridge.myts.prompt;
// A notice from the start (an imported identity) waits for the
// account prompt to close.
paused: Bridge.myts.prompt;
widest: min(560px, parent.width - 32px);
}
if !Bridge.myts.prompt && (Nav.search-open): SearchPalette { }
if !Bridge.myts.prompt && (Nav.lightbox-open): Lightbox { }
if !Bridge.myts.prompt && (Nav.event-form-open): EventDialog {
form <=> Nav.event-form;
done => { Nav.event-form-open = false; }
}
if !Bridge.myts.prompt && (Nav.offline-form-open): OfflineDialog {
done => { Nav.offline-form-open = false; }
}
if !Bridge.myts.prompt && (Nav.topic-form-open): TopicDialog {
done => { Nav.topic-form-open = false; }
}
if !Bridge.myts.prompt && (Nav.bookmark-open): BookmarkDialog {
form <=> Nav.bookmark-form;
done => { Nav.bookmark-open = false; }
}
if !Bridge.myts.prompt && (Nav.share-open): ShareDialog {
form <=> Nav.share-form;
done => { Nav.share-open = false; }
}
if !Bridge.myts.prompt && (Nav.client-open): ClientAudioDialog {
done => { Nav.client-open = false; }
}
if !Bridge.myts.prompt && (Nav.channel-password-open): ChannelPasswordDialog {
done => { Nav.channel-password-open = false; }
}
if !Bridge.myts.prompt && (Nav.poke-open): PokeDialog {
done => { Nav.poke-open = false; }
}
if !Bridge.myts.prompt && (Nav.link-open): LinkDialog {
done => { Nav.link-open = false; }
}
if !Bridge.myts.prompt && (Nav.about-open): AboutDialog {
done => { Nav.about-open = false; }
}
}