From 5529a8cd57e8a46327e018d94f903ee8008b6a70 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 3 Jan 2025 09:47:02 +0000 Subject: [PATCH 1/5] change transactions export default file name --- liana-gui/src/export.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/liana-gui/src/export.rs b/liana-gui/src/export.rs index 842d107d..9fa2a6d5 100644 --- a/liana-gui/src/export.rs +++ b/liana-gui/src/export.rs @@ -382,9 +382,11 @@ pub async fn export_subscription(mut state: State) -> (ExportProgress, State) { } pub async fn get_path() -> Option { + let date = chrono::Local::now().format("%Y-%m-%dT%H-%M-%S"); + let file_name = format!("liana-txs-{date}.csv"); rfd::AsyncFileDialog::new() .set_title("Choose a location to export...") - .set_file_name("liana.csv") + .set_file_name(file_name) .save_file() .await .map(|fh| fh.path().to_path_buf()) From e5208bb7077ed05ebcc29ddec6d426d0efe6e247 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 3 Jan 2025 10:20:23 +0000 Subject: [PATCH 2/5] use button helper for exporting transactions --- liana-gui/src/app/view/export.rs | 12 +++++------- liana-gui/src/app/view/transactions.rs | 6 +----- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/liana-gui/src/app/view/export.rs b/liana-gui/src/app/view/export.rs index beb6bc0a..ffc60dc4 100644 --- a/liana-gui/src/app/view/export.rs +++ b/liana-gui/src/app/view/export.rs @@ -1,13 +1,12 @@ use iced::{ - widget::{progress_bar, Button, Column, Container, Row, Space}, + widget::{progress_bar, Column, Container, Row, Space}, Length, }; use liana_ui::{ component::{ - card, + button, card, text::{h4_bold, text}, }, - theme, widget::Element, }; @@ -22,14 +21,13 @@ pub fn export_modal<'a>( ) -> Element<'a, Message> { let button = match state { ExportState::Started | ExportState::Progress(_) => { - Some(Button::new("Cancel").on_press(ExportMessage::UserStop.into())) + Some(button::secondary(None, "Cancel").on_press(ExportMessage::UserStop.into())) } ExportState::Ended | ExportState::TimedOut | ExportState::Aborted => { - Some(Button::new("Close").on_press(ExportMessage::Close.into())) + Some(button::secondary(None, "Close").on_press(ExportMessage::Close.into())) } _ => None, - } - .map(|b| b.height(32).style(theme::Button::Primary)); + }; let msg = if let Some(error) = error { format!("{:?}", error) } else { diff --git a/liana-gui/src/app/view/transactions.rs b/liana-gui/src/app/view/transactions.rs index 0fa57f3a..071753b5 100644 --- a/liana-gui/src/app/view/transactions.rs +++ b/liana-gui/src/app/view/transactions.rs @@ -45,11 +45,7 @@ pub fn transactions_view<'a>( Row::new() .push(Container::new(h3("Transactions"))) .push(Space::with_width(Length::Fill)) - .push( - Button::new("Export") - .on_press(ExportMessage::Open.into()) - .style(theme::Button::Secondary), - ), + .push(button::secondary(None, "Export").on_press(ExportMessage::Open.into())), ) .push( Column::new() From 98195e03b6878cd31e1d34ba246700b6ae95ceb1 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 3 Jan 2025 11:09:52 +0000 Subject: [PATCH 3/5] hide progress bar once export completed --- liana-gui/src/app/view/export.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/liana-gui/src/app/view/export.rs b/liana-gui/src/app/view/export.rs index ffc60dc4..f604ef49 100644 --- a/liana-gui/src/app/view/export.rs +++ b/liana-gui/src/app/view/export.rs @@ -53,10 +53,12 @@ pub fn export_modal<'a>( 100.0 } }; - let progress_bar_row = Row::new() - .push(Space::with_width(30)) - .push(progress_bar(0.0..=100.0, p)) - .push(Space::with_width(30)); + let progress_bar_row = (*state != ExportState::Ended).then_some( + Row::new() + .push(Space::with_width(30)) + .push(progress_bar(0.0..=100.0, p)) + .push(Space::with_width(30)), + ); let button_row = button.map(|b| { Row::new() .push(Space::with_width(Length::Fill)) @@ -68,7 +70,7 @@ pub fn export_modal<'a>( .spacing(10) .push(Container::new(h4_bold(format!("Export {export_type}"))).width(Length::Fill)) .push(Space::with_height(Length::Fill)) - .push(progress_bar_row) + .push_maybe(progress_bar_row) .push(Space::with_height(Length::Fill)) .push( Row::new() From f92177c04ace796e7eef5bb7ee5cf5b2a6e563ec Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 3 Jan 2025 12:10:47 +0000 Subject: [PATCH 4/5] align export modal buttons to the right --- liana-gui/src/app/view/export.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/liana-gui/src/app/view/export.rs b/liana-gui/src/app/view/export.rs index f604ef49..587190d2 100644 --- a/liana-gui/src/app/view/export.rs +++ b/liana-gui/src/app/view/export.rs @@ -1,4 +1,5 @@ use iced::{ + alignment::Horizontal, widget::{progress_bar, Column, Container, Row, Space}, Length, }; @@ -59,12 +60,6 @@ pub fn export_modal<'a>( .push(progress_bar(0.0..=100.0, p)) .push(Space::with_width(30)), ); - let button_row = button.map(|b| { - Row::new() - .push(Space::with_width(Length::Fill)) - .push(b) - .push(Space::with_width(Length::Fill)) - }); card::simple( Column::new() .spacing(10) @@ -79,7 +74,11 @@ pub fn export_modal<'a>( .push(Space::with_width(Length::Fill)), ) .push(Space::with_height(Length::Fill)) - .push_maybe(button_row) + .push_maybe(button.map(|b| { + Container::new(b) + .align_x(Horizontal::Right) + .width(Length::Fill) + })) .push(Space::with_height(5)), ) .width(Length::Fixed(500.0)) From 6c1d0518eb7748fe801c7fb141fbc7205eed27ec Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Fri, 3 Jan 2025 12:13:42 +0000 Subject: [PATCH 5/5] use left alignment for export modal text --- liana-gui/src/app/view/export.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/liana-gui/src/app/view/export.rs b/liana-gui/src/app/view/export.rs index 587190d2..e47e87af 100644 --- a/liana-gui/src/app/view/export.rs +++ b/liana-gui/src/app/view/export.rs @@ -67,12 +67,7 @@ pub fn export_modal<'a>( .push(Space::with_height(Length::Fill)) .push_maybe(progress_bar_row) .push(Space::with_height(Length::Fill)) - .push( - Row::new() - .push(Space::with_width(Length::Fill)) - .push(text(msg)) - .push(Space::with_width(Length::Fill)), - ) + .push(Row::new().push(text(msg))) .push(Space::with_height(Length::Fill)) .push_maybe(button.map(|b| { Container::new(b)