From 968c36fcf6ec4cbad4fa13e9b05c759c1be05752 Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Wed, 16 Apr 2025 19:43:54 +0200 Subject: [PATCH] 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() }