-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui: add a modal for export tasks in transactions panels
- Loading branch information
1 parent
4aa210b
commit d1e970a
Showing
9 changed files
with
176 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod coins; | ||
pub mod export; | ||
mod label; | ||
mod psbt; | ||
mod psbts; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
use iced::{ | ||
widget::{progress_bar, Button, Column, Container, Row, Space}, | ||
Length, | ||
}; | ||
use liana_ui::{ | ||
component::{ | ||
card, | ||
text::{h4_bold, text}, | ||
}, | ||
theme, | ||
widget::Element, | ||
}; | ||
|
||
use crate::app::{export::Error, state::export::ExportState}; | ||
use crate::app::{state::export::ExportMessage, view::message::Message}; | ||
|
||
/// Return the modal view for an export task | ||
pub fn export_modal<'a>( | ||
state: &ExportState, | ||
error: Option<&'a Error>, | ||
export_type: &str, | ||
) -> Element<'a, Message> { | ||
let button = match state { | ||
ExportState::Started | ExportState::Progress(_) => { | ||
Some(Button::new("Cancel").on_press(ExportMessage::UserStop.into())) | ||
} | ||
ExportState::Ended | ExportState::TimedOut | ExportState::Aborted => { | ||
Some(Button::new("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 { | ||
match state { | ||
ExportState::Init => "".to_string(), | ||
ExportState::ChoosePath => { | ||
"Select the path you want to export in the popup window...".into() | ||
} | ||
ExportState::Path(_) => "".into(), | ||
ExportState::Started => "Starting export...".into(), | ||
ExportState::Progress(p) => format!("Progress: {}%", p.round()), | ||
ExportState::TimedOut => "Export failed: timeout".into(), | ||
ExportState::Aborted => "Export canceled".into(), | ||
ExportState::Ended => "Export successfull!".into(), | ||
ExportState::Closed => "".into(), | ||
} | ||
}; | ||
let p = match state { | ||
ExportState::Init => 0.0, | ||
ExportState::ChoosePath | ExportState::Path(_) | ExportState::Started => 5.0, | ||
ExportState::Progress(p) => *p, | ||
ExportState::TimedOut | ExportState::Aborted | ExportState::Ended | ExportState::Closed => { | ||
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 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) | ||
.push(Container::new(h4_bold(format!("Export {export_type}"))).width(Length::Fill)) | ||
.push(Space::with_height(Length::Fill)) | ||
.push(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(Space::with_height(Length::Fill)) | ||
.push_maybe(button_row) | ||
.push(Space::with_height(5)), | ||
) | ||
.width(Length::Fixed(500.0)) | ||
.height(Length::Fixed(220.0)) | ||
.into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ mod message; | |
mod warning; | ||
|
||
pub mod coins; | ||
pub mod export; | ||
pub mod home; | ||
pub mod hw; | ||
pub mod psbt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters