Implement Android Room UI and customizable palette
android-ci / android-arm64 (push) Successful in 17m10s
android-ci / android-arm64 (push) Successful in 17m10s
This commit is contained in:
1 parent
057bfae87c
commit
87265a3e75
26 files changed
+825
-135
No files matched your search
@@ -251,6 +251,10 @@ jobs:
|
||||
cargo test --locked -p teamspeach-native --no-default-features --target x86_64-unknown-linux-gnu --lib only_explicit_output_device_actions_request_platform_routing --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-native --no-default-features --target x86_64-unknown-linux-gnu --lib android_attachment_ --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-native --no-default-features --target x86_64-unknown-linux-gnu --lib app::connections::tests --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-native --no-default-features --target x86_64-unknown-linux-gnu --lib ui::theme::tests --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-native --no-default-features --target x86_64-unknown-linux-gnu --lib services::prefs::tests::android_palette --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-native --no-default-features --target x86_64-unknown-linux-gnu --lib ui::shell::tests --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-native --no-default-features --target x86_64-unknown-linux-gnu --lib ui::i18n::tests --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-core --target x86_64-unknown-linux-gnu --lib audio::tests --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
cargo test --locked -p teamspeach-core --target x86_64-unknown-linux-gnu --lib output::tests --jobs "$CARGO_BUILD_JOBS" -- --test-threads=1
|
||||
} 2>&1 | tee .android-ci/audio-test-results/tests.log
|
||||
|
||||
@@ -97,7 +97,7 @@ components:
|
||||
|
||||
## Overview
|
||||
|
||||
**North Star: "The official TeamSpeak 6 client, value for value."**
|
||||
**Desktop North Star: "The official TeamSpeak 6 client, value for value."**
|
||||
|
||||
The owner asked for the installed TeamSpeak 6 client's design, without reinterpretation. Two earlier
|
||||
TeamsPeach worlds (flat warm-neutral, then the Liquid Glass approximation) are retired. The target values
|
||||
@@ -115,6 +115,25 @@ and historical non-brand pictograms, have provenance/redistribution limitations
|
||||
The official JavaScript application and removed browser implementation are historical references only,
|
||||
not product runtime dependencies. Native cutover does not establish visual or functional acceptance.
|
||||
|
||||
### Android: Room (approved 2026-11-15)
|
||||
|
||||
The owner selected the entire **Room** direction from the interactive Android comparison, not a blend
|
||||
of the alternatives. This is an Android-only exception to desktop source parity. The reference is the
|
||||
Room variant in `target/tmp/android-ui-concepts/` and its captures in `target/tmp/android-ui-review/`;
|
||||
these local design artifacts are not native-runtime acceptance evidence.
|
||||
|
||||
The current voice channel is the primary surface: centered channel/server context, a responsive grid
|
||||
of participants, speaking emphasis from actual state, and a persistent rounded voice-control strip.
|
||||
Channels, channel chat, and profile/settings have separate labelled navigation destinations. Secondary
|
||||
server, contact, file and moderation operations remain reachable rather than being removed for visual
|
||||
simplicity. Phone navigation changes to a rail/split arrangement at wider windows.
|
||||
|
||||
Start with the TS6 palette and bundled Noto Sans, but allow Android users to edit accent, background,
|
||||
surface and text colors through a preview/save/cancel/reset workflow. Accent fill and readable accent
|
||||
text are separate roles; user palettes must not make controls or status labels illegible. Insets,
|
||||
IME, font scale, Back, focus and hold-release behavior constrain the layout. The installed Windows
|
||||
baseline, its three-pane composition, and its preference behavior are unchanged.
|
||||
|
||||
## Colors
|
||||
|
||||
Dark is the default for new profiles; light follows the official light module. Native stock token data
|
||||
|
||||
@@ -127,7 +127,20 @@ identity/profile contents, device addresses или чужую активност
|
||||
- `.ua/knowledge-graph.json` старый; использовать как навигацию, выводы проверять source. Без полного
|
||||
перескана/автообновления и без перезапуска Understand на каждую небольшую правку.
|
||||
|
||||
## 7. Ссылки и архив
|
||||
## 7. Android Room UI — выбранное направление
|
||||
|
||||
- Владелец выбрал Room целиком; Android-only исключение из desktop-паритета записано в `DESIGN.md`.
|
||||
- `runtime/model.rs::Snapshot.room` проецирует всех участников своего канала, независимо от collapsed tree.
|
||||
`ui/shell.rs` владеет Room-навигацией/Back и captured targets; `ui/shell.slint` — сеткой участников,
|
||||
постоянным voice dock, каналами/чатом/профилем и доступом к прежним secondary-функциям.
|
||||
- `services/prefs.rs` валидирует `androidPalette`; `runtime/settings_actions/themes.rs` владеет preview,
|
||||
атомарным сохранением и отменой. `ui/theme.rs` отделяет контрастный текст акцента от цвета заливки.
|
||||
Null сохраняет штатную/package-тему; desktop override не применяет. Preview не должен переживать уход из Settings.
|
||||
- Каталог EN/RU общий; default **English**, Russian выбирается в Appearance, сохранённый язык сохраняется.
|
||||
- На рабочей базе `057bfae`: integrated Slint compile и изолированные реальные i18n tests3 прошли.
|
||||
Полный Rust/APK и проверка реального устройства ещё не завершены; HTML-прототип не native acceptance.
|
||||
|
||||
## 8. Ссылки и архив
|
||||
|
||||
- [Handoff](mobile-port-progress.md) — текущий кандидат, открытая работа и правила продолжения.
|
||||
- [Android AudioManager](https://developer.android.com/reference/android/media/AudioManager),
|
||||
|
||||
@@ -50,6 +50,22 @@ APK4955 SHA256: `6092ff8801bf38cd6d91f666920fe21162737f51c5425899fd3f6a491a3b85a
|
||||
|
||||
Не откатывать кандидат и не трогать постороннее изменение `.ua/meta.json`; сверять реальное дерево.
|
||||
|
||||
## Android UI — выбор направления
|
||||
|
||||
- На ревизии `057bfae` владелец выбрал voice-first и разрешил собственный Android-стиль:
|
||||
исходная палитра TS6, редактирование цветов в настройках. Windows остаётся без изменений.
|
||||
- До реализации Slint запрошено HTML-сравнение пяти вариантов с одинаковыми сценариями.
|
||||
Локальный прототип: `target/tmp/android-ui-concepts/index.html` (+ CSS, JS, bundled Noto Sans).
|
||||
**Владелец выбрал «Комнату» целиком**, без смешивания вариантов; начат перенос в Android Slint.
|
||||
- В Android Slint перенесены Room-навигация/участники/voice dock, чат и формы; реальные данные идут из
|
||||
`Snapshot.room`, выбор канала/участника и команды остаются typed intents. DSP/media/platform не менялись.
|
||||
- Добавлен `androidPalette`: preview/save/cancel/reset, hex/RGB, контрастные роли; desktop не применяет override.
|
||||
По умолчанию **English**, Russian — через настройки; сохранённый язык не сбрасывается.
|
||||
- Проверено локально: integrated Slint compile PASS; реальные `ui/i18n.rs` tests **3/3 PASS**.
|
||||
Rust/APK CI и новая device-проверка ещё нужны; HTML screenshots не подтверждают нативный результат.
|
||||
- Изменения на базе `057bfae` подготовлены к отдельному mobile CI. Установку/сброс телефона согласовать.
|
||||
Android Room-исключение записано в DESIGN.md; desktop baseline сохраняется.
|
||||
|
||||
## Следующее действие
|
||||
|
||||
- Дождаться новой CI-проверки TX-исходников a0a9b14; не менять код ради необъяснённого обрыва CI.
|
||||
|
||||
@@ -2302,4 +2302,53 @@
|
||||
,"native.audio.new_device": "New device"
|
||||
,"native.audio.copy_template": "Use as template"
|
||||
,"native.audio.apply_template": "Apply template"
|
||||
,"native.room.room": "Room"
|
||||
,"native.room.channels": "Channels"
|
||||
,"native.room.chat": "Chat"
|
||||
,"native.room.profile": "Profile"
|
||||
,"native.room.profile_settings": "Profile and settings"
|
||||
,"native.room.switch": "Change room"
|
||||
,"native.room.open_chat": "Open channel chat"
|
||||
,"native.room.members": "Participants in voice: {count}"
|
||||
,"native.room.listening": "Listening"
|
||||
,"native.room.speaking": "Speaking"
|
||||
,"native.room.microphone_on": "Mic on"
|
||||
,"native.room.microphone_off": "Mic off"
|
||||
,"native.room.sound_on": "Sound on"
|
||||
,"native.room.sound_off": "Sound off"
|
||||
,"native.room.disconnect": "Disconnect from server"
|
||||
,"native.room.empty": "Connect to a server to see your room and its participants."
|
||||
,"native.room.streams": "Streams"
|
||||
,"native.room.settings.conversation": "During a conversation"
|
||||
,"native.room.settings.personal": "Make it yours"
|
||||
,"native.room.settings.application": "Application"
|
||||
,"native.room.settings.profile": "Your local identity"
|
||||
,"native.room.settings.profile.empty": "Your profile"
|
||||
,"native.room.settings.identity": "Name and local profile"
|
||||
,"native.room.settings.privacy": "External links, trusted hosts and confirmations"
|
||||
,"native.room.settings.appearance": "Palette, interface colors and text size"
|
||||
,"native.room.settings.audio": "Microphone, output and transmission mode"
|
||||
,"native.room.settings.video": "Decoding and video capabilities"
|
||||
,"native.room.settings.keys": "Push-to-talk and keyboard shortcuts"
|
||||
,"native.room.settings.chats": "Messages, formatting and ignored users"
|
||||
,"native.room.settings.whispers": "Receive rules and whisper lists"
|
||||
,"native.room.settings.notifications": "Event sounds and message alerts"
|
||||
,"native.room.settings.files": "Download location and transfer limits"
|
||||
,"native.room.settings.system": "Platform integration and permissions"
|
||||
,"native.room.settings.about": "Version, updates, licenses and diagnostics"
|
||||
,"native.palette.title": "Interface palette"
|
||||
,"native.palette.preview": "Preview"
|
||||
,"native.palette.preview.info": "Your colors are previewed throughout the interface. Nothing is saved until you choose Save."
|
||||
,"native.palette.presets": "Presets"
|
||||
,"native.palette.ts6": "TS6"
|
||||
,"native.palette.graphite": "Graphite"
|
||||
,"native.palette.light": "Light"
|
||||
,"native.palette.accent": "Accent"
|
||||
,"native.palette.background": "Background"
|
||||
,"native.palette.surface": "Surfaces"
|
||||
,"native.palette.foreground": "Text"
|
||||
,"native.palette.contrast.ok": "Text remains readable"
|
||||
,"native.palette.contrast.error": "Check your colors"
|
||||
,"native.palette.contrast.info": "Use #RRGGBB colors. Text must have at least 4.5:1 contrast on every surface. The last readable palette stays visible while an edit is invalid."
|
||||
,"native.palette.reset": "Reset to TS6"
|
||||
}
|
||||
@@ -2316,4 +2316,53 @@
|
||||
,"native.audio.new_device": "Новое устройство"
|
||||
,"native.audio.copy_template": "Использовать как шаблон"
|
||||
,"native.audio.apply_template": "Применить шаблон"
|
||||
,"native.room.room": "Комната"
|
||||
,"native.room.channels": "Каналы"
|
||||
,"native.room.chat": "Чат"
|
||||
,"native.room.profile": "Профиль"
|
||||
,"native.room.profile_settings": "Профиль и настройки"
|
||||
,"native.room.switch": "Сменить комнату"
|
||||
,"native.room.open_chat": "Открыть чат канала"
|
||||
,"native.room.members": "Участников в голосе: {count}"
|
||||
,"native.room.listening": "Слушает"
|
||||
,"native.room.speaking": "Говорит"
|
||||
,"native.room.microphone_on": "Микр. вкл."
|
||||
,"native.room.microphone_off": "Микр. выкл."
|
||||
,"native.room.sound_on": "Звук вкл."
|
||||
,"native.room.sound_off": "Звук выкл."
|
||||
,"native.room.disconnect": "Отключиться от сервера"
|
||||
,"native.room.empty": "Подключитесь к серверу, чтобы увидеть свою комнату и участников."
|
||||
,"native.room.streams": "Трансляции"
|
||||
,"native.room.settings.conversation": "Во время разговора"
|
||||
,"native.room.settings.personal": "Под себя"
|
||||
,"native.room.settings.application": "Приложение"
|
||||
,"native.room.settings.profile": "Ваша локальная личность"
|
||||
,"native.room.settings.profile.empty": "Ваш профиль"
|
||||
,"native.room.settings.identity": "Имя и локальный профиль"
|
||||
,"native.room.settings.privacy": "Внешние ссылки, доверенные сайты и подтверждения"
|
||||
,"native.room.settings.appearance": "Палитра, цвета интерфейса и размер текста"
|
||||
,"native.room.settings.audio": "Микрофон, выход и режим передачи"
|
||||
,"native.room.settings.video": "Декодирование и возможности видео"
|
||||
,"native.room.settings.keys": "Push-to-talk и сочетания клавиш"
|
||||
,"native.room.settings.chats": "Сообщения, оформление и игнорируемые пользователи"
|
||||
,"native.room.settings.whispers": "Правила приёма и списки шёпота"
|
||||
,"native.room.settings.notifications": "Звуки событий и уведомления о сообщениях"
|
||||
,"native.room.settings.files": "Папка загрузок и ограничения передачи"
|
||||
,"native.room.settings.system": "Интеграция с системой и разрешения"
|
||||
,"native.room.settings.about": "Версия, обновления, лицензии и диагностика"
|
||||
,"native.palette.title": "Палитра интерфейса"
|
||||
,"native.palette.preview": "Предпросмотр"
|
||||
,"native.palette.preview.info": "Ваши цвета сразу видны во всём интерфейсе. Изменения сохранятся только после нажатия «Сохранить»."
|
||||
,"native.palette.presets": "Готовые палитры"
|
||||
,"native.palette.ts6": "TS6"
|
||||
,"native.palette.graphite": "Графит"
|
||||
,"native.palette.light": "Светлая"
|
||||
,"native.palette.accent": "Акцент"
|
||||
,"native.palette.background": "Фон"
|
||||
,"native.palette.surface": "Поверхности"
|
||||
,"native.palette.foreground": "Текст"
|
||||
,"native.palette.contrast.ok": "Текст остаётся читаемым"
|
||||
,"native.palette.contrast.error": "Проверьте цвета"
|
||||
,"native.palette.contrast.info": "Введите цвета в формате #RRGGBB. Контраст текста на каждой поверхности должен быть не ниже 4,5:1. Пока цвет некорректен, остаётся видна сохранённая читаемая палитра."
|
||||
,"native.palette.reset": "Сбросить к TS6"
|
||||
}
|
||||
@@ -11,6 +11,7 @@ pub struct Snapshot {
|
||||
pub audio_input_starts:u64,pub audio_output_starts:u64,
|
||||
pub connections:Arc<ConnectionsSnapshot>,pub tabs:Vec<Tab>,pub tree:Vec<Entry>,pub bookmarks:Vec<Entry>,pub contacts:Vec<Entry>,
|
||||
pub detail:Detail,pub actions:Vec<Action>,pub voice:Option<Voice>,pub profile_form:Option<Form>,pub dialog:Option<Form>,
|
||||
pub room:Room,
|
||||
pub last_error:Option<crate::services::ServiceError>,pub settings_completed:u64,
|
||||
pub status:String,pub error:String,pub loading:bool,pub destination:Destination,
|
||||
pub settings:SettingsSnapshot,pub settings_view:ViewState,pub chat:ChatPresentation,
|
||||
@@ -22,7 +23,7 @@ pub struct Snapshot {
|
||||
pub insets:crate::platform::lifecycle::Insets,pub text_scale:f32,pub reduced_motion:bool,pub high_contrast:bool,
|
||||
}
|
||||
impl Default for Snapshot {
|
||||
fn default()->Self{Self{revision:0,ready:false,last_error:None,settings_completed:0,audio_input_active:false,audio_output_active:false,audio_input_starts:0,audio_output_starts:0,bootstrap:BootstrapState::Loading,root:None,catalog:Catalog::default(),connections:Arc::default(),tabs:vec![],tree:vec![],bookmarks:vec![],contacts:vec![],detail:Detail::default(),actions:vec![],voice:None,profile_form:None,dialog:None,status:String::new(),error:String::new(),loading:true,destination:Destination::Servers,settings:SettingsSnapshot::default(),settings_view:ViewState::default(),chat:ChatPresentation::default(),streams:vec![],#[cfg(feature="webrtc")]frames:vec![],theme:None,theme_revision:0,theme_fonts:vec![],insets:Default::default(),text_scale:1.,reduced_motion:false,high_contrast:false}}
|
||||
fn default()->Self{Self{revision:0,ready:false,last_error:None,settings_completed:0,audio_input_active:false,audio_output_active:false,audio_input_starts:0,audio_output_starts:0,bootstrap:BootstrapState::Loading,root:None,catalog:Catalog::default(),connections:Arc::default(),tabs:vec![],tree:vec![],bookmarks:vec![],contacts:vec![],detail:Detail::default(),actions:vec![],voice:None,room:Room::default(),profile_form:None,dialog:None,status:String::new(),error:String::new(),loading:true,destination:Destination::Servers,settings:SettingsSnapshot::default(),settings_view:ViewState::default(),chat:ChatPresentation::default(),streams:vec![],#[cfg(feature="webrtc")]frames:vec![],theme:None,theme_revision:0,theme_fonts:vec![],insets:Default::default(),text_scale:1.,reduced_motion:false,high_contrast:false}}
|
||||
}
|
||||
pub struct AppState {
|
||||
pub snapshot:Snapshot,pub selected:Option<Target>,pub expanded:HashSet<(String,u64)>,pub folder:Option<String>,
|
||||
@@ -64,7 +65,8 @@ impl AppState {
|
||||
.and_then(|connection|connection.server.as_ref())
|
||||
.and_then(|server|server["channels"].as_array().and_then(|channels|channels.iter().find(|channel|channel["id"].as_u64()==server["own_channel_id"].as_u64())))
|
||||
.and_then(|channel|channel["name"].as_str()) {
|
||||
voice.status=format!("{}: {channel}",c.text("ui.channel"));
|
||||
voice.title=channel.into();
|
||||
voice.status=c.text(if voice.transmitting{"native.room.speaking"}else if voice.deafened{"native.room.sound_off"}else if voice.muted{"native.room.listening"}else{"native.room.microphone_on"});
|
||||
}
|
||||
}
|
||||
self.snapshot.actions=actions(&Target::application(),&[Operation::NewConnection,Operation::BookmarkCreate,Operation::BookmarkFolderCreate,Operation::ContactAdd,Operation::OpenLogs],&c);
|
||||
@@ -74,8 +76,38 @@ impl AppState {
|
||||
for bookmark in prefs["savedServers"].as_array().into_iter().flatten(){if bookmark["folder"].as_str()!=self.folder.as_deref(){continue}if let Some(id)=bookmark["id"].as_str(){let target=Target{entity:Entity::Bookmark(id.into()),name:bookmark["name"].as_str().unwrap_or_default().into(),..Target::application()};let mut e=entry(target.clone(),format!("bookmark:{id}"),0);e.subtitle=bookmark["address"].as_str().unwrap_or_default().into();e.actions=actions(&target,&[Operation::BookmarkConnect,Operation::BookmarkEdit,Operation::BookmarkRename,Operation::BookmarkDuplicate,Operation::BookmarkMove,Operation::BookmarkPasswordSet,Operation::BookmarkPasswordReveal,Operation::BookmarkPasswordClear,Operation::BookmarkDelete],&c);self.snapshot.bookmarks.push(e);}}
|
||||
self.snapshot.contacts.clear();for contact in prefs["contacts"].as_array().into_iter().flatten(){if let Some(uid)=contact["uid"].as_str(){let target=Target{entity:Entity::Contact(uid.into()),name:contact["alias"].as_str().filter(|s|!s.is_empty()).or_else(||contact["name"].as_str()).unwrap_or(uid).into(),..Target::application()};let mut e=entry(target.clone(),format!("contact:{uid}"),0);e.subtitle=uid.into();e.actions=actions(&target,&[Operation::ContactChat,Operation::ContactRename,Operation::ContactIgnore,Operation::ContactUnignore,Operation::ContactRemove],&c);self.snapshot.contacts.push(e);}}
|
||||
if self.detail_target.as_ref().is_some_and(|t|ctx.require_target(t).is_err()){self.detail_target=None;self.snapshot.detail=Detail::default();}
|
||||
#[cfg(target_os="android")]
|
||||
if self.snapshot.destination!=Destination::Settings {
|
||||
super::settings_actions::cancel_palette_preview(ctx)?;
|
||||
if self.snapshot.settings_view.page()==crate::ui::settings::Page::Palette {self.snapshot.settings_view.pages.clear();}
|
||||
}
|
||||
self.snapshot.settings=super::settings_actions::project(ctx,&self.snapshot.settings_view)?;
|
||||
self.snapshot.chat=super::chat_actions::project(ctx).await?;
|
||||
#[cfg(target_os="android")]
|
||||
{
|
||||
self.snapshot.room=Room::default();
|
||||
if let Some(connection)=viewed.filter(|connection|connection.is_connected()) {
|
||||
if let Some(server)=connection.server.as_ref() {
|
||||
if let Some(channel_id)=server["own_channel_id"].as_u64().filter(|id|*id>0) {
|
||||
let room=&mut self.snapshot.room;
|
||||
room.server=server["server"]["name"].as_str().unwrap_or(&connection.address).into();
|
||||
room.title=server["channels"].as_array().into_iter().flatten().find(|channel|channel["id"].as_u64()==Some(channel_id)).and_then(|channel|channel["name"].as_str()).unwrap_or_default().into();
|
||||
room.target=Some(Target{session:Some(connection.key.clone()),entity:Entity::Channel{id:channel_id},name:room.title.clone(),own_channel_id:Some(channel_id)});
|
||||
for client in server["clients"].as_array().into_iter().flatten().filter(|client|client["channel_id"].as_u64()==Some(channel_id)) {
|
||||
let (Some(id),Some(uid))=(client["id"].as_u64().and_then(|id|u16::try_from(id).ok()),client["uid"].as_str()) else {continue};
|
||||
let target=Target{session:Some(connection.key.clone()),entity:Entity::Client{id,uid:uid.into(),channel_id},name:client["nickname"].as_str().unwrap_or_default().into(),own_channel_id:Some(channel_id)};
|
||||
let mut participant=entry(target.clone(),format!("client:{id}:{uid}"),0);
|
||||
participant.muted=client["input_muted"]==true;
|
||||
participant.talking=if client["id"]==server["own_client_id"] {connection.audio.transmitting && ctx.microphone_enabled(&connection.key)} else {connection.talking.contains(&id)};
|
||||
participant.subtitle=c.text(if participant.talking{"native.room.speaking"}else if participant.muted{"native.room.microphone_off"}else{"native.room.listening"});
|
||||
participant.actions=actions(&target,&[Operation::ClientVolume,Operation::ClientPrivateChat,Operation::ClientInfo,Operation::ClientConnectionInfo,Operation::ClientPoke,Operation::ClientWhisperAdd,Operation::ClientMove,Operation::ClientKickChannel,Operation::ClientKickServer,Operation::ClientBan,Operation::ClientCommander,Operation::ClientServerGroupAdd,Operation::ClientServerGroupRemove,Operation::ClientChannelGroupSet,Operation::ClientPermissions,Operation::ClientChannelPermissionSet,Operation::ClientChannelPermissionRemove,Operation::ClientAvatarChoose,Operation::ClientAvatarDelete,Operation::TalkGrant,Operation::TalkRevoke,Operation::ContactAdd],&c);
|
||||
room.participants.push(participant);
|
||||
}
|
||||
room.chat_id=self.snapshot.chat.tabs.iter().find(|tab|tab.target.session==connection.key && matches!(tab.target.target,crate::ui::chat::ChatTarget::Channel(id) if id==channel_id)).map(|tab|format!("{}\u{1f}{}\u{1f}{:?}\u{1f}{}",tab.target.scope.base.identity,tab.target.scope.base.server,tab.target.scope.kind,tab.target.scope.key)).unwrap_or_default();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.snapshot.streams=super::stream_actions::project(ctx).await?;
|
||||
#[cfg(feature="webrtc")] {self.snapshot.frames=super::stream_actions::frame_sources(ctx).await;}
|
||||
self.snapshot.connections=connections;self.snapshot.loading=false;self.snapshot.bootstrap=BootstrapState::Ready;Ok(())
|
||||
|
||||
@@ -14,6 +14,8 @@ pub use audio::sync_audio;
|
||||
pub(crate) use audio::{activate_microphone,sync_notifications,capture_settings,gate as capture_gate};
|
||||
pub use keys::{sync_keys,physical_key,focus_lost};
|
||||
pub use projection::project;
|
||||
/// Called by the shell projection on Android whenever the destination leaves Settings.
|
||||
pub fn cancel_palette_preview(ctx:&RuntimeServices)->Result<()> {themes::cancel_palette(ctx)}
|
||||
|
||||
fn bad(message:impl Into<String>)->ServiceError{ServiceError::new("bad_request",message)}
|
||||
fn lock<T>(value:&std::sync::Mutex<T>)->Result<MutexGuard<'_,T>>{value.lock().map_err(|_|ServiceError::new("settings_unavailable","Settings state is unavailable"))}
|
||||
@@ -48,10 +50,14 @@ pub async fn handle(ctx:Arc<RuntimeServices>,action:SettingsAction)->Result<Work
|
||||
async fn invoke(ctx:Arc<RuntimeServices>,op:Operation)->Result<WorkflowResult>{
|
||||
use Operation::*;
|
||||
match op {
|
||||
Navigate(nav)=>{match &nav{Navigation::Category(Category::About)|Navigation::Page(Page::Changelog|Page::Licenses|Page::Diagnostics)=>projection::reload_about(&ctx).await?,Navigation::Category(Category::Appearance)|Navigation::Page(Page::Themes)=>themes::reload(&ctx,false).await?,Navigation::Category(Category::Audio|Category::Notifications)=>ctx.audio.send(crate::media::audio::engine::AudioCommand::Enumerate)?,Navigation::Category(Category::OsSpecific)=>ctx.refresh_os_settings().await?,_=>{}}Ok(WorkflowResult::effect(UiEffect::SettingsNavigate(nav)))},
|
||||
Navigate(nav)=>{
|
||||
if cfg!(target_os="android") {if matches!(&nav,Navigation::Page(Page::Palette)){themes::begin_palette(&ctx)?;}else if matches!(&nav,Navigation::Back|Navigation::Category(_)|Navigation::Page(_)){themes::cancel_palette(&ctx)?;}}
|
||||
match &nav{Navigation::Category(Category::About)|Navigation::Page(Page::Changelog|Page::Licenses|Page::Diagnostics)=>projection::reload_about(&ctx).await?,Navigation::Category(Category::Appearance)|Navigation::Page(Page::Themes)=>themes::reload(&ctx,false).await?,Navigation::Category(Category::Audio|Category::Notifications)=>ctx.audio.send(crate::media::audio::engine::AudioCommand::Enumerate)?,Navigation::Category(Category::OsSpecific)=>ctx.refresh_os_settings().await?,_=>{}}
|
||||
Ok(WorkflowResult::effect(UiEffect::SettingsNavigate(nav)))
|
||||
},
|
||||
Reload(category)=>{match category{Category::Audio=>ctx.audio.send(crate::media::audio::engine::AudioCommand::Enumerate)?,Category::Appearance=>themes::reload(&ctx,true).await?,Category::About=>projection::reload_about(&ctx).await?,Category::OsSpecific=>ctx.refresh_os_settings().await?,_=>{}}ctx.changed().await?;done()},
|
||||
IdentityCreate|IdentityDefault(_)|IdentityDelete(_)|IdentityImport|IdentityExport(_)|IdentityCopyUid(_)|IdentityImprove(_)|IdentityCancelImprove(_)=>identities::invoke(ctx,op).await,
|
||||
ThemeSelect(_)|ThemePreview(_)|ThemeReload|ThemeInstall|ThemeOpenDirectory(_)|ThemeLink{..}=>themes::invoke(ctx,op).await,
|
||||
ThemeSelect(_)|ThemePreview(_)|ThemeReload|ThemeInstall|ThemeOpenDirectory(_)|ThemeLink{..}|PalettePreset(_)|PaletteSave|PaletteCancel=>themes::invoke(ctx,op).await,
|
||||
SelectDevice{..}|MapDevice{..}|NewDevice{..}|CopyDspToTemplate{..}|ApplyDspTemplate{..}|AudioTest(_)|PreviewNotification(_)=>audio::invoke(ctx,op).await,
|
||||
CapturePtt|KeyProfileCreate|KeyProfileActivate(_)|KeyProfileDelete(_)|KeyCapture{..}|KeyCaptureDone|KeyCaptureCancel|KeyRemove{..}=>keys::invoke(ctx,op).await,
|
||||
WhisperCreate|WhisperDelete(_)|WhisperRemoveEntry{..}|WhisperAddEntry{..}|WhisperPickServer{..}|WhisperPickGroup{..}|WhisperOverlay(_)=>preferences::whisper(ctx,op).await,
|
||||
|
||||
@@ -3,11 +3,12 @@ use crate::services::{whisper::{WhisperList,ReceiveMode},file_settings::FileSett
|
||||
|
||||
pub(super) async fn edit(ctx:Arc<RuntimeServices>,field:Field,value:SettingValue)->Result<WorkflowResult>{
|
||||
match field {
|
||||
Field::Palette(field)=>return themes::edit_palette(ctx,field,value).await,
|
||||
Field::Preference(pref)=>{
|
||||
let hardware=matches!(pref,Preference::HardwareVideoDecode);let update=matches!(pref,Preference::UpdateChannel);
|
||||
let audio=matches!(pref,Preference::PttEnabled|Preference::OutputLevelDb|Preference::AutoEnableMicrophone|Preference::AutoReactivateMicOnPreviousTarget);
|
||||
let value=if matches!(pref,Preference::RecordingMode){json!(choice_number(value,1,3)?)}else{value.json()};
|
||||
patch(&ctx,pref.key(),value).await?;
|
||||
if cfg!(target_os="android")&&matches!(pref,Preference::Theme){ctx.mutate(move|p|{p.prefs.set(json!({pref.key():value,"androidPalette":null}))?;Ok(())}).await?;}else{patch(&ctx,pref.key(),value).await?;}
|
||||
if hardware{lock(&ctx.settings_status)?.video.restart_required=true;}
|
||||
if update{let channel=serde_json::from_value(ctx.profile()?.prefs.get()["updateChannel"].clone())?;ctx.updates.set_channel(channel,std::time::Instant::now());}
|
||||
if audio{sync_audio(ctx.clone()).await?;}
|
||||
|
||||
@@ -14,10 +14,37 @@ pub(super) async fn reload(ctx:&Arc<RuntimeServices>,force:bool)->Result<()> {
|
||||
let resolved=themes.resolve(scheme(&owner,&profile.prefs.get()))?;publish(&owner,listing,&resolved,None)?;Ok::<_,ServiceError>(resolved)
|
||||
}).await.map_err(|_|bad("Theme worker stopped"))??;ctx.effect(UiEffect::Theme(resolved)).await
|
||||
}
|
||||
/// Clear ephemeral edits when the shell leaves settings; never touches persisted preferences.
|
||||
pub(super) fn cancel_palette(ctx:&RuntimeServices)->Result<()> {lock(&ctx.settings_status)?.palette_draft=None;Ok(())}
|
||||
pub(super) fn begin_palette(ctx:&RuntimeServices)->Result<()> {
|
||||
if !cfg!(target_os="android"){return Err(bad("Palette editing is available on Android"))}
|
||||
let saved=ctx.profile()?.prefs.get()["androidPalette"].clone();let saved=if crate::services::prefs::valid_android_palette(&saved){saved}else{crate::services::prefs::android_palette_default()};lock(&ctx.settings_status)?.palette_draft=Some(saved);Ok(())
|
||||
}
|
||||
pub(super) async fn edit_palette(ctx:Arc<RuntimeServices>,field:PaletteColor,value:SettingValue)->Result<WorkflowResult> {
|
||||
if !cfg!(target_os="android"){return Err(bad("Palette editing is available on Android"))}
|
||||
let value=text(value)?;if value.len()>32{return Err(bad("Color must use #RRGGBB"))}
|
||||
{let mut status=lock(&ctx.settings_status)?;let draft=status.palette_draft.as_mut().ok_or_else(||bad("Open the palette editor before changing colors"))?;draft[field.key()]=json!(value);}
|
||||
ctx.changed().await?;done()
|
||||
}
|
||||
async fn palette(ctx:Arc<RuntimeServices>,op:Operation)->Result<WorkflowResult> {
|
||||
if !cfg!(target_os="android"){return Err(bad("Palette editing is available on Android"))}
|
||||
match op {
|
||||
Operation::PalettePreset(preset)=>{let value=crate::services::prefs::android_palette_preset(preset.key()).ok_or_else(||bad("Unknown palette"))?;let mut status=lock(&ctx.settings_status)?;if status.palette_draft.is_none(){return Err(bad("Open the palette editor before choosing a preset"))}status.palette_draft=Some(value);},
|
||||
Operation::PaletteSave=>{
|
||||
let value=lock(&ctx.settings_status)?.palette_draft.clone().ok_or_else(||bad("Open the palette editor before saving"))?;
|
||||
if !crate::services::prefs::valid_android_palette(&value){return Err(bad("Use #RRGGBB colors with text contrast of at least 4.5:1"))}
|
||||
patch(&ctx,"androidPalette",value).await?;cancel_palette(&ctx)?;
|
||||
return Ok(WorkflowResult::effect(UiEffect::SettingsNavigate(Navigation::Back)))
|
||||
},
|
||||
Operation::PaletteCancel=>{cancel_palette(&ctx)?;return Ok(WorkflowResult::effect(UiEffect::SettingsNavigate(Navigation::Back)))},
|
||||
_=>return Err(bad("Invalid palette operation")),
|
||||
}ctx.changed().await?;done()
|
||||
}
|
||||
pub(super) async fn invoke(ctx:Arc<RuntimeServices>,op:Operation)->Result<WorkflowResult>{
|
||||
match op {
|
||||
Operation::PalettePreset(_)|Operation::PaletteSave|Operation::PaletteCancel=>return palette(ctx,op).await,
|
||||
Operation::ThemeReload=>reload(&ctx,true).await?,
|
||||
Operation::ThemeSelect(selection)=>{let owner=ctx.clone();tokio::task::spawn_blocking(move||{let mut profile=owner.profile()?;lock(&owner.themes)?.select(selection.as_deref(),|value|{profile.prefs.set(json!({"userStyle":value}))?;Ok(())})}).await.map_err(|_|bad("Theme worker stopped"))??;reload(&ctx,false).await?;},
|
||||
Operation::ThemeSelect(selection)=>{let owner=ctx.clone();tokio::task::spawn_blocking(move||{let mut profile=owner.profile()?;lock(&owner.themes)?.select(selection.as_deref(),|value|{let patch=if cfg!(target_os="android"){json!({"userStyle":value,"androidPalette":null})}else{json!({"userStyle":value})};profile.prefs.set(patch)?;Ok(())})}).await.map_err(|_|bad("Theme worker stopped"))??;reload(&ctx,false).await?;},
|
||||
Operation::ThemePreview(selection)=>{let owner=ctx.clone();let resolved=tokio::task::spawn_blocking(move||{let mut profile=owner.profile()?;let mut themes=lock(&owner.themes)?;let listing=themes.list(false,|value|{profile.prefs.set(json!({"userStyle":value}))?;Ok(())})?;let resolved=themes.preview(&selection,scheme(&owner,&profile.prefs.get()))?;publish(&owner,listing,&resolved,Some(selection))?;Ok::<_,ServiceError>(resolved)}).await.map_err(|_|bad("Theme worker stopped"))??;ctx.effect(UiEffect::Theme(resolved)).await?;},
|
||||
Operation::ThemeOpenDirectory(identifier)=>{let owner=ctx.clone();let path=tokio::task::spawn_blocking(move||lock(&owner.themes)?.directory_for(identifier.as_deref())).await.map_err(|_|bad("Theme worker stopped"))??;ctx.open_local_directory(path).await?;},
|
||||
Operation::ThemeLink{identifier,kind}=>{let owner=ctx.clone();let url=tokio::task::spawn_blocking(move||lock(&owner.themes)?.package_link(&identifier,&kind)).await.map_err(|_|bad("Theme worker stopped"))??;let url=url.ok_or_else(||bad("Theme has no such link"))?;open_link(&ctx,&url).await?;},
|
||||
|
||||
@@ -13,6 +13,17 @@ fn choice(v:&Value,options:&[&str])->bool {v.as_str().is_some_and(|s|options.con
|
||||
fn exact(v:&Value,keys:&[&str])->bool {v.as_object().is_some_and(|o|o.len()==keys.len()&&keys.iter().all(|k|o.contains_key(*k)))}
|
||||
pub fn input_default()->Value {json!({"agc":true,"denoise":true,"denoiseLevel":1,"typing":false,"vad":true,"vadMode":"automatic","vadLevel":-30,"vadSensitivity":"normal"})}
|
||||
pub fn output_default()->Value {json!({"aec":false,"agc":true,"comfortNoise":false,"comfortNoiseLevel":-60,"echoReduction":0})}
|
||||
/// Android-only presentation palette. Desktop keeps its stock/package theme semantics.
|
||||
/// A null androidPalette delegates to the existing stock/package theme; saving a palette object installs an override.
|
||||
pub fn android_palette_default()->Value {android_palette_preset("ts6").unwrap()}
|
||||
pub fn android_palette_preset(name:&str)->Option<Value> {let (accent,bg,surface,fg)=match name{"ts6"=>("#1588FA","#222A3C","#2B3346","#F4F6FB"),"graphite"=>("#D2B989","#242626","#323535","#F4F1E9"),"light"=>("#24694F","#F1F4EF","#E2E9DF","#25362D"),_=>return None};Some(json!({"version":1,"accent":accent,"background":bg,"surface":surface,"foreground":fg}))}
|
||||
pub fn palette_rgb(value:&str)->Option<[u8;3]> {if value.len()!=7||!value.starts_with('#')||!value.as_bytes()[1..].iter().all(u8::is_ascii_hexdigit){return None}Some([u8::from_str_radix(&value[1..3],16).ok()?,u8::from_str_radix(&value[3..5],16).ok()?,u8::from_str_radix(&value[5..7],16).ok()?])}
|
||||
pub fn palette_mix(a:[u8;3],b:[u8;3],amount:f64)->[u8;3] {std::array::from_fn(|i|(f64::from(a[i])*(1.-amount)+f64::from(b[i])*amount).round() as u8)}
|
||||
pub fn palette_luminance(rgb:[u8;3])->f64 {let v=rgb.map(|v|{let v=f64::from(v)/255.;if v<=0.04045{v/12.92}else{((v+0.055)/1.055).powf(2.4)}});v[0]*0.2126+v[1]*0.7152+v[2]*0.0722}
|
||||
pub fn palette_contrast(a:[u8;3],b:[u8;3])->f64 {let a=palette_luminance(a);let b=palette_luminance(b);(a.max(b)+0.05)/(a.min(b)+0.05)}
|
||||
pub fn palette_surfaces(bg:[u8;3],surface:[u8;3])->[[u8;3];4] {let end=if palette_luminance(bg)>0.5{[255;3]}else{[0;3]};[bg,surface,palette_mix(bg,end,0.17),palette_mix(bg,end,0.4)]}
|
||||
pub fn android_palette_contrast(v:&Value)->Option<f64> {let bg=palette_rgb(v["background"].as_str()?)?;let surface=palette_rgb(v["surface"].as_str()?)?;let fg=palette_rgb(v["foreground"].as_str()?)?;Some(palette_surfaces(bg,surface).iter().map(|bg|palette_contrast(fg,*bg)).fold(f64::INFINITY,f64::min))}
|
||||
pub fn valid_android_palette(v:&Value)->bool {exact(v,&["version","accent","background","surface","foreground"])&&v["version"]==1&&["accent","background","surface","foreground"].iter().all(|key|v[key].as_str().and_then(palette_rgb).is_some())&&android_palette_contrast(v).is_some_and(|ratio|ratio>=4.5)}
|
||||
pub fn defaults()->Value {
|
||||
let entries = [
|
||||
("lastAddress", json!("")),
|
||||
@@ -38,6 +49,7 @@ pub fn defaults()->Value {
|
||||
("collapsedChannels", json!([])),
|
||||
("savedServersCollapsed", json!(false)),
|
||||
("theme", json!("dark")),
|
||||
("androidPalette", Value::Null),
|
||||
("displaySize", json!("medium")),
|
||||
("treeStyle", json!("detailed")),
|
||||
("chatStyle", json!("detailed")),
|
||||
@@ -96,6 +108,7 @@ fn collapsed(v:&Value)->bool {let Some(a)=v.as_array() else{return false};let mu
|
||||
fn style(v:&Value)->bool {if v.is_null(){return true}let Some(s)=v.as_str() else{return false};if bookmarks::units(s)>200||bookmarks::control(s){return false}let Some((id,name))=s.split_once("//") else{return false};let parts:Vec<_>=id.split('.').collect();id.len()<=64&&parts.len()>=3&&parts.iter().enumerate().all(|(i,p)|p.len()>=(if i==0{2}else{3})&&p.bytes().all(|c|c.is_ascii_lowercase()))&&(4..=30).contains(&name.chars().count())}
|
||||
pub fn validate_value(key:&str,v:&Value)->bool {match key {
|
||||
"lastAddress"=>string(v,255,false)&&v.as_str().is_some_and(|s|!s.chars().any(|c|c<='\u{1f}')),
|
||||
"androidPalette"=>v.is_null()||valid_android_palette(v),
|
||||
"inputDsp"=>dsp(v,true),"outputDsp"=>dsp(v,false),
|
||||
"pttReleaseDelay"=>exact(v,&["active","ms"])&&v["active"].is_boolean()&&[100.0,300.0,500.0].iter().any(|n|v["ms"].as_f64()==Some(*n)),
|
||||
"outputLevelDb"|"notificationLevelDb"=>v.as_f64().is_some_and(|n|n.is_finite()&&(-200.0..=10.0).contains(&n)&&(n*2.0).fract()==0.0),
|
||||
|
||||
@@ -105,3 +105,25 @@ fn repeated_mapping_reconfirms_selected_native_input_without_replacing_dsp(){
|
||||
p.map_legacy_device(DeviceKind::Input,"legacy-a","native-a").unwrap();assert!(!p.capture_allowed(true));assert_eq!(p.get()["inputDeviceId"],"unresolved");assert_eq!(p.get()["inputDsp"],dsp);
|
||||
assert!(p.map_legacy_device(DeviceKind::Input,"legacy-a","unresolved").is_err());assert!(p.confirm_new_device(DeviceKind::Input,"unresolved").is_err());assert!(!p.capture_allowed(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn android_palette_schema_rejects_unsafe_colors_and_contrast_without_rewriting_load() {
|
||||
for name in ["ts6","graphite","light"]{let palette=android_palette_preset(name).unwrap();assert!(valid_android_palette(&palette),"{name}");}
|
||||
for invalid in ["#fff","#11223344","112233","#GG0000","#12é45","transparent",""] {
|
||||
let mut palette=android_palette_default();palette["accent"]=json!(invalid);assert!(!validate_value("androidPalette",&palette),"{invalid}");
|
||||
}
|
||||
let mut palette=android_palette_default();palette["foreground"]=palette["surface"].clone();assert!(!valid_android_palette(&palette));
|
||||
palette=android_palette_default();palette["version"]=json!(2);assert!(!valid_android_palette(&palette));
|
||||
palette=android_palette_default();palette["unknown"]=json!(true);assert!(!valid_android_palette(&palette));
|
||||
let f=Fixture::new();let raw=json!({"androidPalette":palette});let bytes=serde_json::to_vec(&raw).unwrap();fs::write(f.path(),&bytes).unwrap();let p=Prefs::open(f.path()).unwrap();assert_eq!(p.get()["androidPalette"],Value::Null);assert_eq!(fs::read(f.path()).unwrap(),bytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn android_palette_save_restore_reset_and_failed_persistence_are_atomic() {
|
||||
let f=Fixture::new();let mut prefs=Prefs::open(f.path()).unwrap();let graphite=android_palette_preset("graphite").unwrap();
|
||||
prefs.set(json!({"androidPalette":graphite})).unwrap();drop(prefs);
|
||||
let mut prefs=Prefs::open(f.path()).unwrap();assert_eq!(prefs.get()["androidPalette"],graphite);
|
||||
let mut invalid=graphite.clone();invalid["foreground"]=json!("#242626");assert!(prefs.set(json!({"androidPalette":invalid})).is_err());assert_eq!(prefs.get()["androidPalette"],graphite);
|
||||
let bytes=fs::read(f.path()).unwrap();fs::create_dir(f.0.join("prefs.json.tmp")).unwrap();assert!(prefs.set(json!({"androidPalette":android_palette_default()})).is_err());assert_eq!(prefs.get()["androidPalette"],graphite);assert_eq!(fs::read(f.path()).unwrap(),bytes);
|
||||
fs::remove_dir(f.0.join("prefs.json.tmp")).unwrap();prefs.set(json!({"androidPalette":android_palette_default()})).unwrap();drop(prefs);assert_eq!(Prefs::open(f.path()).unwrap().get()["androidPalette"],android_palette_default());
|
||||
}
|
||||
@@ -94,7 +94,7 @@ fn update(ui:&AppWindow,runtime:&AppRuntime,bindings:&mut Bindings){
|
||||
for(id,source)in &snapshot.frames{match source.take_image(width,height){Ok(Some(frame))=>{new_frames.push((id.clone(),frame.image.clone()));if let Some((old_source,old))=bindings.frames.insert(id.clone(),(source.clone(),frame)){let crate::media::stream::frames::PresentedFrame{image,pixels,..}=old;drop(image);old_source.recycle(pixels);}},Ok(None)=>{},Err(error)=>ui.global::<ShellBridge>().set_error(error.message.into())}}
|
||||
}
|
||||
if changed {
|
||||
let mut shell=shell::ShellPresentation{catalog:snapshot.catalog,tabs:snapshot.tabs.clone(),tree:snapshot.tree.clone(),bookmarks:snapshot.bookmarks.clone(),contacts:snapshot.contacts.clone(),detail:snapshot.detail.clone(),actions:snapshot.actions.clone(),streams:vec![],voice:snapshot.voice.clone(),profile_form:snapshot.profile_form.clone(),dialog:snapshot.dialog.clone(),status:snapshot.status.clone(),error:snapshot.error.clone(),loading:snapshot.loading};
|
||||
let mut shell=shell::ShellPresentation{catalog:snapshot.catalog,tabs:snapshot.tabs.clone(),tree:snapshot.tree.clone(),bookmarks:snapshot.bookmarks.clone(),contacts:snapshot.contacts.clone(),room:snapshot.room.clone(),detail:snapshot.detail.clone(),actions:snapshot.actions.clone(),streams:vec![],voice:snapshot.voice.clone(),profile_form:snapshot.profile_form.clone(),dialog:snapshot.dialog.clone(),status:snapshot.status.clone(),error:snapshot.error.clone(),loading:snapshot.loading};
|
||||
for stream in &snapshot.streams{
|
||||
#[cfg(feature="webrtc")]let image=bindings.frames.get(&stream.id).map(|(_,frame)|frame.image.clone());
|
||||
#[cfg(not(feature="webrtc"))]let image:Option<slint::Image>=None;
|
||||
@@ -150,6 +150,17 @@ fn apply_theme(ui:&AppWindow,snapshot:&Snapshot){
|
||||
if let Some(TokenValue::FontFamily(fonts))=resolved.values.get("--tsv-font-family"){if let Some(font)=fonts.first(){let family=snapshot.theme_fonts.iter().find(|prepared|prepared.family==*font).map_or(font.as_str(),|prepared|prepared.alias.as_str());theme.set_font_family(family.into());}}
|
||||
let base=match resolved.values.get("--tsv-font-size"){Some(TokenValue::LengthPx(size))=>*size,_=>15.};let size=match prefs["displaySize"].as_str(){Some("small")=>13./15.,Some("large")=>17./15.,_=>1.};theme.set_font_size(base*snapshot.text_scale*size);
|
||||
}
|
||||
#[cfg(target_os="android")]
|
||||
{
|
||||
if snapshot.theme.is_none() {
|
||||
let color=|dark_rgb:[u8;3],light_rgb:[u8;3]|{let rgb=if dark{dark_rgb}else{light_rgb};slint::Color::from_rgb_u8(rgb[0],rgb[1],rgb[2])};
|
||||
theme.set_bg(color([43,51,70],[245,245,245]));theme.set_shaded(color([34,42,60],[235,235,235]));
|
||||
theme.set_header(color([28,37,57],[226,229,235]));theme.set_contrast(color([12,19,38],[201,217,229]));theme.set_deviant(color([30,37,56],[211,213,222]));
|
||||
theme.set_tint(color([21,136,250],[34,101,143]));theme.set_fg(color([255;3],[26;3]));
|
||||
}
|
||||
super::theme::apply_android_palette(&theme,super::theme::android_palette(snapshot),snapshot.high_contrast);
|
||||
if snapshot.theme.is_none(){let size=match prefs["displaySize"].as_str(){Some("small")=>13.,Some("large")=>17.,_=>15.};theme.set_font_size(size*snapshot.text_scale);}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test,not(any(target_os="android",target_os="ios"))))]
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn bind(ui:&AppWindow,emit:Arc<dyn Fn(SettingsAction)+Send+Sync>)->Binding{
|
||||
Intent::Edit(field)=>{if let Control::Choice{options,..}=&r.control{if let Some((value,_))=options.get(index){if let Some(value)=choice_value(field,value){emit_edit(&emit,&r,value);}}}},_=>{}
|
||||
}
|
||||
});}
|
||||
{let state=state.clone();bridge.on_draft(move |token,text|{if let Some(r)=row(&state,token.as_str()){if matches!(r.control,Control::Text(_)|Control::Number{..}){state.borrow_mut().drafts.insert(r.id,text.to_string());}}});}
|
||||
{let state=state.clone();let emit=emit.clone();bridge.on_draft(move |token,text|{if let Some(r)=row(&state,token.as_str()){if matches!(r.control,Control::Color(_)){emit_edit(&emit,&r,SettingValue::Text(text.to_string()));}else if matches!(r.control,Control::Text(_)|Control::Number{..}){state.borrow_mut().drafts.insert(r.id,text.to_string());}}});}
|
||||
{let state=state.clone();let emit=emit.clone();bridge.on_commit(move |token,text|commit(&state,&emit,token.as_str(),text.as_str()));}
|
||||
{let state=state.clone();let emit=emit.clone();bridge.on_step(move |token,direction|{
|
||||
let Some(r)=row(&state,token.as_str())else{return;};
|
||||
@@ -87,6 +87,12 @@ pub fn bind(ui:&AppWindow,emit:Arc<dyn Fn(SettingsAction)+Send+Sync>)->Binding{
|
||||
}
|
||||
});}
|
||||
{let emit=emit.clone();bridge.on_capture_lost(move ||emit(SettingsAction::CaptureFocusLost));}
|
||||
{let state=state.clone();let emit=emit.clone();bridge.on_color_channel(move |token,channel,value|{
|
||||
let Some(r)=row(&state,token.as_str())else{return};let Control::Color(current)=&r.control else{return};
|
||||
let Ok(channel)=usize::try_from(channel)else{return};if channel>2||!value.is_finite(){return}
|
||||
let mut rgb=crate::services::prefs::palette_rgb(current).unwrap_or([0;3]);rgb[channel]=value.round().clamp(0.,255.) as u8;
|
||||
emit_edit(&emit,&r,SettingValue::Text(format!("#{:02X}{:02X}{:02X}",rgb[0],rgb[1],rgb[2])));
|
||||
});}
|
||||
Binding{state}
|
||||
}
|
||||
|
||||
@@ -108,12 +114,14 @@ pub fn present(ui:&AppWindow,binding:&Binding,p:Presentation){
|
||||
Control::Toggle(v)=>(2,*v,String::new(),Vec::new(),0,0.0),
|
||||
Control::Choice{options,selected}=>(3,false,String::new(),options.iter().map(|(_,s)|SharedString::from(s)).collect(),*selected as i32,0.0),
|
||||
Control::Text(v)=>(4,false,v.clone(),Vec::new(),0,0.0),Control::Number{value,..}=>(5,false,value.to_string(),Vec::new(),0,0.0),
|
||||
Control::Color(v)=>(10,false,v.clone(),Vec::new(),0,0.0),
|
||||
Control::Action=>(6,false,String::new(),Vec::new(),0,0.0),Control::Meter(v)=>(7,false,String::new(),Vec::new(),0,*v),Control::Secret=>(8,false,String::new(),Vec::new(),0,0.0),Control::Rich{..}=>(9,false,String::new(),Vec::new(),0,0.0),
|
||||
};
|
||||
if state.drafts.get(&r.id)==Some(&value){state.drafts.remove(&r.id);}
|
||||
let value=state.drafts.get(&r.id).cloned().unwrap_or(value);
|
||||
let rich=if let Control::Rich{source,document}=&r.control{crate::ui::chat::preview_document(ui,source,document,ui.window().size().width as f32/ui.window().scale_factor()).into_iter().collect()}else{Vec::new()};
|
||||
rows.push(SettingsRow{token:token.clone().into(),stable_id:r.id.clone().into(),title:r.title.clone().into(),subtitle:r.subtitle.clone().into(),kind,checked,value:value.into(),options:model(options),selected,enabled:r.enabled,destructive:r.destructive,inset:r.inset,error:r.error.clone().into(),meter,decrease:p.decrease_template.replace("{name}",&r.title).into(),increase:p.increase_template.replace("{name}",&r.title).into(),rich:model(rich)});
|
||||
let parsed_rgb=crate::services::prefs::palette_rgb(&value);let rgb=parsed_rgb.unwrap_or([0;3]);
|
||||
rows.push(SettingsRow{token:token.clone().into(),stable_id:r.id.clone().into(),title:r.title.clone().into(),subtitle:r.subtitle.clone().into(),kind,checked,value:value.into(),options:model(options),selected,enabled:r.enabled,destructive:r.destructive,inset:r.inset,error:r.error.clone().into(),meter,decrease:p.decrease_template.replace("{name}",&r.title).into(),increase:p.increase_template.replace("{name}",&r.title).into(),rich:model(rich),swatch:parsed_rgb.map(|rgb|slint::Color::from_rgb_u8(rgb[0],rgb[1],rgb[2])).unwrap_or_else(||slint::Color::from_argb_u8(0,0,0,0)),red:f32::from(rgb[0]),green:f32::from(rgb[1]),blue:f32::from(rgb[2])});
|
||||
state.rows.insert(token,r);
|
||||
}
|
||||
// Retain the model object for unchanged identities. Only an actual navigation/reorder replaces it.
|
||||
@@ -122,6 +130,7 @@ pub fn present(ui:&AppWindow,binding:&Binding,p:Presentation){
|
||||
let bridge=ui.global::<SettingsBridge>();bridge.set_rows(state.model.clone().into());
|
||||
bridge.set_categories(model(p.categories.into_iter().map(SharedString::from).collect()));
|
||||
bridge.set_category_groups(model(p.category_groups.into_iter().map(SharedString::from).collect()));
|
||||
bridge.set_category_subtitles(model(p.category_subtitles.into_iter().map(SharedString::from).collect()));bridge.set_profile_name(p.profile_name.into());bridge.set_profile_label(p.profile_label.into());
|
||||
bridge.set_category(Category::ALL.iter().position(|c|*c==p.category).unwrap_or(0) as i32);
|
||||
bridge.set_title(p.title.into());bridge.set_status(p.status.into());bridge.set_error(p.error.into());
|
||||
bridge.set_panel_open(p.panel_open);bridge.set_subpage(p.subpage);bridge.set_show_slint(p.show_slint);
|
||||
|
||||
@@ -82,6 +82,7 @@ impl<'a> Builder<'a> {
|
||||
}
|
||||
pub fn appearance(&mut self) {
|
||||
if self.v.page()==Page::Themes {self.themes();return;}
|
||||
if cfg!(target_os="android") {if self.v.page()==Page::Palette{self.palette();return;}self.nav("native.palette.title",Page::Palette);}
|
||||
self.heading("settings.general");
|
||||
self.pref_choice(Preference::Theme,"settings.theme.stock",&[("dark","ui.dark"),("light","ui.light"),("system","ui.system")]);
|
||||
self.nav("themes.user",Page::Themes);
|
||||
@@ -94,6 +95,23 @@ impl<'a> Builder<'a> {
|
||||
self.pref_choice(Preference::TreeStyle,"appearance.treeStyle",&[("compact","appearance.compact"),("detailed","appearance.detailed")]);
|
||||
self.heading("ui.chats");self.pref_choice(Preference::ChatStyle,"settings.chat_style",&[("compact","appearance.compact"),("detailed","appearance.detailed")]);
|
||||
}
|
||||
fn palette(&mut self) {
|
||||
use crate::services::prefs;
|
||||
let value=self.s.palette_draft.as_ref().unwrap_or(&self.s.prefs["androidPalette"]);
|
||||
self.note("palette-preview","native.palette.preview",self.text("native.palette.preview.info"));
|
||||
self.select("palette-presets","native.palette.presets","",[(PalettePreset::Ts6,"native.palette.ts6"),(PalettePreset::Graphite,"native.palette.graphite"),(PalettePreset::Light,"native.palette.light")].into_iter().map(|(preset,key)|(preset.key().into(),self.text(key),Operation::PalettePreset(preset))).collect());
|
||||
for color in PaletteColor::ALL {
|
||||
let text=value[color.key()].as_str().unwrap_or_default();
|
||||
self.row(format!("palette:{}",color.key()),&format!("native.palette.{}",color.key()),String::new(),Control::Color(text.into()),Intent::Edit(Field::Palette(color)));
|
||||
// Ephemeral color edits remain focusable while their ordered acknowledgement is pending.
|
||||
self.rows.last_mut().unwrap().enabled=true;
|
||||
}
|
||||
let valid=prefs::valid_android_palette(value);
|
||||
self.note("palette-contrast",if valid{"native.palette.contrast.ok"}else{"native.palette.contrast.error"},self.text("native.palette.contrast.info"));
|
||||
self.action("palette-reset","native.palette.reset",Operation::PalettePreset(PalettePreset::Ts6));
|
||||
self.action("palette-cancel","ui.cancel",Operation::PaletteCancel);
|
||||
self.action("palette-save","ui.save",Operation::PaletteSave);self.rows.last_mut().unwrap().enabled&=valid;
|
||||
}
|
||||
fn themes(&mut self) {
|
||||
self.heading("themes.user");
|
||||
self.action("theme-stock","themes.user.disabled",Operation::ThemeSelect(None));
|
||||
@@ -171,5 +189,7 @@ pub fn build(s:&SettingsSnapshot,v:&ViewState,c:&Catalog)->Presentation {
|
||||
if s.loaded{match v.category{Category::Identities=>b.identities(),Category::Privacy=>b.privacy(),Category::Appearance=>b.appearance(),Category::Audio=>b.audio(),Category::Video=>b.video(),Category::KeyBindings=>b.keys(),Category::Chats=>b.chats(),Category::Whispers=>b.whispers(),Category::Notifications=>b.notifications(),Category::FileTransfer=>b.files(),Category::OsSpecific=>b.os(),Category::About=>b.about()}}
|
||||
let readonly=(v.category==Category::KeyBindings&&s.key_read_only)||(v.category==Category::Whispers&&s.whispers.as_ref().is_some_and(|w|w.read_only));
|
||||
if readonly{for row in &mut b.rows{let navigation=match &row.intent{Intent::None=>true,Intent::Invoke(Operation::Navigate(_)|Operation::WhisperOverlay(_))=>true,Intent::Select(ops)=>ops.iter().all(|op|matches!(op,Operation::Navigate(_))),_=>false};row.enabled&=navigation;}}
|
||||
Presentation{category:v.category,title:c.text(v.category.key()),categories:Category::ALL.iter().map(|x|c.text(x.key())).collect(),category_groups:["ui.user","ui.application","ui.information"].into_iter().map(|k|c.text(k)).collect(),rows:b.rows,panel_open:v.panel_open,subpage:!v.pages.is_empty(),show_slint:v.category==Category::About && v.page()==Page::Root,status:if !s.loaded&&s.status.is_empty(){c.text("files.loading")}else{s.status.clone()},error:s.error.clone(),back:c.text("clientMenu.back"),apply:c.text("ui.save"),cancel:c.text("ui.cancel"),loading:!s.loaded,capturing:s.capture.active,decrease_template:c.text("files.settings.decrease"),increase_template:c.text("files.settings.increase")}
|
||||
let category_subtitles=Category::ALL.iter().map(|category|c.text(&format!("native.room.settings.{}",match category{Category::Identities=>"identity",Category::Privacy=>"privacy",Category::Appearance=>"appearance",Category::Audio=>"audio",Category::Video=>"video",Category::KeyBindings=>"keys",Category::Chats=>"chats",Category::Whispers=>"whispers",Category::Notifications=>"notifications",Category::FileTransfer=>"files",Category::OsSpecific=>"system",Category::About=>"about"}))).collect();
|
||||
let profile_label=c.text("native.room.settings.profile");let profile_name=s.identities.iter().find(|i|i.is_default).or(s.identities.first()).map(|i|i.display_name(&profile_label).to_owned()).unwrap_or_else(||c.text("native.room.settings.profile.empty"));
|
||||
Presentation{category:v.category,title:c.text(if cfg!(target_os="android")&&v.page()==Page::Palette{"native.palette.title"}else{v.category.key()}),categories:Category::ALL.iter().map(|x|c.text(x.key())).collect(),category_subtitles,profile_name,profile_label,category_groups:if cfg!(target_os="android"){["native.room.settings.conversation","native.room.settings.personal","native.room.settings.application"].into_iter().map(|k|c.text(k)).collect()}else{["ui.user","ui.application","ui.information"].into_iter().map(|k|c.text(k)).collect()},rows:b.rows,panel_open:v.panel_open,subpage:!v.pages.is_empty(),show_slint:v.category==Category::About && v.page()==Page::Root,status:if !s.loaded&&s.status.is_empty(){c.text("files.loading")}else{s.status.clone()},error:s.error.clone(),back:c.text("clientMenu.back"),apply:c.text("ui.save"),cancel:c.text("ui.cancel"),loading:!s.loaded,capturing:s.capture.active,decrease_template:c.text("files.settings.decrease"),increase_template:c.text("files.settings.increase")}
|
||||
}
|
||||
@@ -56,3 +56,17 @@ fn unsupported_os_action_has_reported_reason_not_fake_success(){
|
||||
let p=presentation(Category::OsSpecific,&s);let r=p.rows.iter().find(|r|r.id=="os:autostart").unwrap();
|
||||
assert!(!r.enabled);assert_eq!(r.subtitle,"reported platform restriction");
|
||||
}
|
||||
|
||||
#[cfg(target_os="android")]
|
||||
#[test]
|
||||
fn palette_has_real_color_intents_and_blocks_invalid_saves() {
|
||||
let mut snapshot=loaded();let mut invalid=crate::services::prefs::android_palette_default();invalid["foreground"]=invalid["background"].clone();snapshot.palette_draft=Some(invalid);
|
||||
let view=ViewState{category:Category::Appearance,pages:vec![Page::Palette],panel_open:true,..Default::default()};
|
||||
let p=build(&snapshot,&view,&Catalog::new(Language::En));
|
||||
assert_eq!(p.rows.iter().filter(|row|matches!(row.intent,Intent::Edit(Field::Palette(_)))).count(),4);
|
||||
assert!(!p.rows.iter().find(|row|row.id=="palette-save").unwrap().enabled);
|
||||
let cancel=p.rows.iter().position(|row|row.id=="palette-cancel").unwrap();assert_eq!(p.rows[cancel+1].id,"palette-save");
|
||||
assert!(matches!(p.rows.iter().find(|row|row.id=="palette-reset").unwrap().intent,Intent::Invoke(Operation::PalettePreset(PalettePreset::Ts6))));
|
||||
snapshot.palette_draft=Some(crate::services::prefs::android_palette_default());snapshot.pending.push("palette:accent".into());
|
||||
let p=build(&snapshot,&view,&Catalog::new(Language::En));assert!(p.rows.iter().find(|row|row.id=="palette-save").unwrap().enabled);assert!(p.rows.iter().find(|row|row.id=="palette:accent").unwrap().enabled);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ impl Category {
|
||||
pub fn key(self)->&'static str {match self {Self::Identities=>"settings.nav.identities",Self::Privacy=>"settings.privacy.title",Self::Appearance=>"ui.appearance",Self::Audio=>"ui.audio",Self::Video=>"ui.video",Self::KeyBindings=>"settings.nav.keybinds",Self::Chats=>"ui.chats",Self::Whispers=>"settings.nav.whispers",Self::Notifications=>"ui.layout.notifications",Self::FileTransfer=>"files.title",Self::OsSpecific=>"os.title",Self::About=>"settings.nav.about"}}
|
||||
}
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub enum Page { #[default] Root, TrustedHosts, PrivacyDetails, Themes, AudioProfiles, DeviceMigration, VideoDetails, MarkdownHelp, Changelog, Licenses, License(String), Diagnostics }
|
||||
pub enum Page { #[default] Root, TrustedHosts, PrivacyDetails, Themes, Palette, AudioProfiles, DeviceMigration, VideoDetails, MarkdownHelp, Changelog, Licenses, License(String), Diagnostics }
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ViewState {
|
||||
pub category: Category, pub pages: Vec<Page>, pub panel_open: bool,
|
||||
@@ -70,8 +70,15 @@ pub enum FileField { AlwaysAsk, LimitUpload, LimitDownload, UploadMiB, DownloadM
|
||||
#[derive(Clone,Copy,Debug,PartialEq)]
|
||||
pub enum WhisperField { Name, Kind, GroupType, GroupTargetMode, ServerUid, GroupId }
|
||||
#[derive(Clone,Debug,PartialEq)]
|
||||
pub enum PaletteColor { Accent, Background, Surface, Foreground }
|
||||
impl PaletteColor {pub const ALL:[Self;4]=[Self::Accent,Self::Background,Self::Surface,Self::Foreground];pub fn key(&self)->&'static str {match self{Self::Accent=>"accent",Self::Background=>"background",Self::Surface=>"surface",Self::Foreground=>"foreground"}}}
|
||||
#[derive(Clone,Copy,Debug,PartialEq)]
|
||||
pub enum PalettePreset { Ts6, Graphite, Light }
|
||||
impl PalettePreset {pub fn key(self)->&'static str {match self{Self::Ts6=>"ts6",Self::Graphite=>"graphite",Self::Light=>"light"}}}
|
||||
#[derive(Clone,Debug,PartialEq)]
|
||||
pub enum Field {
|
||||
Preference(Preference), Device(DeviceKind), PttReleaseDelay,
|
||||
Palette(PaletteColor),
|
||||
Dsp {kind:DeviceKind,target:DspTarget,field:DspField},
|
||||
IdentityName(String), IdentityNickname(String), IdentityTarget(String), NewIdentityName,
|
||||
KeyExact, KeyProfileName(String), NewKeyProfileName,
|
||||
@@ -90,6 +97,7 @@ pub enum Operation {
|
||||
IdentityCreate, IdentityDefault(String), IdentityDelete(String), IdentityImport, IdentityExport(String), IdentityCopyUid(String), IdentityImprove(String), IdentityCancelImprove(String),
|
||||
RemoveTrustedHost(String), ClearTrustedHosts, ResetConfirmations,
|
||||
ThemeSelect(Option<String>), ThemePreview(String), ThemeReload, ThemeInstall, ThemeOpenDirectory(Option<String>), ThemeLink{identifier:String,kind:String},
|
||||
PalettePreset(PalettePreset), PaletteSave, PaletteCancel,
|
||||
SelectDevice{kind:DeviceKind,id:String}, MapDevice{kind:DeviceKind,legacy:String,native:String}, NewDevice{kind:DeviceKind,native:String},
|
||||
CopyDspToTemplate{kind:DeviceKind,device:String}, ApplyDspTemplate{kind:DeviceKind,device:String},
|
||||
AudioTest(AudioTest), CapturePtt,
|
||||
@@ -147,6 +155,7 @@ pub struct SettingsSnapshot {
|
||||
pub whispers:Option<WhisperState>,pub servers:Vec<WhisperServer>,pub input_session:Option<SessionKey>,pub pending_whisper:Option<(SessionKey,WhisperEntry)>,pub whisper_targets:Vec<(String,String)>,
|
||||
pub files:Option<FileSettingsValue>,pub download_location:String,pub recording_location:String,
|
||||
pub themes:Vec<ThemeView>,pub theme_warnings:Vec<String>,pub theme_preview:Option<String>,
|
||||
pub palette_draft:Option<Value>,
|
||||
pub os:OsView,pub about:AboutView,pub status:String,pub error:String,
|
||||
/// Exact stable row IDs currently being persisted; errors and previous values remain visible.
|
||||
pub pending:Vec<String>, pub row_errors:BTreeMap<String,String>,
|
||||
@@ -155,8 +164,8 @@ pub struct SettingsSnapshot {
|
||||
#[derive(Clone,Debug)]
|
||||
pub enum Intent { None, Edit(Field), Invoke(Operation), Select(Vec<Operation>), Secret(SecretBinding) }
|
||||
#[derive(Clone,Debug)]
|
||||
pub enum Control { Heading, Note, Toggle(bool), Choice{options:Vec<(String,String)>,selected:usize}, Text(String), Number{value:f64,min:f64,max:f64,step:f64}, Action, Meter(f32), Secret, Rich{source:String,document:std::sync::Arc<crate::ui::chat::prepared::PreparedDocument>} }
|
||||
pub enum Control { Heading, Note, Toggle(bool), Choice{options:Vec<(String,String)>,selected:usize}, Text(String), Color(String), Number{value:f64,min:f64,max:f64,step:f64}, Action, Meter(f32), Secret, Rich{source:String,document:std::sync::Arc<crate::ui::chat::prepared::PreparedDocument>} }
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct Row {pub id:String,pub title:String,pub subtitle:String,pub control:Control,pub intent:Intent,pub enabled:bool,pub destructive:bool,pub inset:bool,pub error:String}
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct Presentation {pub category:Category,pub title:String,pub categories:Vec<String>,pub category_groups:Vec<String>,pub rows:Vec<Row>,pub panel_open:bool,pub subpage:bool,pub show_slint:bool,pub status:String,pub error:String,pub back:String,pub apply:String,pub cancel:String,pub loading:bool,pub capturing:bool,pub decrease_template:String,pub increase_template:String}
|
||||
pub struct Presentation {pub category:Category,pub title:String,pub categories:Vec<String>,pub category_subtitles:Vec<String>,pub profile_name:String,pub profile_label:String,pub category_groups:Vec<String>,pub rows:Vec<Row>,pub panel_open:bool,pub subpage:bool,pub show_slint:bool,pub status:String,pub error:String,pub back:String,pub apply:String,pub cancel:String,pub loading:bool,pub capturing:bool,pub decrease_template:String,pub increase_template:String}
|
||||
+42
-16
@@ -26,14 +26,16 @@ struct State {
|
||||
presentation:ShellPresentation,
|
||||
targets:BTreeMap<String,Target>, actions:BTreeMap<String,Action>, contexts:BTreeMap<String,Vec<Action>>,
|
||||
editor:Option<Editor>, stack:Vec<Target>, destination:Destination,
|
||||
room_page:i32, room_history:Vec<i32>,
|
||||
fields:Rc<VecModel<ShellField>>, tree:Rc<VecModel<ShellRow>>, bookmarks:Rc<VecModel<ShellRow>>, contacts:Rc<VecModel<ShellRow>>, entries:Rc<VecModel<ShellRow>>,
|
||||
participants:Rc<VecModel<ShellRow>>,
|
||||
held_target:Option<Target>, menu_target:Option<Target>,
|
||||
press_epoch:u64, pressed_row:Option<String>, suppress_click:Option<String>,
|
||||
selection_actions:bool,
|
||||
popouts:BTreeMap<String,(Target,crate::StreamWindow)>,
|
||||
}
|
||||
impl Default for State {
|
||||
fn default()->Self { Self {presentation:ShellPresentation::default(),targets:BTreeMap::new(),actions:BTreeMap::new(),contexts:BTreeMap::new(),editor:None,stack:vec![],destination:Destination::Servers,fields:Rc::new(VecModel::default()),tree:Rc::new(VecModel::default()),bookmarks:Rc::new(VecModel::default()),contacts:Rc::new(VecModel::default()),entries:Rc::new(VecModel::default()),held_target:None,menu_target:None,press_epoch:0,pressed_row:None,suppress_click:None,selection_actions:false,popouts:BTreeMap::new()} }
|
||||
fn default()->Self { Self {presentation:ShellPresentation::default(),targets:BTreeMap::new(),actions:BTreeMap::new(),contexts:BTreeMap::new(),editor:None,stack:vec![],destination:Destination::Servers,room_page:0,room_history:vec![],participants:Rc::new(VecModel::default()),fields:Rc::new(VecModel::default()),tree:Rc::new(VecModel::default()),bookmarks:Rc::new(VecModel::default()),contacts:Rc::new(VecModel::default()),entries:Rc::new(VecModel::default()),held_target:None,menu_target:None,press_epoch:0,pressed_row:None,suppress_click:None,selection_actions:false,popouts:BTreeMap::new()} }
|
||||
}
|
||||
pub struct ShellBinding { state:Rc<RefCell<State>>, emit:Arc<dyn Fn(ShellAction)+Send+Sync> }
|
||||
fn strings(values:impl IntoIterator<Item=String>)->ModelRc<SharedString> { ModelRc::new(VecModel::from(values.into_iter().map(Into::into).collect::<Vec<_>>())) }
|
||||
@@ -94,18 +96,32 @@ fn opens_detail(operation:Operation)->bool {
|
||||
matches!(operation,Operation::ServerInfo|Operation::ServerClients|Operation::ServerLog|Operation::ServerBans|Operation::ServerKeys|Operation::ServerPasswords|Operation::ServerPermissions|Operation::TalkQueue|Operation::ChannelInfo|Operation::ClientInfo|Operation::ClientConnectionInfo|Operation::ClientPermissions|Operation::GroupPermissions|Operation::FileBrowse|Operation::FileRefresh|Operation::TransferList|Operation::RecordingOpen|Operation::ServerIcons|Operation::WhisperHistory)
|
||||
}
|
||||
|
||||
fn room_destination(page:i32)->Destination { match page {2=>Destination::Chats,3=>Destination::Settings,4=>Destination::Contacts,_=>Destination::Servers} }
|
||||
fn room_navigate(ui:&AppWindow,state:&mut State,emit:&Arc<dyn Fn(ShellAction)+Send+Sync>,page:i32) {
|
||||
if !(0..=6).contains(&page){return}
|
||||
release_hold(state,emit);
|
||||
if page>=4 {state.room_history.push(state.room_page);}else{state.room_history.clear();}
|
||||
state.room_page=page;state.destination=room_destination(page);state.stack.clear();state.selection_actions=false;
|
||||
let bridge=ui.global::<ShellBridge>();bridge.set_room_page(page);bridge.set_destination(destination_index(state.destination));bridge.set_depth(0);bridge.set_stage(0);bridge.set_menu_visible(false);
|
||||
if page==2 && !state.presentation.room.chat_id.is_empty(){ui.global::<crate::ChatBridge>().invoke_choose_tab(state.presentation.room.chat_id.clone().into());}
|
||||
emit(ShellAction::Back);emit(ShellAction::Navigate(state.destination));
|
||||
if matches!(page,0|2){if let Some(target)=&state.presentation.room.target{emit(ShellAction::Select(target.clone()));}}
|
||||
}
|
||||
|
||||
pub fn bind(ui:&AppWindow,emit:Arc<dyn Fn(ShellAction)+Send+Sync>)->ShellBinding {
|
||||
let state=Rc::new(RefCell::new(State::default()));
|
||||
{
|
||||
let s=state.borrow();let b=ui.global::<ShellBridge>();
|
||||
b.set_tree(s.tree.clone().into());b.set_bookmarks(s.bookmarks.clone().into());b.set_contacts(s.contacts.clone().into());b.set_entries(s.entries.clone().into());ui.global::<DialogBridge>().set_fields(s.fields.clone().into());
|
||||
b.set_participants(s.participants.clone().into());
|
||||
}
|
||||
let b=ui.global::<ShellBridge>();
|
||||
{let s=state.clone();let e=emit.clone();let weak=ui.as_weak();b.on_room_navigate(move|page|{if let Some(ui)=weak.upgrade(){room_navigate(&ui,&mut s.borrow_mut(),&e,page);}});}
|
||||
{let s=state.clone();let e=emit.clone();let weak=ui.as_weak();b.on_navigate(move|index|{let destination=match index{1=>Destination::Chats,2=>Destination::Contacts,3=>Destination::Settings,_=>Destination::Servers};let mut s=s.borrow_mut();release_hold(&mut s,&e);s.destination=destination;s.stack.clear();if let Some(ui)=weak.upgrade(){ui.global::<ShellBridge>().set_destination(destination_index(destination));ui.global::<ShellBridge>().set_depth(0);}e(ShellAction::Navigate(destination));});}
|
||||
{let s=state.clone();let e=emit.clone();let weak=ui.as_weak();b.on_back(move||{if let Some(ui)=weak.upgrade(){back(&ui,&mut s.borrow_mut(),&e);}});}
|
||||
{let s=state.clone();let e=emit.clone();let weak=ui.as_weak();ui.on_back_requested(move||{if let Some(ui)=weak.upgrade(){back(&ui,&mut s.borrow_mut(),&e);}});}
|
||||
{let s=state.clone();let e=emit.clone();ui.on_focus_lost(move||{let mut s=s.borrow_mut();release_hold(&mut s,&e);if cfg!(target_os="android"){s.press_epoch=s.press_epoch.wrapping_add(1);s.pressed_row=None;}});}
|
||||
{let s=state.clone();let e=emit.clone();let weak=ui.as_weak();b.on_select(move|id|{let mut s=s.borrow_mut();if s.suppress_click.take().as_deref()==Some(id.as_str()){return}if let Some(target)=s.targets.get(id.as_str()).cloned(){if matches!(target.entity,Entity::Connection){s.stack.clear();s.selection_actions=false;}else{if !cfg!(target_os="android") || s.stack.last()!=Some(&target){s.stack.push(target.clone());}s.selection_actions=cfg!(target_os="android");}if let Some(ui)=weak.upgrade(){let b=ui.global::<ShellBridge>();b.set_depth(s.stack.len() as i32);if cfg!(target_os="android"){b.set_stage(0);}}e(ShellAction::Select(target));}});}
|
||||
{let s=state.clone();let e=emit.clone();let weak=ui.as_weak();b.on_select(move|id|{let mut s=s.borrow_mut();if s.suppress_click.take().as_deref()==Some(id.as_str()){return}if cfg!(target_os="android"){release_hold(&mut s,&e);}if let Some(target)=s.targets.get(id.as_str()).cloned(){if matches!(target.entity,Entity::Connection){s.stack.clear();s.selection_actions=false;}else{if !cfg!(target_os="android") || s.stack.last()!=Some(&target){s.stack.push(target.clone());}s.selection_actions=cfg!(target_os="android");}if let Some(ui)=weak.upgrade(){let b=ui.global::<ShellBridge>();b.set_depth(s.stack.len() as i32);if cfg!(target_os="android"){b.set_stage(0);}}e(ShellAction::Select(target));}});}
|
||||
{let s=state.clone();let e=emit.clone();b.on_expand(move|id|{if let Some(target)=s.borrow().targets.get(id.as_str()).cloned(){e(ShellAction::Expand(target));}});}
|
||||
{let s=state.clone();let e=emit.clone();let weak=ui.as_weak();b.on_context(move|id|{let mut s=s.borrow_mut();let Some(target)=s.targets.get(id.as_str()).cloned()else{return};if cfg!(target_os="android"){release_hold(&mut s,&e);}let actions=s.contexts.get(id.as_str()).cloned().unwrap_or_default();s.menu_target=Some(target.clone());if let Some(ui)=weak.upgrade(){let b=ui.global::<ShellBridge>();b.set_menu_title(target.name.clone().into());b.set_menu_actions(commands(&mut s,"context",&actions));b.set_menu_visible(true);}e(ShellAction::Context(target));});}
|
||||
{
|
||||
@@ -150,7 +166,7 @@ pub fn bind(ui:&AppWindow,emit:Arc<dyn Fn(ShellAction)+Send+Sync>)->ShellBinding
|
||||
}
|
||||
}
|
||||
});}
|
||||
{let s=state.clone();let e=emit.clone();b.on_voice(move|kind|{if let Some(v)=&s.borrow().presentation.voice{e(ShellAction::Invoke{target:v.target.clone(),operation:if kind==0{Operation::ToggleMicrophone}else{Operation::ToggleDeafen}});}});}
|
||||
{let s=state.clone();let e=emit.clone();b.on_voice(move|kind|{let mut state=s.borrow_mut();if cfg!(target_os="android"){release_hold(&mut state,&e);}if let Some(v)=&state.presentation.voice{e(ShellAction::Invoke{target:v.target.clone(),operation:if kind==0{Operation::ToggleMicrophone}else{Operation::ToggleDeafen}});}});}
|
||||
{let s=state.clone();let e=emit.clone();b.on_held(move|held|{let mut s=s.borrow_mut();if !held{release_hold(&mut s,&e);}else if s.held_target.is_none(){if let Some(v)=s.presentation.voice.as_ref().filter(|v|v.ptt_enabled){let target=v.target.clone();s.held_target=Some(target.clone());e(ShellAction::PushToTalk{target,held:true});}}});}
|
||||
{let s=state.clone();let e=emit.clone();b.on_search_edited(move|query|{if let Some(target)=&s.borrow().presentation.detail.search_target{e(ShellAction::Search{target:target.clone(),query:query.to_string()});}});}
|
||||
{let s=state.clone();let e=emit.clone();b.on_page(move|next|{let s=s.borrow();let d=&s.presentation.detail;if let Some(target)=&d.search_target{e(ShellAction::Page{target:target.clone(),offset:if next{d.page_offset.saturating_add(d.page_size)}else{d.page_offset.saturating_sub(d.page_size)}});}});}
|
||||
@@ -175,15 +191,22 @@ fn back(ui:&AppWindow,state:&mut State,emit:&Arc<dyn Fn(ShellAction)+Send+Sync>)
|
||||
if settings.get_capturing(){settings.invoke_capture_lost();return}
|
||||
if settings.get_panel_open() || settings.get_subpage(){settings.invoke_back();return}
|
||||
}
|
||||
let previous=state.destination;
|
||||
let return_to_contacts=cfg!(target_os="android") && previous==Destination::Contacts && !state.stack.is_empty();
|
||||
state.stack.pop();if state.stack.is_empty() && !return_to_contacts{state.destination=Destination::Servers;}
|
||||
if cfg!(target_os="android"){state.selection_actions=!state.stack.is_empty();}
|
||||
ui.global::<ShellBridge>().set_depth(state.stack.len() as i32);ui.global::<ShellBridge>().set_destination(destination_index(state.destination));emit(ShellAction::Back);
|
||||
if cfg!(target_os="android"){
|
||||
if previous!=state.destination{emit(ShellAction::Navigate(state.destination));}
|
||||
if let Some(target)=state.stack.last(){emit(ShellAction::Select(target.clone()));}
|
||||
if cfg!(target_os="android") && state.stack.is_empty() {
|
||||
if let Some(page)=state.room_history.pop(){state.room_page=page;}else if state.room_page!=0{state.room_page=0;}else{emit(ShellAction::Back);return}
|
||||
state.destination=room_destination(state.room_page);
|
||||
let bridge=ui.global::<ShellBridge>();bridge.set_room_page(state.room_page);bridge.set_destination(destination_index(state.destination));bridge.set_stage(0);
|
||||
emit(ShellAction::Back);emit(ShellAction::Navigate(state.destination));return
|
||||
}
|
||||
state.stack.pop();
|
||||
if cfg!(target_os="android") {
|
||||
state.selection_actions=!state.stack.is_empty();
|
||||
ui.global::<ShellBridge>().set_depth(state.stack.len() as i32);
|
||||
emit(ShellAction::Back);
|
||||
if let Some(target)=state.stack.last(){emit(ShellAction::Select(target.clone()));}
|
||||
return
|
||||
}
|
||||
if state.stack.is_empty(){state.destination=Destination::Servers;}
|
||||
ui.global::<ShellBridge>().set_depth(state.stack.len() as i32);ui.global::<ShellBridge>().set_destination(destination_index(state.destination));emit(ShellAction::Back);
|
||||
}
|
||||
fn destination_index(d:Destination)->i32{match d{Destination::Servers=>0,Destination::Chats=>1,Destination::Contacts=>2,Destination::Settings=>3}}
|
||||
fn submit(ui:&AppWindow,state:&mut State,emit:&Arc<dyn Fn(ShellAction)+Send+Sync>){
|
||||
@@ -206,8 +229,8 @@ fn submit(ui:&AppWindow,state:&mut State,emit:&Arc<dyn Fn(ShellAction)+Send+Sync
|
||||
project_editor(ui,state);
|
||||
}
|
||||
impl ShellBinding {
|
||||
pub fn navigate(&self,ui:&AppWindow,destination:Destination){let mut state=self.state.borrow_mut();state.destination=destination;state.stack.clear();ui.global::<ShellBridge>().set_destination(destination_index(destination));ui.global::<ShellBridge>().set_depth(0);}
|
||||
pub fn stream_effect(&self,ui:&AppWindow,target:&Target,popout:bool,close:bool)->Result<(),String>{let mut state=self.state.borrow_mut();let Some(stream)=state.presentation.streams.iter().find(|stream|&stream.target==target).cloned()else{return Ok(())};if close{if let Some((_,window))=state.popouts.remove(&stream.id){window.hide().map_err(|e|e.to_string())?;}if ui.global::<ShellBridge>().get_fullscreen_stream()==stream.id{ui.global::<ShellBridge>().set_fullscreen_stream("".into());}return Ok(())}if popout{open_popout(ui,&mut state,&stream)}else{ui.global::<ShellBridge>().set_fullscreen_stream(stream.id.into());Ok(())}}
|
||||
pub fn navigate(&self,ui:&AppWindow,destination:Destination){let mut state=self.state.borrow_mut();if cfg!(target_os="android"){release_hold(&mut state,&self.emit);if state.destination!=destination{state.room_page=match destination{Destination::Servers=>0,Destination::Chats=>2,Destination::Contacts=>4,Destination::Settings=>3};state.room_history.clear();ui.global::<ShellBridge>().set_room_page(state.room_page);}}state.destination=destination;state.stack.clear();ui.global::<ShellBridge>().set_destination(destination_index(destination));ui.global::<ShellBridge>().set_depth(0);}
|
||||
pub fn stream_effect(&self,ui:&AppWindow,target:&Target,popout:bool,close:bool)->Result<(),String>{let mut state=self.state.borrow_mut();if cfg!(target_os="android"){release_hold(&mut state,&self.emit);}let Some(stream)=state.presentation.streams.iter().find(|stream|&stream.target==target).cloned()else{return Ok(())};if close{if let Some((_,window))=state.popouts.remove(&stream.id){window.hide().map_err(|e|e.to_string())?;}if ui.global::<ShellBridge>().get_fullscreen_stream()==stream.id{ui.global::<ShellBridge>().set_fullscreen_stream("".into());}return Ok(())}if popout{open_popout(ui,&mut state,&stream)}else{ui.global::<ShellBridge>().set_fullscreen_stream(stream.id.into());Ok(())}}
|
||||
pub fn update_frames(&self,ui:&AppWindow,frames:&[(String,slint::Image)]){let mut state=self.state.borrow_mut();let model=ui.global::<ShellBridge>().get_streams();for(id,image)in frames{if let Some(stream)=state.presentation.streams.iter_mut().find(|stream|stream.id==*id){stream.frame=image.clone();stream.has_frame=true;}for row in 0..model.row_count(){if let Some(mut stream)=model.row_data(row){if stream.id.as_str()==id{stream.frame=image.clone();stream.has_frame=true;model.set_row_data(row,stream.clone());if let Some((_,window))=state.popouts.get(id){window.set_item(stream);}break}}}}}
|
||||
/// Call on the Slint event loop after runtime has coalesced a snapshot.
|
||||
pub fn present(&self,ui:&AppWindow,p:ShellPresentation){
|
||||
@@ -217,12 +240,13 @@ impl ShellBinding {
|
||||
let b=ui.global::<ShellBridge>();let c=p.catalog;
|
||||
let selected_detail=if cfg!(target_os="android") && s.selection_actions{
|
||||
s.stack.last().map(|target|{
|
||||
let actions=p.tree.iter().chain(&p.bookmarks).chain(&p.contacts).chain(&p.detail.entries).find(|entry|&entry.target==target).map(|entry|entry.actions.clone()).unwrap_or_default();
|
||||
let actions=p.room.participants.iter().chain(&p.tree).chain(&p.bookmarks).chain(&p.contacts).chain(&p.detail.entries).find(|entry|&entry.target==target).map(|entry|entry.actions.clone()).unwrap_or_default();
|
||||
Detail{title:target.name.clone(),actions,..Detail::default()}
|
||||
})
|
||||
}else{None};
|
||||
let detail=selected_detail.as_ref().unwrap_or(&p.detail);
|
||||
let tree=rows(&mut s,"tree",&p.tree,c);reconcile(&s.tree,tree);
|
||||
if cfg!(target_os="android") {let participants=rows(&mut s,"room",&p.room.participants,c);reconcile(&s.participants,participants);b.set_room_title(p.room.title.clone().into());b.set_room_server(p.room.server.clone().into());b.set_room_caption(c.format("native.room.members",&[("count",p.room.participants.len().to_string().as_str())]).into());b.set_room_destinations(strings(["native.room.room","native.room.channels","native.room.chat","native.room.profile"].map(|key|c.text(key))));b.set_room_labels(strings(["native.room.switch","native.room.open_chat","native.room.listening","native.room.speaking","native.room.microphone_on","native.room.microphone_off","native.room.sound_on","native.room.sound_off","native.room.disconnect","native.room.empty","native.room.streams","native.room.profile_settings"].map(|key|c.text(key))));}
|
||||
let bookmarks=rows(&mut s,"bookmark",&p.bookmarks,c);reconcile(&s.bookmarks,bookmarks);
|
||||
let contacts=rows(&mut s,"contact",&p.contacts,c);reconcile(&s.contacts,contacts);
|
||||
let entries=rows(&mut s,"entry",&detail.entries,c);reconcile(&s.entries,entries);
|
||||
@@ -236,9 +260,11 @@ impl ShellBinding {
|
||||
let primary=p.actions.iter().position(|action|action.operation==Operation::NewConnection).and_then(|index|global_commands.row_data(index)).unwrap_or_default();
|
||||
b.set_primary_action(primary);
|
||||
}
|
||||
if cfg!(target_os="android") {let disconnect=p.voice.as_ref().and_then(|voice|p.tabs.iter().find(|tab|tab.target.session==voice.target.session)).and_then(|tab|tab.actions.iter().find(|action|action.operation==Operation::Disconnect)).cloned();b.set_room_disconnect(disconnect.map(|action|{s.actions.insert("room-disconnect".into(),action.clone());command(&action,"room-disconnect".into())}).unwrap_or_default());}
|
||||
b.set_actions(global_commands);b.set_detail_actions(commands(&mut s,"detail",&detail.actions));
|
||||
b.set_info(model(detail.rows.iter().map(|r|ShellInfo{label:r.label.clone().into(),value:r.value.clone().into()}).collect()));
|
||||
let streams:Vec<ShellStream>=p.streams.iter().map(|v|ShellStream{id:v.id.clone().into(),title:v.title.clone().into(),status:v.status.clone().into(),frame:v.frame.clone(),has_frame:v.has_frame,volume:v.volume,actions:commands(&mut s,&format!("stream/{}",v.id),&v.actions)}).collect();
|
||||
let streams:Vec<ShellStream>=p.streams.iter().map(|v|ShellStream{id:v.id.clone().into(),title:v.title.clone().into(),status:v.status.clone().into(),frame:v.frame.clone(),has_frame:v.has_frame,has_volume:v.actions.iter().any(|action|action.operation==Operation::StreamVolume && action.enabled),volume:v.volume,actions:commands(&mut s,&format!("stream/{}",v.id),&v.actions)}).collect();
|
||||
if cfg!(target_os="android") {b.set_room_connected(p.room.target.is_some());b.set_room_streams(model(p.streams.iter().zip(&streams).filter(|(stream,_)|p.room.target.as_ref().is_some_and(|room|stream.target.session==room.session && stream.target.own_channel_id==room.own_channel_id)).map(|(_,stream)|stream.clone()).collect()));}
|
||||
s.popouts.retain(|id,(target,window)|{if p.streams.iter().any(|v|v.id==*id&&v.target==*target){if let Some(stream)=streams.iter().find(|v|v.id.as_str()==id){window.set_item(stream.clone());}true}else{let _=window.hide();false}});
|
||||
if !streams.iter().any(|stream|stream.id==b.get_fullscreen_stream()){b.set_fullscreen_stream("".into());}
|
||||
b.set_streams(model(streams));
|
||||
@@ -272,7 +298,7 @@ impl Drop for ShellBinding{fn drop(&mut self){self.release_holds();}}
|
||||
fn open_popout(ui:&AppWindow,state:&mut State,stream:&Stream)->Result<(),String>{
|
||||
if let Some((_,window))=state.popouts.get(&stream.id){return window.show().map_err(|error|error.to_string())}
|
||||
let window=crate::StreamWindow::new().map_err(|error|error.to_string())?;
|
||||
let item=ShellStream{id:stream.id.clone().into(),title:stream.title.clone().into(),status:stream.status.clone().into(),frame:stream.frame.clone(),has_frame:stream.has_frame,volume:stream.volume,actions:commands(state,&format!("stream/{}",stream.id),&stream.actions)};
|
||||
let item=ShellStream{id:stream.id.clone().into(),title:stream.title.clone().into(),status:stream.status.clone().into(),frame:stream.frame.clone(),has_frame:stream.has_frame,has_volume:stream.actions.iter().any(|action|action.operation==Operation::StreamVolume && action.enabled),volume:stream.volume,actions:commands(state,&format!("stream/{}",stream.id),&stream.actions)};
|
||||
window.set_item(item);
|
||||
let bridge=window.global::<ShellBridge>();
|
||||
bridge.set_label_stream_waiting(state.presentation.catalog.text("native.stream.waiting").into());
|
||||
|
||||
@@ -118,12 +118,18 @@ pub struct Voice {
|
||||
pub target: Target, pub title: String, pub muted: bool, pub deafened: bool,
|
||||
pub transmitting: bool, pub ptt_enabled: bool, pub status: String,
|
||||
}
|
||||
/// Android's current room is independent of the tree's disclosure/selection state.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Room {
|
||||
pub title: String, pub server: String, pub participants: Vec<Entry>, pub chat_id: String, pub target: Option<Target>,
|
||||
}
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ShellPresentation {
|
||||
pub catalog: Catalog, pub tabs: Vec<Tab>, pub tree: Vec<Entry>, pub bookmarks: Vec<Entry>, pub contacts: Vec<Entry>,
|
||||
pub detail: Detail, pub actions: Vec<Action>, pub streams: Vec<Stream>, pub voice: Option<Voice>,
|
||||
pub room: Room,
|
||||
pub profile_form: Option<Form>, pub dialog: Option<Form>, pub status: String, pub error: String, pub loading: bool,
|
||||
}
|
||||
impl Default for ShellPresentation {
|
||||
fn default() -> Self { Self { catalog: Catalog::default(), tabs: vec![], tree: vec![], bookmarks: vec![], contacts: vec![], detail: Detail::default(), actions: vec![], streams: vec![], voice: None, profile_form: None, dialog: None, status: String::new(), error: String::new(), loading: false } }
|
||||
fn default() -> Self { Self { catalog: Catalog::default(), tabs: vec![], tree: vec![], bookmarks: vec![], contacts: vec![], detail: Detail::default(), actions: vec![], streams: vec![], voice: None, room: Room::default(), profile_form: None, dialog: None, status: String::new(), error: String::new(), loading: false } }
|
||||
}
|
||||
@@ -50,3 +50,53 @@ pub fn color(value:&cssparser_color::Color)->Option<slint::Color>{
|
||||
if rgb.iter().any(|v|!v.is_finite())||!alpha.is_finite(){return None}
|
||||
Some(slint::Color::from_argb_u8((alpha.clamp(0.,1.)*255.).round() as u8,(rgb[0].clamp(0.,1.)*255.).round() as u8,(rgb[1].clamp(0.,1.)*255.).round() as u8,(rgb[2].clamp(0.,1.)*255.).round() as u8))
|
||||
}
|
||||
|
||||
/// Only the active Android settings editor may supply ephemeral colors to the renderer.
|
||||
pub fn android_palette(snapshot:&Snapshot)->&serde_json::Value {
|
||||
let saved=&snapshot.settings.prefs["androidPalette"];
|
||||
// Package previews remain usable even when a custom Android palette has been saved.
|
||||
let preview=snapshot.destination==crate::ui::shell::Destination::Settings&&snapshot.settings_view.panel_open&&snapshot.settings_view.page()==crate::ui::settings::Page::Palette;
|
||||
if preview {snapshot.settings.palette_draft.as_ref().filter(|value|crate::services::prefs::valid_android_palette(value)).unwrap_or(saved)}else if snapshot.settings.theme_preview.is_some(){&serde_json::Value::Null}else{saved}
|
||||
}
|
||||
|
||||
/// Derive readable semantic roles without changing the user's chosen accent fill.
|
||||
#[cfg(target_os="android")]
|
||||
pub fn apply_android_palette(theme:&crate::Theme,value:&serde_json::Value,high_contrast:bool) {
|
||||
use crate::services::prefs::*;
|
||||
let custom=valid_android_palette(value);
|
||||
let existing=|color:slint::Color|[color.red(),color.green(),color.blue()];
|
||||
let (bg,surface,fg,accent,surfaces)=if custom {
|
||||
let rgb=|key:&str|palette_rgb(value[key].as_str().unwrap()).unwrap();let bg=rgb("background");let surface=rgb("surface");(bg,surface,rgb("foreground"),rgb("accent"),palette_surfaces(bg,surface))
|
||||
}else{let bg=existing(theme.get_shaded());let surface=existing(theme.get_bg());(bg,surface,existing(theme.get_fg()),existing(theme.get_tint()),[bg,surface,existing(theme.get_header()),existing(theme.get_contrast())])};
|
||||
let ink=|seed:[u8;3]|{(0..=100).map(|step|palette_mix(seed,fg,f64::from(step)/100.)).find(|candidate|surfaces.iter().all(|bg|palette_contrast(*candidate,*bg)>=4.5)).unwrap_or(fg)};
|
||||
let color=|v:[u8;3]|slint::Color::from_rgb_u8(v[0],v[1],v[2]);
|
||||
let on=if palette_contrast(accent,[255;3])>=palette_contrast(accent,[0;3]){[255;3]}else{[0;3]};
|
||||
if custom {theme.set_dark(palette_luminance(bg)<=0.5);theme.set_bg(color(surface));theme.set_shaded(color(bg));theme.set_header(color(surfaces[2]));theme.set_contrast(color(surfaces[3]));theme.set_deviant(color(surface));}
|
||||
theme.set_fg(color(fg));theme.set_tint(color(accent));theme.set_tint_text(color(ink(accent)));theme.set_on_tint(color(on));
|
||||
theme.set_muted(color(if high_contrast{fg}else{ink(palette_mix(fg,surface,0.24))}));theme.set_outline(color(if high_contrast{fg}else{palette_mix(fg,surface,0.65)}));
|
||||
theme.set_success(color(ink([122,221,181])));theme.set_error(color(ink([255,155,155])));theme.set_warning(color(ink([255,180,80])));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod palette_tests {
|
||||
use super::*;
|
||||
use crate::{services::prefs,ui::{settings::{Category,Page},shell::Destination}};
|
||||
#[test]
|
||||
fn preview_never_persists_or_leaks_into_other_destinations() {
|
||||
let mut snapshot=Snapshot::default();snapshot.settings.prefs=prefs::defaults();
|
||||
let saved=snapshot.settings.prefs["androidPalette"].clone();let draft=prefs::android_palette_preset("graphite").unwrap();
|
||||
snapshot.settings.palette_draft=Some(draft.clone());snapshot.settings_view.category=Category::Appearance;snapshot.settings_view.pages=vec![Page::Palette];snapshot.settings_view.panel_open=true;snapshot.destination=Destination::Settings;
|
||||
assert_eq!(android_palette(&snapshot),&draft);assert_eq!(snapshot.settings.prefs["androidPalette"],saved);
|
||||
snapshot.destination=Destination::Servers;assert_eq!(android_palette(&snapshot),&saved);
|
||||
snapshot.destination=Destination::Settings;snapshot.settings.palette_draft=None;assert_eq!(android_palette(&snapshot),&saved);
|
||||
snapshot.settings.palette_draft=Some(draft);snapshot.settings_view.panel_open=false;assert_eq!(android_palette(&snapshot),&saved);
|
||||
}
|
||||
#[test]
|
||||
fn malformed_or_low_contrast_preview_keeps_saved_readable_colors() {
|
||||
let mut snapshot=Snapshot::default();snapshot.settings.prefs=prefs::defaults();snapshot.destination=Destination::Settings;snapshot.settings_view.panel_open=true;snapshot.settings_view.pages=vec![Page::Palette];
|
||||
let saved=snapshot.settings.prefs["androidPalette"].clone();let mut draft=saved.clone();
|
||||
draft["accent"]="#12".into();snapshot.settings.palette_draft=Some(draft.clone());assert_eq!(android_palette(&snapshot),&saved);
|
||||
draft=saved.clone();draft["foreground"]=draft["background"].clone();snapshot.settings.palette_draft=Some(draft);assert_eq!(android_palette(&snapshot),&saved);
|
||||
snapshot.settings.palette_draft=Some(prefs::android_palette_preset("light").unwrap());snapshot.settings_view.pages.clear();assert_eq!(android_palette(&snapshot),&saved);
|
||||
}
|
||||
}
|
||||
+27
-15
@@ -1,6 +1,6 @@
|
||||
import { ListView, ScrollView } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
import { ActionButton, TextField, Toggle } from "controls.slint";
|
||||
import { ActionButton, TextField, Toggle, RoomIconButton } from "controls.slint";
|
||||
|
||||
export struct ChatMeasure { width: float, height: float }
|
||||
export struct ChatRun {
|
||||
@@ -132,8 +132,8 @@ component RichRowContent inherits Rectangle {
|
||||
width: max(root.viewport-width, root.visual.content-width * 1px);
|
||||
background: root.visual.kind == 3 || root.visual.kind == 7 ? Theme.header
|
||||
: root.visual.kind == 4 ? Theme.deviant : root.visual.kind == 8 ? Theme.bg
|
||||
: root.visual.kind == 11 ? Theme.header : !root.visual.compact && !root.visual.header && !root.inert ? (root.visual.own ? Theme.contrast : Theme.muted) : transparent;
|
||||
border-radius: root.visual.kind == 11 ? 10px : 4px;
|
||||
: root.visual.kind == 11 ? Theme.header : !root.visual.compact && !root.visual.header && !root.inert ? (Theme.android ? (root.visual.own ? Theme.bg : transparent) : (root.visual.own ? Theme.contrast : Theme.muted)) : transparent;
|
||||
border-radius: Theme.android ? 12px : root.visual.kind == 11 ? 10px : 4px;
|
||||
row-focus := FocusScope {
|
||||
accessible-role: text;
|
||||
accessible-label: root.visual.plain;
|
||||
@@ -157,7 +157,7 @@ component RichRowContent inherits Rectangle {
|
||||
Rectangle { x: 12px; y: 6px; width: 10px; height: 10px; border-radius: 5px; background: Theme.muted; }
|
||||
Rectangle { x: 6px; y: 18px; width: 22px; height: 12px; border-radius: 8px; background: Theme.muted; }
|
||||
}
|
||||
Text { text: root.visual.author; color: Theme.high-contrast ? Theme.fg : root.visual.author-color; font-family: Theme.font-family; font-size: 13px; font-weight: 700; overflow: elide; vertical-alignment: center; }
|
||||
Text { text: root.visual.author; color: Theme.high-contrast || Theme.android ? Theme.fg : root.visual.author-color; font-family: Theme.font-family; font-size: 13px; font-weight: 700; overflow: elide; vertical-alignment: center; }
|
||||
if !root.visual.compact: Text { text: root.visual.time; color: Theme.muted; font-family: Theme.font-family; font-size: 13px; vertical-alignment: center; horizontal-alignment: right; horizontal-stretch: 1; }
|
||||
}
|
||||
for run in root.visual.runs: Rectangle {
|
||||
@@ -167,7 +167,7 @@ component RichRowContent inherits Rectangle {
|
||||
if run.image-ready && !run.concealed: Image { source: run.asset; image-fit: contain; }
|
||||
if !run.image-ready && !run.concealed: Text {
|
||||
text: run.text;
|
||||
color: run.use-color && !Theme.high-contrast ? run.foreground : run.action != "" && !root.inert ? Theme.tint : Theme.fg;
|
||||
color: run.use-color && !Theme.high-contrast ? run.foreground : run.action != "" && !root.inert ? (Theme.android ? Theme.tint-text : Theme.tint) : Theme.fg;
|
||||
font-family: run.mono ? "monospace" : Theme.font-family;
|
||||
font-size: run.font-size * 1px; font-weight: run.font-weight; font-italic: run.italic;
|
||||
vertical-alignment: top;
|
||||
@@ -255,7 +255,7 @@ export component MarkupPanel inherits Rectangle {
|
||||
}
|
||||
|
||||
export component ChatScreen inherits Rectangle {
|
||||
background: Theme.shaded;
|
||||
background: Theme.android ? Theme.header : Theme.shaded;
|
||||
min-width: 0px; min-height: 0px;
|
||||
preferred-width: 100%; preferred-height: 100%;
|
||||
private property <bool> show-tools;
|
||||
@@ -305,7 +305,7 @@ export component ChatScreen inherits Rectangle {
|
||||
Path { x: parent.width - 24px; y: (parent.height - 6px) / 2; width: 10px; height: 6px; commands: "M 0 0 L 5 5 L 10 0"; stroke: Theme.fg; stroke-width: 1.5px; }
|
||||
clicked => { root.show-conversations = true; ChatBridge.mobile-overlay = true; }
|
||||
}
|
||||
ActionButton { text: ChatBridge.tr("admin.search"); clicked => { root.show-search = true; ChatBridge.mobile-overlay = true; } }
|
||||
RoomIconButton { icon: "search"; label: ChatBridge.tr("admin.search"); clicked => { root.show-search = true; ChatBridge.mobile-overlay = true; } }
|
||||
}
|
||||
if !Theme.android && root.show-search: HorizontalLayout {
|
||||
padding-left: 12px; padding-right: 12px; spacing: 8px;
|
||||
@@ -349,9 +349,9 @@ export component ChatScreen inherits Rectangle {
|
||||
error-text := Text { width: error-scroll.visible-width; text: ChatBridge.error; color: Theme.error; wrap: word-wrap; font-family: Theme.font-family; font-size: 13px; accessible-role: text; }
|
||||
}
|
||||
composer := Rectangle {
|
||||
background: Theme.bg; border-radius: 8px; border-width: 1px; border-color: input.has-focus ? Theme.tint : Theme.outline;
|
||||
min-width: 0px; min-height: Theme.android ? 116px : 92px;
|
||||
max-height: Theme.android ? max(116px, root.allocated-height * 0.5) : max(120px, root.allocated-height * 0.55); vertical-stretch: 0;
|
||||
background: Theme.bg; border-radius: Theme.android ? 12px : 8px; border-width: Theme.android ? 0px : 1px; border-color: input.has-focus ? Theme.tint : Theme.outline;
|
||||
min-width: 0px; min-height: Theme.android ? 64px : 92px;
|
||||
max-height: Theme.android ? max(64px, root.allocated-height * 0.5) : max(120px, root.allocated-height * 0.55); vertical-stretch: 0;
|
||||
VerticalLayout {
|
||||
min-width: 0px; preferred-width: 0px;
|
||||
padding: 8px; spacing: 4px;
|
||||
@@ -375,6 +375,12 @@ export component ChatScreen inherits Rectangle {
|
||||
height: min(160px, ChatBridge.completions.length * Theme.touch-target);
|
||||
for item[index] in ChatBridge.completions: ActionButton { text: item.label; primary: index == ChatBridge.completion-index; clicked => { ChatBridge.complete(index); root.show-emoji = false; } }
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: Theme.android ? 8px : 0px; min-width: 0px;
|
||||
if Theme.android: RoomIconButton {
|
||||
icon: "plus"; label: ChatBridge.tr("chat.toolbar.more");
|
||||
clicked => { root.show-tools = true; ChatBridge.mobile-overlay = true; }
|
||||
}
|
||||
editor-scroll := ScrollView {
|
||||
content-width: Theme.android ? self.visible-width : max(self.visible-width, ChatBridge.editor-width * 1px);
|
||||
horizontal-scrollbar-policy: Theme.android ? always-off : as-needed;
|
||||
@@ -457,11 +463,16 @@ export component ChatScreen inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: Theme.android ? 8px : 4px;
|
||||
if Theme.android: ActionButton { text: ChatBridge.tr("chat.toolbar.more"); clicked => { root.show-tools = true; ChatBridge.mobile-overlay = true; } }
|
||||
ActionButton { text: ChatBridge.tr("chat.emoji.label"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { root.show-emoji = !root.show-emoji; root.show-tools = false; ChatBridge.emoji(""); if Theme.android { ChatBridge.mobile-overlay = true; } } }
|
||||
if !Theme.android && ChatBridge.can-attach: ActionButton { text: ChatBridge.tr("chat.attachment.label"); enabled: ChatBridge.enabled; clicked => { ChatBridge.attach(); } }
|
||||
if Theme.android: RoomIconButton {
|
||||
icon: "send"; label: ChatBridge.tr("ui.send"); primary: true;
|
||||
enabled: ChatBridge.can-send && !ChatBridge.composing;
|
||||
clicked => { ChatBridge.send(); }
|
||||
}
|
||||
}
|
||||
if !Theme.android: HorizontalLayout {
|
||||
spacing: 4px;
|
||||
ActionButton { text: ChatBridge.tr("chat.emoji.label"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { root.show-emoji = !root.show-emoji; root.show-tools = false; ChatBridge.emoji(""); } }
|
||||
if ChatBridge.can-attach: ActionButton { text: ChatBridge.tr("chat.attachment.label"); enabled: ChatBridge.enabled; clicked => { ChatBridge.attach(); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: ChatBridge.tr("ui.send"); primary: true; enabled: ChatBridge.can-send && !ChatBridge.composing; clicked => { ChatBridge.send(); } }
|
||||
}
|
||||
@@ -521,6 +532,7 @@ export component ChatScreen inherits Rectangle {
|
||||
min-width: 0px; min-height: 0px; horizontal-scrollbar-policy: always-off;
|
||||
VerticalLayout {
|
||||
spacing: 8px;
|
||||
ActionButton { text: ChatBridge.tr("chat.emoji.label"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { root.show-tools = false; root.show-emoji = true; ChatBridge.emoji(""); } }
|
||||
if ChatBridge.can-attach: ActionButton { text: ChatBridge.tr("chat.attachment.label"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.mobile-overlay = false; ChatBridge.attach(); } }
|
||||
for item[index] in ChatBridge.completions: ActionButton { text: item.label; primary: index == ChatBridge.completion-index; clicked => { ChatBridge.complete(index); ChatBridge.mobile-overlay = false; } }
|
||||
ActionButton { text: ChatBridge.tr("native.chat.conversations"); enabled: ChatBridge.tabs.length > 0; clicked => { root.show-tools = false; root.show-conversations = true; } }
|
||||
|
||||
@@ -11,8 +11,8 @@ export component ActionButton inherits Rectangle {
|
||||
min-width: Theme.android ? 48px : max(44px, label.preferred-width + 24px);
|
||||
preferred-height: Theme.android ? max(Theme.touch-target, label.preferred-height + 16px) : Theme.touch-target;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
border-radius: primary ? self.height / 2 : 4px;
|
||||
background: primary ? (destructive ? Theme.error : Theme.tint) : (touch.has-hover || focus.has-focus ? Theme.bg : transparent);
|
||||
border-radius: Theme.android || primary ? self.height / 2 : 4px;
|
||||
background: primary ? (destructive ? Theme.error : Theme.tint) : (Theme.android || touch.has-hover || focus.has-focus ? Theme.bg : transparent);
|
||||
border-width: focus.has-focus || Theme.high-contrast ? 2px : 0px;
|
||||
border-color: Theme.outline;
|
||||
opacity: enabled ? 1 : 0.45;
|
||||
@@ -20,7 +20,7 @@ export component ActionButton inherits Rectangle {
|
||||
accessible-label: text;
|
||||
accessible-enabled: enabled;
|
||||
accessible-action-default => { if root.enabled { root.clicked(); } }
|
||||
label := Text { x: Theme.android ? 12px : 0px; width: parent.width - (Theme.android ? 24px : 0px); text: root.text; color: root.primary ? (Theme.dark ? Theme.contrast : #fff) : (root.destructive ? Theme.error : Theme.fg); font-family: Theme.font-family; font-size: Theme.font-size; horizontal-alignment: center; vertical-alignment: center; wrap: Theme.android ? word-wrap : no-wrap; overflow: elide; }
|
||||
label := Text { x: Theme.android ? 12px : 0px; width: parent.width - (Theme.android ? 24px : 0px); text: root.text; color: root.primary ? (Theme.android ? Theme.on-tint : (Theme.dark ? Theme.contrast : #fff)) : (root.destructive ? Theme.error : Theme.fg); font-family: Theme.font-family; font-size: Theme.font-size; horizontal-alignment: center; vertical-alignment: center; wrap: Theme.android ? word-wrap : no-wrap; overflow: elide; }
|
||||
focus := FocusScope {
|
||||
enabled: root.enabled;
|
||||
key-pressed(event) => { if event.text == "\n" || event.text == " " { root.clicked(); return accept; } return reject; }
|
||||
@@ -31,6 +31,7 @@ export component ActionButton inherits Rectangle {
|
||||
export component TextField inherits Rectangle {
|
||||
in-out property <string> text;
|
||||
in property <string> placeholder;
|
||||
in property <string> label: placeholder;
|
||||
in property <bool> secret: false;
|
||||
in property <bool> enabled: true;
|
||||
out property <bool> has-focus: input.has-focus;
|
||||
@@ -59,7 +60,7 @@ export component TextField inherits Rectangle {
|
||||
selection-foreground-color: Theme.contrast;
|
||||
edited => { root.edited(self.text); }
|
||||
accepted => { root.accepted(); }
|
||||
accessible-label: root.placeholder;
|
||||
accessible-label: root.label;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,3 +135,52 @@ export component Choice inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Android Room controls share one stroke vocabulary and labelled 48dp hit targets.
|
||||
export component RoomIcon inherits Path {
|
||||
in property <string> name;
|
||||
in property <color> ink: Theme.fg;
|
||||
width: 24px; height: 24px;
|
||||
fill: transparent; stroke: ink; stroke-width: 1.8px;
|
||||
commands: name == "back" ? "M19 12H5 M12 5L5 12L12 19"
|
||||
: name == "more" ? "M5 11V13 M12 11V13 M19 11V13"
|
||||
: name == "close" ? "M6 6L18 18 M6 18L18 6"
|
||||
: name == "mic" ? "M9 5A3 3 0 0 1 15 5V12A3 3 0 0 1 9 12Z M5 10V12A7 7 0 0 0 19 12V10 M12 19V22 M9 22H15"
|
||||
: name == "mic-off" ? "M3 3L21 21 M9 9V12A3 3 0 0 0 14 14 M9 5A3 3 0 0 1 15 5V11 M5 10V12A7 7 0 0 0 17 17 M19 12V10 M12 19V22 M9 22H15"
|
||||
: name == "headphones" ? "M4 13V12A8 8 0 0 1 20 12V13 M4 12H3V20H7V12Z M20 12H21V20H17V12Z"
|
||||
: name == "sound-off" ? "M4 9H8L13 5V19L8 15H4Z M17 10L22 15 M17 15L22 10"
|
||||
: name == "chat" ? "M4 4H20V16H9L4 20Z M8 8H16 M8 12H13"
|
||||
: name == "users" ? "M9 12A4 4 0 1 0 9 4A4 4 0 0 0 9 12 M2 21V19A6 6 0 0 1 14 19V21 M17 4A4 4 0 0 1 17 12 M19 15A5 5 0 0 1 22 19V21"
|
||||
: name == "user" ? "M12 12A4 4 0 1 0 12 4A4 4 0 0 0 12 12 M5 21V19A7 7 0 0 1 19 19V21"
|
||||
: name == "settings" ? "M9 3L8 6L5 7L3 10L5 12L4 15L6 18L9 17L12 19L15 17L18 18L20 15L19 12L21 10L19 7L16 6L15 3Z M12 9A3 3 0 1 0 12 15A3 3 0 0 0 12 9"
|
||||
: name == "server" ? "M4 3H20V10H4Z M4 14H20V21H4Z M7 6V7 M7 17V18 M11 6H17 M11 17H17"
|
||||
: name == "screen" ? "M3 4H21V17H3Z M12 17V21 M8 21H16"
|
||||
: name == "down" ? "M6 9L12 15L18 9"
|
||||
: name == "chevron" ? "M9 5L16 12L9 19"
|
||||
: name == "leave" ? "M9 4H4V20H9 M13 7L18 12L13 17 M8 12H21"
|
||||
: name == "send" ? "M3 3L22 12L3 21L7 12Z M7 12H22"
|
||||
: name == "plus" ? "M12 5V19 M5 12H19"
|
||||
: name == "search" ? "M10 17A7 7 0 1 0 10 3A7 7 0 0 0 10 17 M15 15L21 21"
|
||||
: name == "palette" ? "M12 3A9 9 0 1 0 12 21H14A2 2 0 0 0 15 17A2 2 0 0 1 16 13H18A3 3 0 0 0 21 10A9 9 0 0 0 12 3 M7 7V9 M12 5V7 M17 7V9 M6 12V14"
|
||||
: name == "shield" ? "M12 3L20 6V12C20 17 12 21 12 21C12 21 4 17 4 12V6Z"
|
||||
: name == "bell" ? "M5 16H19L17 13V9A5 5 0 0 0 7 9V13Z M10 20H14"
|
||||
: "M12 3A9 9 0 1 0 12 21A9 9 0 0 0 12 3 M12 10V16 M12 6V8";
|
||||
}
|
||||
|
||||
export component RoomIconButton inherits Rectangle {
|
||||
in property <string> icon;
|
||||
in property <string> label;
|
||||
in property <bool> enabled: true;
|
||||
in property <bool> primary: false;
|
||||
callback clicked();
|
||||
width: 48px; min-height: 48px; preferred-height: 48px; vertical-stretch: 0;
|
||||
border-radius: 12px;
|
||||
background: primary ? Theme.tint : (touch.has-hover || focus.has-focus ? Theme.bg : transparent);
|
||||
border-width: focus.has-focus || Theme.high-contrast ? 2px : 0px;
|
||||
border-color: Theme.outline; opacity: enabled ? 1 : 0.45;
|
||||
accessible-role: button; accessible-label: label; accessible-enabled: enabled;
|
||||
accessible-action-default => { if root.enabled { root.clicked(); } }
|
||||
RoomIcon { name: root.icon; ink: root.primary ? Theme.on-tint : Theme.fg; x: (parent.width - self.width)/2; y: (parent.height - self.height)/2; }
|
||||
focus := FocusScope { enabled: root.enabled; key-pressed(e) => { if e.text == " " || e.text == Key.Return { root.clicked(); return accept; } return reject; } }
|
||||
touch := TouchArea { enabled: root.enabled; clicked => { focus.focus(); root.clicked(); } }
|
||||
}
|
||||
+30
-6
@@ -1,4 +1,4 @@
|
||||
import { ScrollView, TextEdit } from "std-widgets.slint";
|
||||
import { ScrollView, TextEdit, Slider } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
import { ActionButton, TextField, Choice, Toggle } from "controls.slint";
|
||||
import { ShellBridge, ShellCommand } from "shell.slint";
|
||||
@@ -31,16 +31,21 @@ export global DialogBridge {
|
||||
// Android forms share a bounded viewport: context and decisions stay on screen while
|
||||
// every field, auxiliary action and confirmation remains scrollable above the IME.
|
||||
component AndroidDialog inherits Rectangle {
|
||||
background: Theme.contrast;
|
||||
background: Theme.bg;
|
||||
border-radius: DialogBridge.onboarding || Theme.ime-inset > 0px ? 0px : 20px;
|
||||
accessible-role: form;
|
||||
accessible-label: DialogBridge.title;
|
||||
property <bool> advanced: false;
|
||||
property <length> focused-y: -1px;
|
||||
property <string> focused-field;
|
||||
property <bool> short: root.height < 400px;
|
||||
property <bool> stack-actions: root.width < 480px && !root.short;
|
||||
property <bool> stack-actions: root.width < 360px && Theme.font-size > 17px && !root.short;
|
||||
VerticalLayout {
|
||||
padding: 12px; spacing: 8px;
|
||||
padding: 20px; spacing: 12px;
|
||||
if !DialogBridge.onboarding && !root.short && Theme.ime-inset == 0px: HorizontalLayout {
|
||||
alignment: center; vertical-stretch: 0;
|
||||
Rectangle { width: 32px; height: 3px; border-radius: 2px; background: Theme.muted; }
|
||||
}
|
||||
Text {
|
||||
text: DialogBridge.title; color: Theme.fg;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size * 1.25; font-weight: 700;
|
||||
@@ -74,7 +79,7 @@ component AndroidDialog inherits Rectangle {
|
||||
text: field.label; color: Theme.fg; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
}
|
||||
if field.kind == 0 || field.kind == 1 || field.kind == 3 || field.kind == 4: TextField {
|
||||
if field.kind == 0 || field.kind == 1 || field.kind == 3 || (field.kind == 4 && field.id != "db" && field.id != "volume"): TextField {
|
||||
text: field.value; placeholder: field.label; secret: field.kind == 1;
|
||||
enabled: field.enabled && !DialogBridge.busy; min-width: 0px;
|
||||
edited(value) => { DialogBridge.edit(field.id, value); }
|
||||
@@ -90,6 +95,21 @@ component AndroidDialog inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
if field.kind == 4 && (field.id == "db" || field.id == "volume"): VerticalLayout {
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: field.id == "db" ? "\{round(field.value.to-float() * 10) / 10} dB" : "\{round(field.value.to-float() * 100)}%";
|
||||
color: Theme.tint-text; font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
horizontal-alignment: right;
|
||||
}
|
||||
Slider {
|
||||
min-height: 48px; minimum: field.id == "db" ? -200 : 0;
|
||||
maximum: field.id == "db" ? 10 : 2; value: field.value.to-float();
|
||||
enabled: field.enabled && !DialogBridge.busy;
|
||||
accessible-label: field.label;
|
||||
changed(value) => { DialogBridge.edit(field.id, "\{round(value * 100) / 100}"); }
|
||||
}
|
||||
}
|
||||
if field.kind == 2: TextEdit {
|
||||
text: field.value; enabled: field.enabled && !DialogBridge.busy; wrap: word-wrap;
|
||||
height: max(96px, Theme.font-size * 4); min-width: 0px;
|
||||
@@ -217,7 +237,11 @@ export component ShellDialog inherits Rectangle {
|
||||
property <bool> phone: Theme.android;
|
||||
// An overlay blocks background pointer input without turning Cancel into a submit.
|
||||
TouchArea { }
|
||||
if root.phone: AndroidDialog { width: root.width; height: root.height; }
|
||||
if root.phone: AndroidDialog {
|
||||
width: min(root.width, 640px); x: (root.width - self.width) / 2;
|
||||
height: DialogBridge.onboarding || Theme.ime-inset > 0px || root.height < 480px ? root.height : min(root.height - 24px, 660px);
|
||||
y: root.height - self.height;
|
||||
}
|
||||
if !root.phone: dialog := Rectangle {
|
||||
width: min(parent.width - 24px, 640px);
|
||||
height: min(parent.height - 24px, layout.preferred-height);
|
||||
|
||||
+114
-19
@@ -1,6 +1,6 @@
|
||||
import { ScrollView, ListView, AboutSlint } from "std-widgets.slint";
|
||||
import { ScrollView, ListView, AboutSlint, Slider } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
import { ActionButton, TextField, Toggle, Choice } from "controls.slint";
|
||||
import { ActionButton, TextField, Toggle, Choice, RoomIcon, RoomIconButton } from "controls.slint";
|
||||
import { RichDocument, ChatVisual } from "chat.slint";
|
||||
|
||||
export struct SettingsRow {
|
||||
@@ -8,10 +8,14 @@ export struct SettingsRow {
|
||||
checked: bool, value: string, options: [string], selected: int,
|
||||
enabled: bool, destructive: bool, inset: bool, error: string,
|
||||
meter: float, decrease: string, increase: string, rich: [ChatVisual],
|
||||
swatch: color, red: float, green: float, blue: float,
|
||||
}
|
||||
export global SettingsBridge {
|
||||
in-out property <[string]> categories;
|
||||
in-out property <[string]> category-groups;
|
||||
in-out property <[string]> category-subtitles;
|
||||
in-out property <string> profile-name;
|
||||
in-out property <string> profile-label;
|
||||
in-out property <[SettingsRow]> rows;
|
||||
in-out property <int> category;
|
||||
in-out property <string> title;
|
||||
@@ -33,16 +37,18 @@ export global SettingsBridge {
|
||||
callback commit(string, string);
|
||||
callback step(string, int);
|
||||
callback capture-lost();
|
||||
callback color-channel(string, int, float);
|
||||
}
|
||||
|
||||
component SettingCell inherits Rectangle {
|
||||
in property <SettingsRow> setting;
|
||||
in property <bool> compact;
|
||||
private property <string> secret-draft;
|
||||
private property <bool> color-expanded;
|
||||
private property <string> secret-owner: setting.stable-id;
|
||||
changed secret-owner => { root.secret-draft = ""; }
|
||||
callback field-focused(bool);
|
||||
background: setting.kind == 0 ? transparent : Theme.header;
|
||||
background: Theme.android || setting.kind == 0 ? transparent : Theme.header;
|
||||
min-height: Theme.android ? content.preferred-height : (setting.kind == 0 ? 48px : content.preferred-height + 16px);
|
||||
preferred-height: self.min-height;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
@@ -83,12 +89,19 @@ component SettingCell inherits Rectangle {
|
||||
font-family: Theme.font-family; font-size: Theme.font-size - 1px;
|
||||
accessible-role: text; accessible-label: self.text;
|
||||
}
|
||||
if root.setting.kind == 3: Choice {
|
||||
if root.setting.kind == 3 && root.setting.stable-id != "palette-presets": Choice {
|
||||
values: root.setting.options; current-index: root.setting.selected;
|
||||
enabled: root.setting.enabled; label: root.setting.title;
|
||||
min-height: max(48px, Theme.touch-target);
|
||||
selected(index) => { self.current-index = root.setting.selected; SettingsBridge.choice-value(root.setting.token, index); }
|
||||
}
|
||||
if root.setting.kind == 3 && root.setting.stable-id == "palette-presets": HorizontalLayout {
|
||||
spacing: 8px;
|
||||
for preset[index] in root.setting.options: ActionButton {
|
||||
text: preset; min-width: 0px; enabled: root.setting.enabled;
|
||||
clicked => { SettingsBridge.choice-value(root.setting.token, index); }
|
||||
}
|
||||
}
|
||||
if root.setting.kind == 4 || root.setting.kind == 5 || root.setting.kind == 8: VerticalLayout {
|
||||
spacing: 4px;
|
||||
field := TextField {
|
||||
@@ -124,8 +137,42 @@ component SettingCell inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
if root.setting.kind == 10: VerticalLayout {
|
||||
spacing: 8px;
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
TextField {
|
||||
text: root.setting.value; placeholder: "#RRGGBB"; label: root.setting.title + " · #RRGGBB";
|
||||
enabled: root.setting.enabled; min-width: 0px; horizontal-stretch: 1;
|
||||
changed has-focus => { root.field-focused(self.has-focus); }
|
||||
edited(value) => { SettingsBridge.draft(root.setting.token, value); }
|
||||
accepted => { SettingsBridge.commit(root.setting.token, self.text); }
|
||||
}
|
||||
Rectangle {
|
||||
width: 48px; height: 48px; background: root.setting.swatch; border-radius: 8px;
|
||||
border-width: 1px; border-color: Theme.outline;
|
||||
RoomIconButton { icon: "palette"; label: root.setting.title; enabled: root.setting.enabled;
|
||||
accessible-expandable: true; accessible-expanded: root.color-expanded;
|
||||
clicked => { root.color-expanded = !root.color-expanded; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if root.color-expanded: VerticalLayout {
|
||||
spacing: 8px;
|
||||
for channel[index] in [root.setting.red, root.setting.green, root.setting.blue]: HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: index == 0 ? "R" : index == 1 ? "G" : "B"; color: Theme.fg;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size; width: 24px; vertical-alignment: center; }
|
||||
Slider { minimum: 0; maximum: 255; value: channel; enabled: root.setting.enabled; min-height: 48px;
|
||||
accessible-label: root.setting.title + (index == 0 ? " · R" : index == 1 ? " · G" : " · B");
|
||||
changed(value) => { SettingsBridge.color-channel(root.setting.token, index, value); }
|
||||
}
|
||||
Text { text: "\{round(channel)}"; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; width: 36px; vertical-alignment: center; }
|
||||
}
|
||||
}
|
||||
}
|
||||
if root.setting.kind == 6: ActionButton {
|
||||
text: root.setting.title; enabled: root.setting.enabled; destructive: root.setting.destructive;
|
||||
text: root.setting.title; enabled: root.setting.enabled; destructive: root.setting.destructive; primary: Theme.android && root.setting.stable-id == "palette-save";
|
||||
min-height: max(48px, Theme.touch-target);
|
||||
clicked => { SettingsBridge.invoke(root.setting.token); }
|
||||
}
|
||||
@@ -141,6 +188,30 @@ component SettingCell inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
component RoomSettingsRow inherits Rectangle {
|
||||
in property <int> category;
|
||||
min-height: max(72px, row-content.preferred-height); vertical-stretch: 0;
|
||||
background: row-touch.pressed ? Theme.bg : transparent;
|
||||
accessible-role: button;
|
||||
accessible-label: SettingsBridge.categories[category] + ". " + SettingsBridge.category-subtitles[category];
|
||||
accessible-action-default => { SettingsBridge.category-chosen(root.category); }
|
||||
border-width: row-focus.has-focus ? 2px : 0px; border-color: Theme.tint-text;
|
||||
row-content := HorizontalLayout {
|
||||
padding-left: 0px; padding-right: 0px; padding-top: 12px; padding-bottom: 12px; spacing: 16px;
|
||||
RoomIcon { name: root.category == 3 ? "headphones" : root.category == 8 ? "bell" : root.category == 2 ? "palette" : root.category == 0 ? "user" : root.category == 1 ? "shield" : root.category == 4 ? "screen" : root.category == 6 ? "chat" : root.category == 7 ? "users" : root.category == 11 ? "info" : "settings"; ink: Theme.muted; width: 20px; height: 24px; }
|
||||
VerticalLayout { spacing: 4px; alignment: center;
|
||||
Text { text: SettingsBridge.categories[root.category]; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; font-weight: 600; wrap: word-wrap; }
|
||||
Text { text: SettingsBridge.category-subtitles[root.category]; color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size * 0.85; wrap: word-wrap; }
|
||||
}
|
||||
RoomIcon { name: "chevron"; ink: Theme.muted; width: 20px; height: 24px; }
|
||||
}
|
||||
Rectangle { y: parent.height - 1px; height: 1px; width: parent.width; background: Theme.outline; }
|
||||
row-focus := FocusScope { key-pressed(event) => {
|
||||
if event.text == Key.Return || event.text == " " { SettingsBridge.category-chosen(root.category); return accept; }return reject;
|
||||
} }
|
||||
row-touch := TouchArea { clicked => { row-focus.focus(); SettingsBridge.category-chosen(root.category); } }
|
||||
}
|
||||
|
||||
export component SettingsScreen inherits Rectangle {
|
||||
background: Theme.shaded;
|
||||
min-width: 0px; min-height: 0px;
|
||||
@@ -148,6 +219,8 @@ export component SettingsScreen inherits Rectangle {
|
||||
private property <bool> compact: self.width < 600px;
|
||||
private property <length> focused-row-y: -1px;
|
||||
private property <string> focused-row;
|
||||
private property <string> content-title: SettingsBridge.title;
|
||||
changed content-title => { root.focused-row = ""; root.focused-row-y = -1px; }
|
||||
forward-focus: keyboard;
|
||||
keyboard := FocusScope {
|
||||
key-pressed(event) => {
|
||||
@@ -211,23 +284,36 @@ export component SettingsScreen inherits Rectangle {
|
||||
}
|
||||
}
|
||||
if Theme.android: VerticalLayout {
|
||||
padding: 8px; spacing: 0px; min-width: 0px;
|
||||
padding: 20px; spacing: 0px; min-width: 0px;
|
||||
if !SettingsBridge.panel-open: ScrollView {
|
||||
min-height: 0px; min-width: 0px; vertical-stretch: 1;
|
||||
VerticalLayout {
|
||||
spacing: 4px; alignment: start; min-width: 0px; preferred-width: 0px;
|
||||
for category[index] in SettingsBridge.categories: VerticalLayout {
|
||||
spacing: 4px; vertical-stretch: 0; min-width: 0px; preferred-width: 0px;
|
||||
if index == 0 || index == 2 || index == 11: Text {
|
||||
spacing: 0px; alignment: start; min-width: 0px; preferred-width: 0px;
|
||||
Rectangle {
|
||||
min-height: max(104px, profile-content.preferred-height); vertical-stretch: 0;
|
||||
accessible-role: button; accessible-label: SettingsBridge.profile-label + ". " + SettingsBridge.profile-name;
|
||||
accessible-action-default => { SettingsBridge.category-chosen(0); }
|
||||
border-width: profile-focus.has-focus ? 2px : 0px; border-color: Theme.tint-text;
|
||||
profile-content := HorizontalLayout { spacing: 14px; padding-top: 12px; padding-bottom: 12px;
|
||||
Rectangle { width: 64px; height: 64px; background: Theme.bg; border-radius: 32px;
|
||||
RoomIcon { name: "user"; ink: Theme.tint-text; x: 16px; y: 16px; width: 32px; height: 32px; }
|
||||
}
|
||||
VerticalLayout { spacing: 4px; alignment: center;
|
||||
Text { text: SettingsBridge.profile-name; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size * 1.25; font-weight: 700; wrap: word-wrap; }
|
||||
Text { text: SettingsBridge.profile-label; color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size * 0.85; wrap: word-wrap; }
|
||||
}
|
||||
}
|
||||
profile-focus := FocusScope { key-pressed(event) => { if event.text == Key.Return || event.text == " " { SettingsBridge.category-chosen(0); return accept; }return reject; } }
|
||||
TouchArea { clicked => { profile-focus.focus(); SettingsBridge.category-chosen(0); } }
|
||||
}
|
||||
for category[index] in [3, 8, 2, 0, 1, 4, 5, 6, 7, 9, 10, 11]: VerticalLayout {
|
||||
spacing: 0px; vertical-stretch: 0; min-width: 0px; preferred-width: 0px;
|
||||
if index == 0 || index == 2 || index == 5: Text {
|
||||
text: SettingsBridge.category-groups[index == 0 ? 0 : index == 2 ? 1 : 2];
|
||||
color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size - 1px;
|
||||
min-height: 32px; vertical-alignment: center; wrap: word-wrap;
|
||||
}
|
||||
ActionButton {
|
||||
text: category; primary: index == SettingsBridge.category;
|
||||
min-width: 0px; vertical-stretch: 0;
|
||||
clicked => { SettingsBridge.category-chosen(index); }
|
||||
color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size * 0.85;
|
||||
font-weight: 600; min-height: 48px; vertical-alignment: center; wrap: word-wrap;
|
||||
}
|
||||
RoomSettingsRow { category: category; min-width: 0px; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,7 +334,7 @@ export component SettingsScreen inherits Rectangle {
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
accessible-role: text; accessible-label: self.text;
|
||||
}
|
||||
for row in SettingsBridge.rows: phone-row := VerticalLayout {
|
||||
for row[index] in SettingsBridge.rows: phone-row := VerticalLayout {
|
||||
spacing: 0px; vertical-stretch: 0; min-width: 0px; preferred-width: 0px;
|
||||
changed y => {
|
||||
if root.focused-row == row.stable-id {
|
||||
@@ -256,7 +342,16 @@ export component SettingsScreen inherits Rectangle {
|
||||
phone-list.content-y = clamp(-self.y, min(0px, phone-list.visible-height - phone-list.content-height), 0px);
|
||||
}
|
||||
}
|
||||
if row.kind != 0 || row.title != SettingsBridge.title: SettingCell {
|
||||
if row.stable-id == "palette-cancel": HorizontalLayout {
|
||||
spacing: 8px;
|
||||
ActionButton { text: row.title; enabled: row.enabled;
|
||||
clicked => { SettingsBridge.invoke(row.token); }
|
||||
}
|
||||
ActionButton { text: SettingsBridge.rows[index + 1].title; primary: true; enabled: SettingsBridge.rows[index + 1].enabled;
|
||||
clicked => { SettingsBridge.invoke(SettingsBridge.rows[index + 1].token); }
|
||||
}
|
||||
}
|
||||
if (row.kind != 0 || row.title != SettingsBridge.title) && row.stable-id != "palette-cancel" && row.stable-id != "palette-save": SettingCell {
|
||||
setting: row; compact: true;
|
||||
min-width: 0px; preferred-width: 0px; vertical-stretch: 0;
|
||||
field-focused(focused) => {
|
||||
|
||||
+170
-59
@@ -1,6 +1,6 @@
|
||||
import { ScrollView, ListView, Slider } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
import { ActionButton, TextField, Choice } from "controls.slint";
|
||||
import { ActionButton, TextField, Choice, RoomIcon, RoomIconButton } from "controls.slint";
|
||||
import { ChatScreen } from "chat.slint";
|
||||
import { SettingsScreen, SettingsBridge } from "settings.slint";
|
||||
|
||||
@@ -8,7 +8,7 @@ export struct ShellRow { id: string, title: string, subtitle: string, depth: int
|
||||
export struct ShellTab { id: string, title: string, selected: bool, microphone-owner: bool, connected: bool, unread: string }
|
||||
export struct ShellCommand { id: string, label: string, enabled: bool, reason: string, destructive: bool }
|
||||
export struct ShellInfo { label: string, value: string }
|
||||
export struct ShellStream { id: string, title: string, status: string, frame: image, has-frame: bool, volume: float, actions: [ShellCommand] }
|
||||
export struct ShellStream { id: string, title: string, status: string, frame: image, has-frame: bool, has-volume: bool, volume: float, actions: [ShellCommand] }
|
||||
export global ShellBridge {
|
||||
in-out property <[ShellTab]> tabs;
|
||||
in-out property <[ShellRow]> tree;
|
||||
@@ -68,6 +68,17 @@ export global ShellBridge {
|
||||
in-out property <[string]> stages;
|
||||
in-out property <length> sidebar-width: 270px;
|
||||
in-out property <length> server-width: 500px;
|
||||
in-out property <[ShellRow]> participants;
|
||||
in-out property <[ShellStream]> room-streams;
|
||||
in-out property <bool> room-connected;
|
||||
in-out property <int> room-page;
|
||||
in-out property <string> room-title;
|
||||
in-out property <string> room-server;
|
||||
in-out property <string> room-caption;
|
||||
in-out property <[string]> room-destinations;
|
||||
in-out property <[string]> room-labels;
|
||||
in-out property <ShellCommand> room-disconnect;
|
||||
callback room-navigate(int);
|
||||
callback navigate(int);
|
||||
callback back();
|
||||
callback select(string);
|
||||
@@ -149,13 +160,13 @@ component StreamTile inherits Rectangle {
|
||||
stream-content := VerticalLayout {
|
||||
padding: 8px; spacing: 4px;
|
||||
Text { text: root.item.title; color: Theme.fg; overflow: Theme.android ? clip : elide; wrap: Theme.android ? word-wrap : no-wrap; }
|
||||
Rectangle {
|
||||
if !Theme.android || root.item.has-frame || root.item.has-volume: Rectangle {
|
||||
min-height: Theme.android ? max(100px,root.width * 0.5625) : 150px;
|
||||
if root.item.has-frame: Image { source: root.item.frame; image-fit: contain; }
|
||||
if !root.item.has-frame: Text { text: root.item.status != "" ? root.item.status : ShellBridge.label-stream-waiting; color: Theme.muted; horizontal-alignment: center; vertical-alignment: center; wrap: word-wrap; }
|
||||
}
|
||||
Text { text: root.item.status; color: Theme.muted; overflow: Theme.android ? clip : elide; wrap: Theme.android ? word-wrap : no-wrap; }
|
||||
Slider { min-height: Theme.android ? 48px : 0px; minimum: 0; maximum: 2; value: root.item.volume; accessible-label: ShellBridge.label-volume; changed(value) => { ShellBridge.stream-volume(root.item.id,value); } }
|
||||
if !Theme.android || root.item.has-volume: Slider { min-height: Theme.android ? 48px : 0px; minimum: 0; maximum: 2; value: root.item.volume; accessible-label: ShellBridge.label-volume; changed(value) => { ShellBridge.stream-volume(root.item.id,value); } }
|
||||
CommandList { commands: root.item.actions; }
|
||||
}
|
||||
}
|
||||
@@ -216,7 +227,6 @@ component PhoneEntryRow inherits Rectangle {
|
||||
}
|
||||
|
||||
component PhoneServerList inherits Rectangle {
|
||||
property <bool> saved-open;
|
||||
background: Theme.bg; min-width: 0px; min-height: 0px;
|
||||
VerticalLayout { spacing: 8px; padding: 8px;
|
||||
if ShellBridge.primary-action.id != "": ActionButton { text: ShellBridge.primary-action.label; primary: true; enabled: ShellBridge.primary-action.enabled; clicked => { ShellBridge.invoke(ShellBridge.primary-action.id); } }
|
||||
@@ -224,9 +234,9 @@ component PhoneServerList inherits Rectangle {
|
||||
Choice { horizontal-stretch: 1; values: ShellBridge.connection-names; current-index: ShellBridge.selected-connection; label: ShellBridge.destinations[0]; selected(index) => { if index >= 0 && index < ShellBridge.tabs.length { ShellBridge.select(ShellBridge.tabs[index].id); } } }
|
||||
PhoneIconAction { kind: 0; label: ShellBridge.label-more; enabled: ShellBridge.selected-connection >= 0; clicked => { ShellBridge.context(ShellBridge.tabs[ShellBridge.selected-connection].id); } }
|
||||
}
|
||||
if ShellBridge.bookmarks.length > 0 && ShellBridge.tree.length > 0: ActionButton { text: root.saved-open ? ShellBridge.destinations[0] : ShellBridge.label-bookmarks; clicked => { root.saved-open = !root.saved-open; } }
|
||||
if ShellBridge.tree.length > 0 && !root.saved-open: ListView { min-height: 0px; vertical-stretch: 1; for item in ShellBridge.tree: PhoneEntryRow { item: item; } }
|
||||
if ShellBridge.tree.length == 0 || root.saved-open: ScrollView { min-height: 0px; vertical-stretch: 1;
|
||||
if ShellBridge.bookmarks.length > 0 && ShellBridge.room-page != 6: ActionButton { text: ShellBridge.label-bookmarks; clicked => { ShellBridge.room-navigate(6); } }
|
||||
if ShellBridge.tree.length > 0 && ShellBridge.room-page != 6: ListView { min-height: 0px; vertical-stretch: 1; for item in ShellBridge.tree: PhoneEntryRow { item: item; } }
|
||||
if ShellBridge.tree.length == 0 || ShellBridge.room-page == 6: ScrollView { min-height: 0px; vertical-stretch: 1;
|
||||
VerticalLayout { spacing: 8px;
|
||||
if ShellBridge.tree.length == 0: Text { text: ShellBridge.label-tree-empty; color: Theme.muted; wrap: word-wrap; }
|
||||
if ShellBridge.bookmarks.length > 0: Text { text: ShellBridge.label-bookmarks; color: Theme.fg; font-weight: 600; wrap: word-wrap; }
|
||||
@@ -241,18 +251,15 @@ component PhoneDetail inherits Rectangle {
|
||||
preferred-width: 0px; horizontal-stretch: 1;
|
||||
min-width: 0px; min-height: 0px; background: Theme.shaded;
|
||||
VerticalLayout { spacing: 4px;
|
||||
if !root.typing && ShellBridge.destination != 1: HorizontalLayout { spacing: 8px; padding-left: 8px; padding-right: 8px; vertical-stretch: 0;
|
||||
for name[index] in ShellBridge.stages: ActionButton { min-width: 48px; horizontal-stretch: 1; text: name; primary: ShellBridge.stage == index; clicked => { ShellBridge.stage = index; } }
|
||||
}
|
||||
if ShellBridge.stage == 1 || ShellBridge.destination == 1: ChatScreen { min-height: 0px; }
|
||||
if ShellBridge.stage == 2 && ShellBridge.destination != 1: ScrollView { min-height: 0px; vertical-stretch: 1;
|
||||
if ShellBridge.destination == 1: ChatScreen { min-height: 0px; }
|
||||
if ShellBridge.room-page == 5 && ShellBridge.destination != 1: ScrollView { min-height: 0px; vertical-stretch: 1;
|
||||
VerticalLayout { padding: 8px; spacing: 12px;
|
||||
if ShellBridge.streams.length == 0: Text { text: ShellBridge.label-stream-empty; color: Theme.muted; wrap: word-wrap; }
|
||||
for stream in ShellBridge.streams: StreamTile { item: stream; }
|
||||
CommandList { commands: ShellBridge.detail-actions; }
|
||||
}
|
||||
}
|
||||
if ShellBridge.stage == 0 && ShellBridge.destination != 1: VerticalLayout { spacing: 8px;
|
||||
if ShellBridge.room-page != 5 && ShellBridge.destination != 1: VerticalLayout { spacing: 8px;
|
||||
if ShellBridge.searchable: TextField { text: ShellBridge.search; placeholder: ShellBridge.label-search; edited(value) => { ShellBridge.search-edited(value); } }
|
||||
ScrollView { min-height: 0px; vertical-stretch: 1;
|
||||
VerticalLayout { padding: 8px; spacing: 12px;
|
||||
@@ -273,30 +280,123 @@ component PhoneDetail inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
component PhoneVoice inherits Rectangle {
|
||||
in property <bool> typing;
|
||||
background: Theme.contrast; min-height: voice-content.preferred-height; preferred-height: self.min-height; vertical-stretch: 0;
|
||||
voice-content := VerticalLayout { padding: 4px; spacing: 4px;
|
||||
if !root.typing: Text { text: ShellBridge.voice-title + " · " + ShellBridge.voice-status; color: ShellBridge.transmitting ? Theme.success : Theme.fg; overflow: elide; }
|
||||
HorizontalLayout { spacing: 8px;
|
||||
ActionButton { min-width: 48px; horizontal-stretch: 1; text: ShellBridge.label-mute; primary: ShellBridge.muted; destructive: ShellBridge.muted; clicked => { ShellBridge.voice(0); } }
|
||||
ActionButton { min-width: 48px; horizontal-stretch: 1; text: ShellBridge.label-deafen; primary: ShellBridge.deafened; destructive: ShellBridge.deafened; clicked => { ShellBridge.voice(1); } }
|
||||
if ShellBridge.ptt-enabled: Rectangle {
|
||||
min-width: 48px; horizontal-stretch: 1; min-height: max(48px,hold-label.preferred-height + 16px);
|
||||
background: hold.pressed ? Theme.tint : Theme.bg; border-radius: 4px;
|
||||
accessible-role: button; accessible-label: ShellBridge.label-ptt;
|
||||
border-width: hold-focus.has-focus ? 2px : 0px; border-color: Theme.outline;
|
||||
hold-label := Text { text: ShellBridge.label-ptt; color: Theme.fg; vertical-alignment: center; horizontal-alignment: center; wrap: word-wrap; }
|
||||
hold-focus := FocusScope {
|
||||
changed has-focus => { if !self.has-focus { ShellBridge.held(false); } }
|
||||
key-pressed(e) => { if e.text == " " || e.text == Key.Return { ShellBridge.held(true); return accept; } return reject; }
|
||||
key-released(e) => { if e.text == " " || e.text == Key.Return { ShellBridge.held(false); return accept; } return reject; }
|
||||
}
|
||||
hold := TouchArea {
|
||||
pointer-event(e) => { if e.button == PointerEventButton.left && e.kind == PointerEventKind.down { hold-focus.focus(); ShellBridge.held(true); } else if e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel { ShellBridge.held(false); } }
|
||||
moved => { if self.pressed && (self.mouse-x < 0px || self.mouse-y < 0px || self.mouse-x > self.width || self.mouse-y > self.height) { ShellBridge.held(false); } }
|
||||
component RoomNavigation inherits Rectangle {
|
||||
in property <int> index;
|
||||
property <bool> selected: ShellBridge.room-page == index || (index == 0 && ShellBridge.room-page == 5) || (index == 1 && ShellBridge.room-page == 6) || (index == 3 && ShellBridge.room-page == 4);
|
||||
min-width: 48px; min-height: max(64px, nav-content.preferred-height); vertical-stretch: 0;
|
||||
background: transparent;
|
||||
accessible-role: tab; accessible-label: ShellBridge.room-destinations[index]; accessible-item-selected: selected;
|
||||
accessible-action-default => { ShellBridge.room-navigate(root.index); }
|
||||
nav-content := VerticalLayout { padding: 8px; spacing: 4px; alignment: center;
|
||||
Rectangle { width: 56px; height: 28px; border-radius: 14px; background: root.selected ? Theme.contrast : transparent;
|
||||
RoomIcon { x: (parent.width - self.width)/2; y: 2px; name: root.index == 0 ? "headphones" : root.index == 1 ? "server" : root.index == 2 ? "chat" : "user"; ink: root.selected ? Theme.tint-text : Theme.muted; }
|
||||
}
|
||||
Text { text: ShellBridge.room-destinations[root.index]; color: root.selected ? Theme.tint-text : Theme.fg; font-size: Theme.font-size * 0.86; font-weight: root.selected ? 700 : 400; horizontal-alignment: center; wrap: word-wrap; }
|
||||
}
|
||||
border-width: nav-focus.has-focus ? 2px : 0px; border-color: Theme.outline; border-radius: 12px;
|
||||
nav-focus := FocusScope { key-pressed(e) => { if e.text == "\n" || e.text == " " { ShellBridge.room-navigate(root.index); return accept; } return reject; } }
|
||||
TouchArea { clicked => { nav-focus.focus(); ShellBridge.room-navigate(root.index); } }
|
||||
}
|
||||
|
||||
component RoomParticipant inherits Rectangle {
|
||||
in property <ShellRow> item;
|
||||
min-width: 0px; min-height: max(136px, person-content.preferred-height); preferred-height: self.min-height; vertical-stretch: 0;
|
||||
background: transparent; border-radius: 12px; border-width: person-focus.has-focus ? 2px : 0px; border-color: Theme.outline;
|
||||
accessible-role: button; accessible-label: item.title + ". " + item.subtitle + ". " + ShellBridge.label-more;
|
||||
accessible-action-default => { ShellBridge.context(root.item.id); }
|
||||
person-content := VerticalLayout { padding: 8px; spacing: 8px; alignment: start;
|
||||
Rectangle { width: 68px; height: 68px; border-radius: 34px;
|
||||
background: root.item.talking ? Theme.success.with-alpha(0.14) : Theme.bg;
|
||||
border-width: root.item.talking ? 2px : 0px; border-color: Theme.success;
|
||||
RoomIcon { x: 18px; y: 18px; width: 32px; height: 32px; name: root.item.muted ? "mic-off" : "user"; ink: root.item.talking ? Theme.success : (root.item.muted ? Theme.error : Theme.fg); }
|
||||
}
|
||||
Text { min-width: 0px; text: root.item.title; color: Theme.fg; font-size: Theme.font-size; font-weight: 600; horizontal-alignment: center; wrap: word-wrap; }
|
||||
Text { min-width: 0px; text: root.item.subtitle; color: root.item.talking ? Theme.success : Theme.muted; font-size: Theme.font-size * 0.86; horizontal-alignment: center; wrap: word-wrap; }
|
||||
}
|
||||
person-focus := FocusScope { key-pressed(e) => { if e.text == "\n" || e.text == " " { ShellBridge.context(root.item.id); return accept; } return reject; } }
|
||||
TouchArea { clicked => { person-focus.focus(); ShellBridge.context(root.item.id); } }
|
||||
}
|
||||
|
||||
component RoomView inherits Rectangle {
|
||||
min-width: 0px; min-height: 0px; background: Theme.shaded;
|
||||
property <int> columns: self.width < 360px || Theme.font-size > 18px ? 2 : 3;
|
||||
ScrollView { min-height: 0px;
|
||||
VerticalLayout { padding: 16px; spacing: 24px;
|
||||
VerticalLayout { padding-top: 24px; padding-bottom: 8px; spacing: 8px;
|
||||
if ShellBridge.room-server != "": Text { text: ShellBridge.room-server; color: Theme.muted; horizontal-alignment: center; wrap: word-wrap; }
|
||||
Text { text: ShellBridge.room-title != "" ? ShellBridge.room-title : ShellBridge.room-destinations[0]; color: Theme.fg; font-size: Theme.font-size * 2; font-weight: 700; horizontal-alignment: center; wrap: word-wrap; }
|
||||
Text { text: ShellBridge.room-connected ? ShellBridge.room-caption : ShellBridge.room-labels[9]; color: Theme.muted; horizontal-alignment: center; wrap: word-wrap; }
|
||||
HorizontalLayout { alignment: center; ActionButton { text: ShellBridge.room-labels[0]; clicked => { ShellBridge.room-navigate(1); } } }
|
||||
}
|
||||
VerticalLayout { spacing: 16px;
|
||||
for row in ceil(ShellBridge.participants.length / root.columns): HorizontalLayout { spacing: 8px;
|
||||
for column in root.columns: Rectangle { min-width: 0px; horizontal-stretch: 1; min-height: person.preferred-height;
|
||||
person := RoomParticipant { visible: row * root.columns + column < ShellBridge.participants.length; item: ShellBridge.participants[row * root.columns + column]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
for stream in ShellBridge.room-streams: Rectangle { min-height: max(64px,invite.preferred-height); preferred-height: self.min-height; vertical-stretch: 0; border-radius: 16px; background: Theme.bg;
|
||||
invite := HorizontalLayout { padding: 12px; spacing: 12px;
|
||||
RoomIcon { name: "screen"; ink: Theme.tint-text; }
|
||||
VerticalLayout { horizontal-stretch: 1; spacing: 4px;
|
||||
Text { text: stream.title; color: Theme.fg; font-weight: 600; wrap: word-wrap; }
|
||||
Text { text: stream.status; color: Theme.muted; wrap: word-wrap; }
|
||||
}
|
||||
RoomIconButton { icon: "chevron"; label: ShellBridge.room-labels[10] + ": " + stream.title; clicked => { ShellBridge.room-navigate(5); } }
|
||||
}
|
||||
}
|
||||
ActionButton { text: ShellBridge.room-labels[1]; clicked => { ShellBridge.room-navigate(2); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component RoomVoiceToggle inherits Rectangle {
|
||||
in property <int> kind;
|
||||
property <bool> active: kind == 0 ? !ShellBridge.muted : !ShellBridge.deafened;
|
||||
property <string> label: kind == 0 ? (active ? ShellBridge.room-labels[4] : ShellBridge.room-labels[5]) : (active ? ShellBridge.room-labels[6] : ShellBridge.room-labels[7]);
|
||||
min-width: 48px; min-height: max(48px, toggle-content.preferred-height); preferred-height: self.min-height; vertical-stretch: 0;
|
||||
background: active ? Theme.bg : Theme.error.with-alpha(0.14); border-radius: 24px;
|
||||
accessible-role: button; accessible-label: label; accessible-action-default => { ShellBridge.voice(root.kind); }
|
||||
toggle-content := HorizontalLayout { padding: 12px; spacing: 8px;
|
||||
RoomIcon { name: root.kind == 0 ? (root.active ? "mic" : "mic-off") : (root.active ? "headphones" : "sound-off"); ink: root.active ? Theme.success : Theme.error; }
|
||||
Text { min-width: 0px; text: root.label; color: root.active ? Theme.success : Theme.error; font-size: Theme.font-size * 0.86; font-weight: 600; wrap: word-wrap; vertical-alignment: center; }
|
||||
}
|
||||
border-width: toggle-focus.has-focus ? 2px : 0px; border-color: Theme.outline;
|
||||
toggle-focus := FocusScope { key-pressed(e) => { if e.text == "\n" || e.text == " " { ShellBridge.voice(root.kind); return accept; } return reject; } }
|
||||
TouchArea { clicked => { toggle-focus.focus(); ShellBridge.voice(root.kind); } }
|
||||
}
|
||||
|
||||
component PhoneVoice inherits Rectangle {
|
||||
in property <bool> typing;
|
||||
background: Theme.contrast; border-radius: 16px;
|
||||
min-height: voice-content.preferred-height; preferred-height: self.min-height; vertical-stretch: 0;
|
||||
voice-content := VerticalLayout { padding: 12px; spacing: 8px;
|
||||
if !root.typing: HorizontalLayout { spacing: 8px;
|
||||
RoomIcon { name: "headphones"; ink: ShellBridge.deafened ? Theme.error : Theme.success; }
|
||||
VerticalLayout { horizontal-stretch: 1; spacing: 2px;
|
||||
Text { text: ShellBridge.voice-title; color: Theme.fg; font-size: Theme.font-size * 0.86; font-weight: 600; wrap: word-wrap; }
|
||||
Text { text: ShellBridge.voice-status; color: ShellBridge.transmitting ? Theme.success : Theme.muted; font-size: Theme.font-size * 0.86; wrap: word-wrap; }
|
||||
}
|
||||
if ShellBridge.room-disconnect.id != "": RoomIconButton { icon: "leave"; label: ShellBridge.room-labels[8] + ": " + ShellBridge.voice-title; enabled: ShellBridge.room-disconnect.enabled; clicked => { ShellBridge.invoke(ShellBridge.room-disconnect.id); } }
|
||||
}
|
||||
HorizontalLayout { spacing: 8px;
|
||||
if !ShellBridge.ptt-enabled: RoomVoiceToggle { horizontal-stretch: 1; kind: 0; }
|
||||
if ShellBridge.ptt-enabled: Rectangle {
|
||||
min-width: 48px; horizontal-stretch: 1; min-height: max(48px,hold-label.preferred-height + 16px); background: ShellBridge.transmitting ? Theme.tint : Theme.bg; border-radius: 24px;
|
||||
accessible-role: button; accessible-label: ShellBridge.label-ptt;
|
||||
border-width: hold-focus.has-focus ? 2px : 0px; border-color: Theme.outline;
|
||||
hold-label := Text { text: ShellBridge.label-ptt; color: ShellBridge.transmitting ? Theme.on-tint : Theme.fg; vertical-alignment: center; horizontal-alignment: center; wrap: word-wrap; }
|
||||
hold-focus := FocusScope {
|
||||
changed has-focus => { if !self.has-focus { ShellBridge.held(false); } }
|
||||
key-pressed(e) => { if e.text == " " || e.text == Key.Return { ShellBridge.held(true); return accept; } return reject; }
|
||||
key-released(e) => { if e.text == " " || e.text == Key.Return { ShellBridge.held(false); return accept; } return reject; }
|
||||
}
|
||||
hold := TouchArea {
|
||||
pointer-event(e) => { if e.button == PointerEventButton.left && e.kind == PointerEventKind.down { hold-focus.focus(); ShellBridge.held(true); } else if e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel { ShellBridge.held(false); } }
|
||||
moved => { if self.pressed && (self.mouse-x < 0px || self.mouse-y < 0px || self.mouse-x > self.width || self.mouse-y > self.height) { ShellBridge.held(false); } }
|
||||
}
|
||||
}
|
||||
RoomVoiceToggle { horizontal-stretch: 1; kind: 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,43 +405,49 @@ component AndroidShell inherits Rectangle {
|
||||
property <bool> compact: self.width < 600px;
|
||||
property <bool> split: self.width >= 840px && !typing;
|
||||
property <bool> typing: Theme.ime-inset > 0px;
|
||||
property <length> content-width: max(0px, self.width - (!compact && !typing ? 112px : 0px));
|
||||
property <string> header: ShellBridge.destination == 3 ? (SettingsBridge.panel-open ? SettingsBridge.title : ShellBridge.destinations[3]) : (((ShellBridge.destination == 0 || ShellBridge.destination == 2) && ShellBridge.depth > 0 && ShellBridge.title != "") ? ShellBridge.title : ShellBridge.destinations[ShellBridge.destination]);
|
||||
property <length> content-width: max(0px, self.width - (!compact && !typing ? 104px : 0px));
|
||||
property <string> header: ShellBridge.depth > 0 ? ShellBridge.title : ShellBridge.room-page == 0 ? "TeamsPeach" : ShellBridge.room-page == 1 ? ShellBridge.room-destinations[1] : ShellBridge.room-page == 2 ? ShellBridge.room-title : ShellBridge.room-page == 3 ? (SettingsBridge.panel-open ? SettingsBridge.title : ShellBridge.room-labels[11]) : ShellBridge.room-page == 4 ? ShellBridge.destinations[2] : ShellBridge.room-page == 5 ? ShellBridge.room-labels[10] : ShellBridge.label-bookmarks;
|
||||
VerticalLayout { spacing: 0px;
|
||||
if !root.typing: Rectangle { background: Theme.header; min-height: app-bar.preferred-height; preferred-height: self.min-height; vertical-stretch: 0;
|
||||
app-bar := HorizontalLayout { padding-left: 8px; padding-right: 8px; spacing: 8px;
|
||||
if ShellBridge.depth > 0 || ShellBridge.destination != 0: PhoneIconAction { kind: 1; label: ShellBridge.label-back; clicked => { ShellBridge.back(); } }
|
||||
Text { min-width: 0px; text: root.header; color: Theme.fg; font-size: Theme.font-size * 1.2; font-weight: 600; overflow: elide; horizontal-stretch: 1; vertical-alignment: center; }
|
||||
PhoneIconAction { kind: 0; label: ShellBridge.label-more; clicked => { ShellBridge.menu(); } }
|
||||
if !root.typing: Rectangle { background: Theme.shaded; min-height: app-bar.preferred-height; preferred-height: self.min-height; vertical-stretch: 0;
|
||||
app-bar := HorizontalLayout { padding: 8px; spacing: 8px;
|
||||
if ShellBridge.depth > 0 || ShellBridge.room-page != 0: RoomIconButton { icon: "back"; label: ShellBridge.label-back; clicked => { ShellBridge.back(); } }
|
||||
Text { min-width: 0px; text: root.header; color: Theme.fg; font-size: Theme.font-size * 1.2; font-weight: 700; overflow: elide; horizontal-stretch: 1; vertical-alignment: center; }
|
||||
RoomIconButton { icon: "more"; label: ShellBridge.label-more; clicked => { ShellBridge.menu(); } }
|
||||
}
|
||||
}
|
||||
if ShellBridge.error != "": Text { text: ShellBridge.error; color: Theme.error; wrap: word-wrap; }
|
||||
if ShellBridge.loading: Text { text: ShellBridge.label-loading; color: Theme.muted; }
|
||||
HorizontalLayout { spacing: 0px; min-height: 0px; vertical-stretch: 1;
|
||||
if !root.compact && !root.typing: Rectangle { width: 112px; background: Theme.header;
|
||||
ScrollView { VerticalLayout { padding: 8px; spacing: 8px;
|
||||
for label[index] in ShellBridge.destinations: ActionButton { text: label; min-width: 48px; primary: ShellBridge.destination == index; clicked => { ShellBridge.navigate(index); } }
|
||||
} }
|
||||
if !root.compact && !root.typing: Rectangle { width: 104px; background: Theme.header;
|
||||
ScrollView { VerticalLayout { padding: 8px; spacing: 8px; for index in 4: RoomNavigation { index: index; } } }
|
||||
}
|
||||
if ShellBridge.destination == 3: SettingsScreen { min-width: 0px; min-height: 0px; }
|
||||
if ShellBridge.destination == 2 && (root.split || ShellBridge.depth == 0): ScrollView { min-height: 0px; width: root.split ? root.content-width * 0.35 : root.content-width;
|
||||
VerticalLayout { padding: 8px; spacing: 8px;
|
||||
if ShellBridge.room-page == 3: SettingsScreen { min-width: 0px; min-height: 0px; }
|
||||
if ShellBridge.room-page == 4 && (root.split || ShellBridge.depth == 0): ScrollView { min-height: 0px; width: root.split ? root.content-width * 0.35 : root.content-width;
|
||||
VerticalLayout { padding: 16px; spacing: 8px;
|
||||
if ShellBridge.contacts.length == 0: Text { text: ShellBridge.label-empty; color: Theme.muted; wrap: word-wrap; }
|
||||
for item in ShellBridge.contacts: PhoneEntryRow { item: item; }
|
||||
}
|
||||
}
|
||||
if ShellBridge.destination == 2 && ShellBridge.depth > 0: PhoneDetail { typing: root.typing; }
|
||||
if ShellBridge.destination == 1: PhoneDetail { typing: root.typing; }
|
||||
if ShellBridge.destination == 0: HorizontalLayout { spacing: 0px; min-width: 0px; preferred-width: 0px; horizontal-stretch: 1;
|
||||
if ShellBridge.room-page == 4 && ShellBridge.depth > 0: PhoneDetail { typing: root.typing; }
|
||||
if ShellBridge.room-page == 2: ChatScreen { min-width: 0px; min-height: 0px; }
|
||||
if ShellBridge.room-page == 5: PhoneDetail { typing: root.typing; }
|
||||
if ShellBridge.room-page == 0: HorizontalLayout { min-width: 0px; spacing: 0px;
|
||||
if root.split: PhoneServerList { width: root.content-width * 0.35; }
|
||||
if ShellBridge.depth == 0: RoomView { horizontal-stretch: 1; }
|
||||
if ShellBridge.depth > 0: PhoneDetail { typing: root.typing; }
|
||||
}
|
||||
if ShellBridge.room-page == 1 || ShellBridge.room-page == 6: HorizontalLayout { spacing: 0px; min-width: 0px;
|
||||
if !root.typing && (root.split || ShellBridge.depth == 0): PhoneServerList { width: root.split ? root.content-width * 0.4 : root.content-width; }
|
||||
if root.split: Rectangle { width: 1px; background: Theme.outline; }
|
||||
if root.split || ShellBridge.depth > 0 || root.typing: PhoneDetail { typing: root.typing; }
|
||||
if ShellBridge.depth > 0 || root.typing: PhoneDetail { typing: root.typing; }
|
||||
if root.split && ShellBridge.depth == 0: RoomView { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
if ShellBridge.has-voice: PhoneVoice { typing: root.typing; }
|
||||
if ShellBridge.status != "" && !root.typing: Text { text: ShellBridge.status; color: Theme.muted; overflow: elide; }
|
||||
if root.compact && !root.typing: HorizontalLayout { spacing: 8px; padding: 4px; vertical-stretch: 0;
|
||||
for label[index] in ShellBridge.destinations: ActionButton { min-width: 48px; horizontal-stretch: 1; text: label; primary: ShellBridge.destination == index; clicked => { ShellBridge.navigate(index); } }
|
||||
if ShellBridge.has-voice: Rectangle { min-height: dock.preferred-height + 16px; preferred-height: self.min-height; vertical-stretch: 0;
|
||||
dock := PhoneVoice { x: 12px; y: 8px; width: max(0px,parent.width - 24px); typing: root.typing; }
|
||||
}
|
||||
if root.compact && !root.typing: Rectangle { min-height: bottom-nav.preferred-height; preferred-height: self.min-height; vertical-stretch: 0; background: Theme.header;
|
||||
bottom-nav := HorizontalLayout { spacing: 8px; padding: 4px; for index in 4: RoomNavigation { horizontal-stretch: 1; index: index; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -510,7 +616,12 @@ export component ShellScreen inherits Rectangle {
|
||||
phone-menu := VerticalLayout { padding: 12px; spacing: 8px;
|
||||
menu-title := Text { text: ShellBridge.menu-title; color: Theme.fg; font-weight: 600; wrap: word-wrap; max-height: root.height * 0.2; overflow: elide; }
|
||||
ScrollView { height: min(phone-commands.preferred-height,max(0px,root.height - menu-title.preferred-height - menu-close.preferred-height - 64px));
|
||||
phone-commands := CommandList { commands: ShellBridge.menu-actions; }
|
||||
phone-commands := VerticalLayout { spacing: 8px;
|
||||
CommandList { commands: ShellBridge.menu-actions; }
|
||||
ActionButton { text: ShellBridge.destinations[2]; clicked => { ShellBridge.room-navigate(4); } }
|
||||
ActionButton { text: ShellBridge.label-bookmarks; clicked => { ShellBridge.room-navigate(6); } }
|
||||
ActionButton { text: ShellBridge.room-labels[10]; clicked => { ShellBridge.room-navigate(5); } }
|
||||
}
|
||||
}
|
||||
menu-close := ActionButton { text: ShellBridge.label-close; clicked => { ShellBridge.close-menu(); } }
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ export global Theme {
|
||||
in-out property <color> contrast: dark ? #0C1326 : #C9D9E5;
|
||||
in-out property <color> deviant: dark ? #1E2538 : #d3d5de;
|
||||
in-out property <color> tint: dark ? #1588FA : #22658f;
|
||||
in-out property <color> tint-text: tint;
|
||||
in-out property <color> on-tint: fg;
|
||||
in-out property <color> fg: dark ? #FFFFFF : #1a1a1a;
|
||||
in-out property <color> muted: high-contrast ? fg : (dark ? #bbd6f3 : #445d77);
|
||||
in-out property <color> error: dark ? #ff8282 : #aa2525;
|
||||
|
||||
Reference in new issue
Block a user