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
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
//! The server rail.
|
|
|
|
use voelin_core::{ObserveState, SessionState, VoiceState};
|
|
use voelin_store::Bookmark;
|
|
|
|
use crate::app::ServerItem;
|
|
use crate::vm::avatar;
|
|
|
|
/// "offline", "connecting", "observing" or "connected".
|
|
pub fn status(state: &SessionState) -> &'static str {
|
|
match (state.voice, state.observe) {
|
|
(VoiceState::Connected, _) => "connected",
|
|
(VoiceState::Connecting, _) | (_, ObserveState::Connecting) => "connecting",
|
|
(_, ObserveState::Observing) => "observing",
|
|
_ => "offline",
|
|
}
|
|
}
|
|
|
|
/// A server of the rail. `unread`: messages in its chats; `live`:
|
|
/// streams in our channel there.
|
|
pub fn item(bookmark: &Bookmark, state: &SessionState, unread: i32, live: bool) -> ServerItem {
|
|
ServerItem {
|
|
id: bookmark.id as i32,
|
|
name: bookmark.name.clone().into(),
|
|
address: bookmark.address.clone().into(),
|
|
status: status(state).into(),
|
|
initials: avatar::initials(&bookmark.name).into(),
|
|
tint: avatar::tint(&bookmark.name),
|
|
unread,
|
|
live,
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn states() {
|
|
let mut s = SessionState::default();
|
|
assert_eq!(status(&s), "offline");
|
|
s.observe = ObserveState::Observing;
|
|
assert_eq!(status(&s), "observing");
|
|
s.voice = VoiceState::Connecting;
|
|
assert_eq!(status(&s), "connecting");
|
|
s.voice = VoiceState::Connected;
|
|
assert_eq!(status(&s), "connected");
|
|
}
|
|
}
|