voelin-ui: design system, shells and view models for the new design
The single 1700-line app.slint becomes a design system and screens that later waves can compose: - theme.slint: colour, radius, spacing and type tokens (dark and light, a runtime font scale); icons.slint: Lucide icons as tintable images. - components/: Button, IconButton, TextField, SearchBox, Select, Toggle, Slider, SegmentedTabs, Avatar, badges, Card, Meter, NavItem, ListItem, PopupMenu, Tooltip, Modal, Toast, ResizeHandle, Spinner, RichText and the EmojiPicker. - shells/: the desktop frame (server rail, top bar, sidebar with the user card) and the phone frame with a bottom navigation, switched at a breakpoint from the settings. - screens/: today's screens re-skinned (channels, chat, streams panel and viewer, settings page, home, dialogs, phone pages); all callbacks and properties keep their behaviour. Navigation state is the Nav global. On the Rust side app.rs keeps setup and event glue; servers.rs, chat.rs, settings_page.rs and appearance.rs hold the logic, vm/ the pure view models, bind/ the callbacks, dev.rs the development switches. Models are created once and updated row by row (vm::list::sync); each chat tab owns its lines model, so a message appends one row. Emoji come from the bundled Twemoji archive through a size-bounded image cache, split into runs that wrap with the text. New settings ui.theme, ui.font_scale, ui.narrow_breakpoint and ui.image_cache_mb apply live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
1 parent
529211bfc6
commit
c854053090
58 files changed
+8849
-2628
No files matched your search
@@ -0,0 +1,22 @@
|
||||
//! The chat view.
|
||||
|
||||
use slint::ComponentHandle;
|
||||
use voelin_model::{ChannelId, ChatTarget};
|
||||
|
||||
use crate::app::{Bridge, MainWindow, with_app};
|
||||
|
||||
pub(super) fn wire(ui: &MainWindow) {
|
||||
let bridge = ui.global::<Bridge>();
|
||||
bridge.on_open_channel_chat(|cid| {
|
||||
with_app(|app| app.open_chat(ChatTarget::Channel(cid as ChannelId), true));
|
||||
});
|
||||
bridge.on_select_tab(|i| {
|
||||
with_app(|app| app.select_tab(i as usize));
|
||||
});
|
||||
bridge.on_close_tab(|i| {
|
||||
with_app(|app| app.close_tab(i as usize));
|
||||
});
|
||||
bridge.on_send_message(|text| {
|
||||
with_app(|app| app.send_message(text.to_string()));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
//! Emoji: images for the `Images` global, and the picker's rows.
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use slint::{ComponentHandle, Model, ModelRc, VecModel};
|
||||
|
||||
use crate::app::{Emoji, EmojiCell, EmojiRow, Images, MainWindow};
|
||||
use crate::emoji::{self, PickerEmoji};
|
||||
use crate::images;
|
||||
|
||||
/// Rows of `columns` cells.
|
||||
fn rows(emoji: Vec<PickerEmoji>, columns: usize) -> Vec<EmojiRow> {
|
||||
emoji
|
||||
.chunks(columns.max(1))
|
||||
.map(|chunk| EmojiRow {
|
||||
cells: ModelRc::from(Rc::new(VecModel::from(
|
||||
chunk
|
||||
.iter()
|
||||
.map(|e| EmojiCell {
|
||||
key: e.key.into(),
|
||||
name: e.name.into(),
|
||||
text: e.text.clone().into(),
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
))),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn show(ui: &MainWindow, category: i32, list: Vec<PickerEmoji>) {
|
||||
let global = ui.global::<Emoji>();
|
||||
let columns = usize::try_from(global.get_columns()).unwrap_or(8);
|
||||
global.set_category(category);
|
||||
global.set_rows(ModelRc::from(Rc::new(VecModel::from(rows(list, columns)))));
|
||||
}
|
||||
|
||||
pub(super) fn wire(ui: &MainWindow) {
|
||||
ui.global::<Images>().on_emoji(|key| images::emoji(&key));
|
||||
let global = ui.global::<Emoji>();
|
||||
let weak = ui.as_weak();
|
||||
global.on_load(move || {
|
||||
if let Some(ui) = weak.upgrade()
|
||||
&& ui.global::<Emoji>().get_rows().row_count() == 0
|
||||
{
|
||||
let category = ui.global::<Emoji>().get_category().max(0);
|
||||
show(&ui, category, emoji::archive().category(category as usize));
|
||||
}
|
||||
});
|
||||
let weak = ui.as_weak();
|
||||
global.on_show_category(move |category| {
|
||||
if let Some(ui) = weak.upgrade() {
|
||||
show(&ui, category, emoji::archive().category(category.max(0) as usize));
|
||||
}
|
||||
});
|
||||
let weak = ui.as_weak();
|
||||
global.on_search(move |text| {
|
||||
let Some(ui) = weak.upgrade() else { return };
|
||||
if text.trim().is_empty() {
|
||||
let category = ui.global::<Emoji>().get_category().max(0);
|
||||
show(&ui, category, emoji::archive().category(category as usize));
|
||||
} else {
|
||||
show(&ui, -1, emoji::archive().search(&text));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn rows_of_cells() {
|
||||
let list = emoji::archive().category(0);
|
||||
let n = list.len();
|
||||
let rows = rows(list, 8);
|
||||
assert_eq!(rows.len(), n.div_ceil(8));
|
||||
assert_eq!(rows[0].cells.row_count(), 8);
|
||||
assert_eq!(rows[0].cells.row_data(0).unwrap().key, "1f600");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//! Callbacks of the screens, wired to the app. One module per screen or
|
||||
//! area; each has a `wire` that the window calls once.
|
||||
|
||||
mod chat;
|
||||
mod emoji;
|
||||
mod servers;
|
||||
mod settings;
|
||||
mod streams;
|
||||
|
||||
use crate::app::MainWindow;
|
||||
|
||||
/// Connect every callback of the window.
|
||||
pub(crate) fn wire(ui: &MainWindow) {
|
||||
servers::wire(ui);
|
||||
chat::wire(ui);
|
||||
streams::wire(ui);
|
||||
settings::wire(ui);
|
||||
emoji::wire(ui);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//! The rail, the server card, the channel tree and the voice controls.
|
||||
|
||||
use slint::ComponentHandle;
|
||||
use voelin_core::Command;
|
||||
use voelin_model::ChannelId;
|
||||
|
||||
use crate::app::{Bridge, MainWindow, with_app};
|
||||
|
||||
pub(super) fn wire(ui: &MainWindow) {
|
||||
let bridge = ui.global::<Bridge>();
|
||||
bridge.on_select_server(|id| {
|
||||
with_app(|app| app.select_server(id as i64));
|
||||
});
|
||||
bridge.on_search(|text| {
|
||||
with_app(|app| app.search(text.to_string()));
|
||||
});
|
||||
bridge.on_connect_voice(|| {
|
||||
with_app(|app| app.connect_voice());
|
||||
});
|
||||
bridge.on_disconnect_voice(|| {
|
||||
with_app(|app| app.command(|session| Command::DisconnectVoice { session }));
|
||||
});
|
||||
bridge.on_toggle_observe(|| {
|
||||
with_app(|app| app.toggle_observe());
|
||||
});
|
||||
bridge.on_join_channel(|cid| {
|
||||
with_app(|app| {
|
||||
app.command(|session| Command::MoveToChannel {
|
||||
session,
|
||||
channel: cid as ChannelId,
|
||||
password: None,
|
||||
})
|
||||
});
|
||||
});
|
||||
bridge.on_toggle_collapse(|cid| {
|
||||
with_app(|app| app.toggle_collapse(cid as ChannelId));
|
||||
});
|
||||
bridge.on_set_input_muted(|muted| {
|
||||
with_app(|app| app.command(|session| Command::SetInputMuted { session, muted }));
|
||||
});
|
||||
bridge.on_set_output_muted(|muted| {
|
||||
with_app(|app| app.command(|session| Command::SetOutputMuted { session, muted }));
|
||||
});
|
||||
bridge.on_push_to_talk(|on| {
|
||||
with_app(|app| app.command(|session| Command::SetTransmitting { session, on }));
|
||||
});
|
||||
bridge.on_edit_bookmark(|id| with_app(|app| app.bookmark_form(id as i64)).unwrap_or_default());
|
||||
bridge.on_save_bookmark(|form| {
|
||||
with_app(|app| app.save_bookmark(form));
|
||||
});
|
||||
bridge.on_delete_bookmark(|id| {
|
||||
with_app(|app| app.delete_bookmark(id as i64));
|
||||
});
|
||||
bridge.on_open_client(|id| with_app(|app| app.open_client(id as u16)).unwrap_or(false));
|
||||
bridge.on_client_audio_changed(|form| {
|
||||
with_app(|app| app.client_playback_changed(&form));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//! The settings page, crash reports and About.
|
||||
|
||||
use slint::{ComponentHandle, SharedString};
|
||||
|
||||
use crate::app::{Bridge, MainWindow, with_app};
|
||||
|
||||
pub(super) fn wire(ui: &MainWindow) {
|
||||
let bridge = ui.global::<Bridge>();
|
||||
bridge.on_open_settings(|| {
|
||||
with_app(|app| app.open_settings());
|
||||
});
|
||||
bridge.on_close_settings(|| {
|
||||
with_app(|app| app.close_settings());
|
||||
});
|
||||
bridge.on_audio_changed(|form| {
|
||||
with_app(|app| app.audio_changed(&form));
|
||||
});
|
||||
bridge.on_toggle_mic_test(|| {
|
||||
with_app(|app| app.set_mic_test(!app.mic_test));
|
||||
});
|
||||
bridge.on_apply_ptt(|enabled, key| {
|
||||
with_app(|app| app.apply_ptt(enabled, key.to_string()));
|
||||
});
|
||||
bridge.on_set_h264(|enabled| {
|
||||
with_app(|app| app.set_h264(enabled));
|
||||
});
|
||||
bridge.on_download_h264(|| {
|
||||
with_app(|app| app.download_h264());
|
||||
});
|
||||
bridge.on_appearance_changed(|form| {
|
||||
with_app(|app| app.appearance_changed(&form));
|
||||
});
|
||||
bridge.on_set_crash_reports(|enabled| {
|
||||
with_app(|app| app.set_crash_reports(enabled));
|
||||
});
|
||||
bridge.on_open_crash_folder(|| {
|
||||
with_app(|app| app.open_crash_folder());
|
||||
});
|
||||
bridge.on_delete_crash_reports(|| {
|
||||
with_app(|app| app.delete_crash_reports());
|
||||
});
|
||||
bridge.on_dismiss_crash_notice(|| {
|
||||
with_app(|app| {
|
||||
if let Some(ui) = app.ui.upgrade() {
|
||||
ui.global::<Bridge>().set_crash_notice(SharedString::new());
|
||||
}
|
||||
});
|
||||
});
|
||||
bridge.on_open_about(|| {
|
||||
with_app(|app| app.load_notices());
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//! The streams panel, the share dialog and the viewer.
|
||||
|
||||
use slint::ComponentHandle;
|
||||
|
||||
use crate::app::{Bridge, MainWindow, with_app};
|
||||
|
||||
pub(super) fn wire(ui: &MainWindow) {
|
||||
let bridge = ui.global::<Bridge>();
|
||||
bridge.on_open_share(|| with_app(|app| app.open_share()).unwrap_or_default());
|
||||
bridge.on_start_share(|form| {
|
||||
with_app(|app| app.start_share(form));
|
||||
});
|
||||
bridge.on_stop_share(|| {
|
||||
with_app(|app| app.stop_share());
|
||||
});
|
||||
bridge.on_respond_viewer(|viewer, accept| {
|
||||
with_app(|app| app.respond_viewer(viewer as u16, accept));
|
||||
});
|
||||
bridge.on_kick_viewer(|viewer| {
|
||||
with_app(|app| app.kick_viewer(viewer as u16));
|
||||
});
|
||||
bridge.on_watch_stream(|id| {
|
||||
with_app(|app| app.watch_stream(id.to_string()));
|
||||
});
|
||||
bridge.on_show_viewer(|| {
|
||||
with_app(|app| app.show_viewer(true));
|
||||
});
|
||||
bridge.on_hide_viewer(|| {
|
||||
with_app(|app| app.show_viewer(false));
|
||||
});
|
||||
bridge.on_leave_stream(|| {
|
||||
with_app(|app| app.leave_stream());
|
||||
});
|
||||
bridge.on_set_stream_volume(|volume| {
|
||||
with_app(|app| app.set_stream_volume(volume));
|
||||
});
|
||||
bridge.on_toggle_fullscreen(|| {
|
||||
with_app(|app| app.toggle_fullscreen());
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user