Files
VoelinClient/crates/voelin-ui/ui/screens/drawers.slint
T
selikhovandClaude Opus 5.5 6dfd501560 voelin-ui: lay the server screens out as the design mockups do
The screens were built before the mockups were at hand and guessed at
their layout: a strip of voice controls over the chat, pins and topics
floating over the messages, the voice channel as a grid of tiles and a
members panel of our channel only. The mockups put them elsewhere.

- The members panel lists everyone on the server, "Members — N" with a
  search: those streaming (or, in the voice channel and while watching,
  the people in our channel) first, then each server group in the
  server's order, people elsewhere with the channel they are in, and
  moderator groups as a role next to the name.
- Pinned messages and topics take the members panel's place, as cards;
  topics can be searched and show when they were last active, and the
  chat header opens them with labelled buttons.
- The voice channel view is a header with Voice Settings and Leave, the
  people as large avatars with talking and muted marks, the streams as
  large cards (with the picture while we watch) and the channel's chat.
- The chat drops the extra voice strip (the sidebar has the controls);
  messages are larger, times read "Today at 10:14", reactions end with
  an add button, and the composer has a round attach button.
- Hold-to-talk shows only with push-to-talk.

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

377 lines
12 KiB
Plaintext

// The pinned messages and the topics (threads) of the current chat. They
// take the place of the members panel; both need a gateway, and 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, PinItem, TopicItem, Images } from "../bridge.slint";
import { Nav } from "../nav.slint";
import { Icon, IconButton, Button, ButtonKind, TextField, SearchBox, Avatar, RichText, Spinner, Modal, ListView } from "../components/index.slint";
import { Reactions } from "chat.slint";
// The title row both drawers share, above their content (@children).
component Drawer inherits VerticalLayout {
in property <string> title;
in property <image> icon;
callback closed();
padding-top: Theme.space-4;
spacing: Theme.space-3;
accessible-role: AccessibleRole.groupbox;
accessible-label: title;
HorizontalLayout {
padding-left: Theme.space-5;
padding-right: Theme.space-3;
spacing: Theme.space-3;
if root.icon.width > 0: Icon {
source: root.icon;
size: Theme.icon-md;
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
}
Text {
text: root.title;
color: Theme.text;
font-size: Theme.font-lg;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
IconButton {
icon: Icons.x;
label: @tr("Close");
size: 32px;
icon-size: Theme.icon-md;
y: (parent.height - self.height) / 2;
clicked => { root.closed(); }
}
}
@children
}
// A pinned message as a card: who and when, the pin (unpin), the text and
// its reactions. Clicking the card jumps to the message in the chat.
component PinCard inherits Rectangle {
in property <PinItem> pin;
min-height: body.preferred-height;
border-radius: Theme.radius-lg;
background: area.has-hover ? Theme.surface-3 : Theme.surface-2;
border-width: 1px;
border-color: Theme.border-strong;
accessible-role: AccessibleRole.list-item;
accessible-label: pin.line.author + ": " + pin.line.text;
accessible-description: pin.by;
accessible-action-default => {
Bridge.jump-to-pin(pin.line.key);
Nav.pins-open = false;
}
area := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => {
Bridge.jump-to-pin(pin.line.key);
Nav.pins-open = false;
}
}
body := VerticalLayout {
padding: Theme.space-4;
padding-right: Theme.space-3;
spacing: Theme.space-2;
HorizontalLayout {
spacing: Theme.space-3;
Avatar {
size: 28px;
initials: pin.line.initials;
tint: pin.line.tint;
image: pin.line.avatar;
label: pin.line.author;
y: (parent.height - self.height) / 2;
}
Text {
text: pin.line.author;
color: Theme.name-text;
font-size: Theme.font-md;
font-weight: Theme.weight-medium;
vertical-alignment: center;
overflow: elide;
}
Text {
text: pin.line.time;
color: Theme.text-muted;
font-size: Theme.font-sm;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
IconButton {
icon: Icons.pin;
label: @tr("Unpin");
tint: Theme.accent-text;
size: 28px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Bridge.pin(pin.line.key, false); }
}
}
if !pin.line.rich && pin.line.text != "": Text {
text: pin.line.text;
color: Theme.text;
wrap: word-wrap;
}
if pin.line.rich: RichText {
runs: pin.line.runs;
}
for file in pin.line.files: HorizontalLayout {
spacing: Theme.space-2;
Icon {
source: file.picture ? Icons.image : Icons.file-text;
size: Theme.icon-sm;
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
}
Text {
text: file.name;
color: Theme.accent-text;
font-size: Theme.font-sm;
vertical-alignment: center;
overflow: elide;
}
}
if pin.line.reactions.length > 0: VerticalLayout {
padding-top: Theme.space-2;
Reactions {
key: pin.line.key;
model: pin.line.reactions;
}
}
Text {
text: pin.by;
color: Theme.text-muted;
font-size: Theme.font-xs;
overflow: elide;
}
}
}
// The pinned messages of the current chat.
export component PinsDrawer inherits Drawer {
title: @tr("Pinned Messages");
icon: Icons.pin;
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: VerticalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
padding-bottom: Theme.space-3;
PinCard {
pin: pin;
}
}
}
}
// A topic: its icon, title, what is in it and when it was last active.
component TopicCard inherits Rectangle {
in property <TopicItem> topic;
min-height: body.preferred-height;
border-radius: Theme.radius-lg;
background: Bridge.current-topic == topic.id ? Theme.accent-soft : area.has-hover ? Theme.surface-3 : Theme.surface-2;
border-width: 1px;
border-color: Bridge.current-topic == topic.id ? Theme.accent : Theme.border-strong;
accessible-role: AccessibleRole.list-item;
accessible-label: topic.title;
accessible-description: topic.detail;
accessible-action-default => {
Bridge.open-topic(topic.id);
Nav.topics-open = false;
}
area := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => {
Bridge.open-topic(topic.id);
Nav.topics-open = false;
}
}
body := HorizontalLayout {
padding: Theme.space-4;
spacing: Theme.space-4;
VerticalLayout {
alignment: start;
Rectangle {
width: 40px;
height: 40px;
border-radius: Theme.radius-md;
background: Theme.surface-4;
Icon {
source: topic.archived ? Icons.bookmark : Icons.messages-square;
size: 22px;
tint: topic.archived ? Theme.text-muted : Theme.text-secondary;
}
}
}
VerticalLayout {
horizontal-stretch: 1;
spacing: Theme.space-1;
Text {
text: topic.title;
color: Theme.text;
font-size: Theme.font-md;
font-weight: Theme.weight-medium;
overflow: elide;
}
Text {
text: topic.detail;
color: Theme.text-secondary;
font-size: Theme.font-sm;
overflow: elide;
}
HorizontalLayout {
spacing: Theme.space-2;
padding-top: Theme.space-1;
Rectangle {
width: 7px;
height: 7px;
y: (parent.height - self.height) / 2;
border-radius: 3.5px;
background: topic.recent ? Theme.success : Theme.offline;
}
Text {
text: topic.activity;
color: Theme.text-muted;
font-size: Theme.font-sm;
overflow: elide;
}
}
}
}
}
// The topics (threads) of the current chat: search, open, create.
export component TopicsDrawer inherits Drawer {
title: @tr("Topics");
closed => { Nav.topics-open = false; }
HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
SearchBox {
height: 40px;
show-shortcut: false;
placeholder: @tr("Search topics…");
label: @tr("Search topics");
edited(text) => { Bridge.search-topics(text); }
}
}
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: VerticalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
padding-bottom: Theme.space-3;
TopicCard {
topic: topic;
}
}
}
HorizontalLayout {
padding: Theme.space-3;
padding-bottom: Theme.space-4;
Button {
horizontal-stretch: 1;
kind: ButtonKind.primary;
icon: Icons.plus;
text: @tr("Create 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();
}
}
}
}
}