Adapt complete Android phone UI and fix idle audio and microphone test gates
android-ci / android-arm64 (push) Successful in 17m35s
android-ci / android-arm64 (push) Successful in 17m35s
This commit is contained in:
1 parent
cec86d8e3d
commit
5e2a82b1bb
20 files changed
+976
-201
No files matched your search
@@ -2,6 +2,10 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Adapt Android shell, settings, chat and forms to phone-size navigation and keyboard-safe content;
|
||||
expose New Connection directly and retain all target-bound actions in bounded menus and scroll bodies.
|
||||
- Rebase idle audio deadlines without false device-stall errors, retaining active-device stale PCM
|
||||
protection; permit private microphone testing before a server is connected.
|
||||
- Android CI uses all CPUs available to the runner container for Cargo/Ninja/CMake; scheduling changes
|
||||
retain compatible Cargo artifacts without changing optimization or local Windows resource limits.
|
||||
- Bootstrap creation/recovery now shares validation and worker-owned persistence, preserves committed
|
||||
|
||||
@@ -229,6 +229,28 @@ Updated **2026-11-11**. Windows baseline remains `05e8d34bcf0e24a44f76e65220293c
|
||||
Cargo/Ninja/CMake (no fixed4); Windows remains1. Cache contract excludes scheduling count and accepts
|
||||
previous four-job v2 receipt only after checking its full recorded tool/profile/environment identity.
|
||||
Local compatibility fixture passed; full-parallelism CI execution pending.
|
||||
- Windows bootstrap regression compilation could not fit the authorized5GiB Job Object: rustc allocation
|
||||
failure even with native-only codegen256/LTO-off/debuginfo0. Existing CMake path was supplied explicitly
|
||||
after initial tool lookup failure. No limits raised, no further local heavy retries;7 new tests remain
|
||||
unexecuted. Android compile/package and real creation/relaunch proof are separate successful evidence.
|
||||
- **Run4873 (`cec86d8e3d89aa48c155903c107c30cfce7ee28a`) SUCCESS (12m28s)**. Host reports32 CPUs,
|
||||
container `nproc` exposes16; logs confirm Cargo/xtask/gclient use16 jobs. Compatible application cache
|
||||
restored from run4872; dependencies3m21s versus3m56s. Application/package3m51s included recompiling
|
||||
only teamspeach-native (release1m47s), unlike run4872's no-recompile1.63s; do not infer a clean4-vs16
|
||||
speed comparison from these unequal workloads. Reported oom_kill stayed0. Full available parallelism
|
||||
is enabled, not a claim of100% CPU utilization on sequential/IO stages. Latest phone proof remains4869;
|
||||
later changes are CI/cache/docs only. Handoff results kept local to avoid an unnecessary new CI run.
|
||||
- Owner authorized complete phone UI adaptation and microphone/playback testing against **eeee.moe**
|
||||
with AndroidSmoke. Do NOT start/connect a PC client: owner is already on that server. Test only phone.
|
||||
- Phone UI work: Android size-class shell with immediate New Connection, bounded actions/body and
|
||||
navigation; full-height connection/other forms with persistent footer above IME; one-column settings,
|
||||
identity label fallback/import entry; chat picker/composer/tools and per-row wide-content scrolling.
|
||||
Shared touch buttons wrap within available width; Android Choice uses readable wrapped selection.
|
||||
- Audio defect observed before any device start: idle scheduler delay produced audio_worker_stall.
|
||||
Deadline checks now distinguish live devices and rebase before processing queued work;3 production
|
||||
scheduling regression tests passed under Windows resource guard. Private microphone test no longer
|
||||
requires a connected server slot; permission/current-session validation remains. New APK/device proof
|
||||
pending; local integrated Slint compiler check was stopped by guard/deadline, not claimed as pass.
|
||||
|
||||
|
||||
## First Android APK build
|
||||
|
||||
@@ -19,7 +19,7 @@ impl Bootstrap {
|
||||
if let Some(profile)=profile{if !profile.identities.list()?.identities.is_empty(){state.snapshot.bootstrap=BootstrapState::Ready;state.snapshot.profile_form=None;return Ok(())}}
|
||||
let catalog=Catalog::default();let mut form=crate::ui::shell::forms::form("onboarding",Operation::CreateProfile,Target::application(),&catalog).ok_or_else(||error("profile_form","Username form is unavailable"))?;
|
||||
#[cfg(target_os="android")]
|
||||
form.actions.retain(|action|action.operation!=Operation::ChooseLegacyProfile);
|
||||
form.actions.retain(|action|!matches!(action.operation,Operation::ChooseLegacyProfile|Operation::ImportIdentity));
|
||||
state.snapshot.bootstrap=if self.interrupted{BootstrapState::RecoverImport}else if !self.candidates.is_empty(){BootstrapState::ChooseProfile}else{BootstrapState::Username};
|
||||
if self.interrupted{form.description="An incomplete import was found. Retry the import, or explicitly discard its staging directory before creating a new identity. The source profile is unchanged.".into();form.actions.push(Action{form:None,..Action::new("discard-import",Operation::ConfirmOverwrite,Target::application(),&catalog)});}
|
||||
for(index,path)in self.candidates.iter().enumerate(){let target=Target{entity:Entity::LegacyProfile(index.to_string()),name:path.to_string_lossy().into_owned(),..Target::application()};let mut action=Action::new(format!("legacy-{index}"),Operation::ImportLegacyProfile,target,&catalog);action.form=None;form.actions.push(action);}
|
||||
|
||||
@@ -69,7 +69,9 @@ pub(super) async fn invoke(ctx:Arc<RuntimeServices>,op:Operation)->Result<Workfl
|
||||
AudioTest::Record=>{ctx.policy.check()?;let allowed={let p=ctx.profile()?;p.prefs.capture_allowed(p.migration.is_some())};if !allowed{return Err(ServiceError::new("device_mapping_required","Confirm the imported microphone device first"))}
|
||||
let snapshot=ctx.connected.connections.snapshot();let key=snapshot.input_id.as_deref().and_then(|id|snapshot.get(id)).map(|s|s.key.clone());
|
||||
let resume=(key.clone(),ctx.audio_input_active.load(Ordering::Acquire),ctx.audio_output_active.load(Ordering::Acquire));
|
||||
ctx.request_microphone_permission().await?;if let Some(key)=key{ctx.require_key(&key,true)?;}
|
||||
// The private microphone test needs a current slot, not a live server.
|
||||
// Still reject ownership changes while the OS permission prompt was open.
|
||||
ctx.request_microphone_permission().await?;if let Some(key)=key{ctx.require_key(&key,false)?;}
|
||||
let settings=capture_settings(&ctx.profile()?.prefs.get());
|
||||
{let mut previous=lock(&ctx.microphone_test_resume)?;if previous.is_none(){*previous=Some(resume);}}
|
||||
if let Err(error)=ctx.audio.request(AudioCommand::BeginMicrophoneTest{permission:StartPermission::Granted,settings}).await{lock(&ctx.microphone_test_resume)?.take();return Err(error)}},
|
||||
|
||||
@@ -17,8 +17,9 @@ use super::{capture::CapturePipeline, devices::{self, CapturePort, DeviceCatalog
|
||||
const COMMAND_CAPACITY: usize = 64;
|
||||
const PCM_CAPACITY: usize = 32;
|
||||
const EVENT_CAPACITY: usize = 128;
|
||||
const TICK: Duration = Duration::from_millis(10);
|
||||
const MAX_AGE: Duration = Duration::from_millis(200);
|
||||
#[path = "mix_schedule.rs"]
|
||||
mod mix_schedule;
|
||||
use mix_schedule::{TICK, MAX_AGE};
|
||||
const TEST_SAMPLES: usize = 480_000;
|
||||
|
||||
pub enum AudioCommand {
|
||||
@@ -541,6 +542,11 @@ impl Worker {
|
||||
fn run(&mut self, commands: Receiver<Envelope>, playback: Receiver<PlaybackMessage>) {
|
||||
let mut next_mix = Instant::now();
|
||||
while !self.shared.stop.load(Ordering::Acquire) {
|
||||
// Detect a live-device gap before queued enabling commands or stale PCM
|
||||
// can run. An idle/suspended worker has no hardware deadline to violate.
|
||||
if mix_schedule::resume(&mut next_mix, Instant::now(), self.input.is_some() || !self.outputs.is_empty()) {
|
||||
self.fail_devices(ServiceError::new("audio_worker_stall", "Audio worker stalled; devices require explicit restart"));
|
||||
}
|
||||
self.drain_events();
|
||||
self.check_revision();
|
||||
// Bounded batches ensure command/PCM floods cannot starve hardware clocks.
|
||||
@@ -584,11 +590,10 @@ impl Worker {
|
||||
if let Err(error) = self.capture_blocks() { self.stop_capture(); self.shared.revoke(); self.emit(AudioEvent::Error(error)); }
|
||||
let now = Instant::now();
|
||||
if now >= next_mix {
|
||||
if now.duration_since(next_mix) > MAX_AGE {
|
||||
if mix_schedule::resume(&mut next_mix, now, self.input.is_some() || !self.outputs.is_empty()) {
|
||||
self.fail_devices(ServiceError::new("audio_worker_stall", "Audio worker stalled; devices require explicit restart"));
|
||||
} else if let Err(error) = self.mix(now) { self.fail_devices(error); }
|
||||
// Keep hardware-rate cadence; only discard the schedule after a real stall.
|
||||
next_mix = if now.duration_since(next_mix) > MAX_AGE { now + TICK } else { next_mix + TICK };
|
||||
next_mix += TICK;
|
||||
}
|
||||
if self.notifications.idle_close_due(now).is_some() { self.retire_notifications(); }
|
||||
thread::sleep(Duration::from_millis(1));
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//! Mixer deadlines only describe live device work, not time spent suspended while idle.
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
pub(super) const TICK: Duration = Duration::from_millis(10);
|
||||
pub(super) const MAX_AGE: Duration = Duration::from_millis(200);
|
||||
|
||||
/// Rebase after a scheduling gap before processing queued commands/PCM. Report a
|
||||
/// stall only if devices were already open; a newly requested stream gets a fresh clock.
|
||||
pub(super) fn resume(next: &mut Instant, now: Instant, devices_active: bool) -> bool {
|
||||
if now.saturating_duration_since(*next) > MAX_AGE {
|
||||
*next = now;
|
||||
devices_active
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn idle_suspend_does_not_fail_a_newly_requested_device() {
|
||||
let origin = Instant::now();
|
||||
let mut next = origin;
|
||||
let resumed = origin + Duration::from_secs(60);
|
||||
assert!(!resume(&mut next, resumed, false));
|
||||
// A start command processed after resume must not inherit the old deadline.
|
||||
assert!(!resume(&mut next, resumed + TICK, true));
|
||||
assert_eq!(next, resumed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_device_gap_fails_once_and_rebases_before_queued_work() {
|
||||
let origin = Instant::now();
|
||||
let mut next = origin;
|
||||
let resumed = origin + MAX_AGE + Duration::from_nanos(1);
|
||||
assert!(resume(&mut next, resumed, true));
|
||||
assert_eq!(next, resumed);
|
||||
assert!(!resume(&mut next, resumed, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ordinary_jitter_keeps_the_hardware_cadence() {
|
||||
let origin = Instant::now();
|
||||
let mut next = origin;
|
||||
assert!(!resume(&mut next, origin + TICK, true));
|
||||
assert_eq!(next, origin);
|
||||
assert!(!resume(&mut next, origin + MAX_AGE, true));
|
||||
assert_eq!(next, origin);
|
||||
assert!(!resume(&mut next, origin - TICK, false));
|
||||
assert_eq!(next, origin);
|
||||
}
|
||||
}
|
||||
+12
-5
@@ -151,6 +151,7 @@ pub fn present(ui:&AppWindow,binding:&ChatBinding,presentation:ChatPresentation)
|
||||
let old_target=state.presentation.conversation.as_ref().map(|c|c.target.clone());let new_target=presentation.conversation.as_ref().map(|c|c.target.clone());
|
||||
let changed=old_target!=new_target;
|
||||
if changed {(state.emit)(ChatAction::CancelAssets{generation:state.generation});state.generation=next_render_generation();state.assets.clear();state.requested.clear();state.revealed.clear();state.selection=Selection::default();ui.global::<ChatBridge>().set_selected_text(SharedString::default());ui.global::<ChatBridge>().set_bottom_pinned(true);ui.global::<ChatBridge>().set_log_position(0.);}
|
||||
if changed && cfg!(target_os="android"){ui.global::<ChatBridge>().set_mobile_overlay(false);}
|
||||
if changed {state.scenes.clear();state.avatars.clear();}
|
||||
if language_changed {let bridge=ui.global::<ChatBridge>();bridge.set_language_revision(bridge.get_language_revision().wrapping_add(1));}
|
||||
if let Some(c)=&presentation.conversation{let key=c.target.draft_key();if !state.editors.contains_key(&key){let mut editor=editor::Editor::new(c.draft.clone());editor.revision=c.draft_revision;state.editors.insert(key,editor);(state.emit)(ChatAction::DraftChanged{target:c.target.clone(),text:c.draft.clone(),revision:c.draft_revision});}}
|
||||
@@ -258,8 +259,13 @@ impl State {
|
||||
let empty=PreparedDocument::default();
|
||||
let mut scene=render::prepared_document(if hide_text{&empty}else{&message.document},&id,render::Options{width:self.width,font_scale:scale,preview:false,revealed:&self.revealed,assets:&metadata,auto_images:self.presentation.auto_download_images,auto_diagrams:self.presentation.auto_diagrams},&mut|text,style|measure(ui,text,style));
|
||||
for (index,file) in message.document.files.iter().cloned().enumerate(){
|
||||
let action=format!("{id}/attachment/{index}");let allowed=!file.is_directory&&file.server_uid.as_deref()==Some(target.scope.base.server.as_str());let text=file.name.clone();let style=render::Style{size:14.*scale,underline:allowed,..render::Style::default()};let(width,height)=measure(ui,&text,style);let len=text.len();
|
||||
scene.rows.push(render::Visual{id:action.clone(),height:height.max(44.)+8.,plain:text.clone(),kind:12,runs:vec![render::Run{x:8.,y:4.,width:width.min(self.width-16.),height:height.max(44.),text,style,action:if allowed{action.clone()}else{String::new()},asset:String::new(),text_range:0..len,concealed:false}],..render::Visual::default()});
|
||||
let action=format!("{id}/attachment/{index}");let allowed=!file.is_directory&&file.server_uid.as_deref()==Some(target.scope.base.server.as_str());
|
||||
if cfg!(target_os="android") {
|
||||
scene.rows.push(render::attachment(&action,&file.name,if allowed{&action}else{""},render::Options{width:self.width,font_scale:scale,preview:false,revealed:&self.revealed,assets:&metadata,auto_images:false,auto_diagrams:false},&mut|text,style|measure(ui,text,style)));
|
||||
} else {
|
||||
let text=file.name.clone();let style=render::Style{size:14.*scale,underline:allowed,..render::Style::default()};let(width,height)=measure(ui,&text,style);let len=text.len();
|
||||
scene.rows.push(render::Visual{id:action.clone(),height:height.max(44.)+8.,plain:text.clone(),kind:12,runs:vec![render::Run{x:8.,y:4.,width:width.min(self.width-16.),height:height.max(44.),text,style,action:if allowed{action.clone()}else{String::new()},asset:String::new(),text_range:0..len,concealed:false}],..render::Visual::default()});
|
||||
}
|
||||
if allowed{scene.actions.insert(action,render::Interaction::Link(policy::Link::ServerFile(file)));}
|
||||
}
|
||||
self.scenes.insert(cache_key,scene.clone());scene
|
||||
@@ -281,7 +287,7 @@ impl State {
|
||||
if self.programmatic{return}let bridge=ui.global::<ChatBridge>();let Some(key)=self.current_key()else{bridge.set_editor_text(SharedString::default());bridge.set_before(model(vec![]));bridge.set_after(model(vec![]));bridge.set_can_send(false);return};
|
||||
let hybrid=self.presentation.hybrid;let Some(editor)=self.editors.get_mut(&key)else{return};if editor.composing{return}let old_active=editor.active.clone();let(before,after)=editor.hybrid_blocks(hybrid);let active=editor.active.clone();let text=editor.text()[active.clone()].to_owned();let selection=editor.selection().clone();let can_undo=editor.can_undo();let can_redo=editor.can_redo();let draft_revision=editor.revision;let can_send=!editor.text().trim().is_empty()&&editor.text().trim_end().len()<=8192&&!self.pending.contains_key(&key)&&self.presentation.conversation.as_ref().is_some_and(|c|c.can_send);self.completions=editor.completions();self.completion_index=0;
|
||||
let metadata=self.metadata();let target=self.presentation.conversation.as_ref().map(|c|c.target.clone());let mut automatic=vec![];self.actions.retain(|k,_|!k.starts_with("draft/"));
|
||||
let mut render_preview=|blocks:Vec<editor::PreviewBlock>|{let mut result=vec![];for block in blocks{let id=format!("draft/{key}/{draft_revision}/{}",block.range.start);let scene=render::prepared_document(&block.document,&id,render::Options{width:self.editor_width,font_scale:14./16.,preview:true,revealed:&self.revealed,assets:&metadata,auto_images:false,auto_diagrams:self.presentation.auto_diagrams},&mut|text,style|measure(ui,text,style));for (id,interaction)in scene.actions{if let Some(target)=&target{self.actions.insert(id,BoundInteraction{target:target.clone(),interaction});}}automatic.extend(scene.automatic);for row in scene.rows{result.push(convert_visual(&row,"",&self.assets,block.range.start as i32,false,true));}}result};
|
||||
let mut render_preview=|blocks:Vec<editor::PreviewBlock>|{let mut result=vec![];for block in blocks{let id=format!("draft/{key}/{draft_revision}/{}",block.range.start);let scene=render::prepared_document(&block.document,&id,render::Options{width:self.editor_width,font_scale:14./16.*if cfg!(target_os="android"){(ui.global::<Theme>().get_font_size()/15.).max(0.5)}else{1.},preview:true,revealed:&self.revealed,assets:&metadata,auto_images:false,auto_diagrams:self.presentation.auto_diagrams},&mut|text,style|measure(ui,text,style));for (id,interaction)in scene.actions{if let Some(target)=&target{self.actions.insert(id,BoundInteraction{target:target.clone(),interaction});}}automatic.extend(scene.automatic);for row in scene.rows{result.push(convert_visual(&row,"",&self.assets,block.range.start as i32,false,true));}}result};
|
||||
let before=render_preview(before);let after=render_preview(after);
|
||||
bridge.set_editor_width(before.iter().chain(after.iter()).map(|row|row.content_width).fold(self.editor_width,f32::max));
|
||||
self.programmatic=true;bridge.set_before(model(before));bridge.set_after(model(after));bridge.set_can_send(can_send);bridge.set_can_undo(can_undo);bridge.set_can_redo(can_redo);
|
||||
@@ -292,6 +298,7 @@ impl State {
|
||||
}
|
||||
fn publish_completions(&self,ui:&AppWindow){let bridge=ui.global::<ChatBridge>();bridge.set_completions(model(self.completions.iter().map(|c|ChatCompletion{id:c.id.clone().into(),label:if c.emoji{c.label.clone()}else{format!("{} — {}",c.label,tr(&self.presentation.language,&format!("chat.snippet.{}",c.id)))}.into()}).collect()));bridge.set_completion_index(self.completion_index as i32);}
|
||||
fn command(&mut self,ui:&AppWindow,command:&str)->bool{
|
||||
if command=="clear-selection"{self.selection=Selection::default();self.publish_selection(ui);return true}
|
||||
if command=="completion-next"||command=="completion-previous"{if self.completions.is_empty(){return false}self.completion_index=(self.completion_index+if command=="completion-next"{1}else{self.completions.len()-1})%self.completions.len();self.publish_completions(ui);return true}
|
||||
if command=="dismiss-completion"{self.completions.clear();self.publish_completions(ui);return true}
|
||||
let Some(editor)=self.editor_mut()else{return false};if editor.composing{return false}let changed=match command{
|
||||
@@ -308,7 +315,7 @@ impl State {
|
||||
render::Interaction::Link(policy::Link::ServerFile(file))=>{if !file.is_directory&&file.server_uid.as_deref()==Some(bound.target.scope.base.server.as_str()){(self.emit)(ChatAction::DownloadFile{target:bound.target,file});}return},
|
||||
render::Interaction::Image(file)=>AssetKind::ServerImage(file),
|
||||
render::Interaction::Spoiler(key)|render::Interaction::Details(key)=>{if !self.revealed.remove(&key){self.revealed.insert(key);}self.scenes.clear();self.refresh_log(ui);return},
|
||||
render::Interaction::Footnote(label)=>{let mut offset=0.;for row in &self.log{if row.id==label{ui.global::<ChatBridge>().set_bottom_pinned(false);ui.global::<ChatBridge>().set_log_position(-offset);break}offset+=row.height;if matches!(row.kind,6|7){offset+=ui.global::<Theme>().get_touch_target();}}return},
|
||||
render::Interaction::Footnote(label)=>{let mut offset=0.;for row in &self.log{if row.id==label{ui.global::<ChatBridge>().set_bottom_pinned(false);ui.global::<ChatBridge>().set_log_position(-offset);break}offset+=row.height;if matches!(row.kind,6|7){offset+=ui.global::<Theme>().get_touch_target();}if cfg!(target_os="android")&&row.runs.iter().any(|run|run.x+run.width+8.>self.width){offset+=24.;}}return},
|
||||
render::Interaction::Math{source,display}=>{let color=ui.global::<Theme>().get_fg();AssetKind::Math{source:source.into(),display,font_size_px:if display{18.}else{16.},color:[color.red(),color.green(),color.blue(),color.alpha()],width_px:f64::from(self.width)}},
|
||||
render::Interaction::Diagram{source,retry}=>AssetKind::Diagram{source:source.into(),manual:!automatic,retry},
|
||||
};
|
||||
@@ -344,7 +351,7 @@ pub fn preview_with_assets(ui:&AppWindow,source:&str,document:&PreparedDocument,
|
||||
use std::hash::{Hash,Hasher};let mut hash=std::collections::hash_map::DefaultHasher::new();source.hash(&mut hash);width.to_bits().hash(&mut hash);let theme=ui.global::<Theme>();let color=theme.get_fg();[color.red(),color.green(),color.blue(),color.alpha()].hash(&mut hash);theme.get_font_family().as_str().hash(&mut hash);theme.get_font_size().to_bits().hash(&mut hash);let prefix=format!("help/{}",hash.finish());
|
||||
let mut assets=HashMap::new();for(id,result)in results{let loaded=result.clone().and_then(load_image);let stored=match loaded{Ok((image,width,height))=>StoredAsset{metadata:render::Asset{width,height,ready:true,error:None},image},Err(error)=>StoredAsset{metadata:render::Asset{width:0.,height:0.,ready:false,error:Some(error)},image:slint::Image::default()}};assets.insert(id.clone(),stored);}
|
||||
let metadata=assets.iter().map(|(id,a)|(id.clone(),a.metadata.clone())).collect();
|
||||
let scene=render::prepared_document(document,&prefix,render::Options{width,font_scale:1.,preview:true,revealed:&HashSet::new(),assets:&metadata,auto_images:false,auto_diagrams:false},&mut|text,style|measure(ui,text,style));
|
||||
let scene=render::prepared_document(document,&prefix,render::Options{width,font_scale:if cfg!(target_os="android"){(theme.get_font_size()/15.).max(0.5)}else{1.},preview:true,revealed:&HashSet::new(),assets:&metadata,auto_images:false,auto_diagrams:false},&mut|text,style|measure(ui,text,style));
|
||||
let requests=scene.actions.into_iter().filter_map(|(id,interaction)|{let kind=match interaction{
|
||||
render::Interaction::Math{source,display}=>AssetKind::Math{source:source.into(),display,font_size_px:16.,color:[color.red(),color.green(),color.blue(),color.alpha()],width_px:f64::from(width)},
|
||||
render::Interaction::Diagram{source,retry}=>AssetKind::Diagram{source:source.into(),manual:true,retry},_=>return None};Some((id,kind))}).collect();
|
||||
|
||||
@@ -280,5 +280,7 @@
|
||||
"native.chat.redo": "Redo",
|
||||
"native.chat.cut": "Cut",
|
||||
"native.chat.paste": "Paste",
|
||||
"native.chat.selectAll": "Select All"
|
||||
"native.chat.selectAll": "Select All",
|
||||
"native.chat.conversations": "Conversations",
|
||||
"native.chat.copySelection": "Copy selected message text"
|
||||
}
|
||||
@@ -35,6 +35,16 @@ pub fn prepared_document(doc:&PreparedDocument,id:&str,options:Options<'_>,measu
|
||||
pub fn document(doc:&crate::services::chat::parse::Document,id:&str,options:Options<'_>,measure:&mut dyn FnMut(&str,Style)->(f32,f32))->Scene{
|
||||
prepared_document(&PreparedDocument::from_document(doc.clone()),id,options,measure)
|
||||
}
|
||||
|
||||
/// Server-file names are literal text, not markup. Reuse shaping/wrapping while
|
||||
/// retaining the caller's already validated target-bound download action.
|
||||
pub fn attachment(id:&str,text:&str,action:&str,options:Options<'_>,measure:&mut dyn FnMut(&str,Style)->(f32,f32))->Visual {
|
||||
let policies=PreparedDocument::default();
|
||||
let mut renderer=Renderer{options,scene:Scene::default(),measure,root_id:id.to_owned(),policies:&policies};
|
||||
let atom=Atom{text:text.to_owned(),style:Style{size:14.,underline:!action.is_empty(),..Style::default()},action:action.to_owned(),asset:String::new(),width:None,height:None,concealed:false};
|
||||
renderer.flow(id.to_owned(),vec![atom],8.,12,String::new(),Align::Left);
|
||||
let mut row=renderer.scene.rows.pop().unwrap_or_default();row.height=row.height.max(56.);row
|
||||
}
|
||||
struct Renderer<'a,'b>{options:Options<'a>,scene:Scene,measure:&'b mut dyn FnMut(&str,Style)->(f32,f32),root_id:String,policies:&'a PreparedDocument}
|
||||
impl Renderer<'_,'_>{
|
||||
fn atom(&self,text:String,style:Style)->Atom{Atom{text,style,action:String::new(),asset:String::new(),width:None,height:None,concealed:false}}
|
||||
@@ -61,7 +71,7 @@ impl Renderer<'_,'_>{
|
||||
if let Some(asset)=self.options.assets.get(key){if asset.ready {return Atom{text:source.into(),style,action,asset:key.into(),width:Some(asset.width),height:Some(asset.height),concealed:false}}let text=asset.error.as_ref().map_or_else(||source.to_owned(),|error|format!("{source}\n{error}"));return Atom{action,..self.atom(text,Style{mono:true,..style})}}
|
||||
Atom{action,..self.atom(source.to_owned(),Style{mono:true,..style})}
|
||||
}
|
||||
fn blocks(&mut self,blocks:&[Block],path:&str,indent:f32,style:Style,align:Align){for (i,block) in blocks.iter().enumerate(){let key=format!("{path}/b{i}");match &block.kind{
|
||||
fn blocks(&mut self,blocks:&[Block],path:&str,indent:f32,style:Style,align:Align){let indent=if cfg!(target_os="android"){indent.min((self.options.width-56.).max(0.))}else{indent};for (i,block) in blocks.iter().enumerate(){let key=format!("{path}/b{i}");match &block.kind{
|
||||
BlockKind::Paragraph(nodes)=>{if let [Inline::BbAlign{align:a,children}]=nodes.as_slice(){let a_nodes=self.inline(children,&key,style);self.flow(key,a_nodes,indent,0,String::new(),Align::parse(a));}else{let a=self.inline(nodes,&key,style);self.flow(key,a,indent,0,String::new(),align);}},
|
||||
BlockKind::Heading{level,children}=>{let factor=match level{1=>1.8,2=>1.55,3=>1.3,4=>1.15,_=>1.};let a=self.inline(children,&key,Style{size:style.size*factor,weight:700,..style});self.flow(key,a,indent,1,String::new(),align);},
|
||||
BlockKind::Hr=>self.scene.rows.push(Visual{id:key,height:12.,kind:2,indent,..Visual::default()}),
|
||||
@@ -70,7 +80,7 @@ impl Renderer<'_,'_>{
|
||||
BlockKind::Blockquote{callout,children}=>{if let Some(callout)=callout{let a=vec![self.atom(callout.title.clone(),Style{weight:700,..style})];self.flow(format!("{key}/title"),a,indent,4,callout.kind.clone(),align);}let start=self.scene.rows.len();self.blocks(children,&key,indent+12.,style,align);for row in &mut self.scene.rows[start..]{if matches!(row.kind,0|1){row.kind=4;row.label=callout.as_ref().map_or(String::new(),|c|c.kind.clone());}}},
|
||||
BlockKind::List(list)=>self.list(list,&key,indent,style),
|
||||
BlockKind::Table{align:columns,header,rows}=>{
|
||||
let count=header.len().max(rows.iter().map(Vec::len).max().unwrap_or(0)).max(1);let width=((self.options.width-indent)/count as f32).max(40.);let old_width=self.options.width;
|
||||
let count=header.len().max(rows.iter().map(Vec::len).max().unwrap_or(0)).max(1);let width=((self.options.width-indent)/count as f32).max(if cfg!(target_os="android"){120.}else{40.});let old_width=self.options.width;
|
||||
for (row_index,cells) in std::iter::once(header).chain(rows.iter()).enumerate(){let mut joined=Visual{id:format!("{key}/r{row_index}"),kind:8,indent,..Visual::default()};let mut max_height=0f32;
|
||||
for (column,cell) in cells.iter().enumerate(){self.options.width=width-12.;let atoms=self.inline(cell,&format!("{key}/r{row_index}/c{column}"),Style{weight:if row_index==0{700}else{style.weight},..style});self.flow(format!("{key}/cell"),atoms,0.,8,String::new(),columns.get(column).and_then(|s|s.as_deref()).map_or(Align::Left,Align::parse));let mut visual=self.scene.rows.pop().unwrap_or_default();let offset=joined.plain.len();if column>0{joined.plain.push('\t');}let offset=offset+usize::from(column>0);for run in &mut visual.runs{run.x+=indent+column as f32*width+6.;run.text_range.start+=offset;run.text_range.end+=offset;}joined.plain.push_str(&visual.plain);joined.runs.extend(visual.runs);max_height=max_height.max(visual.height);}
|
||||
joined.height=max_height+8.;self.scene.rows.push(joined);
|
||||
@@ -82,11 +92,16 @@ impl Renderer<'_,'_>{
|
||||
}}}
|
||||
fn list(&mut self,list:&List,path:&str,indent:f32,style:Style){for(i,item)in list.items.iter().enumerate(){let key=format!("{path}/l{i}");let marker=if let Some(checked)=item.task{if checked{"[x] ".into()}else{"[ ] ".into()}}else if list.ordered{format!("{}. ",u64::from(list.start)+i as u64)}else{"• ".into()};let mut a=vec![self.atom(marker,style)];a.extend(self.inline(&item.children,&key,style));self.flow(key.clone(),a,indent,0,String::new(),Align::Left);if let Some(sub)=&item.sub{self.list(sub,&key,indent+20.,style)}}}
|
||||
fn flow(&mut self,id:String,atoms:Vec<Atom>,indent:f32,kind:i32,label:String,align:Align){
|
||||
// Keep deeply nested quotes/lists on screen. Tables retain readable columns
|
||||
// and use the UI's row-local horizontal viewport rather than widening chat.
|
||||
let indent=if cfg!(target_os="android"){indent.min((self.options.width-56.).max(0.))}else{indent};
|
||||
let available=(self.options.width-indent-8.).max(16.);let mut row=Visual{id,kind,indent,label,..Visual::default()};let mut x=0.;let mut y=if kind==1{8.}else{4.};let mut line_height=20.*self.options.font_scale;let mut line_start=0;
|
||||
for atom in atoms {let style=Style{size:atom.style.size*self.options.font_scale,shift:atom.style.shift*self.options.font_scale,..atom.style};
|
||||
if !atom.asset.is_empty(){let width=atom.width.unwrap_or(available).min(available).max(16.);let height=atom.height.unwrap_or(50.)*(width/atom.width.unwrap_or(width).max(1.));if x>0.&&x+width>available{align_line(&mut row.runs[line_start..],x,available,align);y+=line_height;x=0.;line_height=20.;line_start=row.runs.len();}let from=row.plain.len();row.plain.push_str(&atom.text);row.runs.push(Run{x:x+indent,y,width,height,text:atom.text,style,action:atom.action,asset:atom.asset,text_range:from..row.plain.len(),concealed:atom.concealed});x+=width;line_height=line_height.max(height);continue}
|
||||
for token in split_tokens(&atom.text){if token=="\n"{align_line(&mut row.runs[line_start..],x,available,align);row.plain.push('\n');y+=line_height;x=0.;line_height=20.*self.options.font_scale;line_start=row.runs.len();continue}
|
||||
let(width,height)=(self.measure)(token,style);if width>available {
|
||||
for atom in atoms {let style=Style{size:atom.style.size*self.options.font_scale,shift:atom.style.shift*self.options.font_scale,..atom.style};let touch=cfg!(target_os="android")&&!atom.action.is_empty();
|
||||
if !atom.asset.is_empty(){let mut width=atom.width.unwrap_or(available).min(available).max(16.);let mut height=atom.height.unwrap_or(50.)*(width/atom.width.unwrap_or(width).max(1.));if cfg!(target_os="android"){let scale=(available*1.25/height.max(1.)).min(1.);width*=scale;height*=scale;}if touch{width=width.max(48.);height=height.max(48.);}if x>0.&&x+width>available{align_line(&mut row.runs[line_start..],x,available,align);y+=line_height;x=0.;line_height=20.;line_start=row.runs.len();}let from=row.plain.len();row.plain.push_str(&atom.text);row.runs.push(Run{x:x+indent,y,width,height,text:atom.text,style,action:atom.action,asset:atom.asset,text_range:from..row.plain.len(),concealed:atom.concealed});x+=width;line_height=line_height.max(height);continue}
|
||||
// Keep a link's words together so a 48dp target does not introduce
|
||||
// artificial spacing between each word or steal adjacent text taps.
|
||||
for token in split_tokens(&atom.text,touch){if token=="\n"{align_line(&mut row.runs[line_start..],x,available,align);row.plain.push('\n');y+=line_height;x=0.;line_height=20.*self.options.font_scale;line_start=row.runs.len();continue}
|
||||
let(mut width,mut height)=(self.measure)(token,style);if touch{width=width.max(48.);height=height.max(48.);}if width>available {
|
||||
// Shape complete native strings. Splitting glyph-by-glyph breaks Arabic shaping,
|
||||
// ligatures and emoji ZWJ sequences; choose a fitting UTF-8 chunk instead.
|
||||
let mut remaining=token;
|
||||
@@ -95,7 +110,7 @@ impl Renderer<'_,'_>{
|
||||
let boundaries:Vec<_>=remaining.grapheme_indices(true).map(|(i,_)|i).filter(|i|*i>0).chain(std::iter::once(remaining.len())).collect();
|
||||
let(mut lo,mut hi)=(0,boundaries.len());
|
||||
while lo<hi{let mid=(lo+hi)/2;let w=(self.measure)(&remaining[..boundaries[mid]],style).0;if w<=available{lo=mid+1}else{hi=mid}}
|
||||
let end=boundaries[lo.saturating_sub(1)];let chunk=&remaining[..end];let(w,h)=(self.measure)(chunk,style);
|
||||
let end=boundaries[lo.saturating_sub(1)];let chunk=&remaining[..end];let(mut w,mut h)=(self.measure)(chunk,style);if touch{w=w.max(48.);h=h.max(48.);}
|
||||
push_run(&mut row,&atom,chunk.into(),style,x+indent,y,w,h);x=w;line_height=line_height.max(h+style.shift.abs());remaining=&remaining[end..];
|
||||
}continue
|
||||
}
|
||||
@@ -107,7 +122,7 @@ impl Renderer<'_,'_>{
|
||||
}
|
||||
}
|
||||
fn push_run(row:&mut Visual,atom:&Atom,text:String,style:Style,x:f32,y:f32,width:f32,height:f32){let start=row.plain.len();row.plain.push_str(&text);row.runs.push(Run{x,y:y+style.shift,width,height,text,style,action:atom.action.clone(),asset:String::new(),text_range:start..row.plain.len(),concealed:atom.concealed});}
|
||||
fn split_tokens(text:&str)->Vec<&str>{let mut parts=vec![];let mut start=0;let mut whitespace=None;for(i,c)in text.char_indices(){if c=='\n'{if start<i{parts.push(&text[start..i]);}parts.push(&text[i..i+1]);start=i+1;whitespace=None;continue}let ws=c.is_whitespace();if whitespace.is_some_and(|prev|prev!=ws){parts.push(&text[start..i]);start=i;}whitespace=Some(ws);}if start<text.len(){parts.push(&text[start..]);}parts}
|
||||
fn split_tokens(text:&str,whole_lines:bool)->Vec<&str>{let mut parts=vec![];let mut start=0;let mut whitespace=None;for(i,c)in text.char_indices(){if c=='\n'{if start<i{parts.push(&text[start..i]);}parts.push(&text[i..i+1]);start=i+1;whitespace=None;continue}let ws=c.is_whitespace();if !whole_lines&&whitespace.is_some_and(|prev|prev!=ws){parts.push(&text[start..i]);start=i;}whitespace=Some(ws);}if start<text.len(){parts.push(&text[start..]);}parts}
|
||||
fn align_line(runs:&mut[Run],used:f32,width:f32,align:Align){let spare=(width-used).max(0.);let offset=match align{Align::Center=>spare/2.,Align::Right=>spare,_=>0.};let gaps=runs.iter().filter(|r|r.text.chars().all(char::is_whitespace)).count();let mut extra=0.;for run in runs{run.x+=offset+extra;if matches!(align,Align::Justify)&&gaps>0&&run.text.chars().all(char::is_whitespace){let step=spare/gaps as f32;run.width+=step;extra+=step;}}}
|
||||
fn font_size(size:&str,base:f32)->f32{base*match size{"xx-small"=>0.6,"x-small"=>0.75,"small"=>0.9,"large"=>1.2,"x-large"=>1.5,"xx-large"=>2.,"xxx-large"=>3.,_=>1.}}
|
||||
fn parse_color(value:&str)->Option<[u8;4]>{let mut parser=cssparser::Parser::new(value);let color=cssparser_color::Color::parse(&mut parser).ok()?;parser.expect_exhausted().ok()?;match color{cssparser_color::Color::Rgba(c)=>Some([c.red,c.green,c.blue,(c.alpha*255.).round()as u8]),_=>None}}
|
||||
|
||||
@@ -280,5 +280,7 @@
|
||||
"native.chat.redo": "Повторить",
|
||||
"native.chat.cut": "Вырезать",
|
||||
"native.chat.paste": "Вставить",
|
||||
"native.chat.selectAll": "Выделить всё"
|
||||
"native.chat.selectAll": "Выделить всё",
|
||||
"native.chat.conversations": "Разговоры",
|
||||
"native.chat.copySelection": "Копировать выделенный текст сообщения"
|
||||
}
|
||||
@@ -61,3 +61,32 @@ fn selection_paste_and_completion_keep_unrelated_source(){
|
||||
let mut editor=Editor::new("/bo".into());let completion=editor.completions().remove(0);editor.complete(&completion);assert_eq!(editor.text(),"****");assert_eq!(editor.selection().range(),2..2);
|
||||
assert!(!super::editor::emoji_search("smile",0..0,80).is_empty());
|
||||
}
|
||||
|
||||
#[cfg(target_os="android")]
|
||||
#[test]
|
||||
fn phone_actions_have_non_overlapping_touch_geometry(){
|
||||
let rendered=scene("before [a short link](https://example.com) after ||hidden||",&HashSet::new(),&HashMap::new());
|
||||
let actions:Vec<_>=rendered.rows.iter().flat_map(|row|row.runs.iter()).filter(|run|!run.action.is_empty()).collect();
|
||||
assert!(!actions.is_empty());
|
||||
for run in &actions{assert!(run.width>=48.&&run.height>=48.);assert!(run.x+run.width<=360.);}
|
||||
for (i,a) in actions.iter().enumerate(){for b in actions.iter().skip(i+1){assert!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y);}}
|
||||
}
|
||||
|
||||
#[cfg(target_os="android")]
|
||||
#[test]
|
||||
fn phone_attachment_wraps_literal_unicode_without_losing_its_action(){
|
||||
let name="報告👩💻[not markup]<plain>very-long-file-name".repeat(8);
|
||||
let row=render::attachment("file",&name,"file/download",render::Options{width:160.,font_scale:1.,preview:false,revealed:&HashSet::new(),assets:&HashMap::new(),auto_images:false,auto_diagrams:false},&mut|text,style|(text.chars().count()as f32*style.size/2.,style.size+4.));
|
||||
assert_eq!(row.plain,name);assert!(row.runs.len()>1);
|
||||
for run in row.runs{assert_eq!(run.action,"file/download");assert!(run.width>=48.&&run.height>=48.);assert!(run.x+run.width<=160.);}
|
||||
}
|
||||
|
||||
#[cfg(target_os="android")]
|
||||
#[test]
|
||||
fn phone_tall_rendered_media_stays_bounded_and_tables_keep_readable_columns(){
|
||||
let first=scene("$$\nx^2\n$$",&HashSet::new(),&HashMap::new());let id=first.automatic[0].clone();
|
||||
let rendered=scene("$$\nx^2\n$$",&HashSet::new(),&HashMap::from([(id,render::Asset{width:80.,height:10000.,ready:true,error:None})]));
|
||||
for run in rendered.rows.iter().flat_map(|row|&row.runs){assert!(run.width<=360.&&run.height<=450.);}
|
||||
let table=scene("| first | second | third | fourth |\n| --- | --- | --- | --- |\n| a | b | c | d |",&HashSet::new(),&HashMap::new());
|
||||
assert!(table.rows.iter().any(|row|row.runs.iter().any(|run|run.x>360.)));
|
||||
}
|
||||
@@ -97,7 +97,9 @@ pub fn present(ui:&AppWindow,binding:&Binding,p:Presentation){
|
||||
let mut state=binding.state.borrow_mut();
|
||||
state.generation=state.generation.checked_add(1).expect("settings presentation generation exhausted");
|
||||
state.rows.clear();
|
||||
let context=(p.category,p.subpage);if state.context.as_ref()!=Some(&context){state.drafts.clear();state.context=Some(context);}
|
||||
// Android navigation retains unfinished non-secret edits. Target-specific row IDs
|
||||
// keep drafts on their original identity/profile; secrets never enter this map.
|
||||
let context=(p.category,p.subpage);if state.context.as_ref()!=Some(&context){if !cfg!(target_os="android"){state.drafts.clear();}state.context=Some(context);}
|
||||
let mut rows=Vec::with_capacity(p.rows.len());
|
||||
for r in p.rows{
|
||||
let token=format!("{}:{}",state.generation,r.id);
|
||||
|
||||
@@ -32,11 +32,13 @@ impl<'a> Builder<'a> {
|
||||
pub fn identities(&mut self) {
|
||||
self.heading("settings.nav.identities");
|
||||
let selected_uid=self.s.identities.iter().find(|i|Some(i.uid.as_str())==self.v.identity.as_deref()).or_else(||self.s.identities.iter().find(|i|i.is_default)).or(self.s.identities.first()).map(|i|i.uid.as_str()).unwrap_or("");
|
||||
self.select("identity-select","settings.identity.choose",selected_uid,self.s.identities.iter().map(|i|(i.uid.clone(),i.name.clone(),Operation::Navigate(Navigation::Identity(i.uid.clone())))).collect());
|
||||
let identity_default=self.text("identity.default");
|
||||
self.select("identity-select","settings.identity.choose",selected_uid,self.s.identities.iter().map(|i|(i.uid.clone(),i.display_name(&identity_default).to_owned(),Operation::Navigate(Navigation::Identity(i.uid.clone())))).collect());
|
||||
if cfg!(target_os="android"){self.action("identity-import","settings.identity.action.import",Operation::IdentityImport);}
|
||||
self.note("identity-info","settings.identity.info",String::new());
|
||||
self.input("identity-new-name","settings.identity.new.placeholder","",Field::NewIdentityName);
|
||||
self.action("identity-create","settings.identity.add",Operation::IdentityCreate);
|
||||
self.action("identity-import","settings.identity.action.import",Operation::IdentityImport);
|
||||
if !cfg!(target_os="android"){self.action("identity-import","settings.identity.action.import",Operation::IdentityImport);}
|
||||
let selected=self.s.identities.iter().find(|i|Some(i.uid.as_str())==self.v.identity.as_deref()).or_else(||self.s.identities.iter().find(|i|i.is_default)).or(self.s.identities.first());
|
||||
if let Some(i)=selected {
|
||||
self.input(format!("identity-name:{}",i.uid),"universal.rename",&i.name,Field::IdentityName(i.uid.clone()));
|
||||
|
||||
@@ -111,6 +111,13 @@ pub enum SettingsAction {
|
||||
}
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct IdentityView {pub uid:String,pub name:String,pub nickname:String,pub security_level:u8,pub is_default:bool,pub bookmarks:Vec<String>,pub progress:String,pub improving:bool}
|
||||
impl IdentityView {
|
||||
/// Onboarded/legacy identities can have a nickname but no separate display name.
|
||||
/// This fallback never rewrites the stored identity name or key.
|
||||
pub fn display_name<'a>(&'a self, fallback:&'a str)->&'a str {
|
||||
[self.name.as_str(),self.nickname.as_str()].into_iter().map(str::trim).find(|name|!name.is_empty()).unwrap_or(fallback)
|
||||
}
|
||||
}
|
||||
#[derive(Clone,Debug)]
|
||||
pub struct DeviceView {pub id:String,pub name:String,pub available:bool}
|
||||
#[derive(Clone,Debug)]
|
||||
|
||||
+21
-9
@@ -42,10 +42,10 @@ fn command(action:&Action,id:String)->ShellCommand { ShellCommand{id:id.into(),l
|
||||
fn commands(state:&mut State, scope:&str, actions:&[Action])->ModelRc<ShellCommand> {
|
||||
model(actions.iter().enumerate().map(|(index,a)|{let id=format!("{scope}/{index}/{}",a.id);state.actions.insert(id.clone(),a.clone());command(a,id)}).collect())
|
||||
}
|
||||
fn rows(state:&mut State, scope:&str, entries:&[Entry])->Vec<ShellRow> {
|
||||
fn rows(state:&mut State, scope:&str, entries:&[Entry], catalog:super::i18n::Catalog)->Vec<ShellRow> {
|
||||
entries.iter().map(|entry| {
|
||||
let id=format!("{scope}/{}",entry.id); state.targets.insert(id.clone(),entry.target.clone()); state.contexts.insert(id.clone(),entry.actions.clone());
|
||||
ShellRow{id:id.into(),title:entry.title.clone().into(),subtitle:entry.subtitle.clone().into(),depth:entry.depth.min(24) as i32,selected:entry.selected,expanded:entry.expanded,expandable:entry.expandable,talking:entry.talking,muted:entry.muted,unread:if entry.unread==0 {"".into()}else{entry.unread.to_string().into()}}
|
||||
ShellRow{id:id.into(),title:entry.title.clone().into(),subtitle:entry.subtitle.clone().into(),depth:entry.depth.min(24) as i32,selected:entry.selected,expanded:entry.expanded,expandable:entry.expandable,talking:entry.talking,muted:entry.muted,unread:if entry.unread==0 {"".into()}else{entry.unread.to_string().into()},disclosure:if cfg!(target_os="android") && entry.expandable{catalog.format(if entry.expanded{"message.collapse.channel.members"}else{"message.expand.channel.members"},&[("p0",entry.title.as_str())]).into()}else{SharedString::default()}}
|
||||
}).collect()
|
||||
}
|
||||
/// Preserve model identity and update only changed rows, including insert/remove positions.
|
||||
@@ -65,10 +65,11 @@ fn projected_field(field:&Field,raw:&str)->ShellField {
|
||||
}
|
||||
fn project_editor(ui:&AppWindow,state:&mut State) {
|
||||
let bridge=ui.global::<DialogBridge>();
|
||||
let Some(editor)=&state.editor else {bridge.set_visible(false);bridge.set_busy(false);return};
|
||||
let Some(editor)=&state.editor else {bridge.set_visible(false);bridge.set_busy(false);bridge.set_has_advanced(false);return};
|
||||
let c=state.presentation.catalog;
|
||||
bridge.set_visible(true);bridge.set_title(editor.form.title.clone().into());bridge.set_description(editor.form.description.clone().into());
|
||||
bridge.set_onboarding(editor.form.operation==Operation::CreateProfile);
|
||||
bridge.set_has_advanced(editor.form.fields.iter().any(|field|field.advanced));
|
||||
bridge.set_error(editor.form.error.clone().into());bridge.set_busy(editor.form.busy);bridge.set_destructive(editor.form.destructive);
|
||||
bridge.set_submit_label(editor.form.submit_label.clone().into());bridge.set_cancel_label(c.text("native.action.cancel").into());bridge.set_advanced_label(c.text("native.form.advanced").into());bridge.set_loading_label(c.text("native.status.loading").into());
|
||||
bridge.set_confirmation_label(editor.form.confirmation.as_ref().map(|target|c.format("native.form.confirm",&[("target",target)])).unwrap_or_default().into());
|
||||
@@ -168,13 +169,15 @@ fn back(ui:&AppWindow,state:&mut State,emit:&Arc<dyn Fn(ShellAction)+Send+Sync>)
|
||||
if ui.global::<ShellBridge>().get_menu_visible(){ui.global::<ShellBridge>().set_menu_visible(false);return}
|
||||
if !ui.global::<ShellBridge>().get_fullscreen_stream().is_empty(){ui.global::<ShellBridge>().set_fullscreen_stream("".into());return}
|
||||
if let Some(editor)=state.editor.take(){emit(ShellAction::Cancel{editor_id:editor.form.id,target:editor.form.target});project_editor(ui,state);return}
|
||||
if cfg!(target_os="android") && ui.global::<crate::ChatBridge>().get_mobile_overlay(){ui.global::<crate::ChatBridge>().set_mobile_overlay(false);return}
|
||||
if cfg!(target_os="android") && state.destination==Destination::Settings{
|
||||
let settings=ui.global::<crate::SettingsBridge>();
|
||||
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;
|
||||
state.stack.pop();if state.stack.is_empty(){state.destination=Destination::Servers;}
|
||||
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"){
|
||||
@@ -219,12 +222,21 @@ impl ShellBinding {
|
||||
})
|
||||
}else{None};
|
||||
let detail=selected_detail.as_ref().unwrap_or(&p.detail);
|
||||
let tree=rows(&mut s,"tree",&p.tree);reconcile(&s.tree,tree);
|
||||
let bookmarks=rows(&mut s,"bookmark",&p.bookmarks);reconcile(&s.bookmarks,bookmarks);
|
||||
let contacts=rows(&mut s,"contact",&p.contacts);reconcile(&s.contacts,contacts);
|
||||
let entries=rows(&mut s,"entry",&detail.entries);reconcile(&s.entries,entries);
|
||||
let tree=rows(&mut s,"tree",&p.tree,c);reconcile(&s.tree,tree);
|
||||
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);
|
||||
let tabs=p.tabs.iter().enumerate().map(|(index,tab)|{let id=format!("tab/{index}");s.targets.insert(id.clone(),tab.target.clone());s.contexts.insert(id.clone(),tab.actions.clone());ShellTab{id:id.into(),title:tab.title.clone().into(),selected:tab.selected,microphone_owner:tab.microphone_owner,connected:tab.connected,unread:if tab.unread==0{"".into()}else{tab.unread.to_string().into()}}}).collect();b.set_tabs(model(tabs));
|
||||
b.set_actions(commands(&mut s,"global",&p.actions));b.set_detail_actions(commands(&mut s,"detail",&detail.actions));
|
||||
if cfg!(target_os="android") {
|
||||
b.set_connection_names(strings(p.tabs.iter().map(|tab|tab.title.clone())));
|
||||
b.set_selected_connection(p.tabs.iter().position(|tab|tab.selected).map_or(-1,|index|index as i32));
|
||||
}
|
||||
let global_commands=commands(&mut s,"global",&p.actions);
|
||||
if cfg!(target_os="android") {
|
||||
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);
|
||||
}
|
||||
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();
|
||||
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}});
|
||||
|
||||
+199
-45
@@ -53,6 +53,8 @@ export global ChatBridge {
|
||||
in-out property <bool> toolbar-dynamic;
|
||||
in-out property <bool> composing;
|
||||
in-out property <bool> focus-request;
|
||||
// Android transient panels participate in the shell's Back dispatch.
|
||||
in-out property <bool> mobile-overlay;
|
||||
in-out property <bool> bottom-pinned: true;
|
||||
in-out property <float> log-position;
|
||||
in-out property <float> content-width;
|
||||
@@ -98,25 +100,35 @@ component ChatSelectionArea inherits TouchArea {
|
||||
in property <string> action;
|
||||
in property <float> offset-x;
|
||||
in property <float> offset-y;
|
||||
in property <float> row-height;
|
||||
callback begun();
|
||||
mouse-cursor: root.action != "" ? pointer : text;
|
||||
clicked => { if root.action != "" && ChatBridge.selected-text == "" { ChatBridge.activate(root.action); } }
|
||||
clicked => {
|
||||
if Theme.android {
|
||||
if root.action != "" { ChatBridge.activate(root.action); }
|
||||
else {
|
||||
ChatBridge.select-text(root.row-id, 0, 0, false);
|
||||
ChatBridge.select-text(root.row-id, 100000, max(0, root.row-height - 1), true);
|
||||
}
|
||||
} else if root.action != "" && ChatBridge.selected-text == "" { ChatBridge.activate(root.action); }
|
||||
}
|
||||
pointer-event(event) => {
|
||||
if event.button == PointerEventButton.left && event.kind == PointerEventKind.down {
|
||||
if !Theme.android && event.button == PointerEventButton.left && event.kind == PointerEventKind.down {
|
||||
root.begun();
|
||||
ChatBridge.select-text(root.row-id, root.offset-x + self.mouse-x / 1px, root.offset-y + self.mouse-y / 1px, false);
|
||||
}
|
||||
}
|
||||
moved => { if self.pressed { ChatBridge.select-text(root.row-id, root.offset-x + self.mouse-x / 1px, root.offset-y + self.mouse-y / 1px, true); } }
|
||||
// A phone drag belongs to the enclosing flickable, not text selection.
|
||||
moved => { if !Theme.android && self.pressed { ChatBridge.select-text(root.row-id, root.offset-x + self.mouse-x / 1px, root.offset-y + self.mouse-y / 1px, true); } }
|
||||
}
|
||||
|
||||
component RichRow inherits Rectangle {
|
||||
component RichRowContent inherits Rectangle {
|
||||
in property <ChatVisual> visual;
|
||||
in property <bool> inert;
|
||||
in property <length> viewport-width;
|
||||
callback render-request(string);
|
||||
render-request(id) => { ChatBridge.activate(id); }
|
||||
height: root.visual.height * 1px + ((root.visual.kind == 6 || root.visual.kind == 7) ? Theme.touch-target : 0px);
|
||||
height: max(root.visual.height * 1px + ((root.visual.kind == 6 || root.visual.kind == 7) ? Theme.touch-target : 0px), Theme.android && root.inert && root.visual.preview-position >= 0 ? 48px : 0px);
|
||||
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
|
||||
@@ -173,14 +185,37 @@ component RichRow inherits Rectangle {
|
||||
return reject;
|
||||
}
|
||||
Rectangle { border-width: action-focus.has-focus ? 1px : 0px; border-color: Theme.tint; background: transparent; }
|
||||
ChatSelectionArea { row-id: root.visual.id; action: run.action; offset-x: run.x; offset-y: run.y; begun => { action-focus.focus(); } }
|
||||
ChatSelectionArea { row-id: root.visual.id; row-height: root.visual.height; action: run.action; offset-x: run.x; offset-y: run.y; begun => { action-focus.focus(); } }
|
||||
}
|
||||
if !root.inert && run.action == "": ChatSelectionArea { row-id: root.visual.id; offset-x: run.x; offset-y: run.y; begun => { row-focus.focus(); } }
|
||||
if !root.inert && run.action == "": ChatSelectionArea { row-id: root.visual.id; row-height: root.visual.height; offset-x: run.x; offset-y: run.y; begun => { row-focus.focus(); } }
|
||||
}
|
||||
if root.inert && root.visual.preview-position >= 0: TouchArea { clicked => { ChatBridge.preview-edit(root.visual.preview-position); } }
|
||||
if root.visual.kind == 6 || root.visual.kind == 7: HorizontalLayout {
|
||||
y: root.visual.height * 1px; height: Theme.touch-target;
|
||||
for run in root.visual.runs: ActionButton { text: ChatBridge.action-label(run.action) != "" ? ChatBridge.action-label(run.action) : root.visual.kind == 7 ? ChatBridge.tr("chat.message.mermaid.placeholder.load") : ChatBridge.tr("chat.snippet.math"); visible: run.action != "" && !run.image-ready; clicked => { root.render-request(run.action); } }
|
||||
if !Theme.android: HorizontalLayout { for run in root.visual.runs: ActionButton { text: ChatBridge.action-label(run.action) != "" ? ChatBridge.action-label(run.action) : root.visual.kind == 7 ? ChatBridge.tr("chat.message.mermaid.placeholder.load") : ChatBridge.tr("chat.snippet.math"); visible: run.action != "" && !run.image-ready; clicked => { root.render-request(run.action); } } }
|
||||
if Theme.android && root.visual.runs.length > 0 && root.visual.runs[0].action != "" && !root.visual.runs[0].image-ready: ActionButton { text: root.visual.kind == 7 ? ChatBridge.tr("chat.message.mermaid.placeholder.load") : ChatBridge.tr("chat.snippet.math"); clicked => { root.render-request(root.visual.runs[0].action); } }
|
||||
}
|
||||
}
|
||||
|
||||
// Wide tables and code scroll within their row, never the phone's whole page.
|
||||
component RichRow inherits Rectangle {
|
||||
in property <ChatVisual> visual;
|
||||
in property <bool> inert;
|
||||
in property <length> viewport-width;
|
||||
callback render-request(string);
|
||||
render-request(id) => { ChatBridge.activate(id); }
|
||||
private property <length> body-height: max(root.visual.height * 1px + ((root.visual.kind == 6 || root.visual.kind == 7) ? Theme.touch-target : 0px), Theme.android && root.inert && root.visual.preview-position >= 0 ? 48px : 0px);
|
||||
private property <bool> wide: root.visual.content-width * 1px > root.viewport-width;
|
||||
min-width: 0px; horizontal-stretch: 1;
|
||||
preferred-width: Theme.android ? 0px : root.visual.content-width * 1px;
|
||||
height: root.body-height + (Theme.android && root.wide ? 24px : 0px);
|
||||
if !Theme.android || !root.wide: RichRowContent { visual: root.visual; viewport-width: root.viewport-width; inert: root.inert; render-request(id) => { root.render-request(id); } }
|
||||
if Theme.android && root.wide: ScrollView {
|
||||
width: root.width; height: root.height;
|
||||
content-width: max(self.visible-width, root.visual.content-width * 1px);
|
||||
content-height: root.body-height;
|
||||
vertical-scrollbar-policy: always-off;
|
||||
RichRowContent { visual: root.visual; viewport-width: parent.width; inert: root.inert; render-request(id) => { root.render-request(id); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,24 +227,28 @@ export component RichDocument inherits Rectangle {
|
||||
callback render-request(string);
|
||||
render-request(id) => { ChatBridge.activate(id); }
|
||||
height: contents.preferred-height;
|
||||
contents := VerticalLayout { spacing: 0px; for row in root.rows: RichRow { visual: row; viewport-width: root.width; inert: root.inert; render-request(id) => { root.render-request(id); } } }
|
||||
contents := VerticalLayout { min-width: 0px; preferred-width: 0px; spacing: 0px; for row in root.rows: RichRow { visual: row; viewport-width: root.width; inert: root.inert; render-request(id) => { root.render-request(id); } } }
|
||||
}
|
||||
|
||||
export component MarkupPanel inherits Rectangle {
|
||||
background: Theme.bg;
|
||||
changed width => { MarkupBridge.layout(max(32, (self.width - 32px) / 1px)); }
|
||||
changed width => { if !Theme.android { MarkupBridge.layout(max(32, (self.width - 32px) / 1px)); } }
|
||||
init => { focus.focus(); }
|
||||
TouchArea { }
|
||||
focus := FocusScope {
|
||||
VerticalLayout {
|
||||
padding: 16px; spacing: 8px;
|
||||
padding: Theme.android ? 8px : 16px; spacing: 8px;
|
||||
HorizontalLayout {
|
||||
min-height: Theme.touch-target;
|
||||
Text { text: MarkupBridge.title; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; font-weight: 600; vertical-alignment: center; accessible-role: text; accessible-label: self.text; }
|
||||
if !Theme.android: Text { text: MarkupBridge.title; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; font-weight: 600; vertical-alignment: center; accessible-role: text; accessible-label: self.text; }
|
||||
if Theme.android: Text { min-width: 0px; text: MarkupBridge.title; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; font-weight: 600; vertical-alignment: center; overflow: elide; accessible-role: text; accessible-label: self.text; }
|
||||
ActionButton { text: MarkupBridge.close-label; clicked => { MarkupBridge.close(); } }
|
||||
}
|
||||
ScrollView {
|
||||
RichDocument { rows: MarkupBridge.rows; inert: true; render-request(id) => { MarkupBridge.render-request(id); } }
|
||||
document-scroll := ScrollView {
|
||||
min-width: 0px; min-height: 0px;
|
||||
horizontal-scrollbar-policy: Theme.android ? always-off : as-needed;
|
||||
if !Theme.android: RichDocument { rows: MarkupBridge.rows; inert: true; render-request(id) => { MarkupBridge.render-request(id); } }
|
||||
if Theme.android: RichDocument { width: document-scroll.visible-width; rows: MarkupBridge.rows; inert: true; changed width => { MarkupBridge.layout(max(32, self.width / 1px)); } render-request(id) => { MarkupBridge.render-request(id); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,17 +259,27 @@ export component ChatScreen inherits Rectangle {
|
||||
min-width: 0px; min-height: 0px;
|
||||
preferred-width: 100%; preferred-height: 100%;
|
||||
private property <bool> show-tools;
|
||||
init => { if Theme.android { ChatBridge.mobile-overlay = false; } }
|
||||
private property <bool> show-emoji;
|
||||
private property <bool> show-search;
|
||||
private property <bool> show-conversations;
|
||||
private property <bool> mobile-overlay: ChatBridge.mobile-overlay;
|
||||
changed mobile-overlay => {
|
||||
if Theme.android && !root.mobile-overlay {
|
||||
if root.show-emoji { ChatBridge.command("dismiss-completion"); }
|
||||
root.show-tools = false; root.show-emoji = false; root.show-search = false; root.show-conversations = false;
|
||||
}
|
||||
}
|
||||
private property <bool> typing: Theme.android && Theme.ime-inset > 0px;
|
||||
private property <length> caret-y;
|
||||
// Measure the allocated viewport; composer constraints must not size their own parent.
|
||||
private property <length> allocated-height;
|
||||
private property <length> allocated-width;
|
||||
changed height => { allocated-height = self.height; }
|
||||
changed width => { ChatBridge.layout(max(16, (root.width - 32px) / 1px), max(16, (root.width - 40px) / 1px)); }
|
||||
changed width => { allocated-width = self.width; if !Theme.android { ChatBridge.layout(max(16, (root.width - 32px) / 1px), max(16, (root.width - 40px) / 1px)); } }
|
||||
VerticalLayout {
|
||||
spacing: 0px;
|
||||
if ChatBridge.tabs.length > 0 && !root.typing: ScrollView {
|
||||
if !Theme.android && ChatBridge.tabs.length > 0: ScrollView {
|
||||
height: Theme.touch-target; vertical-stretch: 0;
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
@@ -241,27 +290,40 @@ export component ChatScreen inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !root.typing: HorizontalLayout {
|
||||
if !Theme.android: HorizontalLayout {
|
||||
padding: 8px; spacing: 8px; height: 52px;
|
||||
Text { text: ChatBridge.title; color: Theme.fg; font-family: Theme.font-family; font-size: 18px; font-weight: 700; overflow: elide; vertical-alignment: center; horizontal-stretch: 1; }
|
||||
if ChatBridge.can-info: ActionButton { text: ChatBridge.tr("admin.info"); clicked => { ChatBridge.client-info(); } }
|
||||
ActionButton { text: ChatBridge.tr("admin.search"); clicked => { root.show-search = !root.show-search; } }
|
||||
}
|
||||
if root.show-search: HorizontalLayout {
|
||||
if Theme.android && !root.typing && root.allocated-height > 220px: HorizontalLayout {
|
||||
min-height: 48px; vertical-stretch: 0; padding-left: 8px; padding-right: 8px; spacing: 8px;
|
||||
ActionButton {
|
||||
min-width: 48px; horizontal-stretch: 1; text: "";
|
||||
accessible-label: ChatBridge.tr("native.chat.conversations") + ": " + ChatBridge.title; enabled: ChatBridge.tabs.length > 0;
|
||||
Text { x: 12px; width: max(0px, parent.width - 44px); text: ChatBridge.title; overflow: elide; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; vertical-alignment: center; accessible-role: none; }
|
||||
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; } }
|
||||
}
|
||||
if !Theme.android && root.show-search: HorizontalLayout {
|
||||
padding-left: 12px; padding-right: 12px; spacing: 8px;
|
||||
TextField { text <=> ChatBridge.search; placeholder: ChatBridge.tr("admin.search"); accepted => { ChatBridge.search-history(ChatBridge.search); } }
|
||||
ActionButton { text: ChatBridge.tr("admin.search"); clicked => { ChatBridge.search-history(ChatBridge.search); } }
|
||||
}
|
||||
if !root.typing && (ChatBridge.has-older || ChatBridge.older-page || ChatBridge.loading): HorizontalLayout {
|
||||
if !Theme.android && (ChatBridge.has-older || ChatBridge.older-page || ChatBridge.loading): HorizontalLayout {
|
||||
padding-left: 12px; padding-right: 12px; spacing: 8px;
|
||||
if ChatBridge.has-older: ActionButton { text: ChatBridge.tr("chat.history.older"); enabled: !ChatBridge.loading; clicked => { ChatBridge.history(false); } }
|
||||
if ChatBridge.older-page: ActionButton { text: ChatBridge.tr("chat.history.latest"); enabled: !ChatBridge.loading; clicked => { ChatBridge.history(true); } }
|
||||
if ChatBridge.loading: Text { text: ChatBridge.tr("admin.loading"); color: Theme.muted; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle {
|
||||
vertical-stretch: 1;
|
||||
min-width: 0px; min-height: 0px; vertical-stretch: 1; clip: Theme.android;
|
||||
log := ListView {
|
||||
content-width: max(self.visible-width, ChatBridge.content-width * 1px);
|
||||
content-width: Theme.android ? self.visible-width : max(self.visible-width, ChatBridge.content-width * 1px);
|
||||
horizontal-scrollbar-policy: Theme.android ? always-off : as-needed;
|
||||
changed visible-width => { if Theme.android { ChatBridge.layout(max(32, self.visible-width / 1px), max(32, editor-scroll.visible-width / 1px)); } }
|
||||
width: parent.width; height: parent.height;
|
||||
content-y: ChatBridge.log-position * 1px;
|
||||
changed content-y => {
|
||||
@@ -269,45 +331,56 @@ export component ChatScreen inherits Rectangle {
|
||||
ChatBridge.bottom-pinned = self.content-height + self.content-y - self.height < 80px;
|
||||
}
|
||||
changed content-height => { if ChatBridge.bottom-pinned && !ChatBridge.older-page { self.content-y = min(0px, self.height - self.content-height); } }
|
||||
changed visible-height => { if Theme.android && ChatBridge.bottom-pinned && !ChatBridge.older-page { self.content-y = min(0px, self.height - self.content-height); } }
|
||||
for row in ChatBridge.rows: RichRow { visual: row; viewport-width: log.visible-width; inert: false; }
|
||||
}
|
||||
if ChatBridge.rows.length == 0 && !ChatBridge.loading: Text { width: parent.width; text: ChatBridge.tr("chat.history.empty"); color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size; horizontal-alignment: center; }
|
||||
}
|
||||
if ChatBridge.selected-text != "": HorizontalLayout {
|
||||
if !Theme.android && ChatBridge.selected-text != "": HorizontalLayout {
|
||||
padding-left: 12px; spacing: 8px;
|
||||
ActionButton { text: ChatBridge.tr("ui.copy"); clicked => { ChatBridge.copy-selection(); } }
|
||||
Text { text: ChatBridge.selected-text; color: Theme.muted; overflow: elide; vertical-alignment: center; }
|
||||
}
|
||||
if ChatBridge.status != "": Text { text: ChatBridge.status; color: Theme.muted; wrap: word-wrap; font-family: Theme.font-family; font-size: 13px; }
|
||||
if ChatBridge.error != "": Text { text: ChatBridge.error; color: Theme.error; wrap: word-wrap; font-family: Theme.font-family; font-size: 13px; accessible-role: text; }
|
||||
if !Theme.android && ChatBridge.status != "": Text { text: ChatBridge.status; color: Theme.muted; wrap: word-wrap; font-family: Theme.font-family; font-size: 13px; }
|
||||
if !Theme.android && ChatBridge.error != "": Text { text: ChatBridge.error; color: Theme.error; wrap: word-wrap; font-family: Theme.font-family; font-size: 13px; accessible-role: text; }
|
||||
if Theme.android && ChatBridge.error != "" && !root.typing: error-scroll := ScrollView {
|
||||
min-height: 0px; max-height: 48px; preferred-height: error-text.preferred-height;
|
||||
horizontal-scrollbar-policy: always-off;
|
||||
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-height: 92px; max-height: Theme.android ? max(120px, root.allocated-height) : max(120px, root.allocated-height * 0.55); vertical-stretch: 0;
|
||||
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;
|
||||
VerticalLayout {
|
||||
min-width: 0px; preferred-width: 0px;
|
||||
padding: 8px; spacing: 4px;
|
||||
if ChatBridge.toolbar-visible && (!ChatBridge.toolbar-dynamic || input.has-focus || root.show-tools || root.show-emoji): HorizontalLayout {
|
||||
spacing: 4px;
|
||||
if !Theme.android && ChatBridge.toolbar-visible && (!ChatBridge.toolbar-dynamic || input.has-focus || root.show-tools || root.show-emoji): HorizontalLayout {
|
||||
min-width: 0px; preferred-width: 0px; spacing: 4px;
|
||||
ActionButton { text: "B"; accessible-label: ChatBridge.tr("chat.snippet.bold"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.format("bold"); } }
|
||||
ActionButton { text: "I"; accessible-label: ChatBridge.tr("chat.snippet.italic"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.format("italic"); } }
|
||||
if root.width > 420px: ActionButton { text: ChatBridge.tr("chat.snippet.link"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.format("link"); } }
|
||||
if root.allocated-width > 420px: ActionButton { text: ChatBridge.tr("chat.snippet.link"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.format("link"); } }
|
||||
ActionButton { text: ChatBridge.tr("chat.toolbar.more"); enabled: ChatBridge.enabled; clicked => { root.show-tools = !root.show-tools; root.show-emoji = false; } }
|
||||
}
|
||||
HorizontalLayout {
|
||||
if !Theme.android: HorizontalLayout {
|
||||
Text { text: ChatBridge.tr("settings.chat.text_edit.rich_text"); color: Theme.muted; font-family: Theme.font-family; font-size: 13px; vertical-alignment: center; horizontal-stretch: 1; }
|
||||
Toggle { label: ChatBridge.tr("settings.chat.text_edit.rich_text"); checked <=> ChatBridge.hybrid; enabled: !ChatBridge.composing; toggled(value) => { ChatBridge.set-hybrid(value); } }
|
||||
}
|
||||
if root.show-tools: ListView {
|
||||
height: Theme.android ? clamp(root.allocated-height - 240px, 48px, 160px) : 160px;
|
||||
if !Theme.android && root.show-tools: ListView {
|
||||
height: 160px;
|
||||
for tool in ChatBridge.tools: ActionButton { text: tool.label; enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.format(tool.id); root.show-tools = false; } }
|
||||
}
|
||||
if root.show-emoji: TextField { text <=> ChatBridge.emoji-search; placeholder: ChatBridge.tr("chat.emoji.search"); edited(value) => { ChatBridge.emoji(value); } }
|
||||
if ChatBridge.completions.length > 0: ListView {
|
||||
height: min(Theme.android ? clamp(root.allocated-height - 240px, 48px, 160px) : 160px, ChatBridge.completions.length * Theme.touch-target);
|
||||
if !Theme.android && root.show-emoji: TextField { text <=> ChatBridge.emoji-search; placeholder: ChatBridge.tr("chat.emoji.search"); edited(value) => { ChatBridge.emoji(value); } }
|
||||
if !Theme.android && ChatBridge.completions.length > 0: ListView {
|
||||
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; } }
|
||||
}
|
||||
editor-scroll := ScrollView {
|
||||
content-width: max(self.visible-width, ChatBridge.editor-width * 1px);
|
||||
min-height: 48px; preferred-height: min(240px, editor-content.height); vertical-stretch: 1;
|
||||
content-width: Theme.android ? self.visible-width : max(self.visible-width, ChatBridge.editor-width * 1px);
|
||||
horizontal-scrollbar-policy: Theme.android ? always-off : as-needed;
|
||||
min-width: 0px; min-height: 48px;
|
||||
preferred-height: Theme.android ? min(max(48px, root.allocated-height * 0.25), editor-content.height) : min(240px, editor-content.height); vertical-stretch: 1;
|
||||
changed visible-width => { if Theme.android { ChatBridge.layout(max(32, log.visible-width / 1px), max(32, self.visible-width / 1px)); } }
|
||||
changed visible-height => {
|
||||
if Theme.android && input.has-focus {
|
||||
if root.caret-y + self.content-y < 0px { self.content-y = -root.caret-y; }
|
||||
@@ -317,13 +390,13 @@ export component ChatScreen inherits Rectangle {
|
||||
VerticalLayout {
|
||||
spacing: 0px;
|
||||
editor-content := Rectangle {
|
||||
width: ChatBridge.editor-width * 1px;
|
||||
height: before-doc.height + max(36px, input.preferred-height) + after-doc.height;
|
||||
width: Theme.android ? editor-scroll.visible-width : ChatBridge.editor-width * 1px;
|
||||
height: before-doc.height + max(Theme.android ? 48px : 36px, input.preferred-height) + after-doc.height;
|
||||
before-doc := RichDocument { rows: ChatBridge.before; width: parent.width; }
|
||||
input := TextInput {
|
||||
y: before-doc.height; width: parent.width; height: max(36px, self.preferred-height);
|
||||
y: before-doc.height; width: parent.width; height: max(Theme.android ? 48px : 36px, self.preferred-height);
|
||||
text <=> ChatBridge.editor-text; enabled: ChatBridge.enabled;
|
||||
single-line: false; wrap: word-wrap; font-family: Theme.font-family; font-size: 14px;
|
||||
single-line: false; wrap: word-wrap; font-family: Theme.font-family; font-size: Theme.android ? Theme.font-size * 14 / 15 : 14px;
|
||||
color: Theme.fg; selection-foreground-color: Theme.fg; selection-background-color: Theme.tint;
|
||||
accessible-label: ChatBridge.tr("ui.message"); accessible-placeholder-text: ChatBridge.placeholder;
|
||||
page-height: editor-scroll.visible-height;
|
||||
@@ -347,7 +420,7 @@ export component ChatScreen inherits Rectangle {
|
||||
if event.text == "c" && event.modifiers.alt { ChatBridge.format("codeblock"); return accept; }
|
||||
if event.text == "a" { ChatBridge.command("select-all"); return accept; }
|
||||
}
|
||||
if ChatBridge.completions.length > 0 {
|
||||
if ChatBridge.completions.length > 0 && !(Theme.android && event.text == Key.Return && !event.modifiers.control && !event.modifiers.meta) {
|
||||
if event.text == Key.DownArrow { ChatBridge.command("completion-next"); return accept; }
|
||||
if event.text == Key.UpArrow { ChatBridge.command("completion-previous"); return accept; }
|
||||
if event.text == Key.Return || event.text == Key.Tab { ChatBridge.complete(ChatBridge.completion-index); return accept; }
|
||||
@@ -379,19 +452,100 @@ export component ChatScreen inherits Rectangle {
|
||||
MenuItem { title: ChatBridge.tr("native.chat.selectAll"); activated => { ChatBridge.command("select-all"); } }
|
||||
}
|
||||
}
|
||||
if input.text == "" && input.preedit-text == "": Text { y: input.y; text: ChatBridge.placeholder; color: Theme.muted; font-family: Theme.font-family; font-size: 14px; }
|
||||
if input.text == "" && input.preedit-text == "": Text { y: input.y; width: parent.width; text: ChatBridge.placeholder; color: Theme.muted; font-family: Theme.font-family; font-size: Theme.android ? Theme.font-size * 14 / 15 : 14px; wrap: Theme.android ? word-wrap : no-wrap; }
|
||||
after-doc := RichDocument { y: input.y + input.height; rows: ChatBridge.after; width: parent.width; }
|
||||
}
|
||||
}
|
||||
}
|
||||
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(); } }
|
||||
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(); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: ChatBridge.tr("ui.send"); primary: true; enabled: ChatBridge.can-send && !ChatBridge.composing; clicked => { ChatBridge.send(); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if Theme.android && ChatBridge.selected-text != "" && ChatBridge.completions.length == 0 && !ChatBridge.mobile-overlay && composer.y >= 48px: Rectangle {
|
||||
y: max(0px, composer.y - 48px); height: 48px; background: Theme.header;
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
ActionButton { text: ChatBridge.tr("ui.copy"); clicked => { ChatBridge.copy-selection(); ChatBridge.command("clear-selection"); } }
|
||||
Text { min-width: 0px; text: ChatBridge.selected-text; color: Theme.muted; font-family: Theme.font-family; font-size: 13px; overflow: elide; vertical-alignment: center; horizontal-stretch: 1; }
|
||||
ActionButton { text: ChatBridge.tr("ui.close"); clicked => { ChatBridge.command("clear-selection"); } }
|
||||
}
|
||||
}
|
||||
// Completion suggestions float over the log instead of increasing the minimum
|
||||
// composer height while Android's IME owns most of the landscape viewport.
|
||||
if Theme.android && !ChatBridge.mobile-overlay && ChatBridge.completions.length > 0 && composer.y >= 48px: Rectangle {
|
||||
width: root.width; height: min(144px, max(48px, composer.y));
|
||||
y: max(0px, composer.y - self.height); background: Theme.header;
|
||||
ListView {
|
||||
for item[index] in ChatBridge.completions: ActionButton { text: item.label; primary: index == ChatBridge.completion-index; clicked => { ChatBridge.complete(index); } }
|
||||
}
|
||||
}
|
||||
if Theme.android && ChatBridge.mobile-overlay: Rectangle {
|
||||
background: Theme.header;
|
||||
TouchArea { }
|
||||
VerticalLayout {
|
||||
padding: 8px; spacing: 8px;
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
if root.show-emoji: TextField { text <=> ChatBridge.emoji-search; placeholder: ChatBridge.tr("chat.emoji.search"); edited(value) => { ChatBridge.emoji(value); } }
|
||||
if !root.show-emoji: Text { min-width: 0px; text: root.show-search ? ChatBridge.tr("admin.search") : root.show-conversations ? ChatBridge.tr("native.chat.conversations") : ChatBridge.tr("chat.toolbar.more"); color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; font-weight: 600; overflow: elide; vertical-alignment: center; horizontal-stretch: 1; }
|
||||
ActionButton { text: ChatBridge.tr("ui.close"); clicked => { ChatBridge.mobile-overlay = false; } }
|
||||
}
|
||||
if root.show-conversations: ListView {
|
||||
min-width: 0px; min-height: 0px;
|
||||
for tab in ChatBridge.tabs: HorizontalLayout {
|
||||
spacing: 8px;
|
||||
ActionButton { horizontal-stretch: 1; text: tab.label + (tab.unread != "" ? " " + tab.unread : ""); primary: tab.active; clicked => { ChatBridge.choose-tab(tab.id); ChatBridge.mobile-overlay = false; } }
|
||||
if tab.closable: ActionButton { text: ChatBridge.tr("ui.close"); accessible-label: ChatBridge.tr("ui.close.private.chat") + " " + tab.label; clicked => { ChatBridge.close-tab(tab.id); } }
|
||||
}
|
||||
}
|
||||
if root.show-emoji: ListView {
|
||||
min-width: 0px; min-height: 0px;
|
||||
for item[index] in ChatBridge.completions: ActionButton { text: item.label; primary: index == ChatBridge.completion-index; clicked => { ChatBridge.complete(index); ChatBridge.mobile-overlay = false; } }
|
||||
}
|
||||
if root.show-search: ScrollView {
|
||||
min-width: 0px; min-height: 0px;
|
||||
VerticalLayout {
|
||||
spacing: 8px;
|
||||
TextField { text <=> ChatBridge.search; placeholder: ChatBridge.tr("admin.search"); accepted => { ChatBridge.search-history(ChatBridge.search); ChatBridge.mobile-overlay = false; } }
|
||||
ActionButton { text: ChatBridge.tr("admin.search"); clicked => { ChatBridge.search-history(ChatBridge.search); ChatBridge.mobile-overlay = false; } }
|
||||
}
|
||||
}
|
||||
if root.show-tools: ScrollView {
|
||||
min-width: 0px; min-height: 0px; horizontal-scrollbar-policy: always-off;
|
||||
VerticalLayout {
|
||||
spacing: 8px;
|
||||
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; } }
|
||||
ActionButton { text: ChatBridge.tr("admin.search"); clicked => { root.show-tools = false; root.show-search = true; } }
|
||||
if ChatBridge.can-info: ActionButton { text: ChatBridge.tr("admin.info"); clicked => { ChatBridge.mobile-overlay = false; ChatBridge.client-info(); } }
|
||||
if ChatBridge.has-older: ActionButton { text: ChatBridge.tr("chat.history.older"); enabled: !ChatBridge.loading; clicked => { ChatBridge.history(false); ChatBridge.mobile-overlay = false; } }
|
||||
if ChatBridge.older-page: ActionButton { text: ChatBridge.tr("chat.history.latest"); enabled: !ChatBridge.loading; clicked => { ChatBridge.history(true); ChatBridge.mobile-overlay = false; } }
|
||||
if ChatBridge.loading: Text { text: ChatBridge.tr("admin.loading"); color: Theme.muted; wrap: word-wrap; }
|
||||
if ChatBridge.selected-text != "": ActionButton { text: ChatBridge.tr("native.chat.copySelection"); clicked => { ChatBridge.copy-selection(); ChatBridge.command("clear-selection"); ChatBridge.mobile-overlay = false; } }
|
||||
if ChatBridge.status != "": Text { text: ChatBridge.status; color: Theme.muted; font-family: Theme.font-family; font-size: 13px; wrap: word-wrap; }
|
||||
if ChatBridge.error != "": Text { text: ChatBridge.error; color: Theme.error; font-family: Theme.font-family; font-size: 13px; wrap: word-wrap; }
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { min-width: 0px; text: ChatBridge.tr("settings.chat.text_edit.rich_text"); color: Theme.fg; font-family: Theme.font-family; font-size: 13px; wrap: word-wrap; vertical-alignment: center; horizontal-stretch: 1; }
|
||||
Toggle { label: ChatBridge.tr("settings.chat.text_edit.rich_text"); checked <=> ChatBridge.hybrid; enabled: !ChatBridge.composing; toggled(value) => { ChatBridge.set-hybrid(value); ChatBridge.mobile-overlay = false; } }
|
||||
}
|
||||
ActionButton { text: ChatBridge.tr("native.chat.undo"); enabled: ChatBridge.can-undo && !ChatBridge.composing; clicked => { ChatBridge.command("undo"); ChatBridge.mobile-overlay = false; } }
|
||||
ActionButton { text: ChatBridge.tr("native.chat.redo"); enabled: ChatBridge.can-redo && !ChatBridge.composing; clicked => { ChatBridge.command("redo"); ChatBridge.mobile-overlay = false; } }
|
||||
ActionButton { text: ChatBridge.tr("native.chat.cut"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { input.cut(); ChatBridge.mobile-overlay = false; } }
|
||||
ActionButton { text: ChatBridge.tr("ui.copy"); clicked => { input.copy(); ChatBridge.mobile-overlay = false; } }
|
||||
ActionButton { text: ChatBridge.tr("native.chat.paste"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { input.paste(); ChatBridge.mobile-overlay = false; } }
|
||||
ActionButton { text: ChatBridge.tr("native.chat.selectAll"); enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.command("select-all"); ChatBridge.mobile-overlay = false; } }
|
||||
for tool in ChatBridge.tools: ActionButton { text: tool.label; enabled: ChatBridge.enabled && !ChatBridge.composing; clicked => { ChatBridge.format(tool.id); ChatBridge.mobile-overlay = false; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ComboBox } from "std-widgets.slint";
|
||||
import { ComboBox, ScrollView } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
|
||||
export component ActionButton inherits Rectangle {
|
||||
@@ -7,9 +7,10 @@ export component ActionButton inherits Rectangle {
|
||||
in property <bool> primary: false;
|
||||
in property <bool> destructive: false;
|
||||
callback clicked();
|
||||
min-height: Theme.touch-target;
|
||||
min-width: max(Theme.android ? 48px : 44px, label.preferred-width + 24px);
|
||||
preferred-height: Theme.touch-target;
|
||||
min-height: Theme.android ? max(Theme.touch-target, label.preferred-height + 16px) : Theme.touch-target;
|
||||
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-width: focus.has-focus || Theme.high-contrast ? 2px : 0px;
|
||||
@@ -19,7 +20,7 @@ export component ActionButton inherits Rectangle {
|
||||
accessible-label: text;
|
||||
accessible-enabled: enabled;
|
||||
accessible-action-default => { if root.enabled { root.clicked(); } }
|
||||
label := Text { 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; overflow: elide; }
|
||||
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; }
|
||||
focus := FocusScope {
|
||||
enabled: root.enabled;
|
||||
key-pressed(event) => { if event.text == "\n" || event.text == " " { root.clicked(); return accept; } return reject; }
|
||||
@@ -37,6 +38,7 @@ export component TextField inherits Rectangle {
|
||||
callback accepted();
|
||||
min-height: Theme.touch-target;
|
||||
preferred-height: Theme.touch-target;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
background: Theme.bg;
|
||||
border-radius: 4px;
|
||||
forward-focus: input;
|
||||
@@ -87,18 +89,48 @@ export component Choice inherits Rectangle {
|
||||
in property <bool> enabled: true;
|
||||
in property <string> label;
|
||||
callback selected(int);
|
||||
min-height: Theme.touch-target;
|
||||
preferred-height: Theme.touch-target;
|
||||
min-width: Theme.android ? 48px : 0px;
|
||||
min-height: Theme.android ? mobile.preferred-height : Theme.touch-target;
|
||||
preferred-height: Theme.android ? mobile.preferred-height : Theme.touch-target;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
forward-focus: input;
|
||||
// ComboBox normalizes its local model/index internally. Never let those writes sever
|
||||
// the caller's authoritative selected-index binding during a snapshot/model update.
|
||||
changed current-index => { input.current-index = root.current-index; }
|
||||
changed values => { input.current-index = root.current-index; }
|
||||
input := ComboBox {
|
||||
visible: !Theme.android;
|
||||
width: parent.width; height: parent.height;
|
||||
model: root.values;
|
||||
current-index: root.current-index;
|
||||
enabled: root.enabled;
|
||||
accessible-label: root.label;
|
||||
selected(value) => { root.selected(self.current-index); }
|
||||
}
|
||||
mobile := ActionButton {
|
||||
visible: Theme.android;
|
||||
width: parent.width; height: parent.height;
|
||||
text: root.current-index >= 0 && root.current-index < root.values.length ? root.values[root.current-index] : root.label;
|
||||
enabled: root.enabled && root.values.length > 0;
|
||||
background: Theme.bg; border-width: 1px; border-color: Theme.outline;
|
||||
accessible-label: root.label + ": " + self.text;
|
||||
clicked => { options.show(); }
|
||||
}
|
||||
options := PopupWindow {
|
||||
x: 0px; y: root.height;
|
||||
width: root.width; height: min(240px, root.values.length * Theme.touch-target + 16px);
|
||||
Rectangle {
|
||||
background: Theme.contrast; border-width: 1px; border-color: Theme.outline;
|
||||
ScrollView {
|
||||
width: parent.width; height: parent.height;
|
||||
VerticalLayout {
|
||||
padding: 8px; spacing: 4px; alignment: start;
|
||||
for value[index] in root.values: ActionButton {
|
||||
text: value; primary: root.current-index == index;
|
||||
clicked => { root.current-index = index; root.selected(index); options.close(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+184
-50
@@ -19,6 +19,7 @@ export global DialogBridge {
|
||||
in-out property <string> submit-label;
|
||||
in-out property <string> cancel-label;
|
||||
in-out property <string> advanced-label;
|
||||
in-out property <bool> has-advanced;
|
||||
in-out property <string> loading-label;
|
||||
callback edit(string, string);
|
||||
callback choose(string, int);
|
||||
@@ -27,54 +28,197 @@ export global DialogBridge {
|
||||
callback cancel();
|
||||
}
|
||||
|
||||
// Android first-run is a page, not a small modal with its required fields hidden in a scroller.
|
||||
component AndroidOnboarding inherits Rectangle {
|
||||
background: Theme.shaded;
|
||||
// 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;
|
||||
accessible-role: form;
|
||||
accessible-label: DialogBridge.title;
|
||||
// A resized Android surface can exclude the IME entirely, leaving a zero overlap inset.
|
||||
property <bool> typing: Theme.ime-inset > 0px || root.height < 480px;
|
||||
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;
|
||||
VerticalLayout {
|
||||
padding: root.typing ? 12px : 24px;
|
||||
padding-top: root.typing ? 16px : 28px;
|
||||
padding-bottom: 8px;
|
||||
spacing: root.typing ? 6px : 16px;
|
||||
Text { text: DialogBridge.title; color: Theme.fg; font-size: Theme.font-size * (root.typing ? 1.25 : 1.8); font-weight: 700; wrap: word-wrap; }
|
||||
if !root.typing: Text { text: DialogBridge.description; color: Theme.fg; font-size: Theme.font-size; wrap: word-wrap; }
|
||||
for field in DialogBridge.fields: VerticalLayout {
|
||||
spacing: 4px;
|
||||
vertical-stretch: 0;
|
||||
Text { text: field.label; color: Theme.fg; font-size: Theme.font-size; }
|
||||
if field.kind == 0: TextField {
|
||||
height: Theme.touch-target; vertical-stretch: 0;
|
||||
text: field.value; placeholder: field.label; enabled: field.enabled && !DialogBridge.busy;
|
||||
edited(value) => { DialogBridge.edit(field.id,value); }
|
||||
accepted => { DialogBridge.submit(); }
|
||||
padding: 12px; spacing: 8px;
|
||||
Text {
|
||||
text: DialogBridge.title; color: Theme.fg;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size * 1.25; font-weight: 700;
|
||||
wrap: word-wrap; vertical-stretch: 0;
|
||||
accessible-role: text; accessible-label: self.text;
|
||||
}
|
||||
body := ScrollView {
|
||||
min-height: 0px; min-width: 0px; vertical-stretch: 1;
|
||||
changed visible-height => {
|
||||
if root.focused-y >= 0px { self.content-y = clamp(-root.focused-y, min(0px, self.visible-height - self.content-height), 0px); }
|
||||
}
|
||||
if field.kind == 6: HorizontalLayout {
|
||||
spacing: 8px; height: Theme.touch-target; vertical-stretch: 0;
|
||||
for label[index] in field.choices: ActionButton {
|
||||
text: label; primary: field.choice-index == index; enabled: field.enabled && !DialogBridge.busy;
|
||||
horizontal-stretch: 1; clicked => { DialogBridge.choose(field.id,index); }
|
||||
VerticalLayout {
|
||||
spacing: 12px; alignment: start;
|
||||
if DialogBridge.description != "": Text {
|
||||
text: DialogBridge.description; color: Theme.muted; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
}
|
||||
for field in DialogBridge.fields: field-row := Rectangle {
|
||||
visible: !field.advanced || root.advanced;
|
||||
height: self.visible ? row.preferred-height : 0px;
|
||||
vertical-stretch: 0; min-width: 0px;
|
||||
changed y => {
|
||||
if root.focused-field == field.id {
|
||||
root.focused-y = self.y;
|
||||
body.content-y = clamp(-self.y, min(0px, body.visible-height - body.content-height), 0px);
|
||||
}
|
||||
}
|
||||
row := VerticalLayout {
|
||||
spacing: 4px;
|
||||
if field.kind != 5: Text {
|
||||
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 {
|
||||
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); }
|
||||
accepted => { if DialogBridge.onboarding { DialogBridge.submit(); } }
|
||||
changed has-focus => {
|
||||
if self.has-focus {
|
||||
root.focused-field = field.id;
|
||||
root.focused-y = field-row.y;
|
||||
body.content-y = clamp(-field-row.y, min(0px, body.visible-height - body.content-height), 0px);
|
||||
} else if root.focused-field == field.id {
|
||||
root.focused-field = "";
|
||||
root.focused-y = -1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
accessible-label: field.label;
|
||||
edited => { DialogBridge.edit(field.id, self.text); }
|
||||
changed has-focus => {
|
||||
if self.has-focus {
|
||||
root.focused-field = field.id;
|
||||
root.focused-y = field-row.y;
|
||||
body.content-y = clamp(-field-row.y, min(0px, body.visible-height - body.content-height), 0px);
|
||||
} else if root.focused-field == field.id {
|
||||
root.focused-field = "";
|
||||
root.focused-y = -1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
if field.kind == 5: HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: field.label; color: Theme.fg; wrap: word-wrap; vertical-alignment: center;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
horizontal-stretch: 1; min-width: 0px;
|
||||
}
|
||||
Toggle {
|
||||
width: max(48px, Theme.touch-target); horizontal-stretch: 0;
|
||||
checked: field.checked; label: field.label; enabled: field.enabled && !DialogBridge.busy;
|
||||
toggled(value) => { DialogBridge.edit(field.id, value ? "true" : "false"); }
|
||||
}
|
||||
}
|
||||
if field.kind == 6: Choice {
|
||||
values: field.choices; current-index: field.choice-index; label: field.label;
|
||||
enabled: field.enabled && !DialogBridge.busy; min-width: 0px;
|
||||
selected(index) => { DialogBridge.choose(field.id, index); }
|
||||
}
|
||||
if field.hint != "": Text {
|
||||
text: field.hint; color: Theme.muted; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
}
|
||||
if field.error != "": Text {
|
||||
text: field.error; color: Theme.error; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
accessible-role: text; accessible-live-region: assertive;
|
||||
}
|
||||
}
|
||||
}
|
||||
for action in DialogBridge.actions: ActionButton {
|
||||
text: action.label; enabled: action.enabled && !DialogBridge.busy;
|
||||
destructive: action.destructive; min-width: 0px;
|
||||
clicked => { ShellBridge.invoke(action.id); }
|
||||
}
|
||||
if !DialogBridge.onboarding && DialogBridge.has-advanced: ActionButton {
|
||||
text: DialogBridge.advanced-label; min-width: 0px;
|
||||
clicked => { root.advanced = !root.advanced; }
|
||||
}
|
||||
if DialogBridge.confirmation-label != "": confirmation-row := VerticalLayout {
|
||||
spacing: 4px; vertical-stretch: 0;
|
||||
changed y => {
|
||||
if root.focused-field == "__confirmation" {
|
||||
root.focused-y = self.y;
|
||||
body.content-y = clamp(-self.y, min(0px, body.visible-height - body.content-height), 0px);
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: DialogBridge.confirmation-label; color: Theme.warning; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
}
|
||||
TextField {
|
||||
text: DialogBridge.confirmation; placeholder: DialogBridge.confirmation-label;
|
||||
enabled: !DialogBridge.busy; min-width: 0px;
|
||||
edited(value) => { DialogBridge.confirm(value); }
|
||||
changed has-focus => {
|
||||
if self.has-focus {
|
||||
root.focused-field = "__confirmation";
|
||||
root.focused-y = confirmation-row.y;
|
||||
body.content-y = clamp(-confirmation-row.y, min(0px, body.visible-height - body.content-height), 0px);
|
||||
} else if root.focused-field == "__confirmation" {
|
||||
root.focused-field = "";
|
||||
root.focused-y = -1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if DialogBridge.error != "": Text {
|
||||
text: DialogBridge.error; color: Theme.error; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
accessible-live-region: assertive;
|
||||
}
|
||||
if DialogBridge.busy: Text {
|
||||
text: DialogBridge.loading-label; color: Theme.muted; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
}
|
||||
}
|
||||
if field.error != "": Text { text: field.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
|
||||
}
|
||||
if DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
|
||||
if DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.fg; }
|
||||
Rectangle { vertical-stretch: 1; min-height: 0px; }
|
||||
ActionButton { height: Theme.touch-target; vertical-stretch: 0; text: DialogBridge.submit-label; primary: true; enabled: !DialogBridge.busy; clicked => { DialogBridge.submit(); } }
|
||||
ActionButton { height: Theme.touch-target; vertical-stretch: 0; text: DialogBridge.cancel-label; enabled: !DialogBridge.busy; clicked => { DialogBridge.cancel(); } }
|
||||
if root.stack-actions: VerticalLayout {
|
||||
spacing: 8px; vertical-stretch: 0;
|
||||
ActionButton {
|
||||
text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive;
|
||||
enabled: !DialogBridge.busy; min-width: 0px;
|
||||
clicked => { DialogBridge.submit(); }
|
||||
}
|
||||
ActionButton {
|
||||
text: DialogBridge.cancel-label; enabled: !DialogBridge.onboarding || !DialogBridge.busy; min-width: 0px;
|
||||
clicked => { DialogBridge.cancel(); }
|
||||
}
|
||||
}
|
||||
if !root.stack-actions: HorizontalLayout {
|
||||
spacing: 8px; vertical-stretch: 0;
|
||||
ActionButton {
|
||||
text: DialogBridge.cancel-label; enabled: !DialogBridge.onboarding || !DialogBridge.busy;
|
||||
min-width: 0px; horizontal-stretch: 1;
|
||||
clicked => { DialogBridge.cancel(); }
|
||||
}
|
||||
ActionButton {
|
||||
text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive;
|
||||
enabled: !DialogBridge.busy; min-width: 0px; horizontal-stretch: 1;
|
||||
clicked => { DialogBridge.submit(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component ShellDialog inherits Rectangle {
|
||||
background: Theme.contrast.with-alpha(0.75);
|
||||
property <bool> fullscreen-onboarding: Theme.android && DialogBridge.onboarding;
|
||||
property <bool> phone: Theme.android;
|
||||
// An overlay blocks background pointer input without turning Cancel into a submit.
|
||||
TouchArea { }
|
||||
if root.fullscreen-onboarding: AndroidOnboarding { width: root.width; height: root.height; }
|
||||
if !root.fullscreen-onboarding: dialog := Rectangle {
|
||||
if root.phone: AndroidDialog { width: root.width; height: root.height; }
|
||||
if !root.phone: dialog := Rectangle {
|
||||
width: min(parent.width - 24px, 640px);
|
||||
height: min(parent.height - 24px, layout.preferred-height);
|
||||
x: (parent.width - self.width)/2;
|
||||
@@ -89,15 +233,12 @@ export component ShellDialog inherits Rectangle {
|
||||
property <length> focused-y: 0px;
|
||||
layout := VerticalLayout {
|
||||
padding: 20px; spacing: 12px;
|
||||
if !Theme.android: Text { text: DialogBridge.title; font-size: Theme.font-size * 1.6; font-weight: 700; color: Theme.fg; wrap: word-wrap; }
|
||||
if !Theme.android && DialogBridge.description != "": Text { text: DialogBridge.description; color: Theme.muted; wrap: word-wrap; }
|
||||
Text { text: DialogBridge.title; font-size: Theme.font-size * 1.6; font-weight: 700; color: Theme.fg; wrap: word-wrap; }
|
||||
if DialogBridge.description != "": Text { text: DialogBridge.description; color: Theme.muted; wrap: word-wrap; }
|
||||
form-scroll := ScrollView {
|
||||
min-height: Theme.android ? min(80px, max(0px, root.height - 112px)) : 80px; max-height: 600px;
|
||||
changed visible-height => { if Theme.android { self.content-y = clamp(-dialog.focused-y, min(0px, self.visible-height - self.content-height), 0px); } }
|
||||
min-height: 80px; max-height: 600px;
|
||||
VerticalLayout {
|
||||
spacing: 12px;
|
||||
if Theme.android: Text { text: DialogBridge.title; font-size: Theme.font-size * 1.6; font-weight: 700; color: Theme.fg; wrap: word-wrap; }
|
||||
if Theme.android && DialogBridge.description != "": Text { text: DialogBridge.description; color: Theme.muted; wrap: word-wrap; }
|
||||
for field in DialogBridge.fields: field-row := Rectangle {
|
||||
visible: !field.advanced || dialog.advanced;
|
||||
height: self.visible ? row.preferred-height : 0px;
|
||||
@@ -125,22 +266,15 @@ export component ShellDialog inherits Rectangle {
|
||||
ActionButton { text: DialogBridge.advanced-label; clicked => { dialog.advanced = !dialog.advanced; } }
|
||||
if DialogBridge.confirmation-label != "": Text { text: DialogBridge.confirmation-label; color: Theme.warning; wrap: word-wrap; }
|
||||
if DialogBridge.confirmation-label != "": TextField { text: DialogBridge.confirmation; placeholder: DialogBridge.confirmation-label; enabled: !DialogBridge.busy; edited(value) => { DialogBridge.confirm(value); } }
|
||||
if Theme.android && DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
|
||||
if Theme.android && DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.muted; }
|
||||
}
|
||||
}
|
||||
if !Theme.android && DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
|
||||
if !Theme.android && DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.muted; }
|
||||
if !Theme.android: HorizontalLayout {
|
||||
if DialogBridge.error != "": Text { text: DialogBridge.error; color: Theme.error; wrap: word-wrap; accessible-live-region: assertive; }
|
||||
if DialogBridge.busy: Text { text: DialogBridge.loading-label; color: Theme.muted; }
|
||||
HorizontalLayout {
|
||||
alignment: end; spacing: 8px;
|
||||
ActionButton { text: DialogBridge.cancel-label; clicked => { DialogBridge.cancel(); } }
|
||||
ActionButton { text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive; enabled: !DialogBridge.busy; clicked => { DialogBridge.submit(); } }
|
||||
}
|
||||
if Theme.android: HorizontalLayout {
|
||||
spacing: 8px;
|
||||
ActionButton { min-width: 48px; horizontal-stretch: 1; text: DialogBridge.cancel-label; clicked => { DialogBridge.cancel(); } }
|
||||
ActionButton { min-width: 48px; horizontal-stretch: 1; text: DialogBridge.submit-label; primary: true; destructive: DialogBridge.destructive; enabled: !DialogBridge.busy; clicked => { DialogBridge.submit(); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+115
-19
@@ -38,30 +38,51 @@ export global SettingsBridge {
|
||||
component SettingCell inherits Rectangle {
|
||||
in property <SettingsRow> setting;
|
||||
in property <bool> compact;
|
||||
callback field-focused();
|
||||
private property <string> secret-draft;
|
||||
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;
|
||||
min-height: setting.kind == 0 ? 48px : content.preferred-height + 16px;
|
||||
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;
|
||||
VerticalLayout { padding: 0px;
|
||||
content := VerticalLayout {
|
||||
padding-top: root.setting.kind == 0 ? 14px : 8px;
|
||||
padding-top: root.setting.kind == 0 ? (Theme.android ? 12px : 14px) : 8px;
|
||||
padding-bottom: 8px;
|
||||
padding-left: root.setting.inset ? 36px : 20px;
|
||||
padding-right: 20px;
|
||||
spacing: 8px;
|
||||
Text { text: root.setting.title; color: Theme.fg; font-family: Theme.font-family;
|
||||
padding-left: Theme.android ? (root.setting.inset ? 24px : 12px) : (root.setting.inset ? 36px : 20px);
|
||||
padding-right: Theme.android ? 12px : 20px;
|
||||
spacing: Theme.android ? 6px : 8px;
|
||||
if !Theme.android || (root.setting.title != "" && root.setting.kind != 6 && root.setting.kind != 2): Text { text: root.setting.title; color: Theme.fg; font-family: Theme.font-family;
|
||||
font-size: Theme.font-size; font-weight: root.setting.kind == 0 ? 700 : 450;
|
||||
wrap: word-wrap; accessible-role: text; accessible-label: self.text;
|
||||
}
|
||||
if root.setting.subtitle != "": Text { text: root.setting.subtitle; color: Theme.muted;
|
||||
if root.setting.subtitle != "" && (!Theme.android || root.setting.kind != 2): Text { text: root.setting.subtitle; color: Theme.muted;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size - 1px; wrap: word-wrap;
|
||||
accessible-role: text; accessible-label: self.text;
|
||||
}
|
||||
if root.setting.kind == 2: Toggle {
|
||||
if root.setting.kind == 2 && !Theme.android: Toggle {
|
||||
checked: root.setting.checked; enabled: root.setting.enabled; label: root.setting.title;
|
||||
min-height: max(48px, Theme.touch-target);
|
||||
toggled(value) => { self.checked = root.setting.checked; SettingsBridge.toggle-value(root.setting.token, value); }
|
||||
}
|
||||
if root.setting.kind == 2 && Theme.android: HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: root.setting.title; color: Theme.fg; font-family: Theme.font-family;
|
||||
font-size: Theme.font-size; wrap: word-wrap; vertical-alignment: center;
|
||||
horizontal-stretch: 1; min-width: 0px;
|
||||
}
|
||||
Toggle {
|
||||
width: max(48px, Theme.touch-target); horizontal-stretch: 0;
|
||||
checked: root.setting.checked; enabled: root.setting.enabled; label: root.setting.title;
|
||||
toggled(value) => { self.checked = root.setting.checked; SettingsBridge.toggle-value(root.setting.token, value); }
|
||||
}
|
||||
}
|
||||
if Theme.android && root.setting.kind == 2 && root.setting.subtitle != "": Text {
|
||||
text: root.setting.subtitle; color: Theme.muted; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size - 1px;
|
||||
accessible-role: text; accessible-label: self.text;
|
||||
}
|
||||
if root.setting.kind == 3: Choice {
|
||||
values: root.setting.options; current-index: root.setting.selected;
|
||||
enabled: root.setting.enabled; label: root.setting.title;
|
||||
@@ -71,11 +92,19 @@ component SettingCell inherits Rectangle {
|
||||
if root.setting.kind == 4 || root.setting.kind == 5 || root.setting.kind == 8: VerticalLayout {
|
||||
spacing: 4px;
|
||||
field := TextField {
|
||||
text: root.setting.value; placeholder: root.setting.title; secret: root.setting.kind == 8;
|
||||
text: Theme.android && root.setting.kind == 8 ? root.secret-draft : root.setting.value;
|
||||
placeholder: root.setting.title; secret: root.setting.kind == 8;
|
||||
enabled: root.setting.enabled; min-height: max(48px, Theme.touch-target);
|
||||
changed has-focus => { if self.has-focus { root.field-focused(); } }
|
||||
edited(value) => { SettingsBridge.draft(root.setting.token, value); }
|
||||
accepted() => { SettingsBridge.commit(root.setting.token, self.text); }
|
||||
min-width: 0px;
|
||||
changed has-focus => { root.field-focused(self.has-focus); }
|
||||
edited(value) => {
|
||||
if Theme.android && root.setting.kind == 8 { root.secret-draft = value; }
|
||||
else { SettingsBridge.draft(root.setting.token, value); }
|
||||
}
|
||||
accepted() => {
|
||||
SettingsBridge.commit(root.setting.token, self.text);
|
||||
if root.setting.kind == 8 { root.secret-draft = ""; }
|
||||
}
|
||||
}
|
||||
HorizontalLayout { spacing: 4px;
|
||||
if root.setting.kind == 5: ActionButton { text: "-"; accessible-label: root.setting.decrease; enabled: root.setting.enabled;
|
||||
@@ -88,7 +117,10 @@ component SettingCell inherits Rectangle {
|
||||
}
|
||||
ActionButton { text: SettingsBridge.apply-label; enabled: root.setting.enabled;
|
||||
min-height: max(48px, Theme.touch-target);
|
||||
clicked => { SettingsBridge.commit(root.setting.token, field.text); }
|
||||
clicked => {
|
||||
SettingsBridge.commit(root.setting.token, field.text);
|
||||
if root.setting.kind == 8 { root.secret-draft = ""; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,18 +146,19 @@ export component SettingsScreen inherits Rectangle {
|
||||
min-width: 0px; min-height: 0px;
|
||||
preferred-width: 100%; preferred-height: 100%;
|
||||
private property <bool> compact: self.width < 600px;
|
||||
private property <length> focused-row-y;
|
||||
private property <length> focused-row-y: -1px;
|
||||
private property <string> focused-row;
|
||||
forward-focus: keyboard;
|
||||
keyboard := FocusScope {
|
||||
key-pressed(event) => {
|
||||
if event.text == Key.Escape && !SettingsBridge.capturing { SettingsBridge.back(); return accept; }
|
||||
if !Theme.android && event.text == Key.Escape && !SettingsBridge.capturing { SettingsBridge.back(); return accept; }
|
||||
if !SettingsBridge.panel-open && event.text == Key.DownArrow { SettingsBridge.category-chosen(SettingsBridge.category < 11 ? SettingsBridge.category + 1 : 0); return accept; }
|
||||
if !SettingsBridge.panel-open && event.text == Key.UpArrow { SettingsBridge.category-chosen(SettingsBridge.category > 0 ? SettingsBridge.category - 1 : 11); return accept; }
|
||||
if !SettingsBridge.panel-open && event.text == Key.Home { SettingsBridge.category-chosen(0); return accept; }
|
||||
if !SettingsBridge.panel-open && event.text == Key.End { SettingsBridge.category-chosen(11); return accept; }
|
||||
return reject;
|
||||
}
|
||||
HorizontalLayout {
|
||||
if !Theme.android: HorizontalLayout {
|
||||
spacing: 0px;
|
||||
if !root.compact || !SettingsBridge.panel-open: Rectangle {
|
||||
width: root.compact ? parent.width : min(280px, root.width * 0.34);
|
||||
@@ -170,14 +203,77 @@ export component SettingsScreen inherits Rectangle {
|
||||
if SettingsBridge.error != "": Text { text: SettingsBridge.error; color: Theme.error; wrap: word-wrap; accessible-role: text; accessible-label: self.text; }
|
||||
if SettingsBridge.status != "": Text { text: SettingsBridge.status; color: Theme.muted; wrap: word-wrap; accessible-role: text; accessible-label: self.text; }
|
||||
settings-list := ListView {
|
||||
changed visible-height => { if Theme.android { self.content-y = clamp(-root.focused-row-y, min(0px, self.visible-height - self.content-height), 0px); } }
|
||||
for row in SettingsBridge.rows: cell := SettingCell {
|
||||
setting: row; compact: root.compact;
|
||||
field-focused => { if Theme.android { root.focused-row-y = cell.y; settings-list.content-y = clamp(-cell.y, min(0px, settings-list.visible-height - settings-list.content-height), 0px); } }
|
||||
}
|
||||
}
|
||||
if SettingsBridge.show-slint: AboutSlint { }
|
||||
}
|
||||
}
|
||||
if Theme.android: VerticalLayout {
|
||||
padding: 8px; 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 {
|
||||
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); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if SettingsBridge.panel-open: phone-list := ScrollView {
|
||||
min-height: 0px; min-width: 0px; vertical-stretch: 1;
|
||||
changed visible-height => {
|
||||
if root.focused-row-y >= 0px { self.content-y = clamp(-root.focused-row-y, min(0px, self.visible-height - self.content-height), 0px); }
|
||||
}
|
||||
VerticalLayout {
|
||||
spacing: 4px; alignment: start; min-width: 0px; preferred-width: 0px;
|
||||
if SettingsBridge.error != "": Text {
|
||||
text: SettingsBridge.error; color: Theme.error; wrap: word-wrap;
|
||||
font-family: Theme.font-family; font-size: Theme.font-size;
|
||||
accessible-role: text; accessible-label: self.text; accessible-live-region: assertive;
|
||||
}
|
||||
if SettingsBridge.status != "": Text {
|
||||
text: SettingsBridge.status; color: Theme.muted; wrap: word-wrap;
|
||||
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 {
|
||||
spacing: 0px; vertical-stretch: 0; min-width: 0px; preferred-width: 0px;
|
||||
changed y => {
|
||||
if root.focused-row == row.stable-id {
|
||||
root.focused-row-y = self.y;
|
||||
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 {
|
||||
setting: row; compact: true;
|
||||
min-width: 0px; preferred-width: 0px; vertical-stretch: 0;
|
||||
field-focused(focused) => {
|
||||
if focused {
|
||||
root.focused-row = row.stable-id;
|
||||
root.focused-row-y = phone-row.y;
|
||||
phone-list.content-y = clamp(-phone-row.y, min(0px, phone-list.visible-height - phone-list.content-height), 0px);
|
||||
} else if root.focused-row == row.stable-id {
|
||||
root.focused-row = "";
|
||||
root.focused-row-y = -1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if SettingsBridge.show-slint: AboutSlint { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+240
-46
@@ -1,10 +1,10 @@
|
||||
import { ScrollView, ListView, Slider } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
import { ActionButton, TextField } from "controls.slint";
|
||||
import { ActionButton, TextField, Choice } from "controls.slint";
|
||||
import { ChatScreen } from "chat.slint";
|
||||
import { SettingsScreen } from "settings.slint";
|
||||
import { SettingsScreen, SettingsBridge } from "settings.slint";
|
||||
|
||||
export struct ShellRow { id: string, title: string, subtitle: string, depth: int, selected: bool, expanded: bool, expandable: bool, talking: bool, muted: bool, unread: string }
|
||||
export struct ShellRow { id: string, title: string, subtitle: string, depth: int, selected: bool, expanded: bool, expandable: bool, talking: bool, muted: bool, unread: string, disclosure: string }
|
||||
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 }
|
||||
@@ -21,6 +21,9 @@ export global ShellBridge {
|
||||
in-out property <[ShellCommand]> menu-actions;
|
||||
in-out property <[ShellStream]> streams;
|
||||
in-out property <[string]> destinations;
|
||||
in-out property <[string]> connection-names;
|
||||
in-out property <int> selected-connection: -1;
|
||||
in-out property <ShellCommand> primary-action;
|
||||
in-out property <int> destination;
|
||||
in-out property <int> depth;
|
||||
in-out property <int> stage;
|
||||
@@ -128,7 +131,7 @@ component EntryRow inherits Rectangle {
|
||||
|
||||
component CommandList inherits VerticalLayout {
|
||||
in property <[ShellCommand]> commands;
|
||||
spacing: 4px;
|
||||
spacing: Theme.android ? 8px : 4px;
|
||||
for command in root.commands: VerticalLayout {
|
||||
ActionButton { text: command.label; enabled: command.enabled; destructive: command.destructive; clicked => { ShellBridge.invoke(command.id); } }
|
||||
if command.reason != "": Text { text: command.reason; color: Theme.muted; wrap: word-wrap; }
|
||||
@@ -137,25 +140,212 @@ component CommandList inherits VerticalLayout {
|
||||
|
||||
component StreamTile inherits Rectangle {
|
||||
in property <ShellStream> item;
|
||||
min-height: 230px;
|
||||
min-height: Theme.android ? stream-content.preferred-height : 230px;
|
||||
vertical-stretch: Theme.android ? 0 : 1;
|
||||
background: Theme.contrast;
|
||||
border-radius: 8px;
|
||||
border-width: 2px;
|
||||
border-color: Theme.bg;
|
||||
VerticalLayout {
|
||||
stream-content := VerticalLayout {
|
||||
padding: 8px; spacing: 4px;
|
||||
Text { text: root.item.title; color: Theme.fg; overflow: elide; }
|
||||
Text { text: root.item.title; color: Theme.fg; overflow: Theme.android ? clip : elide; wrap: Theme.android ? word-wrap : no-wrap; }
|
||||
Rectangle {
|
||||
min-height: 150px;
|
||||
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: elide; }
|
||||
Slider { minimum: 0; maximum: 2; value: root.item.volume; accessible-label: ShellBridge.label-volume; changed(value) => { ShellBridge.stream-volume(root.item.id,value); } }
|
||||
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); } }
|
||||
CommandList { commands: root.item.actions; }
|
||||
}
|
||||
}
|
||||
|
||||
// Touch navigation is structurally separate from the desktop's three fixed slots.
|
||||
component PhoneIconAction inherits Rectangle {
|
||||
in property <int> kind;
|
||||
in property <string> label;
|
||||
in property <bool> enabled: true;
|
||||
callback clicked();
|
||||
width: 48px; min-height: 48px; vertical-stretch: 0;
|
||||
background: icon-touch.has-hover || icon-focus.has-focus ? Theme.bg : transparent;
|
||||
border-radius: 8px; border-width: icon-focus.has-focus ? 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(); } }
|
||||
if root.kind == 0: HorizontalLayout { padding: 15px; spacing: 3px; for dot in 3: Rectangle { width: 4px; height: 4px; border-radius: 2px; background: Theme.fg; } }
|
||||
if root.kind == 1: Path { x: 12px; y: (parent.height - 24px)/2; width: 24px; height: 24px; commands: "M 15 4 L 7 12 L 15 20 M 7 12 L 22 12"; fill: transparent; stroke: Theme.fg; stroke-width: 2px; }
|
||||
if root.kind == 2: Path { x: 12px; y: (parent.height - 24px)/2; width: 24px; height: 24px; commands: "M 8 4 L 16 12 L 8 20"; fill: transparent; stroke: Theme.fg; stroke-width: 2px; }
|
||||
if root.kind == 3: Path { x: 12px; y: (parent.height - 24px)/2; width: 24px; height: 24px; commands: "M 4 8 L 12 16 L 20 8"; fill: transparent; stroke: Theme.fg; stroke-width: 2px; }
|
||||
icon-focus := FocusScope { enabled: root.enabled; key-pressed(e) => { if e.text == "\n" || e.text == " " { root.clicked(); return accept; } return reject; } }
|
||||
icon-touch := TouchArea { enabled: root.enabled; clicked => { icon-focus.focus(); root.clicked(); } }
|
||||
}
|
||||
|
||||
component PhoneEntryRow inherits Rectangle {
|
||||
in property <ShellRow> item;
|
||||
min-width: 0px;
|
||||
property <length> indent: min(item.depth * 12px, 48px);
|
||||
min-height: max(48px, row-content.preferred-height); preferred-height: self.min-height; vertical-stretch: 0;
|
||||
background: item.selected ? Theme.contrast : transparent;
|
||||
border-radius: 9px; border-width: item.selected || row-focus.has-focus ? 1.5px : 0px; border-color: Theme.tint;
|
||||
accessible-role: list-item; accessible-label: item.title + ". " + item.subtitle;
|
||||
accessible-item-selectable: true; accessible-item-selected: item.selected;
|
||||
accessible-expandable: item.expandable; accessible-expanded: item.expanded;
|
||||
accessible-action-default => { ShellBridge.select(root.item.id); }
|
||||
accessible-action-expand => { if root.item.expandable { ShellBridge.expand(root.item.id); } }
|
||||
row-content := HorizontalLayout { padding-left: root.indent; spacing: 8px;
|
||||
if root.item.expandable: PhoneIconAction { kind: root.item.expanded ? 3 : 2; label: root.item.disclosure; clicked => { ShellBridge.expand(root.item.id); } }
|
||||
Rectangle { width: 6px; height: 6px; border-radius: 3px; background: root.item.talking ? Theme.success : (root.item.muted ? Theme.error : Theme.muted); }
|
||||
VerticalLayout { padding-top: 8px; padding-bottom: 8px; spacing: 2px; alignment: center; horizontal-stretch: 1;
|
||||
Text { min-width: 0px; text: root.item.title; color: Theme.fg; font-size: Theme.font-size; wrap: word-wrap; }
|
||||
if root.item.subtitle != "": Text { min-width: 0px; text: root.item.subtitle; color: Theme.muted; font-size: Theme.font-size * 0.86; wrap: word-wrap; }
|
||||
}
|
||||
if root.item.unread != "": Text { text: root.item.unread; color: Theme.tint; vertical-alignment: center; }
|
||||
PhoneIconAction { kind: 0; label: ShellBridge.label-more + ": " + root.item.title; clicked => { ShellBridge.context(root.item.id); } }
|
||||
}
|
||||
row-focus := FocusScope { key-pressed(e) => { if e.text == "\n" { ShellBridge.select(root.item.id); return accept; } if e.text == Key.F10 && e.modifiers.shift { ShellBridge.context(root.item.id); return accept; } return reject; } }
|
||||
TouchArea {
|
||||
x: root.indent + (root.item.expandable ? 56px : 0px); width: max(0px,parent.width - self.x - 56px);
|
||||
clicked => { row-focus.focus(); ShellBridge.select(root.item.id); }
|
||||
pointer-event(e) => {
|
||||
if e.button == PointerEventButton.right && e.kind == PointerEventKind.down { ShellBridge.context(root.item.id); }
|
||||
if e.button == PointerEventButton.left && e.kind == PointerEventKind.down { ShellBridge.row-press(root.item.id,true); }
|
||||
if e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel { ShellBridge.row-press(root.item.id,false); }
|
||||
if e.kind == PointerEventKind.move && (abs((self.mouse-x - self.pressed-x)/1px)>8 || abs((self.mouse-y - self.pressed-y)/1px)>8) { ShellBridge.row-press(root.item.id,false); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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); } }
|
||||
if ShellBridge.tabs.length > 0: HorizontalLayout { spacing: 8px; vertical-stretch: 0;
|
||||
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;
|
||||
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; }
|
||||
for item in ShellBridge.bookmarks: PhoneEntryRow { item: item; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component PhoneDetail inherits Rectangle {
|
||||
in property <bool> typing;
|
||||
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;
|
||||
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.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;
|
||||
if ShellBridge.detail-loading: Text { text: ShellBridge.label-loading; color: Theme.muted; wrap: word-wrap; }
|
||||
if ShellBridge.detail-error != "": Text { text: ShellBridge.detail-error; color: Theme.error; wrap: word-wrap; }
|
||||
if ShellBridge.subtitle != "": Text { text: ShellBridge.subtitle; color: Theme.muted; wrap: word-wrap; }
|
||||
if ShellBridge.description != "": Text { text: ShellBridge.description; color: Theme.fg; wrap: word-wrap; }
|
||||
for row in ShellBridge.info: VerticalLayout { spacing: 4px; Text { text: row.label; color: Theme.muted; wrap: word-wrap; } Text { text: row.value; color: Theme.fg; wrap: word-wrap; } }
|
||||
CommandList { commands: ShellBridge.detail-actions; }
|
||||
for item in ShellBridge.entries: PhoneEntryRow { item: item; }
|
||||
if ShellBridge.has-previous || ShellBridge.has-next: HorizontalLayout { spacing: 8px;
|
||||
ActionButton { min-width: 48px; horizontal-stretch: 1; text: ShellBridge.label-previous; enabled: ShellBridge.has-previous; clicked => { ShellBridge.page(false); } }
|
||||
ActionButton { min-width: 48px; horizontal-stretch: 1; text: ShellBridge.label-next; enabled: ShellBridge.has-next; clicked => { ShellBridge.page(true); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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]);
|
||||
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 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 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.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 !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.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); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component ShellScreen inherits Rectangle {
|
||||
background: Theme.shaded;
|
||||
min-width: 0px; min-height: 0px;
|
||||
@@ -169,7 +359,7 @@ export component ShellScreen inherits Rectangle {
|
||||
property <length> actual-server: desktop ? min(server-width,max(220px,self.width - actual-sidebar - 295px)) : min(300px,self.width * 0.4);
|
||||
property <length> main-width: max(0px, self.width - actual-sidebar - (desktop ? 4px : 0px));
|
||||
property <length> detail-width: max(0px, main-width - (ShellBridge.destination == 0 && !compact ? actual-server + (desktop ? 4px : 0px) : 0px));
|
||||
VerticalLayout {
|
||||
if !Theme.android: VerticalLayout {
|
||||
spacing: 0px;
|
||||
Rectangle {
|
||||
height: max(44px, Theme.touch-target); background: Theme.header;
|
||||
@@ -216,18 +406,13 @@ export component ShellScreen inherits Rectangle {
|
||||
background: Theme.bg;
|
||||
VerticalLayout {
|
||||
spacing: 0px;
|
||||
if !Theme.android: ScrollView { height: Theme.touch-target; HorizontalLayout { for tab in ShellBridge.tabs: ActionButton {
|
||||
ScrollView { height: Theme.touch-target; HorizontalLayout { for tab in ShellBridge.tabs: ActionButton {
|
||||
text: tab.title + (tab.microphone-owner ? " · " + ShellBridge.label-mute : "") + (tab.unread != "" ? " (" + tab.unread + ")" : ""); primary: tab.selected; clicked => { ShellBridge.select(tab.id); }
|
||||
} } }
|
||||
if Theme.android: ScrollView { height: Theme.touch-target; HorizontalLayout { for tab in ShellBridge.tabs: HorizontalLayout {
|
||||
ActionButton { text: tab.title + (tab.microphone-owner ? " · " + ShellBridge.label-mute : "") + (tab.unread != "" ? " (" + tab.unread + ")" : ""); primary: tab.selected; clicked => { ShellBridge.select(tab.id); } }
|
||||
ActionButton { text: ShellBridge.label-more; clicked => { ShellBridge.context(tab.id); } }
|
||||
} } }
|
||||
if root.compact && (ShellBridge.tabs.length == 0 || Theme.android) && ShellBridge.bookmarks.length > 0: ListView { max-height: Theme.android && ShellBridge.tabs.length > 0 ? root.height * 0.25 : root.height; for item in ShellBridge.bookmarks: EntryRow { item: item; } }
|
||||
if root.compact && ShellBridge.tabs.length == 0 && ShellBridge.bookmarks.length > 0: ListView { max-height: root.height; for item in ShellBridge.bookmarks: EntryRow { item: item; } }
|
||||
ListView { for item in ShellBridge.tree: EntryRow { item: item; } }
|
||||
if ShellBridge.tree.length == 0: Text { text: ShellBridge.label-tree-empty; color: Theme.muted; wrap: word-wrap; }
|
||||
if !root.desktop && !Theme.android: CommandList { commands: ShellBridge.actions; }
|
||||
if !root.desktop && Theme.android: ScrollView { height: min(Theme.touch-target * 2, root.height * 0.22); CommandList { commands: ShellBridge.actions; } }
|
||||
if !root.desktop: CommandList { commands: ShellBridge.actions; }
|
||||
}
|
||||
}
|
||||
if root.desktop && ShellBridge.destination == 0: Rectangle {
|
||||
@@ -239,11 +424,10 @@ export component ShellScreen inherits Rectangle {
|
||||
background: Theme.shaded;
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
if !Theme.android || !root.compact || (ShellBridge.stage != 1 && ShellBridge.destination != 1): Rectangle { min-height: 71px; background: Theme.shaded;
|
||||
Rectangle { min-height: 71px; background: Theme.shaded;
|
||||
VerticalLayout { padding: 12px; Text { text: ShellBridge.title; color: Theme.fg; font-size: Theme.font-size * 1.6; font-weight: 700; overflow: elide; } Text { text: ShellBridge.subtitle; color: Theme.muted; overflow: elide; } }
|
||||
}
|
||||
if !Theme.android: HorizontalLayout { for name[index] in ShellBridge.stages: ActionButton { text: name; primary: ShellBridge.stage == index; clicked => { ShellBridge.stage = index; } } }
|
||||
if Theme.android && !root.typing: ScrollView { height: Theme.touch-target; vertical-stretch: 0; HorizontalLayout { for name[index] in ShellBridge.stages: ActionButton { text: name; primary: ShellBridge.stage == index; clicked => { ShellBridge.stage = index; } } } }
|
||||
HorizontalLayout { for name[index] in ShellBridge.stages: ActionButton { text: name; primary: ShellBridge.stage == index; clicked => { ShellBridge.stage = index; } } }
|
||||
if ShellBridge.stage == 1 || ShellBridge.destination == 1: ChatScreen { width: root.detail-width; }
|
||||
if ShellBridge.stage == 2 && ShellBridge.destination != 1: ScrollView {
|
||||
VerticalLayout { padding: 10px; spacing: 10px;
|
||||
@@ -261,7 +445,7 @@ export component ShellScreen inherits Rectangle {
|
||||
for row in ShellBridge.info: VerticalLayout { Text { text: row.label; color: Theme.muted; } Text { text: row.value; color: Theme.fg; wrap: word-wrap; } }
|
||||
CommandList { commands: ShellBridge.detail-actions; }
|
||||
} }
|
||||
if !Theme.android || ShellBridge.entries.length > 0: ListView { for item in ShellBridge.entries: EntryRow { item: item; } }
|
||||
ListView { for item in ShellBridge.entries: EntryRow { item: item; } }
|
||||
if ShellBridge.has-previous || ShellBridge.has-next: HorizontalLayout {
|
||||
ActionButton { text: ShellBridge.label-previous; enabled: ShellBridge.has-previous; clicked => { ShellBridge.page(false); } }
|
||||
ActionButton { text: ShellBridge.label-next; enabled: ShellBridge.has-next; clicked => { ShellBridge.page(true); } }
|
||||
@@ -277,49 +461,59 @@ export component ShellScreen inherits Rectangle {
|
||||
if !root.typing: Text { text: ShellBridge.voice-title + " · " + ShellBridge.voice-status; color: ShellBridge.transmitting ? Theme.success : Theme.fg; overflow: elide; }
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
ActionButton { min-width: Theme.android ? 48px : 0px; horizontal-stretch: 1; text: ShellBridge.label-mute; primary: Theme.android && ShellBridge.muted; destructive: ShellBridge.muted; clicked => { ShellBridge.voice(0); } }
|
||||
ActionButton { min-width: Theme.android ? 48px : 0px; horizontal-stretch: 1; text: ShellBridge.label-deafen; primary: Theme.android && ShellBridge.deafened; destructive: ShellBridge.deafened; clicked => { ShellBridge.voice(1); } }
|
||||
if !Theme.android: Rectangle { min-height: Theme.touch-target; background: desktop-ptt.pressed ? Theme.tint : Theme.bg; border-radius: 4px; accessible-role: button; accessible-label: ShellBridge.label-ptt;
|
||||
ActionButton { min-width: 0px; horizontal-stretch: 1; text: ShellBridge.label-mute; destructive: ShellBridge.muted; clicked => { ShellBridge.voice(0); } }
|
||||
ActionButton { min-width: 0px; horizontal-stretch: 1; text: ShellBridge.label-deafen; destructive: ShellBridge.deafened; clicked => { ShellBridge.voice(1); } }
|
||||
Rectangle { min-height: Theme.touch-target; background: desktop-ptt.pressed ? Theme.tint : Theme.bg; border-radius: 4px; accessible-role: button; accessible-label: ShellBridge.label-ptt;
|
||||
Text { text: ShellBridge.label-ptt; color: Theme.fg; vertical-alignment: center; horizontal-alignment: center; wrap: word-wrap; }
|
||||
desktop-ptt := TouchArea { enabled: ShellBridge.ptt-enabled; pointer-event(e) => { if e.kind == PointerEventKind.down { ShellBridge.held(true); } else if e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel { ShellBridge.held(false); } } }
|
||||
}
|
||||
if Theme.android: Rectangle { min-width: 48px; horizontal-stretch: 1; min-height: Theme.touch-target; background: ptt.pressed ? Theme.tint : Theme.bg; border-radius: 4px; opacity: ShellBridge.ptt-enabled ? 1 : 0.45;
|
||||
accessible-role: button; accessible-label: ShellBridge.label-ptt; accessible-enabled: ShellBridge.ptt-enabled;
|
||||
border-width: ptt-focus.has-focus ? 2px : 0px; border-color: Theme.outline;
|
||||
Text { text: ShellBridge.label-ptt; color: Theme.fg; vertical-alignment: center; horizontal-alignment: center; wrap: word-wrap; }
|
||||
ptt-focus := FocusScope {
|
||||
enabled: ShellBridge.ptt-enabled;
|
||||
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; }
|
||||
}
|
||||
ptt := TouchArea {
|
||||
enabled: ShellBridge.ptt-enabled;
|
||||
pointer-event(e) => { if e.button == PointerEventButton.left && e.kind == PointerEventKind.down { ptt-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); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ShellBridge.status != "": Text { text: ShellBridge.status; color: Theme.muted; overflow: elide; }
|
||||
if root.compact && !root.typing: HorizontalLayout { for label[index] in ShellBridge.destinations: ActionButton { min-width: Theme.android ? 48px : 0px; horizontal-stretch: 1; text: label; primary: ShellBridge.destination == index; clicked => { ShellBridge.navigate(index); } } }
|
||||
if root.compact: HorizontalLayout { for label[index] in ShellBridge.destinations: ActionButton { min-width: 0px; horizontal-stretch: 1; text: label; primary: ShellBridge.destination == index; clicked => { ShellBridge.navigate(index); } } }
|
||||
}
|
||||
if ShellBridge.fullscreen-stream != "": Rectangle {
|
||||
if Theme.android: AndroidShell { }
|
||||
if !Theme.android && ShellBridge.fullscreen-stream != "": Rectangle {
|
||||
background: Theme.contrast;
|
||||
VerticalLayout {
|
||||
ActionButton { text: ShellBridge.label-close; clicked => { ShellBridge.fullscreen-stream = ""; } }
|
||||
for stream in ShellBridge.streams: StreamTile { visible: stream.id == ShellBridge.fullscreen-stream; height: self.visible ? parent.height - Theme.touch-target : 0px; item: stream; }
|
||||
}
|
||||
}
|
||||
if ShellBridge.menu-visible: Rectangle {
|
||||
if !Theme.android && ShellBridge.menu-visible: Rectangle {
|
||||
background: Theme.contrast.with-alpha(0.7);
|
||||
TouchArea { clicked => { ShellBridge.close-menu(); } }
|
||||
Rectangle {
|
||||
width: min(parent.width - 24px,360px); height: min(parent.height - 24px, menu.preferred-height);
|
||||
x: parent.width - self.width - 12px; y: root.compact ? parent.height - self.height - 12px : 12px;
|
||||
background: Theme.header; border-radius: 8px; border-width: 1px; border-color: Theme.outline;
|
||||
menu := VerticalLayout { padding: 12px; spacing: 8px; Text { text: ShellBridge.menu-title; color: Theme.fg; font-weight: 600; wrap: word-wrap; } ScrollView { min-height: Theme.android ? min(Theme.touch-target * 3, max(0px, root.height - 160px)) : 0px; CommandList { commands: ShellBridge.menu-actions; } } ActionButton { text: ShellBridge.label-close; clicked => { ShellBridge.close-menu(); } } }
|
||||
menu := VerticalLayout { padding: 12px; spacing: 8px; Text { text: ShellBridge.menu-title; color: Theme.fg; font-weight: 600; wrap: word-wrap; } ScrollView { min-height: 0px; CommandList { commands: ShellBridge.menu-actions; } } ActionButton { text: ShellBridge.label-close; clicked => { ShellBridge.close-menu(); } } }
|
||||
}
|
||||
}
|
||||
if Theme.android && ShellBridge.fullscreen-stream != "": Rectangle {
|
||||
background: Theme.contrast;
|
||||
VerticalLayout {
|
||||
ActionButton { text: ShellBridge.label-close; clicked => { ShellBridge.fullscreen-stream = ""; } }
|
||||
ScrollView { min-height: 0px; vertical-stretch: 1;
|
||||
VerticalLayout { padding: 8px; for stream in ShellBridge.streams: VerticalLayout { if stream.id == ShellBridge.fullscreen-stream: StreamTile { item: stream; } } }
|
||||
}
|
||||
}
|
||||
}
|
||||
if Theme.android && ShellBridge.menu-visible: Rectangle {
|
||||
background: Theme.contrast.with-alpha(0.7);
|
||||
TouchArea { clicked => { ShellBridge.close-menu(); } }
|
||||
Rectangle {
|
||||
width: min(parent.width - 16px,480px); height: min(parent.height - 16px,phone-menu.preferred-height);
|
||||
x: (parent.width - self.width)/2; y: parent.height - self.height - 8px;
|
||||
background: Theme.header; border-radius: 8px; border-width: 1px; border-color: Theme.outline;
|
||||
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; }
|
||||
}
|
||||
menu-close := ActionButton { text: ShellBridge.label-close; clicked => { ShellBridge.close-menu(); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user