feat(client): icon buttons, emoji picker, reactions and a redesigned voice room

- Replace every hand drawn symbol and unicode glyph with Lucide icons via
  Symbol, with tooltips on icon buttons (built-in Tooltip, which does not
  swallow clicks), a proper gear and a clear log-out button for leaving a
  server.
- Center text and controls vertically in channel rows, headers, the user
  panel and friend rows.
- Message actions: quick reactions, add reaction, reply, edit and delete as
  icons. The bar stays visible while the pointer is over its buttons.
- Emoji picker with categories and Russian and English search for the
  composer and for reactions. Reactions are shown under the message and
  toggle on click (ReactionAdd or ReactionRemove).
- Remove the keyboard hint under the composer, add a placeholder and a
  growing editor with emoji and send buttons.
- Voice room: participant cards with avatar and speaking ring, round icon
  controls with off states in red, accent gradient background.
- One AvatarView everywhere (including voice cards and members). The local
  user is listed as online in the member list.
- Real checkbox on the connect screen, theme overlay colour for the trust
  dialog, accent primary button.
- ui_smoke now renders screens in all four themes and checks the member
  status, the action bar and the picker with real pointer input.
This commit is contained in:
Loki 2026-10-25 10:26:02 +01:00
parent 4462ef4708
commit 220af2d6a4
Signed by: boba
GPG key ID: 253067914055423B
24 changed files with 1120 additions and 258 deletions

View file

