prev/next A2UI surface and better dismissal

This commit is contained in:
Georg Bauer
2026-07-27 11:52:15 +02:00
parent c9c2d8efd5
commit 4a309091b6
14 changed files with 466 additions and 61 deletions

View File

@@ -3,6 +3,8 @@ use super::*;
impl App {
pub(super) fn clear_a2ui(&mut self) {
self.a2ui.clear();
self.a2ui_history.clear();
self.a2ui_history_index = None;
self.a2ui_tabs.clear();
self.a2ui_modals.clear();
self.a2ui_editors.clear();
@@ -11,15 +13,16 @@ impl App {
self.a2ui_images.clear();
self.a2ui_image_requests.clear();
self.a2ui_image_loading = false;
self.pending_a2ui_dismissal = None;
}
pub(super) fn load_next_a2ui_image(&mut self) -> Task<Message> {
if self.a2ui_image_loading {
return Task::none();
}
let Some(url) = self
.a2ui
.image_urls()
let urls = self.displayed_a2ui_store().image_urls().collect::<Vec<_>>();
let Some(url) = urls
.into_iter()
.find(|url| !self.a2ui_image_requests.contains(url))
else {
return Task::none();
@@ -49,12 +52,32 @@ impl App {
)
}
pub(super) fn displayed_a2ui_store(&self) -> &crate::a2ui::Store {
self.a2ui_history_index
.and_then(|index| self.a2ui_history.get(index))
.unwrap_or(&self.a2ui)
}
pub(super) fn has_previous_a2ui_surface(&self) -> bool {
self.a2ui_history_index
.map_or(!self.a2ui_history.is_empty(), |index| index > 0)
}
pub(super) fn has_next_a2ui_surface(&self) -> bool {
self.a2ui_history_index.is_some_and(|index| {
index + 1 < self.a2ui_history.len() || self.a2ui.active_surface().is_some()
})
}
pub(super) fn change_a2ui_data(
&mut self,
surface_id: String,
path: String,
value: serde_json::Value,
) -> Task<Message> {
if self.a2ui_history_index.is_some() {
return Task::none();
}
let owner = self
.a2ui
.surface(&surface_id)