export: add a cross button to the modal

This commit is contained in:
pythcoiner 2025-04-16 19:43:54 +02:00
parent 733c3a6071
commit 968c36fcf6
No known key found for this signature in database
GPG Key ID: C1048AEEDF303B88
2 changed files with 23 additions and 5 deletions

View File

@ -232,7 +232,7 @@ impl ExportModal {
pub fn view<'a, M>(&'a self, content: Element<'a, M>) -> Element<M>
where
M: 'a + Close + Clone + From<export::ImportExportMessage>,
M: 'a + Close + Clone + From<export::ImportExportMessage> + 'static,
{
let modal = Modal::new(
content,

View File

@ -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<ImportExportMessage> + Clone + 'a>(
pub fn export_modal<'a, Message: From<ImportExportMessage> + Clone + 'static>(
state: &ImportExportState,
error: Option<&'a Error>,
title: &str,
@ -32,6 +33,16 @@ pub fn export_modal<'a, Message: From<ImportExportMessage> + 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<ImportExportMessage> + 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<ImportExportMessage> + Clone + 'a>(
.push(Space::with_height(5)),
)
.width(Length::Fixed(500.0))
.height(Length::Fixed(250.0))
.height(Length::Fixed(300.0))
.into()
}