@ -14,6 +14,16 @@ fn presence_label(status: &str) -> String {
})
}
/// Presence dot variant for the avatar.
fn presence_key(status: &str) -> &'static str {
match status.to_ascii_lowercase().as_str() {
"online" => "online",
"idle" | "away" => "idle",
"dnd" | "busy" => "dnd",
_ => "offline",
}
}
type MainWindow = crate::ui::slint::MainWindow;
type BookmarkItem = crate::ui::slint::BookmarkItem;
type ChannelItem = crate::ui::slint::ChannelItem;
@ -23,6 +33,7 @@ type MessageItem = crate::ui::slint::MessageItem;
type MemberItem = crate::ui::slint::MemberItem;
type FriendItem = crate::ui::slint::FriendItem;
type VoiceMemberItem = crate::ui::slint::VoiceMemberItem;
type ReactionItem = crate::ui::slint::ReactionItem;
fn replace_model<T: Clone + PartialEq + 'static>(
current: ModelRc<T>,
@ -34,6 +45,49 @@ fn replace_model<T: Clone + PartialEq + 'static>(
}
}
fn initials(name: &str) -> SharedString {
name.chars().take(2).collect::<String>().into()
}
/// Reaction chips of a message in a stable order, with the bundled emoji image when known.
fn reaction_items(m: &crate::ui::state::ChatMessage, own_user_id: &str) -> Vec<ReactionItem> {
let mut reactions: Vec<(&String, &Vec<String>)> = m
.reactions
.iter()
.filter(|(_, users)| !users.is_empty())
.collect();
reactions.sort_by(|a, b| b.1.len().cmp(&a.1.len()).then_with(|| a.0.cmp(b.0)));
reactions
.into_iter()
.map(|(emoji, users)| {
let image = crate::ui::emoji::image_for_glyph(emoji);
ReactionItem {
emoji: SharedString::from(emoji.as_str()),
has_image: image.is_some(),
image: image.unwrap_or_default(),
count: users.len().min(i32::MAX as usize) as i32,
mine: users.iter().any(|u| u == own_user_id),
}
})
.collect()
}
/// Field by field comparison; `ModelRc` fields (reactions) compare by identity otherwise and
/// would make every refresh look like a change.
fn same_message(a: &MessageItem, b: &MessageItem) -> bool {
a.message_id == b.message_id
&& a.sender_id == b.sender_id
&& a.sender_name == b.sender_name
&& a.content == b.content
&& a.timestamp == b.timestamp
&& a.is_own == b.is_own
&& a.edited == b.edited
&& a.reply_to == b.reply_to
&& a.avatar_text == b.avatar_text
&& a.show_author == b.show_author
&& a.reactions.iter().eq(b.reactions.iter())
}
fn fmt_ts(ts: i64) -> String {
let secs = (ts / 1000).abs() % 86400;
format!("{:02}:{:02}", secs / 3600, (secs % 3600) / 60)
@ -49,12 +103,7 @@ fn set_messages(
.iter()
.enumerate()
.map(|(index, m)| MessageItem {
avatar_text: state
.nick_for(&m.sender_id)
.chars()
.take(2)
.collect::<String>()
.into(),
avatar_text: initials(state.nick_for(&m.sender_id)),
show_author: index == 0
|| msgs[index - 1].sender_id != m.sender_id
|| m.timestamp.saturating_sub(msgs[index - 1].timestamp) > 300_000,
@ -65,6 +114,7 @@ fn set_messages(
timestamp: SharedString::from(fmt_ts(m.timestamp)),
is_own: m.sender_id == own_user_id,
edited: m.edited,
reactions: Rc::new(VecModel::from(reaction_items(m, own_user_id))).into(),
reply_to: SharedString::from(
m.reply_to
.as_ref()
@ -86,12 +136,18 @@ fn set_messages(
),
})
.collect();
replace_model(window.get_messages(), items, |model| {
window.set_messages(model)
});
let current = window.get_messages();
if current.row_count() != items.len()
|| !current
.iter()
.zip(items.iter())
.all(|(a, b)| same_message(&a, b))
{
window.set_messages(Rc::new(VecModel::from(items)).into());
}
}
fn set_members_state(window: &MainWindow, state: &UiState, ch_id: &str) {
fn set_members_state(window: &MainWindow, state: &UiState, ch_id: &str, own_user_id: &str) {
if let Some(ch) = state.channels.iter().find(|c| c.id == ch_id) {
let items: Vec<MemberItem> = ch
.members
@ -103,16 +159,25 @@ fn set_members_state(window: &MainWindow, state: &UiState, ch_id: &str) {
.find(|(_, n)| *n == nick)
.map(|(id, _)| id.clone())
.unwrap_or_else(|| nick.clone());
let status = state
.presences
.get(&user_id)
.map(|p| p.status.as_str())
.unwrap_or("offline");
let is_own = user_id == own_user_id;
// This client is connected whenever the member list is shown, so the local user
// is online even though the server sends no presence update about oneself.
let status = if is_own {
"online"
} else {
state
.presences
.get(&user_id)
.map(|p| p.status.as_str())
.unwrap_or("offline")
};
MemberItem {
avatar_text: nick.chars().take(2).collect::<String>().into(),
avatar_text: initials(nick),
user_id: SharedString::from(user_id),
nickname: SharedString::from(nick.as_str()),
status: presence_label(status).into(),
presence: presence_key(status).into(),
is_own,
}
})
.collect();
@ -173,6 +238,7 @@ fn sync_sidebar(window: &MainWindow, state: &UiState, own_nickname: &str) {
});
window.set_username(SharedString::from(own_nickname));
window.set_own_initials(initials(own_nickname));
window.set_user_status(crate::ui::i18n::text("Online").into());
window.set_show_dms(state.browsing_dms);
window.set_active_dm_id(state.active_dm_id.as_deref().unwrap_or("").into());
@ -236,7 +302,7 @@ fn sync_chat(window: &MainWindow, state: &UiState, own_user_id: &str) {
.unwrap_or_default(),
own_user_id,
);
set_members_state(window, state, &channel.id);
set_members_state(window, state, &channel.id, own_user_id);
}
// User edits are immediately written back through input-edited. Only a real
// state change (navigation/send/edit) should replace the editor contents.
@ -252,6 +318,7 @@ fn sync_friends(window: &MainWindow, state: &UiState) {
.map(|f| FriendItem {
user_id: SharedString::from(f.user_id.as_str()),
nickname: SharedString::from(f.nickname.as_str()),
avatar_text: initials(&f.nickname),
status_label: presence_label(
state
.presences
@ -279,6 +346,7 @@ fn sync_friends(window: &MainWindow, state: &UiState) {
.map(|f| FriendItem {
user_id: SharedString::from(f.user_id.as_str()),
nickname: SharedString::from(f.nickname.as_str()),
avatar_text: initials(&f.nickname),
status: "pending".into(),
status_label: presence_label("pending").into(),
})
@ -299,7 +367,7 @@ fn sync_friends(window: &MainWindow, state: &UiState) {
window.set_friends_active_tab(SharedString::from(state.friends_tab.as_str()));
}
pub fn sync_voice(window: &MainWindow, state: &UiState) {
pub fn sync_voice(window: &MainWindow, state: &UiState, own_user_id: &str) {
let members: Vec<VoiceMemberItem> = state
.channels
.iter()
@ -318,7 +386,8 @@ pub fn sync_voice(window: &MainWindow, state: &UiState) {
.map(|(id, _)| id.clone())
.unwrap_or_else(|| nick.clone());
VoiceMemberItem {
avatar_text: nick.chars().take(2).collect::<String>().into(),
avatar_text: initials(nick),
is_own: user_id == own_user_id,
user_id: SharedString::from(user_id.clone()),
nickname: SharedString::from(nick.as_str()),
speaking: state.remote_speaking && state.last_remote_speaker_id == user_id,
@ -465,7 +534,7 @@ pub fn sync_ui(
sync_sidebar(window, state, own_nickname);
sync_chat(window, state, own_user_id);
sync_friends(window, state);
sync_voice(window, state);
sync_voice(window, state, own_user_id);
sync_connect(window, state);
sync_settings(window, state, own_pubkey);
}

175
src/ui/emoji/mod.rs Normal file
View file

@ -0,0 +1,175 @@
//! Emoji picker data: a bundled catalog of Noto Emoji images (Apache-2.0, see
//! `docs/THIRD_PARTY.md`) with English and Russian search keywords.
//!
//! Colour emoji are drawn from the embedded PNG images rather than from a system font. Many
//! machines have no colour emoji font and Slint's renderers would then show empty boxes.
mod images;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use slint::{ComponentHandle, Image, Rgba8Pixel, SharedPixelBuffer, SharedString, VecModel};
use crate::ui::slint::{EmojiCatalog, EmojiItem, MainWindow};
/// One catalog row of `catalog.tsv`: code, category, glyph, English keywords, Russian keywords.
struct Entry {
code: &'static str,
category: i32,
glyph: &'static str,
keywords: String,
}
fn entries() -> &'static [Entry] {
use std::sync::OnceLock;
static ENTRIES: OnceLock<Vec<Entry>> = OnceLock::new();
ENTRIES.get_or_init(|| {
include_str!("catalog.tsv")
.lines()
.filter_map(|line| {
let mut cols = line.split('\t');
Some(Entry {
code: cols.next()?,
category: cols.next()?.parse().ok()?,
glyph: cols.next()?,
keywords: format!("{} {}", cols.next()?, cols.next().unwrap_or(""))
.to_lowercase(),
})
})
.collect()
})
}
/// Removes the emoji presentation selector so that `❤` and `❤️` identify the same image.
fn normalize(glyph: &str) -> String {
glyph.chars().filter(|c| *c != '\u{fe0f}').collect()
}
thread_local! {
static CACHE: RefCell<HashMap<&'static str, Image>> = RefCell::new(HashMap::new());
}
fn decode(bytes: &[u8]) -> Option<Image> {
let rgba = image::load_from_memory_with_format(bytes, image::ImageFormat::Png)
.ok()?
.to_rgba8();
let buffer = SharedPixelBuffer::<Rgba8Pixel>::clone_from_slice(
rgba.as_raw(),
rgba.width(),
rgba.height(),
);
Some(Image::from_rgba8(buffer))
}
fn image_of(entry: &'static Entry) -> Option<Image> {
CACHE.with(|cache| {
if let Some(image) = cache.borrow().get(entry.code) {
return Some(image.clone());
}
let bytes = images::IMAGES
.iter()
.find(|(code, _)| *code == entry.code)
.map(|(_, bytes)| *bytes)?;
let image = decode(bytes)?;
cache.borrow_mut().insert(entry.code, image.clone());
Some(image)
})
}
/// The bundled image for `glyph`, when the catalog contains it.
pub fn image_for_glyph(glyph: &str) -> Option<Image> {
let wanted = normalize(glyph);
entries()
.iter()
.find(|entry| normalize(entry.glyph) == wanted)
.and_then(image_of)
}
/// Indexes of catalog entries for a category (`-1` meaning all) and a free text query.
fn search(category: i32, query: &str) -> Vec<usize> {
let query = query.trim().to_lowercase();
entries()
.iter()
.enumerate()
.filter(|(_, entry)| {
if query.is_empty() {
category < 0 || entry.category == category
} else {
// A query searches every category.
entry
.keywords
.split_whitespace()
.any(|word| word.starts_with(&query))
|| entry.keywords.contains(&query)
}
})
.map(|(index, _)| index)
.collect()
}
fn items(category: i32, query: &str) -> Vec<EmojiItem> {
search(category, query)
.into_iter()
.filter_map(|index| {
let entry = &entries()[index];
Some(EmojiItem {
glyph: SharedString::from(entry.glyph),
image: image_of(entry)?,
name: SharedString::from(entry.keywords.split(' ').next().unwrap_or("")),
})
})
.collect()
}
/// Fills the shared picker model and answers search or category changes from the picker.
pub fn wire(window: &MainWindow) {
let catalog = window.global::<EmojiCatalog>();
catalog.set_shown(Rc::new(VecModel::from(items(0, ""))).into());
let weak = window.as_weak();
catalog.on_query(move |category, text| {
if let Some(window) = weak.upgrade() {
window
.global::<EmojiCatalog>()
.set_shown(Rc::new(VecModel::from(items(category, text.as_str()))).into());
}
});
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_catalog_row_has_a_decodable_image() {
assert!(entries().len() > 150);
for entry in entries() {
let bytes = images::IMAGES
.iter()
.find(|(code, _)| *code == entry.code)
.unwrap_or_else(|| panic!("image for {}", entry.code))
.1;
assert!(decode(bytes).is_some(), "{} must decode", entry.code);
}
}
#[test]
fn search_understands_english_and_russian() {
let find = |query: &str| -> Vec<&str> {
search(-1, query)
.into_iter()
.map(|i| entries()[i].glyph)
.collect()
};
assert!(find("fire").contains(&"🔥"));
assert!(find("огонь").contains(&"🔥"));
assert!(find("лайк").contains(&"👍"));
assert!(find("zzzz-no-such-emoji").is_empty());
assert!(search(1, "").len() < search(-1, "").len());
}
#[test]
fn selector_variants_share_an_image() {
assert!(entries().iter().any(|e| normalize(e.glyph) == "❤"));
}
}

View file

@ -2,6 +2,7 @@ pub mod appearance;
pub mod avatar;
pub mod bridge;
pub mod devices;
pub mod emoji;
pub mod i18n;
pub mod media;
pub mod preferences;

View file

@ -38,7 +38,7 @@ export component AvatarCropper inherits Rectangle {
padding: 18px; spacing: 8px; alignment: start;
HorizontalLayout {
Text { text: @tr("Crop photo"); color: Theme.text-primary; font-size: Theme.font-size + 5px; font-weight: 600; horizontal-stretch: 1; vertical-alignment: center; }
ActionButton { text: "×"; width: 30px; quiet: true; clicked => { root.cancel(); } }
ActionButton { text: @tr("Cancel"); icon: "x"; width: 30px; quiet: true; clicked => { root.cancel(); } }
}
Text { text: @tr("Drag the photo and adjust the zoom."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); }
Rectangle { height: 4px; }
@ -95,7 +95,7 @@ export component AvatarCropper inherits Rectangle {
Rectangle { height: 2px; }
HorizontalLayout {
spacing: 10px;
ActionButton { text: "−"; width: 32px; clicked => { root.set-zoom(root.zoom - 0.1); } }
ActionButton { text: "-"; width: 32px; clicked => { root.set-zoom(root.zoom - 0.1); } }
AudioSlider { minimum: 1; maximum: 3; value <=> root.zoom; changed(value) => { root.zoom-changed(value); } }
ActionButton { text: "+"; width: 32px; clicked => { root.set-zoom(root.zoom + 0.1); } }
}

View file

@ -1,16 +1,23 @@
import { Theme } from "theme.slint";
/// The one avatar component used for every person in the app: user panel, messages, member
/// lists, voice cards, friends and settings. Shows the picture when there is one and the
/// initials otherwise. `mask` must be the colour of the surface behind the avatar.
export component AvatarView inherits Rectangle {
in property <image> source;
in property <bool> has-source;
in property <string> initials;
in property <brush> mask: Theme.bg-base;
// "", "online", "idle", "dnd" or "offline": draws a presence dot at the bottom right.
in property <string> presence;
// Draws a highlight ring around the avatar, used for the person currently speaking.
in property <bool> speaking;
width: 34px; height: 34px;
border-radius: self.width / 2;
background: Theme.avatar-bg;
clip: true;
if root.has-source : Image { source: root.source; width: parent.width; height: parent.height; image-fit: cover; }
if !root.has-source : Text { text: root.initials; color: Theme.accent; font-size: Math.max(11px, Theme.font-size - 3px); horizontal-alignment: center; vertical-alignment: center; overflow: elide; }
if !root.has-source : Text { text: root.initials; color: Theme.accent; font-size: Math.max(11px, root.width * 0.38); font-weight: 600; horizontal-alignment: center; vertical-alignment: center; overflow: elide; }
// Explicit mask also works on software renderers that only clip rectangular bounds.
Path {
width: parent.width; height: parent.height;
@ -18,4 +25,25 @@ export component AvatarView inherits Rectangle {
commands: "M0 0H320V320H0Z M320 160 A160 160 0 1 0 0 160 A160 160 0 1 0 320 160Z";
fill-rule: evenodd; fill: root.mask;
}
if root.speaking : Rectangle {
width: parent.width; height: parent.height;
border-radius: self.width / 2;
border-width: Math.max(2px, root.width * 0.04);
border-color: Theme.success;
}
}
/// Presence dot drawn over an avatar corner; kept outside AvatarView because the avatar clips.
export component PresenceDot inherits Rectangle {
in property <string> presence;
in property <brush> ring: Theme.bg-base;
visible: root.presence != "";
width: 12px; height: 12px;
border-radius: 6px;
background: root.ring;
Rectangle {
x: 2px; y: 2px; width: parent.width - 4px; height: parent.height - 4px;
border-radius: self.width / 2;
background: root.presence == "online" ? Theme.success : root.presence == "idle" ? Theme.accent : root.presence == "dnd" ? Theme.danger : Theme.text-disabled;
}
}

View file

@ -1,15 +1,51 @@
import { AvatarView } from "avatar-view.slint";
import { Theme, ActionButton } from "theme.slint";
import { AvatarView, PresenceDot } from "avatar-view.slint";
import { Theme, ActionButton, Symbol } from "theme.slint";
import { EmojiPicker } from "emoji-picker.slint";
export struct ReactionItem { emoji: string, image: image, has_image: bool, count: int, mine: bool }
export struct MessageItem {
message_id: string, sender_id: string, sender_name: string,
content: string, timestamp: string, is_own: bool, edited: bool, reply_to: string, avatar_text: string, show_author: bool,
reactions: [ReactionItem],
}
export struct DmConversationItem {
dm_id: string, other_user_id: string, other_nickname: string,
e2ee_enabled: bool, messages: [MessageItem],
}
export struct MemberItem { user_id: string, nickname: string, status: string, avatar_text: string }
export struct MemberItem { user_id: string, nickname: string, status: string, presence: string, avatar_text: string, is_own: bool }
component QuickReaction inherits Rectangle {
in property <image> glyph;
in property <string> label;
callback clicked();
width: 30px; height: 28px;
border-radius: 6px;
background: touch.has-hover ? Theme.bg-hover : transparent;
accessible-role: button;
accessible-label: root.label;
Image { source: root.glyph; width: 18px; height: 18px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; }
touch := TouchArea { clicked => { root.clicked(); } }
}
component ReactionChip inherits Rectangle {
in property <ReactionItem> reaction;
callback clicked();
height: 24px;
width: content.preferred-width + 16px;
border-radius: 12px;
background: root.reaction.mine ? Theme.accent.with-alpha(0.18) : touch.has-hover ? Theme.bg-hover : Theme.bg-interactive;
border-width: 1px;
border-color: root.reaction.mine ? Theme.accent : Theme.border;
accessible-role: button;
accessible-label: root.reaction.emoji;
content := HorizontalLayout {
padding-left: 8px; padding-right: 8px; spacing: 5px;
if root.reaction.has_image : Image { source: root.reaction.image; width: 15px; height: 15px; y: (root.height - self.height) / 2; }
if !root.reaction.has_image : Text { text: root.reaction.emoji; vertical-alignment: center; font-size: Math.max(11px, Theme.font-size * 0.8125); color: Theme.text-primary; }
Text { text: root.reaction.count; vertical-alignment: center; color: root.reaction.mine ? Theme.accent : Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); font-weight: 600; }
}
touch := TouchArea { clicked => { root.clicked(); } }
}
component MessageRow inherits Rectangle {
in property <MessageItem> message;
@ -24,42 +60,66 @@ component MessageRow inherits Rectangle {
preferred-height: row-content.preferred-height;
vertical-stretch: 0;
background: row-touch.has-hover || row-focus.has-focus ? Theme.bg-hover : transparent;
row-touch := TouchArea { clicked => { row-focus.focus(); } }
row-focus := FocusScope { focus-on-click: false; }
row-content := HorizontalLayout {
padding-left: 22px; padding-right: 22px;
padding-top: root.message.show_author ? 9px : 2px; padding-bottom: root.message.show_author ? 9px : 2px; spacing: 13px;
AvatarView {
width: 34px; height: root.message.show_author ? 34px : 0px; visible: root.message.show_author;
source: root.own-avatar; has-source: root.has-own-avatar && root.message.is_own;
initials: root.message.avatar_text; mask: root.background;
// Content and action bar are children of the hover area: a sibling area would lose hover as
// soon as the pointer reaches a button or reaction chip.
row-touch := TouchArea {
row-content := HorizontalLayout {
padding-left: 22px; padding-right: 22px;
padding-top: root.message.show_author ? 9px : 2px; padding-bottom: root.message.show_author ? 9px : 2px; spacing: 13px;
AvatarView {
width: 34px; height: root.message.show_author ? 34px : 0px; visible: root.message.show_author;
source: root.own-avatar; has-source: root.has-own-avatar && root.message.is_own;
initials: root.message.avatar_text; mask: root.background;
}
VerticalLayout {
spacing: 4px;
if root.message.reply_to != "" : HorizontalLayout {
spacing: 6px;
Symbol { kind: "corner-down-right"; ink: Theme.text-muted; width: 13px; height: 13px; y: (parent.height - self.height) / 2; }
Text { text: root.message.reply_to; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); wrap: word-wrap; vertical-alignment: center; horizontal-stretch: 1; }
}
if root.message.show_author : HorizontalLayout {
spacing: 9px;
Text { text: root.message.sender_name; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.875); font-weight: 600; overflow: elide; vertical-alignment: center; }
Text { text: root.message.timestamp + (root.message.edited ? @tr(" · edited") : ""); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); vertical-alignment: center; }
Rectangle { horizontal-stretch: 1; }
}
Text { text: root.message.content; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); wrap: word-wrap; }
if root.message.reactions.length > 0 : HorizontalLayout {
spacing: 6px; alignment: start; padding-top: 2px;
for reaction in root.message.reactions: ReactionChip {
reaction: reaction;
clicked => { root.react(root.message.message_id, reaction.emoji); }
}
}
}
}
VerticalLayout {
spacing: 4px;
if root.message.reply_to != "" : Text {
text: "↳ " + root.message.reply_to;
color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); wrap: word-wrap;
if root.actions-enabled && (row-touch.has-hover || row-focus.has-focus) : Rectangle {
x: parent.width - self.width - 16px; y: 0px;
width: bar.preferred-width; height: 34px;
background: Theme.bg-surface; border-radius: 8px;
border-width: 1px; border-color: Theme.border;
bar := HorizontalLayout {
padding: 2px; spacing: 2px;
QuickReaction { label: @tr("Like"); glyph: @image-url("assets/emoji/1f44d.png"); clicked => { root.react(root.message.message_id, "👍"); } }
QuickReaction { label: @tr("Heart"); glyph: @image-url("assets/emoji/2764-fe0f.png"); clicked => { root.react(root.message.message_id, "❤️"); } }
QuickReaction { label: @tr("Laugh"); glyph: @image-url("assets/emoji/1f602.png"); clicked => { root.react(root.message.message_id, "😂"); } }
Rectangle { width: 1px; background: Theme.border; }
ActionButton { text: @tr("Add reaction"); icon: "smile-plus"; quiet: true; width: 30px; height: 28px; clicked => { reaction-popup.show(); } }
ActionButton { text: @tr("Reply"); icon: "reply"; quiet: true; width: 30px; height: 28px; clicked => { root.reply-to-msg(root.message.message_id); } }
if root.message.is_own : ActionButton { text: @tr("Edit"); icon: "pencil"; quiet: true; width: 30px; height: 28px; clicked => { root.edit-msg(root.message.message_id); } }
if root.message.is_own : ActionButton { text: @tr("Delete"); icon: "trash-2"; danger: true; quiet: true; width: 30px; height: 28px; clicked => { root.delete-msg(root.message.message_id); } }
}
if root.message.show_author : HorizontalLayout {
spacing: 9px;
Text { text: root.message.sender_name; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.875); font-weight: 600; overflow: elide; }
Text { text: root.message.timestamp + (root.message.edited ? @tr(" · edited") : ""); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); }
Rectangle { horizontal-stretch: 1; }
}
Text { text: root.message.content; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); wrap: word-wrap; }
}
}
if root.actions-enabled && (row-touch.has-hover || row-focus.has-focus) : Rectangle {
x: parent.width - self.width - 16px; y: 0px;
width: root.message.is_own ? 245px : 136px; height: 32px;
background: Theme.bg-surface; border-radius: 6px;
border-width: 1px; border-color: Theme.border;
HorizontalLayout {
spacing: 3px;
ActionButton { text: "👍"; quiet: true; clicked => { root.react(root.message.message_id, "👍"); } }
ActionButton { text: @tr("Reply"); quiet: true; clicked => { root.reply-to-msg(root.message.message_id); } }
if root.message.is_own : ActionButton { text: @tr("Edit"); quiet: true; clicked => { root.edit-msg(root.message.message_id); } }
if root.message.is_own : ActionButton { text: @tr("Delete"); danger: true; quiet: true; clicked => { root.delete-msg(root.message.message_id); } }
reaction-popup := PopupWindow {
close-policy: PopupClosePolicy.close-on-click-outside;
width: 336px; height: 320px;
x: root.width - self.width - 16px;
y: root.absolute-position.y > 420px ? -self.height - 4px : 38px;
reaction-picker := EmojiPicker {
picked(glyph) => { reaction-popup.close(); root.react(root.message.message_id, glyph); }
}
}
}
@ -95,13 +155,13 @@ export component ChatPanel inherits Rectangle {
Rectangle {
height: 56px; border-width: 1px; border-color: Theme.border;
HorizontalLayout {
padding-left: 22px; padding-right: 16px; spacing: 12px;
Text { text: root.is-dm ? "@" : "#"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 1.4375); width: 20px; vertical-alignment: center; }
padding-left: 22px; padding-right: 16px; spacing: 10px;
Symbol { kind: root.is-dm ? "at-sign" : "hash"; ink: Theme.text-muted; width: 20px; height: 20px; y: (parent.height - self.height) / 2; }
Text { text: root.is-dm ? root.dm-partner-name : root.active-channel-name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; overflow: elide; vertical-alignment: center; }
if root.e2ee-enabled : Text { text: @tr("End-to-end encrypted"); color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.6875); }
if root.e2ee-enabled : Text { text: @tr("End-to-end encrypted"); color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.6875); vertical-alignment: center; }
Rectangle { horizontal-stretch: 1; }
if !root.is-dm : ActionButton { text: @tr("Webhooks"); quiet: true; clicked => { root.open-webhooks(); } }
if !root.is-dm : ActionButton { text: @tr("Members"); active: root.members-visible; clicked => { root.toggle-members(); } }
if !root.is-dm : VerticalLayout { alignment: center; ActionButton { text: @tr("Webhooks"); icon: "webhook"; quiet: true; clicked => { root.open-webhooks(); } } }
if !root.is-dm : VerticalLayout { alignment: center; ActionButton { text: @tr("Members"); icon: "users"; active: root.members-visible; clicked => { root.toggle-members(); } } }
}
}
HorizontalLayout {
@ -133,41 +193,65 @@ export component ChatPanel inherits Rectangle {
height: 34px; background: Theme.bg-elevated;
HorizontalLayout {
padding-left: 16px; padding-right: 16px; spacing: 9px;
Text { text: @tr("Reply to {}", root.replying-to-sender); color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.75); }
Text { text: root.replying-to-content; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-stretch: 1; overflow: elide; }
ActionButton { text: "×"; quiet: true; width: 28px; clicked => { root.cancel-reply(); } }
Text { text: @tr("Reply to {}", root.replying-to-sender); color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.75); vertical-alignment: center; }
Text { text: root.replying-to-content; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-stretch: 1; overflow: elide; vertical-alignment: center; }
VerticalLayout { alignment: center; ActionButton { text: @tr("Cancel reply"); icon: "x"; quiet: true; width: 28px; height: 26px; clicked => { root.cancel-reply(); } } }
}
}
Rectangle {
height: 92px;
VerticalLayout {
padding-left: 20px; padding-right: 20px; padding-top: 8px; spacing: 5px;
Rectangle {
background: Theme.bg-interactive; border-radius: 9px;
border-width: 1px; border-color: Theme.border;
HorizontalLayout {
padding: 10px; spacing: 10px;
editor := TextInput {
text <=> root.input-text;
single-line: false;
color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.9375);
horizontal-stretch: 1; wrap: word-wrap;
edited => { root.input-edited(self.text); }
key-pressed(event) => {
if event.text == "\n" && !event.modifiers.shift {
root.send-message(root.is-dm ? "" : root.active-channel-id, root.input-text);
return accept;
}
return reject;
height: composer.height + 24px;
composer := Rectangle {
x: 20px; y: 8px;
width: parent.width - 40px;
height: Math.min(150px, Math.max(48px, editor.preferred-height + 22px));
background: Theme.bg-interactive; border-radius: 9px;
border-width: 1px; border-color: editor.has-focus ? Theme.accent.with-alpha(0.6) : Theme.border;
HorizontalLayout {
padding-left: 14px; padding-right: 8px; padding-top: 11px; padding-bottom: 11px; spacing: 6px;
editor := TextInput {
text <=> root.input-text;
single-line: false;
color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.9375);
horizontal-stretch: 1; wrap: word-wrap;
selection-background-color: Theme.selected; selection-foreground-color: Theme.text-primary;
edited => { root.input-edited(self.text); }
key-pressed(event) => {
if event.text == "\n" && !event.modifiers.shift {
root.send-message(root.is-dm ? "" : root.active-channel-id, root.input-text);
return accept;
}
return reject;
}
ActionButton {
text: @tr("Send");
clicked => { root.send-message(root.is-dm ? "" : root.active-channel-id, root.input-text); }
}
VerticalLayout {
alignment: end;
ActionButton { text: @tr("Emoji"); icon: "smile"; quiet: true; width: 32px; height: 30px; clicked => { emoji-popup.show(); } }
}
VerticalLayout {
alignment: end;
ActionButton { text: @tr("Send"); icon: "send"; primary: true; width: 32px; height: 30px; clicked => { root.send-message(root.is-dm ? "" : root.active-channel-id, root.input-text); } }
}
}
Text {
x: 14px; y: 11px; width: parent.width - 100px;
visible: root.input-text == "";
text: @tr("Message");
color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.9375);
}
emoji-popup := PopupWindow {
close-policy: PopupClosePolicy.close-on-click-outside;
width: 336px; height: 320px;
x: parent.width - self.width - 8px;
y: -self.height - 8px;
composer-picker := EmojiPicker {
picked(glyph) => {
editor.text = editor.text + glyph;
root.input-edited(editor.text);
emoji-popup.close();
editor.focus();
}
}
}
Text { text: @tr("Enter to send · Shift+Enter for a new line"); color: Theme.text-disabled; font-size: Math.max(11px, Theme.font-size * 0.6875); height: 18px; }
}
}
}
@ -176,13 +260,21 @@ export component ChatPanel inherits Rectangle {
Flickable {
content-width: self.width;
VerticalLayout {
padding: 16px; spacing: 12px;
Text { text: @tr("Members — {}", root.members.length); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 28px; }
padding: 16px; spacing: 10px;
Text { text: @tr("{n} member" | "{n} members" % root.members.length); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 28px; }
for member in root.members: HorizontalLayout {
height: 38px; spacing: 9px;
Rectangle { width: 28px; height: 28px; background: Theme.avatar-bg; border-radius: 11px; Text { text: member.avatar_text; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.6875); horizontal-alignment: center; vertical-alignment: center; } }
height: 40px; spacing: 10px;
Rectangle {
width: 30px;
AvatarView {
width: 30px; height: 30px; y: (parent.height - self.height) / 2;
source: root.own-avatar; has-source: root.has-own-avatar && member.is_own;
initials: member.avatar_text; mask: Theme.bg-surface;
}
PresenceDot { x: 19px; y: parent.height / 2 + 4px; presence: member.presence; ring: Theme.bg-surface; }
}
VerticalLayout {
spacing: 1px;
spacing: 1px; alignment: center;
Text { text: member.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.8125); overflow: elide; }
Text { text: member.status; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
}

View file

@ -1,4 +1,4 @@
import { Theme, ActionButton } from "theme.slint";
import { Theme, ActionButton, Symbol } from "theme.slint";
export struct BookmarkItem { name: string, address: string }
@ -28,10 +28,11 @@ export component ConnectScreen inherits Rectangle {
VerticalLayout {
padding: 32px; spacing: 22px;
HorizontalLayout {
spacing: 10px;
Image { source: @image-url("assets/vnox-mark.svg"); width: 32px; height: 32px; image-fit: contain; }
Text { text: "Vnox"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.1875); font-weight: 700; }
Text { text: "Vnox"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.1875); font-weight: 700; vertical-alignment: center; }
Rectangle { horizontal-stretch: 1; }
ActionButton { text: @tr("Settings"); quiet: true; clicked => { root.open-settings(); } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Settings"); icon: "settings"; quiet: true; clicked => { root.open-settings(); } } }
}
Rectangle { vertical-stretch: 1; }
HorizontalLayout {
@ -63,11 +64,26 @@ export component ConnectScreen inherits Rectangle {
if !root.connecting : ActionButton { text: @tr("Connect"); height: 40px; clicked => { root.connect(root.address-input); } }
if root.connecting : ActionButton { text: @tr("Cancel"); height: 40px; clicked => { root.disconnect(); } }
}
HorizontalLayout {
Rectangle {
height: 30px;
ActionButton { text: root.auto-reconnect ? "✓" : "○"; width: 30px; height: 30px; quiet: true; clicked => { root.auto-reconnect = !root.auto-reconnect; root.auto-reconnect-changed(root.auto-reconnect); } }
accessible-role: checkbox; accessible-checked: root.auto-reconnect; accessible-label: @tr("Reconnect automatically");
HorizontalLayout {
spacing: 9px;
Rectangle {
width: 20px;
Rectangle {
width: 18px; height: 18px; y: (parent.height - self.height) / 2;
border-radius: 5px;
background: root.auto-reconnect ? Theme.accent : Theme.bg-interactive;
border-width: 1px; border-color: root.auto-reconnect ? Theme.accent : Theme.text-disabled;
Symbol { visible: root.auto-reconnect; kind: "check"; ink: Theme.on-accent; width: 14px; height: 14px; x: 2px; y: 2px; }
}
}
Text { text: @tr("Reconnect automatically"); color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); vertical-alignment: center; }
Rectangle { horizontal-stretch: 1; }
}
// The whole row is one control, as users expect from a checkbox.
TouchArea { clicked => { root.auto-reconnect = !root.auto-reconnect; root.auto-reconnect-changed(root.auto-reconnect); } }
}
if root.connecting : Text { text: @tr("Connecting…"); color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.8125); }
if root.status-text != "" : Text { text: root.status-text; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.8125); wrap: word-wrap; }
@ -75,7 +91,7 @@ export component ConnectScreen inherits Rectangle {
HorizontalLayout {
Text { text: @tr("Saved servers"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); font-weight: 600; }
Rectangle { horizontal-stretch: 1; }
ActionButton { text: @tr("+ Save address"); quiet: true; clicked => { root.add-bookmark(root.address-input); } }
ActionButton { text: @tr("Save address"); icon: "plus"; labeled: true; quiet: true; clicked => { root.add-bookmark(root.address-input); } }
}
if root.bookmarks.length == 0 : Text { text: @tr("No saved servers yet."); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
for server in root.bookmarks: HorizontalLayout {
@ -85,8 +101,8 @@ export component ConnectScreen inherits Rectangle {
Text { text: server.name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); overflow: elide; }
Text { text: server.address; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
}
ActionButton { text: @tr("Join"); quiet: true; clicked => { if !root.connecting { root.connect(server.address); } } }
ActionButton { text: "×"; width: 28px; quiet: true; clicked => { root.remove-bookmark(server.address); } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Join"); quiet: true; clicked => { if !root.connecting { root.connect(server.address); } } } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Remove saved server"); icon: "x"; width: 28px; quiet: true; clicked => { root.remove-bookmark(server.address); } } }
}
}
}
@ -96,7 +112,7 @@ export component ConnectScreen inherits Rectangle {
Text { text: @tr("Your server. Your community."); color: Theme.text-disabled; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-alignment: center; }
}
if root.trust-kind != 0 : Rectangle {
background: #000000a0;
background: Theme.overlay;
TouchArea { }
HorizontalLayout {
Rectangle { horizontal-stretch: 1; }

View file

@ -1,4 +1,4 @@
import { Theme, ActionButton } from "theme.slint";
import { Theme, ActionButton, Symbol } from "theme.slint";
export component DeviceSelect inherits Rectangle {
in property <[string]> model;
@ -13,7 +13,7 @@ export component DeviceSelect inherits Rectangle {
HorizontalLayout {
padding-left: 11px; padding-right: 11px;
Text { text: root.model[root.current-index]; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.8125); vertical-alignment: center; overflow: elide; horizontal-stretch: 1; }
Text { text: "⌄"; color: Theme.text-muted; width: 16px; vertical-alignment: center; }
Rectangle { width: 16px; Symbol { kind: "chevron-down"; ink: Theme.text-muted; width: 16px; height: 16px; y: (parent.height - self.height) / 2; } }
}
TouchArea { clicked => { keyboard.focus(); popup.show(); } }
keyboard := FocusScope {

View file

@ -0,0 +1,88 @@
import { Theme, Symbol } from "theme.slint";
export struct EmojiItem { glyph: string, image: image, name: string }
/// Emoji shown by the picker. Rust fills `shown` from the bundled catalog and answers `query`
/// (category index and search text), so searching works in English and Russian.
export global EmojiCatalog {
in-out property <[EmojiItem]> shown;
callback query(int, string);
}
component CategoryTab inherits Rectangle {
in property <image> glyph;
in property <bool> selected;
in property <string> label;
callback clicked();
height: 32px;
border-radius: 6px;
background: root.selected ? Theme.selected : touch.has-hover ? Theme.bg-hover : transparent;
accessible-role: button;
accessible-label: root.label;
Image { source: root.glyph; width: 20px; height: 20px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; }
touch := TouchArea { clicked => { root.clicked(); } }
}
/// Emoji panel with categories and search. Place it inside a PopupWindow.
export component EmojiPicker inherits Rectangle {
callback picked(string);
in-out property <int> category: 0;
width: 336px;
height: 320px;
background: Theme.bg-elevated;
border-radius: 10px;
border-width: 1px;
border-color: Theme.border;
init => { search-input.focus(); }
VerticalLayout {
padding: 10px; spacing: 8px;
Rectangle {
height: 32px;
background: Theme.bg-interactive;
border-radius: 6px;
border-width: 1px;
border-color: search-input.has-focus ? Theme.accent : Theme.border;
Symbol { kind: "search"; ink: Theme.text-muted; width: 16px; height: 16px; x: 9px; y: (parent.height - self.height) / 2; }
Text {
x: 33px; width: parent.width - 42px; height: parent.height;
visible: search-input.text == "";
text: @tr("Search emoji");
color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125);
vertical-alignment: center;
}
search-input := TextInput {
x: 33px; y: (parent.height - self.height) / 2; width: parent.width - 42px;
single-line: true; color: Theme.text-primary;
font-size: Math.max(11px, Theme.font-size * 0.8125);
selection-background-color: Theme.selected; selection-foreground-color: Theme.text-primary;
edited => { EmojiCatalog.query(root.category, self.text); }
}
}
HorizontalLayout {
spacing: 4px;
CategoryTab { label: @tr("Smileys"); glyph: @image-url("assets/emoji/1f600.png"); selected: root.category == 0 && search-input.text == ""; clicked => { root.category = 0; search-input.text = ""; EmojiCatalog.query(0, ""); } }
CategoryTab { label: @tr("Gestures"); glyph: @image-url("assets/emoji/1f44d.png"); selected: root.category == 1 && search-input.text == ""; clicked => { root.category = 1; search-input.text = ""; EmojiCatalog.query(1, ""); } }
CategoryTab { label: @tr("Hearts and symbols"); glyph: @image-url("assets/emoji/2764-fe0f.png"); selected: root.category == 2 && search-input.text == ""; clicked => { root.category = 2; search-input.text = ""; EmojiCatalog.query(2, ""); } }
CategoryTab { label: @tr("Animals and food"); glyph: @image-url("assets/emoji/1f436.png"); selected: root.category == 3 && search-input.text == ""; clicked => { root.category = 3; search-input.text = ""; EmojiCatalog.query(3, ""); } }
CategoryTab { label: @tr("Objects and activities"); glyph: @image-url("assets/emoji/1f3ae.png"); selected: root.category == 4 && search-input.text == ""; clicked => { root.category = 4; search-input.text = ""; EmojiCatalog.query(4, ""); } }
}
Flickable {
content-width: self.width;
content-height: Math.max(self.height, Math.ceil(EmojiCatalog.shown.length / 8) * 37px);
for item[index] in EmojiCatalog.shown: Rectangle {
x: Math.mod(index, 8) * 37px; y: Math.floor(index / 8) * 37px;
width: 36px; height: 36px; border-radius: 6px;
background: cell.has-hover ? Theme.bg-hover : transparent;
accessible-role: button;
accessible-label: item.name;
Image { source: item.image; width: 26px; height: 26px; x: 5px; y: 5px; }
cell := TouchArea { clicked => { root.picked(item.glyph); } }
}
if EmojiCatalog.shown.length == 0 : Text {
text: @tr("Nothing found");
color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125);
horizontal-alignment: center; width: parent.width; y: 20px;
}
}
}
}

View file

@ -1,6 +1,8 @@
import { Theme, ActionButton } from "theme.slint";
import { Theme, ActionButton, Symbol } from "theme.slint";
import { ThemeInput } from "controls.slint";
import { AvatarView, PresenceDot } from "avatar-view.slint";
export struct FriendItem { user_id: string, nickname: string, status: string, status_label: string }
export struct FriendItem { user_id: string, nickname: string, status: string, status_label: string, avatar_text: string }
export component FriendsPanel inherits Rectangle {
in-out property <[FriendItem]> friends;
@ -22,11 +24,12 @@ export component FriendsPanel inherits Rectangle {
height: 56px; border-width: 1px; border-color: Theme.border;
HorizontalLayout {
padding-left: 22px; padding-right: 16px; spacing: 10px;
Text { text: @tr("Friends"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; }
ActionButton { text: @tr("Online"); active: root.active-tab == "online"; quiet: true; clicked => { root.tab-changed("online"); } }
ActionButton { text: @tr("All"); active: root.active-tab == "all"; quiet: true; clicked => { root.tab-changed("all"); } }
ActionButton { text: @tr("Requests"); active: root.active-tab == "pending"; quiet: true; clicked => { root.tab-changed("pending"); } }
ActionButton { text: @tr("Blocked"); active: root.active-tab == "blocked"; quiet: true; clicked => { root.tab-changed("blocked"); } }
Symbol { kind: "users"; ink: Theme.text-muted; width: 20px; height: 20px; y: (parent.height - self.height) / 2; }
Text { text: @tr("Friends"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; vertical-alignment: center; }
VerticalLayout { alignment: center; ActionButton { text: @tr("Online"); active: root.active-tab == "online"; quiet: true; clicked => { root.tab-changed("online"); } } }
VerticalLayout { alignment: center; ActionButton { text: @tr("All"); active: root.active-tab == "all"; quiet: true; clicked => { root.tab-changed("all"); } } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Requests"); active: root.active-tab == "pending"; quiet: true; clicked => { root.tab-changed("pending"); } } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Blocked"); active: root.active-tab == "blocked"; quiet: true; clicked => { root.tab-changed("blocked"); } } }
Rectangle { horizontal-stretch: 1; }
}
}
@ -34,13 +37,7 @@ export component FriendsPanel inherits Rectangle {
padding: 22px; spacing: 16px;
HorizontalLayout {
spacing: 9px;
Rectangle {
height: 38px; background: Theme.bg-interactive; border-radius: 7px;
HorizontalLayout {
padding: 10px;
TextInput { text <=> root.add-friend-input; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); single-line: true; edited => { root.input-edited(self.text); } accepted => { root.add-friend(root.add-friend-input); } }
}
}
ThemeInput { text <=> root.add-friend-input; placeholder-text: @tr("Friend ID"); edited(text) => { root.input-edited(text); } accepted => { root.add-friend(root.add-friend-input); } }
ActionButton { text: @tr("Add by ID"); height: 38px; clicked => { root.add-friend(root.add-friend-input); } }
}
Text { text: root.active-tab == "pending" ? @tr("Incoming requests") : root.active-tab == "blocked" ? @tr("Blocked users") : root.active-tab == "online" ? @tr("Online friends") : @tr("All friends"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
@ -55,14 +52,18 @@ export component FriendsPanel inherits Rectangle {
row-touch := TouchArea { }
HorizontalLayout {
padding: 10px; spacing: 12px;
Rectangle { width: 32px; height: 32px; background: Theme.avatar-bg; border-radius: 12px; Text { text: "@"; color: Theme.accent; horizontal-alignment: center; vertical-alignment: center; } }
Rectangle {
width: 36px;
AvatarView { width: 36px; height: 36px; y: (parent.height - self.height) / 2; initials: friend.avatar_text; mask: row-touch.has-hover ? Theme.bg-elevated : Theme.bg-base; }
PresenceDot { x: 25px; y: parent.height / 2 + 6px; presence: friend.status == "offline" ? "" : friend.status; ring: row-touch.has-hover ? Theme.bg-elevated : Theme.bg-base; }
}
VerticalLayout {
spacing: 2px; horizontal-stretch: 1;
spacing: 2px; horizontal-stretch: 1; alignment: center;
Text { text: friend.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); }
Text { text: friend.status_label; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); }
}
ActionButton { text: @tr("Message"); quiet: true; clicked => { root.start-dm(friend.user_id); } }
ActionButton { text: @tr("Delete"); quiet: true; danger: true; clicked => { root.remove-friend(friend.user_id); } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Message"); quiet: true; clicked => { root.start-dm(friend.user_id); } } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Delete"); quiet: true; danger: true; clicked => { root.remove-friend(friend.user_id); } } }
}
}
for friend in root.pending-requests: Rectangle {
@ -70,9 +71,9 @@ export component FriendsPanel inherits Rectangle {
height: 58px;
HorizontalLayout {
padding: 10px; spacing: 10px;
Text { text: friend.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-stretch: 1; }
ActionButton { text: @tr("Accept"); clicked => { root.accept-friend(friend.user_id); } }
ActionButton { text: @tr("Decline"); danger: true; quiet: true; clicked => { root.decline-friend(friend.user_id); } }
Text { text: friend.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-stretch: 1; vertical-alignment: center; }
VerticalLayout { alignment: center; ActionButton { text: @tr("Accept"); clicked => { root.accept-friend(friend.user_id); } } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Decline"); danger: true; quiet: true; clicked => { root.decline-friend(friend.user_id); } } }
}
}
for user in root.blocked-users: Rectangle {

View file

@ -2,6 +2,7 @@ export { WebhookWindow, WebhookRow } from "webhooks.slint";
export { ScreenShareWindow, ScreenViewerWindow } from "screen-share.slint";
export { UnlockWindow } from "unlock.slint";
export { Theme } from "theme.slint";
export { EmojiCatalog, EmojiItem } from "emoji-picker.slint";
import { Theme, ActionButton } from "theme.slint";
import { Sidebar, ChannelItem, GuildItem, DmItem } from "sidebar.slint";
import { ChatPanel, MessageItem, MemberItem } from "chat.slint";
@ -17,6 +18,7 @@ export component MainWindow inherits Window {
in-out property <[DmItem]> dm-conversations;
in-out property <string> username;
in-out property <string> user-status;
in-out property <string> own-initials;
in-out property <string> active-channel-id;
in-out property <int> active-guild-idx;
in-out property <bool> show-dms;
@ -227,6 +229,7 @@ export component MainWindow inherits Window {
show-friends => { root.show-friends-view(); }
own-avatar: root.own-avatar;
has-avatar: root.has-avatar;
own-initials: root.own-initials;
username: root.username;
user-status: root.user-status;
active-channel-id: root.active-channel-id;
@ -244,7 +247,7 @@ export component MainWindow inherits Window {
HorizontalLayout {
padding-left: 16px; padding-right: 10px; spacing: 12px;
Text { text: root.status-text; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); wrap: word-wrap; vertical-alignment: center; horizontal-stretch: 1; }
ActionButton { text: "×"; width: 28px; quiet: true; clicked => { root.dismiss-status(); } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Dismiss"); icon: "x"; width: 28px; quiet: true; clicked => { root.dismiss-status(); } } }
}
}
if root.show-chat : ChatPanel {
@ -295,6 +298,8 @@ export component MainWindow inherits Window {
channel-name: root.voice-channel-name;
activity-banner: root.activity-banner;
joining: root.voice-joining;
own-avatar: root.own-avatar;
has-own-avatar: root.has-avatar;
push-to-talk: root.vad-mode == 0;
ptt-held(held) => { root.ptt-held(held); }
toggle-mic => { root.toggle-mic(); }

View file

@ -19,7 +19,7 @@ component SettingsNav inherits Rectangle {
accessible-label: root.label;
HorizontalLayout {
padding-left: 12px; padding-right: 12px; spacing: 11px;
Text { text: root.mark; color: root.active ? Theme.text-primary : Theme.text-muted; font-size: Theme.font-size + 2px; width: 23px; vertical-alignment: center; }
Rectangle { width: 23px; Symbol { kind: root.mark; ink: root.active ? Theme.text-primary : Theme.text-muted; width: 20px; height: 20px; y: (parent.height - self.height) / 2; } }
VerticalLayout {
spacing: 2px; alignment: center;
Text { text: root.label; color: Theme.text-primary; font-size: Math.max(Theme.font-size - 2px, 11px); font-weight: root.active ? 600 : 400; overflow: elide; }
@ -99,9 +99,9 @@ export component SettingsWindow inherits Rectangle {
VerticalLayout {
padding-left: 16px; padding-right: 16px; padding-top: 32px; padding-bottom: 20px; spacing: 7px;
Text { text: @tr("Settings"); color: Theme.text-primary; font-size: Theme.font-size + 6px; font-weight: 700; height: 46px; }
SettingsNav { label: @tr("Audio & microphone"); detail: @tr("Devices and voice input"); mark: "◖"; active: root.active-tab == "audio"; clicked => { root.active-tab = "audio"; } }
SettingsNav { label: @tr("Appearance"); detail: @tr("Themes, colours and text"); mark: "Aa"; active: root.active-tab == "appearance"; clicked => { root.active-tab = "appearance"; } }
SettingsNav { label: @tr("Profile and keys"); detail: @tr("Security and backup"); mark: "◇"; active: root.active-tab == "identity"; clicked => { root.active-tab = "identity"; } }
SettingsNav { label: @tr("Audio & microphone"); detail: @tr("Devices and voice input"); mark: "mic"; active: root.active-tab == "audio"; clicked => { root.active-tab = "audio"; } }
SettingsNav { label: @tr("Appearance"); detail: @tr("Themes, colours and text"); mark: "palette"; active: root.active-tab == "appearance"; clicked => { root.active-tab = "appearance"; } }
SettingsNav { label: @tr("Profile and keys"); detail: @tr("Security and backup"); mark: "user"; active: root.active-tab == "identity"; clicked => { root.active-tab = "identity"; } }
Rectangle { vertical-stretch: 1; }
Rectangle { height: 1px; background: Theme.border; }
Text { text: "VNOX"; color: Theme.text-secondary; font-size: Math.max(Theme.font-size - 3px, 11px); font-weight: 700; height: 30px; vertical-alignment: bottom; }
@ -122,7 +122,7 @@ export component SettingsWindow inherits Rectangle {
Text { text: root.active-tab == "appearance" ? @tr("Make Vnox yours.") : root.active-tab == "identity" ? @tr("Your profile, kept safe.") : @tr("Make yourself heard, your way."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); }
}
Rectangle { horizontal-stretch: 1; }
ActionButton { text: "×"; width: 34px; text-size: 21px; quiet: true; clicked => { root.close(); } }
VerticalLayout { alignment: start; ActionButton { text: @tr("Close settings"); icon: "x"; width: 34px; height: 34px; quiet: true; clicked => { root.close(); } } }
}
}
Rectangle { height: 1px; background: Theme.border; }

View file

@ -1,4 +1,4 @@
import { Theme, ActionButton } from "../theme.slint";
import { Theme, ActionButton, Symbol } from "../theme.slint";
import { AudioSlider, ThemeInput, ThemeEditor } from "../controls.slint";
component ThemeChoice inherits Rectangle {
@ -44,7 +44,7 @@ component ThemeChoice inherits Rectangle {
Rectangle { x: 14px; y: 5px; width: Math.max(parent.width - 21px, 3px); height: 3px; border-radius: 1px; background: root.preview-ink.with-alpha(0.65); }
}
Text { x: 7px; y: 42px; text: "#"; color: root.preview-ink.with-alpha(0.4); font-size: 8px; }
Text { x: 7px; y: 59px; text: "♪"; color: root.preview-ink.with-alpha(0.4); font-size: 8px; }
Rectangle { x: 7px; y: 60px; width: 7px; height: 7px; border-radius: 3px; background: root.preview-ink.with-alpha(0.4); }
Rectangle { x: 7px; y: 80px; width: 4px; height: 4px; border-radius: 2px; background: root.preview-accent; }
Rectangle { x: 15px; y: 81px; width: Math.max(parent.width - 24px, 3px); height: 2px; background: root.preview-ink.with-alpha(0.3); }
}
@ -67,7 +67,7 @@ component ThemeChoice inherits Rectangle {
}
HorizontalLayout {
Text { text: root.label; color: Theme.text-primary; font-size: Math.max(Theme.font-size - 3px, 11px); font-weight: 500; overflow: elide; horizontal-stretch: 1; }
Text { text: root.selected ? "✓" : ""; color: Theme.accent; width: 16px; font-size: Math.max(Theme.font-size - 2px, 11px); }
Rectangle { width: 16px; Symbol { visible: root.selected; kind: "check"; ink: Theme.accent; width: 16px; height: 16px; y: (parent.height - self.height) / 2; } }
}
}
pointer := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }

View file

@ -60,7 +60,7 @@ export component IdentitySettings inherits Rectangle {
Rectangle { height: 24px; }
HorizontalLayout {
Text { text: @tr("Device security"); color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; horizontal-stretch: 1; }
Text { text: root.vault-enabled ? @tr("● Passphrase protected") : @tr("No passphrase"); color: root.vault-enabled ? Theme.success : Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); vertical-alignment: center; }
Text { text: root.vault-enabled ? @tr("Passphrase protected") : @tr("No passphrase"); color: root.vault-enabled ? Theme.success : Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); vertical-alignment: center; }
}
Rectangle { height: 6px; }
Text { text: root.vault-enabled ? @tr("Vnox will ask for your passphrase to unlock your keys on startup.") : @tr("Add a passphrase to encrypt your saved secret key."); color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }

View file

@ -1,5 +1,5 @@
import { AvatarView } from "avatar-view.slint";
import { Theme, ActionButton } from "theme.slint";
import { AvatarView, PresenceDot } from "avatar-view.slint";
import { Theme, ActionButton, Symbol } from "theme.slint";
export struct ChannelItem { channel_id: string, name: string, kind: string }
export struct GuildItem { guild_id: string, name: string, short_name: string, selected: bool }
@ -7,7 +7,7 @@ export struct DmItem { dm_id: string, name: string, unread: int }
component NavRow inherits Rectangle {
in property <string> label;
in property <string> symbol: "#";
in property <string> symbol: "hash";
in property <bool> selected;
in property <int> unread;
callback clicked();
@ -20,9 +20,9 @@ component NavRow inherits Rectangle {
accessible-label: label;
HorizontalLayout {
padding-left: 10px; padding-right: 10px; spacing: 10px;
Text { text: root.symbol; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 1.125); width: 20px; }
Text { text: root.label; color: root.selected || root.unread > 0 ? Theme.text-primary : Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-stretch: 1; overflow: elide; }
if root.unread > 0 : Text { text: root.unread; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.75); }
Symbol { kind: root.symbol; ink: root.selected ? Theme.text-primary : Theme.text-muted; width: 17px; height: 17px; y: (parent.height - self.height) / 2; }
Text { text: root.label; color: root.selected || root.unread > 0 ? Theme.text-primary : Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-stretch: 1; overflow: elide; vertical-alignment: center; }
if root.unread > 0 : Text { text: root.unread; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.75); vertical-alignment: center; font-weight: 600; }
}
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
keyboard := FocusScope {
@ -42,6 +42,7 @@ export component Sidebar inherits Rectangle {
in property <bool> has-avatar;
in-out property <string> username;
in-out property <string> user-status;
in property <string> own-initials;
in-out property <string> active-channel-id;
in-out property <string> active-dm-id;
in-out property <int> active-guild-idx;
@ -70,7 +71,7 @@ export component Sidebar inherits Rectangle {
background: Theme.bg-rail;
VerticalLayout {
padding: 9px; spacing: 11px;
ActionButton { text: @tr("Direct messages"); icon: "home"; height: 44px; text-size: 20px; active: root.show-dms; clicked => { root.show-friends(); } }
ActionButton { text: @tr("Direct messages"); icon: "house"; height: 44px; active: root.show-dms; clicked => { root.show-friends(); } }
Rectangle { height: 1px; background: Theme.border; }
ActionButton { text: "V"; height: 44px; text-size: 19px; active: !root.show-dms && root.active-guild-idx < 0; clicked => { root.guild-selected(-1); } }
for guild[index] in root.guilds: ActionButton {
@ -80,7 +81,7 @@ export component Sidebar inherits Rectangle {
clicked => { root.guild-selected(index); }
}
Rectangle { vertical-stretch: 1; }
ActionButton { text: @tr("Settings"); icon: "settings"; quiet: true; text-size: 19px; clicked => { root.open-settings(); } }
ActionButton { text: @tr("Settings"); icon: "settings"; quiet: true; clicked => { root.open-settings(); } }
}
}
Rectangle {
@ -93,19 +94,19 @@ export component Sidebar inherits Rectangle {
HorizontalLayout {
padding-left: 17px; padding-right: 10px; spacing: 8px;
Text { text: root.show-dms ? @tr("Direct messages") : root.active-guild-idx >= 0 && root.active-guild-idx < root.guilds.length ? root.guilds[root.active-guild-idx].name : root.node-name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; overflow: elide; horizontal-stretch: 1; vertical-alignment: center; }
ActionButton { text: @tr("Disconnect"); icon: "power"; width: 30px; quiet: true; clicked => { root.disconnect(); } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Disconnect from server"); icon: "log-out"; width: 32px; quiet: true; clicked => { root.disconnect(); } } }
}
}
Flickable {
content-width: self.width;
VerticalLayout {
padding: 10px; spacing: 3px;
if root.show-dms : NavRow { label: @tr("Friends"); symbol: "@"; clicked => { root.show-friends(); } }
if root.show-dms : NavRow { label: @tr("Friends"); symbol: "at-sign"; clicked => { root.show-friends(); } }
if root.show-dms : Text { text: @tr("Direct messages"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 32px; vertical-alignment: bottom; }
if root.show-dms && root.dm-conversations.length == 0 : Text { text: @tr("Open a friend's profile to send a message."); wrap: word-wrap; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
for dm in root.dm-conversations: NavRow {
visible: root.show-dms;
label: dm.name; symbol: "@"; unread: dm.unread;
label: dm.name; symbol: "at-sign"; unread: dm.unread;
selected: root.active-dm-id == dm.dm_id;
clicked => { root.dm-selected(dm.dm_id); }
}
@ -119,7 +120,7 @@ export component Sidebar inherits Rectangle {
if !root.show-dms : Text { text: @tr("Voice rooms"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 40px; vertical-alignment: bottom; }
for ch in root.channels: NavRow {
visible: !root.show-dms && ch.kind == "voice";
label: ch.name; symbol: "◖";
label: ch.name; symbol: "volume-2";
selected: root.voice-connected && root.voice-channel-name == ch.name;
clicked => { root.channel-selected(ch.channel_id); }
}
@ -133,7 +134,11 @@ export component Sidebar inherits Rectangle {
border-width: 1px; border-color: Theme.border;
VerticalLayout {
padding: 10px; spacing: 5px;
Text { text: @tr("● Voice connected"); color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); font-weight: 600; }
HorizontalLayout {
spacing: 7px;
Rectangle { width: 8px; VerticalLayout { alignment: center; Rectangle { height: 8px; border-radius: 4px; background: Theme.success; } } }
Text { text: @tr("Voice connected"); color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); font-weight: 600; vertical-alignment: center; }
}
Text { text: root.voice-channel-name; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
HorizontalLayout {
spacing: 6px;
@ -147,15 +152,19 @@ export component Sidebar inherits Rectangle {
background: Theme.bg-elevated;
HorizontalLayout {
padding: 9px; spacing: 5px;
AvatarView { width: 30px; height: 30px; source: root.own-avatar; has-source: root.has-avatar; initials: "●"; mask: Theme.bg-elevated; }
VerticalLayout {
spacing: 1px; horizontal-stretch: 1;
Text { text: root.username; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.8125); font-weight: 600; overflow: elide; }
Text { text: root.user-status; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.625); overflow: elide; }
Rectangle {
width: 34px;
AvatarView { width: 32px; height: 32px; y: (parent.height - self.height) / 2; source: root.own-avatar; has-source: root.has-avatar; initials: root.own-initials; mask: Theme.bg-elevated; }
PresenceDot { x: 21px; y: parent.height / 2 + 6px; presence: "online"; ring: Theme.bg-elevated; }
}
ActionButton { text: root.mic-enabled ? @tr("Mute microphone") : @tr("Unmute microphone"); icon: "mic"; width: 30px; danger: !root.mic-enabled; quiet: true; clicked => { root.toggle-mic(); } }
ActionButton { text: root.deafened ? @tr("Undeafen") : @tr("Deafen"); icon: "headphones"; width: 30px; danger: root.deafened; quiet: true; clicked => { root.toggle-deafen(); } }
ActionButton { text: @tr("Settings"); icon: "settings"; width: 30px; quiet: true; clicked => { root.open-settings(); } }
VerticalLayout {
spacing: 1px; horizontal-stretch: 1; alignment: center;
Text { text: root.username; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.8125); font-weight: 600; overflow: elide; }
Text { text: root.user-status; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
}
VerticalLayout { alignment: center; ActionButton { text: root.mic-enabled ? @tr("Mute microphone") : @tr("Unmute microphone"); icon: root.mic-enabled ? "mic" : "mic-off"; width: 30px; danger: !root.mic-enabled; quiet: true; clicked => { root.toggle-mic(); } } }
VerticalLayout { alignment: center; ActionButton { text: root.deafened ? @tr("Undeafen") : @tr("Deafen"); icon: root.deafened ? "headphone-off" : "headphones"; width: 30px; danger: root.deafened; quiet: true; clicked => { root.toggle-deafen(); } } }
VerticalLayout { alignment: center; ActionButton { text: @tr("Settings"); icon: "settings"; width: 30px; quiet: true; clicked => { root.open-settings(); } } }
}
}
}

View file

@ -23,14 +23,71 @@ export global Theme {
in-out property <length> radius: 7px;
}
export component Symbol inherits Rectangle {
/// Lucide icon (ISC license, see assets/icons/LICENSE) tinted with the theme ink colour.
export component Symbol inherits Image {
in property <string> kind;
in property <color> ink: Theme.text-secondary;
if kind == "mic" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M9 11V5 A3 3 0 0 1 15 5 V11 A3 3 0 0 1 9 11 M5 10V12 A7 7 0 0 0 19 12 V10 M12 19V22 M8 22H16"; }
if kind == "headphones" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M3 14V11 A9 9 0 0 1 21 11 V14 M3 13H7V21H3Z M17 13H21V21H17Z"; }
if kind == "settings" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M9 3L8 6L5 7L3 10L5 12L4 15L7 17L10 16L12 18L15 16V13L17 11L16 8L13 7L12 3Z M14 11 A3 3 0 1 1 8 11 A3 3 0 1 1 14 11"; }
if kind == "power" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M12 2V12 M6 5 A9 9 0 1 0 18 5"; }
if kind == "home" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M2 10L12 2L22 10V22H2Z M9 22V13H15V22"; }
colorize: root.ink;
image-fit: contain;
source: kind == "mic" ? @image-url("assets/icons/mic.svg") :
kind == "mic-off" ? @image-url("assets/icons/mic-off.svg") :
kind == "headphones" ? @image-url("assets/icons/headphones.svg") :
kind == "headphone-off" ? @image-url("assets/icons/headphone-off.svg") :
kind == "settings" ? @image-url("assets/icons/settings.svg") :
kind == "log-out" ? @image-url("assets/icons/log-out.svg") :
kind == "pin" ? @image-url("assets/icons/pin.svg") :
kind == "reply" ? @image-url("assets/icons/reply.svg") :
kind == "pencil" ? @image-url("assets/icons/pencil.svg") :
kind == "trash-2" ? @image-url("assets/icons/trash-2.svg") :
kind == "smile" ? @image-url("assets/icons/smile.svg") :
kind == "smile-plus" ? @image-url("assets/icons/smile-plus.svg") :
kind == "plus" ? @image-url("assets/icons/plus.svg") :
kind == "search" ? @image-url("assets/icons/search.svg") :
kind == "hash" ? @image-url("assets/icons/hash.svg") :
kind == "volume-2" ? @image-url("assets/icons/volume-2.svg") :
kind == "phone-off" ? @image-url("assets/icons/phone-off.svg") :
kind == "users" ? @image-url("assets/icons/users.svg") :
kind == "house" ? @image-url("assets/icons/house.svg") :
kind == "webhook" ? @image-url("assets/icons/webhook.svg") :
kind == "monitor" ? @image-url("assets/icons/monitor.svg") :
kind == "screen-share" ? @image-url("assets/icons/screen-share.svg") :
kind == "x" ? @image-url("assets/icons/x.svg") :
kind == "check" ? @image-url("assets/icons/check.svg") :
kind == "chevron-down" ? @image-url("assets/icons/chevron-down.svg") :
kind == "at-sign" ? @image-url("assets/icons/at-sign.svg") :
kind == "user" ? @image-url("assets/icons/user.svg") :
kind == "send" ? @image-url("assets/icons/send.svg") :
kind == "user-plus" ? @image-url("assets/icons/user-plus.svg") :
kind == "ban" ? @image-url("assets/icons/ban.svg") :
kind == "circle" ? @image-url("assets/icons/circle.svg") :
kind == "corner-down-right" ? @image-url("assets/icons/corner-down-right.svg") :
kind == "audio-lines" ? @image-url("assets/icons/audio-lines.svg") :
kind == "palette" ? @image-url("assets/icons/palette.svg") :
kind == "key-round" ? @image-url("assets/icons/key-round.svg") :
kind == "minus" ? @image-url("assets/icons/minus.svg") :
kind == "shield-check" ? @image-url("assets/icons/shield-check.svg") :
kind == "image" ? @image-url("assets/icons/image.svg") :
kind == "bell" ? @image-url("assets/icons/bell.svg") :
@image-url("assets/icons/circle.svg");
}
/// Tooltip bubble content. Used inside Slint's built-in `Tooltip`, which shows it after a short
/// hover delay near the pointer and, unlike a PopupWindow, never swallows clicks.
export component TipBubble inherits Rectangle {
in property <string> text;
background: Theme.bg-elevated;
border-radius: 6px;
border-width: 1px;
border-color: Theme.text-disabled.with-alpha(0.45);
HorizontalLayout {
padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px;
Text {
text: root.text;
color: Theme.text-primary;
font-size: Math.max(11px, Theme.font-size * 0.75);
vertical-alignment: center;
}
}
}
export component ActionButton inherits Rectangle {
@ -39,24 +96,34 @@ export component ActionButton inherits Rectangle {
in property <bool> active: false;
in property <bool> danger: false;
in property <bool> quiet: false;
// Filled with the accent colour for the main action of a view.
in property <bool> primary: false;
// Shows the icon together with the text instead of using the text as a tooltip only.
in property <bool> labeled: false;
in property <length> text-size: 13px;
// Bubble text. Icon-only buttons show their label here by default.
in property <string> tooltip: icon != "" && !labeled ? text : "";
callback clicked();
min-width: 30px;
preferred-width: icon == "" ? label.preferred-width + 22px : 32px;
horizontal-stretch: 0;
preferred-width: icon == "" ? label.preferred-width + 22px : labeled ? label.preferred-width + 48px : 32px;
height: 32px;
border-radius: 6px;
background: active ? Theme.selected : touch.has-hover ? Theme.bg-hover : quiet ? transparent : Theme.bg-interactive;
background: primary ? (touch.has-hover ? Theme.accent.brighter(8%) : Theme.accent) : active ? Theme.selected : touch.has-hover ? Theme.bg-hover : quiet ? transparent : Theme.bg-interactive;
border-width: keyboard.has-focus ? 1px : 0px;
border-color: Theme.accent;
accessible-role: button;
accessible-label: text;
Symbol { visible: root.icon != ""; kind: root.icon; ink: root.danger ? Theme.danger : Theme.text-secondary; width: 18px; height: 18px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; }
Symbol { visible: root.icon != ""; kind: root.icon; ink: root.primary ? Theme.on-accent : root.danger ? Theme.danger : root.active ? Theme.text-primary : Theme.text-secondary; width: 18px; height: 18px; x: root.labeled ? 12px : (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; }
label := Text {
visible: root.icon == "";
visible: root.icon == "" || root.labeled;
x: root.labeled ? 36px : 0px;
width: root.labeled ? parent.width - 46px : parent.width;
height: parent.height;
text: root.text;
color: root.danger ? Theme.danger : root.active ? Theme.text-primary : Theme.text-secondary;
color: root.primary ? Theme.on-accent : root.danger ? Theme.danger : root.active ? Theme.text-primary : Theme.text-secondary;
font-size: Math.max(11px, root.text-size * Theme.scale);
horizontal-alignment: center;
horizontal-alignment: root.labeled ? left : center;
vertical-alignment: center;
overflow: elide;
}
@ -68,4 +135,5 @@ export component ActionButton inherits Rectangle {
return reject;
}
}
if root.tooltip != "" : Tooltip { TipBubble { text: root.tooltip; } }
}

View file

@ -2,7 +2,7 @@ import { Theme, ActionButton } from "theme.slint";
import { ThemeInput } from "controls.slint";
export component UnlockWindow inherits Window {
title: @tr("Vnox — unlock");
title: @tr("Vnox: unlock");
icon: @image-url("assets/vnox-mark.svg");
preferred-width: 480px;
preferred-height: 300px;

View file

@ -1,6 +1,64 @@
import { Theme, ActionButton } from "theme.slint";
import { AvatarView } from "avatar-view.slint";
import { Theme, ActionButton, Symbol, TipBubble } from "theme.slint";
export struct VoiceMemberItem { user_id: string, nickname: string, speaking: bool, avatar_text: string }
export struct VoiceMemberItem { user_id: string, nickname: string, speaking: bool, avatar_text: string, is_own: bool }
/// Round control of the voice room bar. `off` shows the muted state highlighted in red.
component RoundControl inherits Rectangle {
in property <string> icon;
in property <string> tooltip;
in property <bool> off: false;
in property <bool> leave: false;
callback clicked();
width: 52px; height: 52px;
border-radius: 26px;
background: root.leave ? (touch.has-hover ? Theme.danger.darker(10%) : Theme.danger)
: root.off ? Theme.danger.with-alpha(touch.has-hover ? 0.32 : 0.22)
: touch.has-hover ? Theme.bg-hover : Theme.bg-interactive;
border-width: keyboard.has-focus ? 2px : 1px;
border-color: keyboard.has-focus ? Theme.accent : root.off ? Theme.danger.with-alpha(0.5) : Theme.border;
accessible-role: button;
accessible-label: root.tooltip;
Symbol {
kind: root.icon;
ink: root.leave ? Theme.on-accent : root.off ? Theme.danger : Theme.text-primary;
width: 22px; height: 22px;
x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2;
}
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
keyboard := FocusScope {
focus-on-click: false;
key-pressed(event) => {
if event.text == " " || event.text == "\n" { root.clicked(); return accept; }
return reject;
}
}
if root.tooltip != "" : Tooltip { TipBubble { text: root.tooltip; } }
}
component ParticipantCard inherits Rectangle {
in property <VoiceMemberItem> member;
in property <image> own-avatar;
in property <bool> has-own-avatar;
border-radius: 16px;
background: Theme.bg-elevated;
border-width: root.member.speaking ? 2px : 1px;
border-color: root.member.speaking ? Theme.success : Theme.border;
VerticalLayout {
padding: 18px; spacing: 10px; alignment: center;
HorizontalLayout {
alignment: center;
AvatarView {
width: 80px; height: 80px;
source: root.own-avatar; has-source: root.has-own-avatar && root.member.is_own;
initials: root.member.avatar_text; mask: Theme.bg-elevated;
speaking: root.member.speaking;
}
}
Text { text: root.member.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.9375); font-weight: 600; horizontal-alignment: center; overflow: elide; }
Text { text: root.member.speaking ? @tr("Speaking") : @tr("In voice"); color: root.member.speaking ? Theme.success : Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-alignment: center; }
}
}
export component VoicePanel inherits Rectangle {
in-out property <[VoiceMemberItem]> members;
@ -10,59 +68,53 @@ export component VoicePanel inherits Rectangle {
in-out property <string> activity-banner;
in property <bool> joining;
in-out property <bool> push-to-talk;
in property <image> own-avatar;
in property <bool> has-own-avatar;
private property <length> gap: 14px;
private property <int> columns: Math.max(1, Math.floor((grid.width + root.gap) / (210px + root.gap)));
private property <length> card-width: (grid.width - (root.columns - 1) * root.gap) / root.columns;
callback preview-screen();
callback ptt-held(bool);
callback toggle-mic();
callback toggle-deafen();
callback leave-voice();
background: Theme.bg-base;
background: @linear-gradient(180deg, Theme.bg-base 0%, Theme.bg-surface 100%);
VerticalLayout {
spacing: 0;
Rectangle {
height: 56px; border-width: 1px; border-color: Theme.border;
HorizontalLayout {
padding-left: 22px; spacing: 12px;
Text { text: "◖"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 1.4375); width: 20px; vertical-alignment: center; }
padding-left: 22px; padding-right: 16px; spacing: 10px;
Symbol { kind: "volume-2"; ink: Theme.text-muted; width: 20px; height: 20px; y: (parent.height - self.height) / 2; }
Text { text: root.channel-name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; vertical-alignment: center; }
Text { text: @tr("{n} participant" | "{n} participants" % root.members.length); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125); vertical-alignment: center; }
Rectangle { horizontal-stretch: 1; }
ActionButton { text: @tr("Screen preview"); clicked => { root.preview-screen(); } }
}
}
VerticalLayout {
padding: 24px; spacing: 16px;
Text { text: @tr("{n} participant" | "{n} participants" % root.members.length); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125); }
Flickable {
grid := Flickable {
content-width: self.width;
VerticalLayout {
spacing: 12px;
for member in root.members: Rectangle {
height: 120px; border-radius: 12px;
background: Theme.bg-interactive;
border-width: member.speaking ? 2px : 1px;
border-color: member.speaking ? Theme.success : Theme.border;
HorizontalLayout {
padding: 24px; spacing: 18px;
Rectangle {
width: 58px; height: 58px; border-radius: 20px; background: Theme.avatar-bg;
Text { text: member.avatar_text; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 1.625); horizontal-alignment: center; vertical-alignment: center; }
}
VerticalLayout {
spacing: 5px;
Text { text: member.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0625); }
Text { text: member.speaking ? @tr("Speaking") : @tr("In voice"); color: member.speaking ? Theme.success : Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
}
Rectangle { horizontal-stretch: 1; }
}
}
if root.joining : Text { text: @tr("Joining voice…"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); }
Rectangle { vertical-stretch: 1; }
content-height: Math.max(self.height, Math.ceil(root.members.length / root.columns) * (170px + root.gap));
for member[index] in root.members: ParticipantCard {
x: Math.mod(index, root.columns) * (root.card-width + root.gap);
y: Math.floor(index / root.columns) * (170px + root.gap);
width: root.card-width; height: 170px;
member: member;
own-avatar: root.own-avatar;
has-own-avatar: root.has-own-avatar;
}
if root.members.length == 0 : Text { text: @tr("Joining voice…"); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); }
}
if root.push-to-talk : Rectangle {
height: 46px; background: ptt-area.pressed ? Theme.voice-bg : Theme.bg-interactive;
border-radius: 8px; border-width: ptt-focus.has-focus ? 1px : 0px; border-color: Theme.accent;
border-radius: 10px; border-width: ptt-focus.has-focus ? 1px : 0px; border-color: Theme.accent;
accessible-role: button; accessible-label: @tr("Push to talk");
Text { text: ptt-area.pressed ? @tr("Microphone is transmitting") : @tr("Hold here to talk"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-alignment: center; vertical-alignment: center; }
HorizontalLayout {
alignment: center; spacing: 10px;
Symbol { kind: "mic"; ink: ptt-area.pressed ? Theme.success : Theme.text-secondary; width: 18px; height: 18px; y: (parent.height - self.height) / 2; }
Text { text: ptt-area.pressed ? @tr("Microphone is transmitting") : @tr("Hold here to talk"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); vertical-alignment: center; }
}
ptt-area := TouchArea {
clicked => { ptt-focus.focus(); }
changed pressed => { root.ptt-held(self.pressed); }
@ -74,14 +126,13 @@ export component VoicePanel inherits Rectangle {
changed has-focus => { if !self.has-focus { root.ptt-held(false); } }
}
}
Text { text: root.activity-banner; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); height: 22px; }
Text { text: root.joining ? @tr("Joining voice…") : root.activity-banner; color: root.joining ? Theme.text-muted : Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); height: 22px; horizontal-alignment: center; }
HorizontalLayout {
spacing: 10px;
Rectangle { horizontal-stretch: 1; }
ActionButton { text: root.mic-enabled ? @tr("Mute microphone") : @tr("Unmute microphone"); danger: !root.mic-enabled; clicked => { root.toggle-mic(); } }
ActionButton { text: root.deafened ? @tr("Undeafen") : @tr("Deafen"); danger: root.deafened; clicked => { root.toggle-deafen(); } }
ActionButton { text: @tr("Leave room"); danger: true; clicked => { root.leave-voice(); } }
Rectangle { horizontal-stretch: 1; }
alignment: center; spacing: 14px;
RoundControl { icon: root.mic-enabled ? "mic" : "mic-off"; off: !root.mic-enabled; tooltip: root.mic-enabled ? @tr("Mute microphone") : @tr("Unmute microphone"); clicked => { root.toggle-mic(); } }
RoundControl { icon: root.deafened ? "headphone-off" : "headphones"; off: root.deafened; tooltip: root.deafened ? @tr("Undeafen") : @tr("Deafen"); clicked => { root.toggle-deafen(); } }
RoundControl { icon: "screen-share"; tooltip: @tr("Screen preview"); clicked => { root.preview-screen(); } }
RoundControl { icon: "phone-off"; leave: true; tooltip: @tr("Leave room"); clicked => { root.leave-voice(); } }
}
}
}

View file

@ -407,6 +407,35 @@ fn process_net_event(ui: &mut UiState, net: &NetHandle, event: NetEvent) {
}
}
/// Reaction click: removes the local user's reaction when it is already set, adds it otherwise.
pub fn reaction_command(
ui: &UiState,
own_user_id: &str,
channel_id: String,
message_id: String,
emoji: String,
) -> NetCommand {
let already = ui
.messages
.get(&channel_id)
.and_then(|messages| messages.iter().find(|m| m.message_id == message_id))
.and_then(|m| m.reactions.get(&emoji))
.is_some_and(|users| users.iter().any(|u| u == own_user_id));
if already {
NetCommand::ReactionRemove {
channel_id,
message_id,
emoji,
}
} else {
NetCommand::ReactionAdd {
channel_id,
message_id,
emoji,
}
}
}
fn into_msg(m: ChatMsg) -> ChatMessage {
ChatMessage {
message_id: m.message_id,
@ -1070,3 +1099,42 @@ mod voice_pipeline_tests {
assert!(!pipeline_should_stop(Some("a"), None));
}
}
#[cfg(test)]
mod reaction_tests {
use super::*;
fn message_with(reactions: &[(&str, &[&str])]) -> ChatMessage {
ChatMessage {
message_id: "m1".into(),
sender_id: "other".into(),
content: "hi".into(),
timestamp: 0,
edited: false,
reactions: reactions
.iter()
.map(|(emoji, users)| {
(
(*emoji).to_string(),
users.iter().map(|u| (*u).to_string()).collect(),
)
})
.collect(),
reply_to: None,
}
}
#[test]
fn clicking_a_reaction_toggles_the_local_users_vote() {
let mut ui = UiState::default();
ui.messages.insert(
"ch".into(),
vec![message_with(&[("👍", &["me", "x"]), ("🔥", &["x"])])],
);
let command =
|emoji: &str| reaction_command(&ui, "me", "ch".into(), "m1".into(), emoji.into());
assert!(matches!(command("👍"), NetCommand::ReactionRemove { .. }));
assert!(matches!(command("🔥"), NetCommand::ReactionAdd { .. }));
assert!(matches!(command("😀"), NetCommand::ReactionAdd { .. }));
}
}