From 968c36fcf6ec4cbad4fa13e9b05c759c1be05752 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Wed, 16 Apr 2025 19:43:54 +0200 Subject: [PATCH 1/2] export: add a cross button to the modal --- liana-gui/src/app/state/export.rs | 2 +- liana-gui/src/app/view/export.rs | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/liana-gui/src/app/state/export.rs b/liana-gui/src/app/state/export.rs index 046d8c2f..47d2fded 100644 --- a/liana-gui/src/app/state/export.rs +++ b/liana-gui/src/app/state/export.rs @@ -232,7 +232,7 @@ impl ExportModal { pub fn view<'a, M>(&'a self, content: Element<'a, M>) -> Element where - M: 'a + Close + Clone + From, + M: 'a + Close + Clone + From + 'static, { let modal = Modal::new( content, diff --git a/liana-gui/src/app/view/export.rs b/liana-gui/src/app/view/export.rs index 6c707985..ecce970f 100644 --- a/liana-gui/src/app/view/export.rs +++ b/liana-gui/src/app/view/export.rs @@ -1,5 +1,5 @@ use iced::{ - alignment::Horizontal, + alignment::{self, Horizontal}, widget::{progress_bar, Column, Container, Row, Space}, Length, }; @@ -8,6 +8,7 @@ use liana_ui::{ button, card, text::{h4_bold, text}, }, + icon, widget::Element, }; @@ -15,7 +16,7 @@ use crate::export::ImportExportState; use crate::export::{Error, ImportExportMessage, ImportExportType}; /// Return the modal view for an export task -pub fn export_modal<'a, Message: From + Clone + 'a>( +pub fn export_modal<'a, Message: From + Clone + 'static>( state: &ImportExportState, error: Option<&'a Error>, title: &str, @@ -32,6 +33,16 @@ pub fn export_modal<'a, Message: From + Clone + 'a>( } .map(Container::new); + let cross = match state { + ImportExportState::Ended | ImportExportState::TimedOut | ImportExportState::Aborted => { + Some( + button::transparent(Some(icon::cross_icon().size(30)), "") + .on_press(ImportExportMessage::Close.into()), + ) + } + _ => None, + }; + let msg = if let Some(error) = error { format!("{}", error) } else { @@ -114,7 +125,14 @@ pub fn export_modal<'a, Message: From + Clone + 'a>( card::simple( Column::new() .spacing(10) - .push(Container::new(h4_bold(title)).width(Length::Fill)) + .push( + Row::new() + .push(Space::with_width(20)) + .push(h4_bold(title)) + .push(Space::with_width(Length::Fill)) + .push_maybe(cross) + .align_y(alignment::Vertical::Center), + ) .push(Space::with_height(Length::Fill)) .push(progress_bar_row) .push(Space::with_height(Length::Fill)) @@ -124,6 +142,6 @@ pub fn export_modal<'a, Message: From + Clone + 'a>( .push(Space::with_height(5)), ) .width(Length::Fixed(500.0)) - .height(Length::Fixed(250.0)) + .height(Length::Fixed(300.0)) .into() } From a50fa04519160169ecae9fb56b047ab76303f712 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Thu, 17 Apr 2025 18:51:31 +0200 Subject: [PATCH 2/2] export: remove stop button from the modal --- liana-gui/src/app/view/export.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/liana-gui/src/app/view/export.rs b/liana-gui/src/app/view/export.rs index ecce970f..5498d2be 100644 --- a/liana-gui/src/app/view/export.rs +++ b/liana-gui/src/app/view/export.rs @@ -22,13 +22,10 @@ pub fn export_modal<'a, Message: From + Clone + 'static>( title: &str, import_export_type: &ImportExportType, ) -> Element<'a, Message> { - let cancel_close = match state { + let cancel = match state { ImportExportState::Started | ImportExportState::Progress(_) => { Some(button::secondary(None, "Cancel").on_press(ImportExportMessage::UserStop.into())) } - ImportExportState::Ended | ImportExportState::TimedOut | ImportExportState::Aborted => { - Some(button::secondary(None, "Close").on_press(ImportExportMessage::Close.into())) - } _ => None, } .map(Container::new); @@ -93,9 +90,9 @@ pub fn export_modal<'a, Message: From + Clone + 'static>( (Some(_), _) => labels_btn, (_, Some(_)) => aliases_btn, - _ => (msg, cancel_close), + _ => (msg, cancel), }, - _ => (msg, cancel_close), + _ => (msg, cancel), }; let button = button.map(|b| { Container::new(b)