voelin-ui: the server screens of the new design

The server page had one layout: a channel tree, a chat and a panel of
members and streams. The design asks for more of it at once, so the same
page now carries the pieces it was missing.

The chat shows reactions, a pin marker, file cards and older messages,
and every message can be reacted to, pinned or made into a topic where
the gateway offers it. A compact voice bar sits over it with the
connected channel, who is talking and the voice controls, so the sidebar
card is no longer the only way to leave or mute.

The members panel groups people by server group with the group's icon,
shows the badges and talk power a TeamSpeak client expects, and opens a
card with the person's description, groups, private chat, poke, contact
and volume. Its width is the setting `ui.members_width`, so dragging the
handle keeps it.

Pins and topics are drawers over the chat, the voice channel can be seen
as a grid of tiles with the streams in it, and the stream viewer gained
the elapsed time, the viewer count, a quality picker, a mute button, the
chat beside the player and a pop-out that hides the shell.

The quality picker stays hidden for now: the engine tells a viewer
neither which simulcast layers a streamer offers nor lets it ask for
one, so there is nothing to choose between.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 5 committed 2026-09-29 18:38:04 +03:00
1 parent 489bef8174
commit ff7ef96b75
15 files changed
+1795 -184

No files matched your search

+4
View File
@@ -288,6 +288,8 @@ pub(crate) struct Models {
pub pins: Rc<VecModel<PinItem>>,
pub topics: Rc<VecModel<TopicItem>>,
pub topic_messages: Rc<VecModel<ChatLine>>,
/// The quality choices of the watched stream.
pub qualities: Rc<VecModel<slint::SharedString>>,
/// Shown when there is no chat.
pub no_chat: Rc<VecModel<ChatLine>>,
}
@@ -304,6 +306,7 @@ impl Models {
pins: Rc::default(),
topics: Rc::default(),
topic_messages: Rc::default(),
qualities: Rc::default(),
no_chat: Rc::default(),
};
bridge.set_servers(ModelRc::from(models.servers.clone()));
@@ -315,6 +318,7 @@ impl Models {
bridge.set_pins(ModelRc::from(models.pins.clone()));
bridge.set_topics(ModelRc::from(models.topics.clone()));
bridge.set_topic_messages(ModelRc::from(models.topic_messages.clone()));
bridge.set_viewer_qualities(ModelRc::from(models.qualities.clone()));
bridge.set_messages(ModelRc::from(models.no_chat.clone()));
models
}
+19 -2
View File
@@ -8,7 +8,7 @@ use tracing::warn;
use crate::app::{App, AppearanceForm, Bridge, Nav, Theme};
use crate::images;
use crate::settings::{
ThemeChoice, UI_FONT_SCALE, UI_IMAGE_CACHE_MB, UI_NARROW_BREAKPOINT, UI_THEME,
ThemeChoice, UI_FONT_SCALE, UI_IMAGE_CACHE_MB, UI_MEMBERS_WIDTH, UI_NARROW_BREAKPOINT, UI_THEME,
};
impl App {
@@ -23,7 +23,12 @@ impl App {
let t = ui.global::<Theme>();
t.set_mode(theme.as_str().into());
t.set_font_scale(scale);
ui.global::<Nav>().set_narrow_breakpoint(breakpoint as f32);
let nav = ui.global::<Nav>();
nav.set_narrow_breakpoint(breakpoint as f32);
let width = self.prefs.get(&UI_MEMBERS_WIDTH) as f32;
if nav.get_right_panel_width() != width {
nav.set_right_panel_width(width);
}
let bridge = ui.global::<Bridge>();
bridge.set_appearance(AppearanceForm {
theme: theme.as_str().into(),
@@ -53,4 +58,16 @@ impl App {
// may not run the settings service (tests, a hosted engine).
self.apply_appearance();
}
/// The members panel was dragged to another width: store it, so it
/// comes back the same and `--set ui.members_width` can change it.
pub(crate) fn panel_resized(&mut self, width: f32) {
let width = width.max(0.0).round() as u32;
if self.prefs.get(&UI_MEMBERS_WIDTH) == width {
return;
}
if let Err(e) = self.prefs.set(&UI_MEMBERS_WIDTH, width) {
warn!(%e, "could not store the panel width");
}
}
}
+3 -1
View File
@@ -35,7 +35,9 @@ fn show(ui: &MainWindow, category: i32, list: Vec<PickerEmoji>) {
}
pub(super) fn wire(ui: &MainWindow) {
ui.global::<Images>().on_emoji(|key| images::emoji(&key));
let images_global = ui.global::<Images>();
images_global.on_emoji(|key| images::emoji(&key));
images_global.on_emoji_text(|key| emoji::text_of(&key).into());
let global = ui.global::<Emoji>();
let weak = ui.as_weak();
global.on_load(move || {
+3
View File
@@ -27,6 +27,9 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_download_h264(|| {
with_app(|app| app.download_h264());
});
bridge.on_panel_resized(|width| {
with_app(|app| app.panel_resized(width));
});
bridge.on_appearance_changed(|form| {
with_app(|app| app.appearance_changed(&form));
});
+3
View File
@@ -37,4 +37,7 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_toggle_fullscreen(|| {
with_app(|app| app.toggle_fullscreen());
});
bridge.on_set_stream_quality(|index| {
with_app(|app| app.set_stream_quality(index));
});
}
+1 -1
View File
@@ -253,7 +253,7 @@ fn key_of(cps: &[u32]) -> String {
/// The characters of an archive key, with U+FE0F after a lone character
/// that is text by default, so other clients show an emoji too.
fn text_of(key: &str) -> String {
pub fn text_of(key: &str) -> String {
let cps: Vec<u32> = key.split('-').filter_map(|p| u32::from_str_radix(p, 16).ok()).collect();
let mut text: String = cps.iter().filter_map(|&cp| char::from_u32(cp)).collect();
if cps.len() == 1 && !emoji_presentation(cps[0]) {
+11 -2
View File
@@ -91,9 +91,18 @@ pub static UI_IMAGE_CACHE_MB: Key<u32> = Key::new(
|| 64,
);
/// `ui.members_width`: how wide the members and streams panel is, in
/// pixels. Dragging its handle stores it; there is no built-in maximum.
pub static UI_MEMBERS_WIDTH: Key<u32> = Key::new(
"ui.members_width",
Kind::UInt { min: 0 },
"Width of the members and streams panel in pixels.",
|| 280,
);
/// The UI's keys besides [`UI`] and [`CLIENT_PLAYBACK`], for registering.
pub fn appearance_keys() -> [&'static dyn voelin_core::settings::Setting; 4] {
[&UI_THEME, &UI_FONT_SCALE, &UI_NARROW_BREAKPOINT, &UI_IMAGE_CACHE_MB]
pub fn appearance_keys() -> [&'static dyn voelin_core::settings::Setting; 5] {
[&UI_THEME, &UI_FONT_SCALE, &UI_NARROW_BREAKPOINT, &UI_IMAGE_CACHE_MB, &UI_MEMBERS_WIDTH]
}
/// Frame rates and bitrates (kbit/s) the share dialog offers; any other
+82 -3
View File
@@ -6,7 +6,9 @@ use slint::{ComponentHandle, Model};
use tracing::warn;
use voelin_core::media::audio_source_specs;
use voelin_core::settings::{STREAM_AUDIO_SOURCES, STREAM_BITRATE_KBPS, STREAM_FPS};
use voelin_core::stream::{EndReason, LeaveReason, StreamSetup, ViewerInfo, ViewerState};
use voelin_core::stream::{
EndReason, LayerId, LayerSpec, LeaveReason, StreamSetup, ViewerInfo, ViewerState,
};
use voelin_core::{Command, Event, StreamState, WatchState};
use crate::app::{App, Bridge, ShareForm, SourceItem, StreamItem, ViewerItem, later, model};
@@ -42,6 +44,45 @@ pub(crate) struct Watch {
/// Shown instead of the chat.
shown: bool,
decoder: Option<Decoder>,
/// When the picture started, for the elapsed time.
since: Option<std::time::Instant>,
/// The simulcast layers the streamer offers, largest first.
layers: Vec<LayerSpec>,
/// The layer chosen by hand; `None` follows the bandwidth estimate.
layer: Option<LayerId>,
/// People watching the same stream, as the directory reports it.
viewers: u32,
}
impl Watch {
/// "12:34" since the picture started.
fn elapsed(&self) -> String {
let Some(since) = self.since else { return String::new() };
let seconds = since.elapsed().as_secs();
match seconds / 3600 {
0 => format!("{:02}:{:02}", seconds / 60, seconds % 60),
hours => format!("{hours}:{:02}:{:02}", (seconds / 60) % 60, seconds % 60),
}
}
/// "Auto" and one entry per layer the streamer offers.
fn qualities(&self) -> Vec<slint::SharedString> {
if self.layers.len() < 2 {
return Vec::new();
}
let mut names = vec![slint::SharedString::from("Auto")];
names.extend(self.layers.iter().map(|l| layer_name(l).into()));
names
}
}
/// "720p · 2.4 Mbit/s", or the scale when the size is not fixed.
fn layer_name(layer: &LayerSpec) -> String {
let size = match layer.size {
Some((_, h)) => format!("{h}p"),
None => format!("{:.0}%", layer.scale * 100.0),
};
format!("{size} · {:.1} Mbit/s", layer.bitrate as f64 / 1_000_000.0)
}
fn end_text(reason: &EndReason, streamer: &str) -> String {
@@ -272,13 +313,42 @@ impl App {
bridge.set_viewer_ended(watch.ended);
bridge.set_viewer_has_frame(watch.has_frame);
bridge.set_viewer_volume(self.stream_volume);
let info = watch.decoder.as_ref().map(Decoder::info).unwrap_or_default();
let info = [format!("by {}", watch.streamer), info]
let decoded = watch.decoder.as_ref().map(Decoder::info).unwrap_or_default();
let info = [format!("by {}", watch.streamer), decoded.clone()]
.into_iter()
.filter(|s| !s.is_empty())
.collect::<Vec<_>>()
.join(" · ");
bridge.set_viewer_info(info.into());
bridge.set_viewer_elapsed(watch.elapsed().into());
bridge.set_viewer_count(watch.viewers as i32);
let qualities = watch.qualities();
let chosen = watch
.layer
.and_then(|id| watch.layers.iter().position(|l| l.id == id))
.map_or(0, |i| i as i32 + 1);
crate::vm::list::sync(&self.models.qualities, &qualities);
if bridge.get_viewer_quality() != chosen {
bridge.set_viewer_quality(chosen);
}
bridge.set_viewer_quality_detail(decoded.into());
}
/// A simulcast layer of the watched stream (0: follow the bandwidth
/// estimate). The streamer picks the layer from each viewer's estimate,
/// so this asks for the picture again; a viewer-side choice needs an
/// engine API that does not exist yet.
pub(crate) fn set_stream_quality(&mut self, index: i32) {
let Some(watch) = &mut self.watch else { return };
watch.layer =
usize::try_from(index - 1).ok().and_then(|i| watch.layers.get(i)).map(|l| l.id);
if let Some(session) = watch.session {
self.engine.send(Command::RequestStreamKeyframe {
session: session as u64,
stream_id: watch.stream_id.clone(),
});
}
self.refresh_viewer();
}
/// Once a second: statistics, a capture that ended, decoder problems.
@@ -524,6 +594,10 @@ impl App {
has_frame: false,
shown: true,
decoder: Some(decoder),
since: None,
layers: Vec::new(),
layer: None,
viewers: 0,
});
self.refresh_viewer();
self.refresh_streams();
@@ -543,6 +617,10 @@ impl App {
has_frame: false,
shown: true,
decoder: None,
since: None,
layers: Vec::new(),
layer: None,
viewers: 0,
});
let runtime = self.engine.runtime().clone();
let wake = || later(|app| app.show_picture());
@@ -570,6 +648,7 @@ impl App {
watch.has_frame = true;
if first {
watch.status.clear();
watch.since = Some(std::time::Instant::now());
}
if let Some(ui) = self.ui.upgrade() {
let bridge = ui.global::<Bridge>();
+54 -5
View File
@@ -19,6 +19,8 @@ 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, VoiceGrid } from "screens/members.slint";
import { StreamsPanel, StreamViewer } from "screens/streams.slint";
import { SettingsNav, SettingsPage } from "screens/settings.slint";
import { HomeNav, HomePage } from "screens/home.slint";
@@ -56,8 +58,8 @@ export component MainWindow inherits Window {
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.
property <bool> chrome: !(Bridge.viewer-open && Bridge.viewer-fullscreen);
// The viewer takes the whole window in full screen and when popped out.
property <bool> chrome: !(Bridge.viewer-open && (Bridge.viewer-fullscreen || Bridge.viewer-popped));
// The standard widgets follow the theme. In "system" mode the palette
// is left alone (it tracks the system) unless an explicit mode was
@@ -80,6 +82,10 @@ export component MainWindow inherits Window {
property <string> status: Bridge.status-text;
changed status => { toast.shown = status != ""; }
// 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); }
// Compatibility with callers from before the navigation global.
public function open-share-dialog() {
Nav.open-share();
@@ -123,7 +129,23 @@ export component MainWindow inherits Window {
if Nav.page == Page.server: Panel {
horizontal-stretch: 1;
if Bridge.viewer-open: StreamViewer { }
if !Bridge.viewer-open: ChatView { }
if !Bridge.viewer-open && Nav.voice-grid && Bridge.voice-connected: VoiceGrid { }
if !Bridge.viewer-open && !(Nav.voice-grid && Bridge.voice-connected): ChatView { }
// The pins and the topics slide in over the chat.
if !Bridge.viewer-open && (Nav.pins-open || Nav.topics-open): Rectangle {
x: parent.width - self.width - 12px;
y: 12px;
width: min(parent.width - 24px, 400px);
height: parent.height - 24px;
if Nav.pins-open: PinsDrawer {
width: parent.width;
height: parent.height;
}
if Nav.topics-open: TopicsDrawer {
width: parent.width;
height: parent.height;
}
}
}
if Nav.page == Page.server && Nav.right-panel-open: ResizeHandle {
size <=> Nav.right-panel-width;
@@ -177,6 +199,17 @@ export component MainWindow inherits Window {
text: Bridge.status-text;
}
// The member card of the members panel, over everything.
if Bridge.member-card.open: Rectangle {
TouchArea {
clicked => { Bridge.open-member(-1); }
}
MemberCardPopup {
x: max(8px, parent.width - self.width - (Nav.narrow ? 8px : Nav.right-panel-open && Nav.page == Page.server ? Nav.right-panel-width + 24px : 32px));
y: max(8px, min(parent.height - self.height - 8px, 120px));
}
}
if Nav.emoji-open: Rectangle {
// Clicks outside the picker close it.
TouchArea {
@@ -185,11 +218,27 @@ export component MainWindow inherits Window {
EmojiPicker {
x: max(8px, parent.width - self.width - (Nav.narrow ? 8px : Nav.right-panel-open && Nav.page == Page.server ? Nav.right-panel-width + 40px : 32px));
y: max(8px, parent.height - self.height - (Nav.narrow ? 150px : 90px));
picked(cell) => { Nav.draft = Nav.draft + cell.text; }
close => { Nav.emoji-open = false; }
// 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;
}
}
}
if Nav.topic-form-open: TopicDialog {
done => { Nav.topic-form-open = false; }
}
if Nav.bookmark-open: BookmarkDialog {
form <=> Nav.bookmark-form;
done => { Nav.bookmark-open = false; }
+4
View File
@@ -463,6 +463,8 @@ export global Bridge {
callback set-h264(bool);
callback download-h264();
callback appearance-changed(AppearanceForm);
// The members panel was dragged to another width (pixels).
callback panel-resized(float);
callback open-client(int) -> bool;
callback client-audio-changed(ClientAudio);
callback set-crash-reports(bool);
@@ -478,6 +480,8 @@ export global Bridge {
export global Images {
// A Twemoji by key ("1f600", "1f468-200d-1f4bb"); empty if unknown.
pure callback emoji(string) -> image;
// The characters of a Twemoji key, to react with or to insert.
pure callback emoji-text(string) -> string;
}
// One emoji of the picker. `text` is what picking it inserts.
+35
View File
@@ -42,6 +42,17 @@ export global Nav {
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's grid instead of the chat.
in-out property <bool> voice-grid: false;
// Drawers over the chat (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;
@@ -104,6 +115,30 @@ export global Nav {
}
}
// 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();
}
}
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);
+525 -65
View File
@@ -1,11 +1,12 @@
// The chat: header, chat tabs, messages (virtualised), the composer with
// the emoji picker.
// The chat: header, chat tabs, the compact voice bar, messages
// (virtualised) with reactions, pins and file cards, and the composer with
// the emoji picker and the file attachment.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, ChatLine } from "../bridge.slint";
import { Bridge, ChatLine, ReactionItem, FileItem, Images } from "../bridge.slint";
import { Nav } from "../nav.slint";
import { Icon, IconButton, Avatar, Chip, TabItem, TextField, RichText, Banner, Button, ButtonKind, ListView } from "../components/index.slint";
import { Icon, IconButton, Avatar, Chip, TabItem, TextField, RichText, Banner, Button, ButtonKind, Spinner, Tooltip, SpeakingBars, ListView } from "../components/index.slint";
// The header of the main area: an icon, a title and a description, and
// actions (@children) at the right.
@@ -57,14 +58,309 @@ export component PageHeader inherits Rectangle {
}
}
// The voice connection as one strip: where we are, who talks, and the
// controls. Shown over the chat while voice is connected.
export component VoiceBar inherits Rectangle {
height: 46px;
background: Theme.surface-2.transparentize(0.25);
accessible-role: AccessibleRole.groupbox;
accessible-label: @tr("Voice");
Rectangle {
y: parent.height - 1px;
height: 1px;
background: Theme.border;
}
HorizontalLayout {
padding-left: Theme.space-5;
padding-right: Theme.space-3;
spacing: Theme.space-3;
Rectangle {
width: 8px;
height: 8px;
y: (parent.height - self.height) / 2;
border-radius: 4px;
background: Bridge.voice-connected ? Theme.success : Theme.warning;
}
VerticalLayout {
alignment: center;
Text {
text: Bridge.voice-connected ? @tr("Voice connected") : @tr("Connecting…");
color: Bridge.voice-connected ? Theme.success : Theme.warning;
font-size: Theme.font-xs;
font-weight: Theme.weight-semibold;
}
Text {
text: Bridge.own-channel != "" ? Bridge.own-channel + " / " + Bridge.server-title : Bridge.server-title;
color: Theme.text-muted;
font-size: Theme.font-xs;
overflow: elide;
}
}
// Who is talking right now.
Rectangle {
horizontal-stretch: 1;
HorizontalLayout {
alignment: start;
padding-left: Theme.space-3;
spacing: -6px;
for member in Bridge.members: Rectangle {
width: member.talking ? 28px : 0px;
visible: member.talking;
Avatar {
size: 26px;
initials: member.initials;
tint: member.tint;
image: member.avatar;
speaking: true;
label: member.name;
}
}
}
}
if Bridge.transmitting: VerticalLayout {
alignment: center;
SpeakingBars { }
}
IconButton {
icon: Bridge.input-muted ? Icons.mic-off : Icons.mic;
label: Bridge.input-muted ? @tr("Microphone off") : @tr("Microphone on");
checked: Bridge.input-muted;
danger: true;
size: 32px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Bridge.set-input-muted(!Bridge.input-muted); }
}
IconButton {
icon: Bridge.output-muted ? Icons.headphone-off : Icons.headphones;
label: Bridge.output-muted ? @tr("Sound off") : @tr("Sound on");
checked: Bridge.output-muted;
danger: true;
size: 32px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
}
if Bridge.streams-available && Bridge.can-share: IconButton {
icon: Icons.monitor-up;
label: Bridge.share-state == "live" ? @tr("Sharing") : @tr("Share screen");
checked: Bridge.share-state == "live";
size: 32px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Nav.open-share(); }
}
IconButton {
icon: Icons.layout-grid;
label: @tr("Voice channel");
checked: Nav.voice-grid;
size: 32px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Nav.voice-grid = !Nav.voice-grid; }
}
IconButton {
icon: Icons.phone-off;
label: @tr("Disconnect");
size: 32px;
icon-size: Theme.icon-sm;
tint: Theme.danger;
y: (parent.height - self.height) / 2;
clicked => { Bridge.disconnect-voice(); }
}
}
}
// The emoji under a message; clicking one adds or removes ours.
component Reactions inherits HorizontalLayout {
in property <int> key;
in property <[ReactionItem]> model;
spacing: Theme.space-2;
alignment: start;
for reaction in root.model: Rectangle {
width: pill.preferred-width + 16px;
height: 24px;
border-radius: Theme.radius-pill;
background: reaction.me ? Theme.accent-soft : Theme.surface-2;
border-width: 1px;
border-color: reaction.me ? Theme.accent : Theme.border;
accessible-role: AccessibleRole.button;
accessible-label: @tr("{} reacted {} times", reaction.text, reaction.count);
accessible-checkable: true;
accessible-checked: reaction.me;
accessible-action-default => { Bridge.react(root.key, reaction.text); }
TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => { Bridge.react(root.key, reaction.text); }
}
pill := HorizontalLayout {
spacing: Theme.space-2;
alignment: center;
if reaction.key != "": Image {
width: 15px;
height: 15px;
source: Images.emoji(reaction.key);
y: (parent.height - self.height) / 2;
}
if reaction.key == "": Text {
text: reaction.text;
font-size: Theme.font-sm;
vertical-alignment: center;
}
Text {
text: reaction.count;
color: reaction.me ? Theme.accent-text : Theme.text-secondary;
font-size: Theme.font-xs;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
}
}
}
}
// A file a message links: name, size or progress, and a download button.
component FileCard inherits Rectangle {
in property <int> key;
in property <FileItem> file;
height: 56px;
border-radius: Theme.radius-md;
background: Theme.surface-2;
border-width: 1px;
border-color: file.state == "failed" ? Theme.danger : Theme.border;
accessible-role: AccessibleRole.groupbox;
accessible-label: file.name;
HorizontalLayout {
padding: Theme.space-3;
spacing: Theme.space-3;
Rectangle {
width: 34px;
height: 34px;
y: (parent.height - self.height) / 2;
border-radius: Theme.radius-sm;
background: Theme.accent-soft;
Icon {
source: file.picture ? Icons.image : Icons.file-text;
size: Theme.icon-md;
tint: Theme.accent-text;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 2px;
Text {
text: file.name;
color: Theme.text;
font-weight: Theme.weight-medium;
overflow: elide;
}
Text {
text: file.detail;
color: file.state == "failed" ? Theme.danger : Theme.text-muted;
font-size: Theme.font-xs;
overflow: elide;
}
if file.state == "running": Rectangle {
height: 3px;
border-radius: 1.5px;
background: Theme.surface-4;
Rectangle {
x: 0;
width: parent.width * file.progress;
height: parent.height;
border-radius: parent.border-radius;
background: Theme.accent;
}
}
}
if file.state != "running": IconButton {
icon: file.state == "done" ? Icons.folder-open : Icons.download;
label: file.state == "done" ? @tr("Downloaded") : @tr("Download {}", file.name);
y: (parent.height - self.height) / 2;
clicked => { Bridge.download-file(root.key, file.index); }
}
if file.state == "running": Spinner {
size: 18px;
y: (parent.height - self.height) / 2;
}
}
}
// Quick reactions, pin and "start a topic" on a hovered message.
component MessageActions inherits Rectangle {
in property <int> key;
in property <bool> pinned;
width: row.preferred-width;
height: 30px;
border-radius: Theme.radius-md;
background: Theme.surface-3;
border-width: 1px;
border-color: Theme.border-strong;
row := HorizontalLayout {
padding-left: 2px;
padding-right: 2px;
spacing: 0px;
if Bridge.has-reactions: HorizontalLayout {
spacing: 0px;
for quick in ["1f44d", "2764", "1f389", "1f602", "1f440"]: Rectangle {
width: 26px;
accessible-role: AccessibleRole.button;
accessible-label: @tr("React");
accessible-action-default => { Bridge.react(root.key, Images.emoji-text(quick)); }
Image {
width: 16px;
height: 16px;
source: Images.emoji(quick);
}
TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => { Bridge.react(root.key, Images.emoji-text(quick)); }
}
}
}
if Bridge.has-reactions: IconButton {
icon: Icons.smile-plus;
label: @tr("More emoji");
size: 26px;
icon-size: Theme.icon-sm;
clicked => {
Nav.react-key = root.key;
Nav.emoji-open = true;
}
}
if Bridge.has-pins: IconButton {
icon: Icons.pin;
label: root.pinned ? @tr("Unpin") : @tr("Pin");
checked: root.pinned;
size: 26px;
icon-size: Theme.icon-sm;
clicked => { Bridge.pin(root.key, !root.pinned); }
}
if Bridge.has-topics: IconButton {
icon: Icons.messages-square;
label: @tr("Start a topic");
size: 26px;
icon-size: Theme.icon-sm;
clicked => { Nav.start-topic(root.key); }
}
}
}
// One message; `continued` lines (same author just before) omit the header.
component MessageRow inherits Rectangle {
export component MessageRow inherits Rectangle {
in property <ChatLine> line;
// The pins and topic lists show messages without their actions.
in property <bool> actions: true;
property <length> avatar: 40px;
min-height: body.preferred-height;
background: line.marked ? Theme.accent-soft : hover.has-hover ? Theme.surface-2.transparentize(0.6) : transparent;
accessible-role: AccessibleRole.list-item;
accessible-label: line.author + ": " + line.text;
accessible-description: line.time;
hover := TouchArea {
// Let clicks through to the buttons inside.
mouse-cursor: MouseCursor.default;
}
body := HorizontalLayout {
padding-left: Theme.space-6;
padding-right: Theme.space-6;
@@ -78,6 +374,7 @@ component MessageRow inherits Rectangle {
size: root.avatar;
initials: line.initials;
tint: line.tint;
image: line.avatar;
label: line.author;
}
}
@@ -106,16 +403,179 @@ component MessageRow inherits Rectangle {
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
}
if line.pinned: Chip {
text: @tr("pinned");
icon: Icons.pin;
tint: Theme.warning;
y: (parent.height - self.height) / 2;
}
if line.topic != "": Chip {
text: line.topic;
icon: Icons.messages-square;
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
}
}
if !line.rich: Text {
if line.blocked: Text {
text: @tr("Message from a blocked contact.");
color: Theme.text-disabled;
font-size: Theme.font-sm;
font-italic: true;
}
if !line.blocked && !line.rich && line.text != "": Text {
text: line.text;
color: Theme.text;
wrap: word-wrap;
}
if line.rich: RichText {
if !line.blocked && line.rich: RichText {
runs: line.runs;
emoji-size: line.jumbo ? 44px : Theme.font-body * 1.4;
}
if line.files.length > 0 && !line.blocked: VerticalLayout {
padding-top: Theme.space-2;
padding-bottom: Theme.space-1;
spacing: Theme.space-2;
for file in line.files: FileCard {
key: line.key;
file: file;
max-width: 420px;
}
}
if line.reactions.length > 0: VerticalLayout {
padding-top: Theme.space-2;
padding-bottom: Theme.space-1;
Reactions {
key: line.key;
model: line.reactions;
}
}
}
}
if root.actions && line.remote && hover.has-hover: MessageActions {
x: parent.width - self.width - Theme.space-6;
y: -12px;
key: line.key;
pinned: line.pinned;
}
}
// The messages of the current chat (or of an open topic).
component MessageList inherits VerticalLayout {
in property <[ChatLine]> model;
in property <bool> older;
if Bridge.local-history: Rectangle {
height: 30px;
background: Theme.warning-soft;
HorizontalLayout {
padding-left: Theme.space-6;
spacing: Theme.space-2;
Icon {
source: Icons.hard-drive;
size: 14px;
tint: Theme.warning;
y: (parent.height - self.height) / 2;
}
Text {
text: @tr("Only messages seen by this device.");
color: Theme.warning;
font-size: Theme.font-xs;
vertical-alignment: center;
}
}
}
if root.older && Bridge.more-history: Rectangle {
height: 40px;
HorizontalLayout {
alignment: center;
Button {
small: true;
icon: Icons.chevron-up;
text: Bridge.loading-history ? @tr("Loading…") : @tr("Older messages");
enabled: !Bridge.loading-history;
y: (parent.height - self.height) / 2;
clicked => { Bridge.load-older(); }
}
}
}
ListView {
vertical-stretch: 1;
accessible-label: @tr("Messages");
for line in root.model: MessageRow {
line: line;
}
}
}
// The composer: emoji, attachment and the text field.
component Composer inherits HorizontalLayout {
in property <string> placeholder;
in property <bool> topic;
padding: Theme.space-4;
padding-left: Theme.space-5;
padding-right: Theme.space-5;
spacing: Theme.space-3;
Rectangle {
horizontal-stretch: 1;
min-height: 48px;
border-radius: Theme.radius-lg;
background: Theme.surface-2;
border-width: 1px;
border-color: input.has-focus ? Theme.accent : Theme.border;
HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-2;
spacing: Theme.space-2;
IconButton {
icon: Icons.paperclip;
label: @tr("Attach a file");
y: (parent.height - self.height) / 2;
clicked => { Bridge.attach-file(); }
}
input := TextField {
text <=> Nav.draft;
bare: true;
placeholder: root.placeholder;
label: @tr("Message");
accepted(text) => {
if text != "" {
if root.topic {
Bridge.send-topic-message(text);
} else {
Bridge.send-message(text);
}
self.clear();
}
}
}
IconButton {
icon: Icons.smile;
label: @tr("Emoji");
checked: Nav.emoji-open;
y: (parent.height - self.height) / 2;
clicked => {
Nav.react-key = 0;
Nav.emoji-open = !Nav.emoji-open;
}
}
IconButton {
icon: Icons.send;
label: @tr("Send");
round: true;
enabled: input.text != "";
tint: input.text != "" ? Theme.on-accent : Theme.text-muted;
filled: input.text != "";
y: (parent.height - self.height) / 2;
clicked => {
if input.text != "" {
if root.topic {
Bridge.send-topic-message(input.text);
} else {
Bridge.send-message(input.text);
}
input.clear();
}
}
}
}
}
}
@@ -139,6 +599,20 @@ export component ChatView inherits VerticalLayout {
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
}
if Bridge.has-pins: IconButton {
icon: Icons.pin;
label: @tr("Pinned messages");
checked: Nav.pins-open;
y: (parent.height - self.height) / 2;
clicked => { Nav.show-pins(!Nav.pins-open); }
}
if Bridge.has-topics: IconButton {
icon: Icons.messages-square;
label: @tr("Topics");
checked: Nav.topics-open;
y: (parent.height - self.height) / 2;
clicked => { Nav.show-topics(!Nav.topics-open); }
}
if Bridge.viewer-open == false && Bridge.streams.length > 0: Button {
small: true;
icon: Icons.monitor-up;
@@ -207,65 +681,51 @@ export component ChatView inherits VerticalLayout {
}
}
}
messages := ListView {
vertical-stretch: 1;
accessible-label: @tr("Messages");
for line in Bridge.messages: MessageRow {
line: line;
}
}
// Composer.
HorizontalLayout {
padding: Theme.space-4;
padding-left: Theme.space-5;
padding-right: Theme.space-5;
spacing: Theme.space-3;
composer := Rectangle {
horizontal-stretch: 1;
min-height: 48px;
border-radius: Theme.radius-lg;
background: Theme.surface-2;
border-width: 1px;
border-color: input.has-focus ? Theme.accent : Theme.border;
HorizontalLayout {
padding-left: Theme.space-5;
padding-right: Theme.space-2;
spacing: Theme.space-2;
input := TextField {
text <=> Nav.draft;
bare: true;
placeholder: root.tab-title != "" ? @tr("Message {}", root.tab-title) : @tr("Message");
label: @tr("Message");
accepted(text) => {
if text != "" {
Bridge.send-message(text);
self.clear();
}
}
}
IconButton {
icon: Icons.smile;
label: @tr("Emoji");
checked: Nav.emoji-open;
y: (parent.height - self.height) / 2;
clicked => { Nav.emoji-open = !Nav.emoji-open; }
}
IconButton {
icon: Icons.send;
label: @tr("Send");
round: true;
enabled: input.text != "";
tint: input.text != "" ? Theme.on-accent : Theme.text-muted;
filled: input.text != "";
y: (parent.height - self.height) / 2;
clicked => {
if input.text != "" {
Bridge.send-message(input.text);
input.clear();
}
}
}
if Bridge.voice-connected || Bridge.voice-connecting: VoiceBar { }
// The open topic replaces the chat.
if Bridge.current-topic >= 0: Rectangle {
height: 44px;
background: Theme.surface-2.transparentize(0.4);
HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-4;
spacing: Theme.space-3;
IconButton {
icon: Icons.arrow-left;
label: @tr("Back to the chat");
size: 28px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Bridge.open-topic(-1); }
}
Icon {
source: Icons.messages-square;
size: Theme.icon-sm;
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
}
Text {
text: Bridge.topic-title;
color: Theme.text;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
}
}
if Bridge.current-topic >= 0: MessageList {
vertical-stretch: 1;
model: Bridge.topic-messages;
}
if Bridge.current-topic < 0: MessageList {
vertical-stretch: 1;
model: Bridge.messages;
older: true;
}
Composer {
topic: Bridge.current-topic >= 0;
placeholder: Bridge.current-topic >= 0 ? @tr("Reply in {}", Bridge.topic-title)
: root.tab-title != "" ? @tr("Message {}", root.tab-title) : @tr("Message");
}
}
+290
View File
@@ -0,0 +1,290 @@
// Drawers that slide over the chat: the pinned messages and the topics
// (threads). Both need a gateway; the chat header hides their buttons when
// the gateway does not offer them.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, TopicItem } from "../bridge.slint";
import { Nav } from "../nav.slint";
import { Icon, IconButton, Button, ButtonKind, TextField, Spinner, Modal, ListView } from "../components/index.slint";
import { MessageRow } from "chat.slint";
// The frame both drawers share: a title bar and the content (@children).
component Drawer inherits Rectangle {
in property <string> title;
in property <image> icon;
in property <int> count;
callback closed();
background: Theme.surface;
border-width: 1px;
border-color: Theme.border-strong;
border-radius: Theme.radius-lg;
clip: true;
accessible-role: AccessibleRole.groupbox;
accessible-label: title;
VerticalLayout {
Rectangle {
height: 52px;
background: Theme.surface-2;
Rectangle {
y: parent.height - 1px;
height: 1px;
background: Theme.border;
}
HorizontalLayout {
padding-left: Theme.space-5;
padding-right: Theme.space-3;
spacing: Theme.space-3;
Icon {
source: root.icon;
size: Theme.icon-md;
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
}
Text {
text: root.count > 0 ? root.title + " — " + root.count : root.title;
color: Theme.text;
font-size: Theme.font-md;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
IconButton {
icon: Icons.x;
label: @tr("Close");
size: 28px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { root.closed(); }
}
}
}
@children
}
}
// The pinned messages of the current chat: jump to one or unpin it.
export component PinsDrawer inherits Drawer {
title: @tr("Pinned");
icon: Icons.pin;
count: Bridge.pins.length;
closed => { Nav.pins-open = false; }
if Bridge.pins-loading: HorizontalLayout {
padding: Theme.space-6;
alignment: center;
Spinner { size: 20px; }
}
if !Bridge.pins-loading && Bridge.pins.length == 0: VerticalLayout {
padding: Theme.space-6;
spacing: Theme.space-2;
Text {
text: @tr("Nothing pinned yet.");
color: Theme.text-secondary;
font-weight: Theme.weight-medium;
horizontal-alignment: center;
}
Text {
text: @tr("Hover a message and press the pin.");
color: Theme.text-muted;
font-size: Theme.font-sm;
horizontal-alignment: center;
wrap: word-wrap;
}
}
ListView {
vertical-stretch: 1;
accessible-label: @tr("Pinned messages");
for pin in Bridge.pins: Rectangle {
min-height: entry.preferred-height;
entry := VerticalLayout {
padding-bottom: Theme.space-3;
MessageRow {
line: pin.line;
actions: false;
}
HorizontalLayout {
padding-left: 78px;
padding-right: Theme.space-5;
spacing: Theme.space-2;
Text {
text: pin.by;
color: Theme.text-muted;
font-size: Theme.font-xs;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
Button {
small: true;
icon: Icons.arrow-right;
text: @tr("Jump");
clicked => {
Bridge.jump-to-pin(pin.line.key);
Nav.pins-open = false;
}
}
Button {
small: true;
kind: ButtonKind.danger;
icon: Icons.pin;
text: @tr("Unpin");
clicked => { Bridge.pin(pin.line.key, false); }
}
}
Rectangle {
height: 1px;
background: Theme.border;
}
}
}
}
}
component TopicRow inherits Rectangle {
in property <TopicItem> topic;
height: 62px;
border-radius: Theme.radius-md;
background: Bridge.current-topic == topic.id ? Theme.accent-soft : area.has-hover ? Theme.surface-3 : transparent;
accessible-role: AccessibleRole.list-item;
accessible-label: topic.title;
accessible-description: topic.detail;
accessible-action-default => { Bridge.open-topic(topic.id); }
area := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => {
Bridge.open-topic(topic.id);
Nav.topics-open = false;
}
}
HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-3;
Rectangle {
width: 34px;
height: 34px;
y: (parent.height - self.height) / 2;
border-radius: Theme.radius-sm;
background: Theme.surface-3;
Icon {
source: topic.archived ? Icons.bookmark : Icons.messages-square;
size: Theme.icon-sm;
tint: topic.archived ? Theme.text-muted : Theme.accent-text;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 2px;
Text {
text: topic.title;
color: Theme.text;
font-weight: Theme.weight-medium;
overflow: elide;
}
Text {
text: topic.detail;
color: Theme.text-muted;
font-size: Theme.font-xs;
overflow: elide;
}
}
Icon {
source: Icons.chevron-right;
size: Theme.icon-sm;
tint: Theme.text-muted;
y: (parent.height - self.height) / 2;
}
}
}
// The topics (threads) of the current chat.
export component TopicsDrawer inherits Drawer {
title: @tr("Topics");
icon: Icons.messages-square;
count: Bridge.topics.length;
closed => { Nav.topics-open = false; }
if Bridge.topics-loading: HorizontalLayout {
padding: Theme.space-6;
alignment: center;
Spinner { size: 20px; }
}
if !Bridge.topics-loading && Bridge.topics.length == 0: VerticalLayout {
padding: Theme.space-6;
spacing: Theme.space-2;
Text {
text: @tr("No topics yet.");
color: Theme.text-secondary;
font-weight: Theme.weight-medium;
horizontal-alignment: center;
}
Text {
text: @tr("Start one from a message, or below.");
color: Theme.text-muted;
font-size: Theme.font-sm;
horizontal-alignment: center;
wrap: word-wrap;
}
}
ListView {
vertical-stretch: 1;
accessible-label: @tr("Topics");
for topic in Bridge.topics: TopicRow {
topic: topic;
}
}
HorizontalLayout {
padding: Theme.space-3;
Button {
horizontal-stretch: 1;
icon: Icons.plus;
text: @tr("New topic");
clicked => { Nav.start-topic(-1); }
}
}
}
// Asking for a topic's title (from a message, or standalone).
export component TopicDialog inherits Modal {
title: @tr("Start a topic");
subtitle: Nav.topic-form-key > 0 ? @tr("From the chosen message.") : @tr("A new thread in this chat.");
icon: Icons.messages-square;
card-width: 460px;
card-height: 260px;
callback done();
dismissed => { root.done(); }
VerticalLayout {
spacing: Theme.space-4;
field := TextField {
text <=> Nav.topic-form-title;
placeholder: @tr("What is it about?");
label: @tr("Title");
accepted(text) => {
if text != "" {
Bridge.create-topic(Nav.topic-form-key, text);
root.done();
}
}
}
Rectangle { vertical-stretch: 1; }
HorizontalLayout {
spacing: Theme.space-3;
alignment: end;
Button {
text: @tr("Cancel");
clicked => { root.done(); }
}
Button {
kind: ButtonKind.primary;
icon: Icons.check;
text: @tr("Create");
enabled: field.text != "";
clicked => {
Bridge.create-topic(Nav.topic-form-key, field.text);
root.done();
}
}
}
}
}
+571
View File
@@ -0,0 +1,571 @@
// The members panel: who is in our voice channel, grouped by server group,
// with a card for one person; and the voice channel as a grid of tiles.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, MemberItem } from "../bridge.slint";
import { Nav } from "../nav.slint";
import { Icon, IconButton, Button, ButtonKind, Avatar, Status, LiveBadge, Chip, Divider, Slider, SpeakingBars, Tooltip, ListView } from "../components/index.slint";
// Crown, priority speaker, channel commander, recording.
component MemberBadges inherits HorizontalLayout {
in property <MemberItem> member;
in property <length> size: 14px;
spacing: 3px;
if member.admin: Icon {
source: Icons.crown;
size: root.size;
tint: Theme.gold;
accessible-role: AccessibleRole.image;
accessible-label: @tr("server admin");
}
if member.priority: Icon {
source: Icons.star;
size: root.size;
tint: Theme.accent-text;
accessible-role: AccessibleRole.image;
accessible-label: @tr("priority speaker");
}
if member.commander: Icon {
source: Icons.flag;
size: root.size;
tint: Theme.info;
accessible-role: AccessibleRole.image;
accessible-label: @tr("channel commander");
}
if member.recording: Icon {
source: Icons.record;
size: root.size;
tint: Theme.danger;
accessible-role: AccessibleRole.image;
accessible-label: @tr("recording");
}
}
// The header above the first member of a server group.
export component GroupHeader inherits HorizontalLayout {
in property <MemberItem> member;
padding-top: Theme.space-4;
padding-bottom: Theme.space-1;
padding-left: Theme.space-2;
spacing: Theme.space-2;
if member.group-icon.width > 0: Image {
width: 14px;
height: 14px;
source: member.group-icon;
y: (parent.height - self.height) / 2;
}
if member.group-icon.width == 0: Icon {
source: member.admin ? Icons.shield-check : Icons.users;
size: 13px;
tint: Theme.text-muted;
y: (parent.height - self.height) / 2;
}
Text {
text: member.group != "" ? member.group : @tr("Others");
color: Theme.text-muted;
font-size: Theme.font-xs;
font-weight: Theme.weight-semibold;
letter-spacing: 0.4px;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
}
// One person in the panel.
export component MemberRow inherits Rectangle {
in property <MemberItem> member;
height: 48px * Theme.font-scale;
border-radius: Theme.radius-md;
background: Bridge.member-card.open && Bridge.member-card.id == member.id ? Theme.accent-soft
: area.has-hover ? Theme.surface-3 : transparent;
accessible-role: AccessibleRole.list-item;
accessible-label: member.name;
accessible-description: member.status;
accessible-action-default => { Bridge.open-member(member.id); }
area := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => { Bridge.open-member(member.id); }
}
HorizontalLayout {
padding-left: Theme.space-2;
padding-right: Theme.space-2;
spacing: Theme.space-3;
VerticalLayout {
alignment: center;
Avatar {
size: 34px;
initials: member.initials;
tint: member.tint;
image: member.avatar;
speaking: member.talking;
crown: member.admin;
status: member.away ? Status.idle : member.sound-off ? Status.dnd : Status.online;
label: member.name;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
HorizontalLayout {
spacing: Theme.space-2;
Text {
text: member.name;
color: member.myself ? Theme.accent-text : Theme.name-text;
font-weight: Theme.weight-medium;
overflow: elide;
}
MemberBadges {
member: member;
y: (parent.height - self.height) / 2;
}
if member.streaming: VerticalLayout {
alignment: center;
LiveBadge { }
}
}
HorizontalLayout {
spacing: Theme.space-2;
Text {
text: member.status;
color: member.talking ? Theme.success : Theme.text-muted;
font-size: Theme.font-sm;
overflow: elide;
}
if member.talking: SpeakingBars {
width: 12px;
height: 12px;
y: (parent.height - self.height) / 2;
}
}
}
if member.talk-power > 0: Text {
text: member.talk-power;
color: Theme.text-muted;
font-size: Theme.font-xs;
vertical-alignment: center;
accessible-label: @tr("talk power");
}
if member.muted: Icon {
source: Icons.mic-off;
size: 16px;
tint: Theme.danger;
y: (parent.height - self.height) / 2;
}
if member.sound-off: Icon {
source: Icons.headphone-off;
size: 16px;
tint: Theme.danger;
y: (parent.height - self.height) / 2;
}
}
}
// Everything about one person, over the panel.
export component MemberCardPopup inherits Rectangle {
property <length> card-width: 300px;
width: root.card-width;
height: card.preferred-height;
background: Theme.surface-3;
border-radius: Theme.radius-lg;
border-width: 1px;
border-color: Theme.border-strong;
accessible-role: AccessibleRole.groupbox;
accessible-label: Bridge.member-card.name;
// Clicks inside stay inside.
TouchArea { }
card := VerticalLayout {
padding: Theme.space-4;
spacing: Theme.space-3;
HorizontalLayout {
spacing: Theme.space-3;
Avatar {
size: 52px;
initials: Bridge.member-card.initials;
tint: Bridge.member-card.tint;
image: Bridge.member-card.avatar;
label: Bridge.member-card.name;
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 2px;
Text {
text: Bridge.member-card.name;
color: Theme.text;
font-size: Theme.font-lg;
font-weight: Theme.weight-semibold;
overflow: elide;
}
Text {
text: Bridge.member-card.status;
color: Theme.text-muted;
font-size: Theme.font-sm;
overflow: elide;
}
}
IconButton {
icon: Icons.x;
label: @tr("Close");
size: 26px;
icon-size: Theme.icon-sm;
clicked => { Bridge.open-member(-1); }
}
}
if Bridge.member-card.description != "": Text {
text: Bridge.member-card.description;
color: Theme.text-secondary;
font-size: Theme.font-sm;
wrap: word-wrap;
}
if Bridge.member-card.groups.length > 0: VerticalLayout {
spacing: Theme.space-2;
Text {
text: @tr("Groups");
color: Theme.text-muted;
font-size: Theme.font-xs;
font-weight: Theme.weight-semibold;
}
for group in Bridge.member-card.groups: Text {
text: group;
color: Theme.text-secondary;
font-size: Theme.font-sm;
overflow: elide;
}
}
HorizontalLayout {
spacing: Theme.space-2;
alignment: start;
if Bridge.member-card.talk-power > 0: Chip {
text: @tr("talk power {}", Bridge.member-card.talk-power);
icon: Icons.mic;
}
if Bridge.member-card.country != "": Chip {
text: Bridge.member-card.country;
icon: Icons.globe;
}
}
Divider { }
// Local playback of this person.
VerticalLayout {
spacing: Theme.space-2;
HorizontalLayout {
spacing: Theme.space-2;
Text {
text: @tr("Volume");
color: Theme.text-secondary;
font-size: Theme.font-sm;
vertical-alignment: center;
horizontal-stretch: 1;
}
Text {
text: @tr("{}%", round(Bridge.member-card.volume));
color: Theme.text-muted;
font-size: Theme.font-xs;
vertical-alignment: center;
}
}
HorizontalLayout {
spacing: Theme.space-2;
IconButton {
icon: Bridge.member-card.muted ? Icons.volume-x : Icons.volume-2;
label: Bridge.member-card.muted ? @tr("Unmute for me") : @tr("Mute for me");
checked: Bridge.member-card.muted;
danger: true;
size: 30px;
icon-size: Theme.icon-sm;
enabled: Bridge.member-card.known;
clicked => { Bridge.member-action("mute"); }
}
Slider {
horizontal-stretch: 1;
minimum: 0;
maximum: 200;
step: 5;
value: Bridge.member-card.volume;
enabled: Bridge.member-card.known && !Bridge.member-card.muted;
label: @tr("Volume of {}", Bridge.member-card.name);
changed(v) => { Bridge.member-volume(v); }
}
}
}
Divider { }
HorizontalLayout {
spacing: Theme.space-2;
Button {
horizontal-stretch: 1;
small: true;
icon: Icons.message-square;
text: @tr("Message");
enabled: Bridge.member-card.known;
clicked => { Bridge.member-action("message"); }
}
Button {
horizontal-stretch: 1;
small: true;
icon: Icons.hand;
text: @tr("Poke");
clicked => { Bridge.member-action("poke"); }
}
}
HorizontalLayout {
spacing: Theme.space-2;
Button {
horizontal-stretch: 1;
small: true;
icon: Icons.user-plus;
text: Bridge.member-card.friend ? @tr("Friend") : @tr("Add friend");
checked: Bridge.member-card.friend;
enabled: Bridge.member-card.known;
clicked => { Bridge.member-action("friend"); }
}
Button {
horizontal-stretch: 1;
small: true;
kind: Bridge.member-card.blocked ? ButtonKind.danger : ButtonKind.secondary;
icon: Icons.shield;
text: Bridge.member-card.blocked ? @tr("Blocked") : @tr("Block");
enabled: Bridge.member-card.known;
clicked => { Bridge.member-action("blocked"); }
}
}
}
}
// The members of our channel, grouped by server group.
export component MembersList inherits VerticalLayout {
if Bridge.members.length == 0: Text {
text: @tr("Join a channel with voice to see who is there.");
color: Theme.text-muted;
font-size: Theme.font-sm;
wrap: word-wrap;
}
ListView {
vertical-stretch: 1;
accessible-role: AccessibleRole.list;
accessible-label: @tr("Members");
for member in Bridge.members: VerticalLayout {
if member.first-in-group: GroupHeader {
member: member;
}
MemberRow {
member: member;
}
}
}
}
// One person as a tile of the voice grid.
component VoiceTile inherits Rectangle {
in property <MemberItem> member;
min-height: 150px;
border-radius: Theme.radius-lg;
background: Theme.surface-2;
border-width: member.talking ? 2px : 1px;
border-color: member.talking ? Theme.success : Theme.border;
accessible-role: AccessibleRole.list-item;
accessible-label: member.name;
accessible-description: member.status;
accessible-action-default => { Bridge.open-member(member.id); }
TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => { Bridge.open-member(member.id); }
}
VerticalLayout {
padding: Theme.space-4;
spacing: Theme.space-3;
alignment: center;
HorizontalLayout {
alignment: center;
Avatar {
size: 64px;
initials: member.initials;
tint: member.tint;
image: member.avatar;
speaking: member.talking;
crown: member.admin;
label: member.name;
}
}
HorizontalLayout {
alignment: center;
spacing: Theme.space-2;
Text {
text: member.name;
color: member.myself ? Theme.accent-text : Theme.text;
font-weight: Theme.weight-semibold;
overflow: elide;
}
MemberBadges {
member: member;
y: (parent.height - self.height) / 2;
}
}
HorizontalLayout {
alignment: center;
spacing: Theme.space-2;
if member.muted: Icon {
source: Icons.mic-off;
size: 15px;
tint: Theme.danger;
}
if member.sound-off: Icon {
source: Icons.headphone-off;
size: 15px;
tint: Theme.danger;
}
if member.streaming: LiveBadge { }
if !member.muted && !member.sound-off && !member.streaming: Text {
text: member.status;
color: member.talking ? Theme.success : Theme.text-muted;
font-size: Theme.font-sm;
overflow: elide;
}
}
}
}
// A stream in the channel as a tile next to the people.
component StreamTile inherits Rectangle {
in property <string> name;
in property <string> streamer;
in property <string> id;
in property <bool> watching;
min-height: 150px;
border-radius: Theme.radius-lg;
clip: true;
background: @linear-gradient(135deg, #2b1f6e 0%, #0f2a66 100%);
border-width: root.watching ? 2px : 1px;
border-color: root.watching ? Theme.accent : Theme.border;
accessible-role: AccessibleRole.groupbox;
accessible-label: root.name;
LiveBadge {
x: Theme.space-3;
y: Theme.space-3;
large: true;
}
VerticalLayout {
padding: Theme.space-4;
spacing: Theme.space-2;
alignment: center;
Icon {
source: Icons.monitor-up;
size: 34px;
tint: #ffffffd0;
}
Text {
text: root.name != "" ? root.name : @tr("Untitled stream");
color: #ffffff;
font-weight: Theme.weight-semibold;
horizontal-alignment: center;
overflow: elide;
}
Text {
text: @tr("by {}", root.streamer);
color: #ffffffb0;
font-size: Theme.font-sm;
horizontal-alignment: center;
overflow: elide;
}
if root.id != "": HorizontalLayout {
padding-top: Theme.space-2;
alignment: center;
Button {
small: true;
kind: root.watching ? ButtonKind.secondary : ButtonKind.primary;
icon: root.watching ? Icons.monitor : Icons.eye;
text: root.watching ? @tr("Show") : @tr("Watch");
clicked => {
if root.watching {
Bridge.show-viewer();
} else {
Bridge.watch-stream(root.id);
}
}
}
}
}
}
// The voice channel as tiles: the people in it and the streams there.
export component VoiceGrid inherits VerticalLayout {
// How many tiles fit; the grid wraps into rows of that many.
property <int> columns: max(1, min(4, floor((root.width - 32px) / 250px)));
property <int> total: Bridge.members.length + Bridge.streams.length;
property <int> rows: ceil(total / columns);
Rectangle {
height: 56px;
HorizontalLayout {
padding-left: Theme.space-6;
padding-right: Theme.space-4;
spacing: Theme.space-3;
Icon {
source: Icons.volume-2;
size: 22px;
tint: Theme.text-secondary;
y: (parent.height - self.height) / 2;
}
Text {
text: Bridge.own-channel != "" ? Bridge.own-channel : @tr("Voice");
color: Theme.text;
font-size: Theme.font-xl;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
}
Text {
text: @tr("{} in voice", Bridge.members.length);
color: Theme.text-muted;
font-size: Theme.font-sm;
vertical-alignment: center;
horizontal-stretch: 1;
}
Button {
small: true;
icon: Icons.message-square;
text: @tr("Chat");
y: (parent.height - self.height) / 2;
clicked => { Nav.voice-grid = false; }
}
}
Rectangle {
y: parent.height - 1px;
height: 1px;
background: Theme.border;
}
}
if root.total == 0: VerticalLayout {
padding: Theme.space-8;
alignment: center;
Text {
text: @tr("Nobody is in this channel.");
color: Theme.text-muted;
horizontal-alignment: center;
}
}
ListView {
vertical-stretch: 1;
accessible-label: @tr("Voice channel");
for row in root.rows: HorizontalLayout {
padding: Theme.space-3;
padding-left: Theme.space-5;
padding-right: Theme.space-5;
spacing: Theme.space-4;
for column in root.columns: Rectangle {
property <int> index: row * root.columns + column;
horizontal-stretch: 1;
if index < Bridge.members.length: VoiceTile {
width: parent.width;
member: Bridge.members[index];
}
if index >= Bridge.members.length && index < root.total: StreamTile {
width: parent.width;
name: Bridge.streams[index - Bridge.members.length].name;
streamer: Bridge.streams[index - Bridge.members.length].streamer;
id: Bridge.streams[index - Bridge.members.length].id;
watching: Bridge.streams[index - Bridge.members.length].watching;
}
}
}
}
}
+190 -105
View File
@@ -5,7 +5,9 @@ import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, StreamItem, MemberItem } from "../bridge.slint";
import { Nav } from "../nav.slint";
import { Icon, Button, ButtonKind, IconButton, Avatar, Status, LiveBadge, Chip, SectionHeader, SpeakingBars, Slider, Spinner, ListView, ScrollView } from "../components/index.slint";
import { Icon, Button, ButtonKind, IconButton, Avatar, Status, LiveBadge, Chip, Select, SectionHeader, SpeakingBars, Slider, Spinner, TextField, ListView, ScrollView } from "../components/index.slint";
import { MemberRow, GroupHeader } from "members.slint";
import { MessageRow } from "chat.slint";
// A stream card: the streamer, the title, watch / show / leave.
component StreamCard inherits Rectangle {
@@ -88,82 +90,6 @@ component StreamCard inherits Rectangle {
}
}
// A person in our channel.
component MemberRow inherits Rectangle {
in property <MemberItem> member;
height: 48px * Theme.font-scale;
border-radius: Theme.radius-md;
background: area.has-hover ? Theme.surface-3 : transparent;
accessible-role: AccessibleRole.list-item;
accessible-label: member.name;
accessible-description: member.status;
accessible-action-default => { Nav.open-client(member.id); }
area := TouchArea {
enabled: !member.myself;
mouse-cursor: MouseCursor.pointer;
clicked => { Nav.open-client(member.id); }
}
HorizontalLayout {
padding-left: Theme.space-2;
padding-right: Theme.space-2;
spacing: Theme.space-3;
VerticalLayout {
alignment: center;
Avatar {
size: 34px;
initials: member.initials;
tint: member.tint;
speaking: member.talking;
status: member.away ? Status.idle : member.sound-off ? Status.dnd : Status.online;
label: member.name;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
HorizontalLayout {
spacing: Theme.space-2;
Text {
text: member.name;
color: member.myself ? Theme.accent-text : Theme.name-text;
font-weight: Theme.weight-medium;
overflow: elide;
}
if member.streaming: VerticalLayout {
alignment: center;
LiveBadge { }
}
}
HorizontalLayout {
spacing: Theme.space-2;
Text {
text: member.status;
color: member.talking ? Theme.success : Theme.text-muted;
font-size: Theme.font-sm;
overflow: elide;
}
if member.talking: SpeakingBars {
width: 12px;
height: 12px;
y: (parent.height - self.height) / 2;
}
}
}
if member.muted: Icon {
source: Icons.mic-off;
size: 16px;
tint: Theme.danger;
y: (parent.height - self.height) / 2;
}
if member.sound-off: Icon {
source: Icons.headphone-off;
size: 16px;
tint: Theme.danger;
y: (parent.height - self.height) / 2;
}
}
}
// The right panel of a server: who is in our channel, the streams there,
// and requests to watch ours.
export component StreamsPanel inherits VerticalLayout {
@@ -199,8 +125,13 @@ export component StreamsPanel inherits VerticalLayout {
width: sv.visible-width;
spacing: Theme.space-2;
alignment: start;
for member in Bridge.members: MemberRow {
member: member;
for member in Bridge.members: VerticalLayout {
if member.first-in-group: GroupHeader {
member: member;
}
MemberRow {
member: member;
}
}
if Bridge.streams-available: VerticalLayout {
padding-top: Theme.space-4;
@@ -258,11 +189,9 @@ export component StreamsPanel inherits VerticalLayout {
}
}
// The stream we watch: title bar, picture, player controls.
export component StreamViewer inherits Rectangle {
// The player: title bar, picture and controls (no chat).
component StreamPlayer inherits Rectangle {
background: Theme.dark ? #03060f : #0b1330;
accessible-role: AccessibleRole.groupbox;
accessible-label: @tr("Stream viewer");
VerticalLayout {
// Title bar.
Rectangle {
@@ -302,9 +231,45 @@ export component StreamViewer inherits Rectangle {
overflow: elide;
}
}
if !Bridge.viewer-ended: VerticalLayout {
// How long we have been watching, and how many others do.
if !Bridge.viewer-ended: HorizontalLayout {
spacing: Theme.space-3;
alignment: center;
LiveBadge { large: true; }
if Bridge.viewer-elapsed != "": HorizontalLayout {
spacing: Theme.space-2;
Icon {
source: Icons.clock;
size: 14px;
tint: Theme.text-muted;
y: (parent.height - self.height) / 2;
}
Text {
text: Bridge.viewer-elapsed;
color: Theme.text-secondary;
font-size: Theme.font-sm;
vertical-alignment: center;
}
}
if Bridge.viewer-count > 0: HorizontalLayout {
spacing: Theme.space-2;
Icon {
source: Icons.eye;
size: 14px;
tint: Theme.text-muted;
y: (parent.height - self.height) / 2;
}
Text {
text: Bridge.viewer-count;
color: Theme.text-secondary;
font-size: Theme.font-sm;
vertical-alignment: center;
accessible-label: @tr("viewers");
}
}
VerticalLayout {
alignment: center;
LiveBadge { large: true; }
}
}
}
}
@@ -345,13 +310,16 @@ export component StreamViewer inherits Rectangle {
padding-left: Theme.space-4;
padding-right: Theme.space-4;
spacing: Theme.space-3;
Icon {
source: Bridge.viewer-volume > 0 ? Icons.volume-2 : Icons.volume-x;
tint: Theme.text-secondary;
IconButton {
icon: Bridge.viewer-volume > 0 ? Icons.volume-2 : Icons.volume-x;
label: Bridge.viewer-volume > 0 ? @tr("Mute") : @tr("Unmute");
size: 30px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Bridge.set-stream-volume(Bridge.viewer-volume > 0 ? 0 : 100); }
}
Slider {
width: 140px;
width: 120px;
horizontal-stretch: 0;
y: (parent.height - self.height) / 2;
minimum: 0;
@@ -369,24 +337,33 @@ export component StreamViewer inherits Rectangle {
color: Theme.text-secondary;
font-size: Theme.font-sm;
}
if !Bridge.viewer-ended: HorizontalLayout {
spacing: Theme.space-2;
Rectangle {
width: 8px;
height: 8px;
y: (parent.height - self.height) / 2;
border-radius: 4px;
background: Theme.live;
}
Text {
text: @tr("LIVE");
color: Theme.text;
font-size: Theme.font-sm;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
}
// Simulcast layers the streamer offers; "Auto" follows the
// bandwidth estimate.
if Bridge.viewer-qualities.length > 1: Select {
width: 150px;
horizontal-stretch: 0;
y: (parent.height - self.height) / 2;
icon: Icons.sliders-horizontal;
label: @tr("Quality");
model: Bridge.viewer-qualities;
current-index <=> Bridge.viewer-quality;
enabled: !Bridge.viewer-ended;
selected(_) => { Bridge.set-stream-quality(Bridge.viewer-quality); }
}
if Bridge.viewer-quality == 0 && Bridge.viewer-quality-detail != "": Text {
text: Bridge.viewer-quality-detail;
color: Theme.text-muted;
font-size: Theme.font-xs;
vertical-alignment: center;
}
Rectangle { horizontal-stretch: 1; }
IconButton {
icon: Icons.external-link;
label: Bridge.viewer-popped ? @tr("Back to the window") : @tr("Pop out");
checked: Bridge.viewer-popped;
y: (parent.height - self.height) / 2;
clicked => { Bridge.viewer-popped = !Bridge.viewer-popped; }
}
IconButton {
icon: Bridge.viewer-fullscreen ? Icons.minimize-2 : Icons.maximize;
label: Bridge.viewer-fullscreen ? @tr("Exit full screen") : @tr("Full screen");
@@ -413,3 +390,111 @@ export component StreamViewer inherits Rectangle {
}
}
}
// The chat beside the player: the current chat's messages and a composer.
component StreamChat inherits Rectangle {
background: Theme.surface;
Rectangle {
x: 0;
width: 1px;
background: Theme.border;
}
VerticalLayout {
Rectangle {
height: 44px;
HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-3;
spacing: Theme.space-2;
Icon {
source: Icons.message-square;
size: Theme.icon-sm;
tint: Theme.text-secondary;
y: (parent.height - self.height) / 2;
}
Text {
text: Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].title : @tr("Chat");
color: Theme.text;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
}
Rectangle {
y: parent.height - 1px;
height: 1px;
background: Theme.border;
}
}
ListView {
vertical-stretch: 1;
accessible-label: @tr("Messages");
for line in Bridge.messages: MessageRow {
line: line;
actions: false;
}
}
HorizontalLayout {
padding: Theme.space-3;
Rectangle {
min-height: 40px;
border-radius: Theme.radius-lg;
background: Theme.surface-2;
border-width: 1px;
border-color: field.has-focus ? Theme.accent : Theme.border;
HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-2;
field := TextField {
text <=> Nav.draft;
bare: true;
placeholder: @tr("Message");
label: @tr("Message");
accepted(text) => {
if text != "" {
Bridge.send-message(text);
self.clear();
}
}
}
IconButton {
icon: Icons.send;
label: @tr("Send");
round: true;
enabled: field.text != "";
tint: field.text != "" ? Theme.on-accent : Theme.text-muted;
filled: field.text != "";
y: (parent.height - self.height) / 2;
clicked => {
if field.text != "" {
Bridge.send-message(field.text);
field.clear();
}
}
}
}
}
}
}
}
// The stream we watch: the player, with the chat beside it when there is
// room (and not in full screen).
export component StreamViewer inherits Rectangle {
background: Theme.dark ? #03060f : #0b1330;
// Reading our own width here would loop through the layout, so the
// phone breakpoint (a setting) decides.
property <bool> with-chat: !Bridge.viewer-fullscreen && !Nav.narrow;
accessible-role: AccessibleRole.groupbox;
accessible-label: @tr("Stream viewer");
HorizontalLayout {
StreamPlayer {
horizontal-stretch: 1;
}
if root.with-chat: StreamChat {
width: Nav.right-panel-width + 40px;
horizontal-stretch: 0;
}
}
}