ui: add history events to design-system
This commit is contained in:
parent
196b8cc3e9
commit
e7e8028d8a
2
gui/Cargo.lock
generated
2
gui/Cargo.lock
generated
@ -1887,6 +1887,8 @@ dependencies = [
|
|||||||
name = "liana_ui"
|
name = "liana_ui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bitcoin",
|
||||||
|
"chrono",
|
||||||
"iced",
|
"iced",
|
||||||
"iced_lazy",
|
"iced_lazy",
|
||||||
"iced_native",
|
"iced_native",
|
||||||
|
|||||||
@ -2,17 +2,14 @@ use iced::{Alignment, Length};
|
|||||||
|
|
||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
color,
|
color,
|
||||||
component::{badge, separation, text::*},
|
component::{amount::*, badge, separation, text::*},
|
||||||
icon, theme,
|
icon, theme,
|
||||||
util::Collection,
|
util::Collection,
|
||||||
widget::*,
|
widget::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{
|
app::{cache::Cache, view::message::Message},
|
||||||
cache::Cache,
|
|
||||||
view::{message::Message, util::*},
|
|
||||||
},
|
|
||||||
daemon::model::{remaining_sequence, Coin},
|
daemon::model::{remaining_sequence, Coin},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -5,16 +5,13 @@ use iced::{alignment, Alignment, Length};
|
|||||||
use liana::miniscript::bitcoin;
|
use liana::miniscript::bitcoin;
|
||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
color,
|
color,
|
||||||
component::{badge, text::*},
|
component::{amount::*, badge, text::*},
|
||||||
icon, theme,
|
icon, theme,
|
||||||
util::Collection,
|
util::Collection,
|
||||||
widget::*,
|
widget::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{app::view::message::Message, daemon::model::HistoryTransaction};
|
||||||
app::view::{message::Message, util::*},
|
|
||||||
daemon::model::HistoryTransaction,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const HISTORY_EVENT_PAGE_SIZE: u64 = 20;
|
pub const HISTORY_EVENT_PAGE_SIZE: u64 = 20;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
mod message;
|
mod message;
|
||||||
mod util;
|
|
||||||
mod warning;
|
mod warning;
|
||||||
|
|
||||||
pub mod coins;
|
pub mod coins;
|
||||||
|
|||||||
@ -2,14 +2,14 @@ use iced::{widget::Space, Alignment, Length};
|
|||||||
|
|
||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
color,
|
color,
|
||||||
component::{badge, button, card, form, text::*},
|
component::{amount::*, badge, button, card, form, text::*},
|
||||||
icon, theme,
|
icon, theme,
|
||||||
util::Collection,
|
util::Collection,
|
||||||
widget::*,
|
widget::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{error::Error, menu::Menu, view::util::*},
|
app::{error::Error, menu::Menu},
|
||||||
daemon::model::{SpendStatus, SpendTx},
|
daemon::model::{SpendStatus, SpendTx},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -11,15 +11,12 @@ use liana::miniscript::bitcoin::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
component::{button, form, text::*},
|
component::{amount::*, button, form, text::*},
|
||||||
icon, theme,
|
icon, theme,
|
||||||
widget::*,
|
widget::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::app::view::{
|
use crate::app::view::message::{CreateSpendMessage, Message};
|
||||||
message::{CreateSpendMessage, Message},
|
|
||||||
util::amount,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn recovery<'a>(
|
pub fn recovery<'a>(
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use liana::{
|
|||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
color,
|
color,
|
||||||
component::{
|
component::{
|
||||||
|
amount::*,
|
||||||
badge, button, card,
|
badge, button, card,
|
||||||
collapse::Collapse,
|
collapse::Collapse,
|
||||||
form, hw, separation,
|
form, hw, separation,
|
||||||
@ -29,7 +30,7 @@ use liana_ui::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::{
|
app::{
|
||||||
error::Error,
|
error::Error,
|
||||||
view::{hw::hw_list_view, message::*, util::*, warning::warn},
|
view::{hw::hw_list_view, message::*, warning::warn},
|
||||||
},
|
},
|
||||||
daemon::model::{Coin, SpendStatus, SpendTx},
|
daemon::model::{Coin, SpendStatus, SpendTx},
|
||||||
hw::HardwareWallet,
|
hw::HardwareWallet,
|
||||||
|
|||||||
@ -5,6 +5,7 @@ use liana::miniscript::bitcoin::Amount;
|
|||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
color,
|
color,
|
||||||
component::{
|
component::{
|
||||||
|
amount::*,
|
||||||
badge, button, form,
|
badge, button, form,
|
||||||
text::{text, Text},
|
text::{text, Text},
|
||||||
},
|
},
|
||||||
@ -17,7 +18,7 @@ use crate::{
|
|||||||
app::{
|
app::{
|
||||||
cache::Cache,
|
cache::Cache,
|
||||||
error::Error,
|
error::Error,
|
||||||
view::{message::*, modal, util::amount},
|
view::{message::*, modal},
|
||||||
},
|
},
|
||||||
daemon::model::{remaining_sequence, Coin},
|
daemon::model::{remaining_sequence, Coin},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,17 +3,14 @@ use chrono::NaiveDateTime;
|
|||||||
use iced::{alignment, Alignment, Length};
|
use iced::{alignment, Alignment, Length};
|
||||||
|
|
||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
component::{badge, card, text::*},
|
component::{amount::*, badge, card, text::*},
|
||||||
icon, theme,
|
icon, theme,
|
||||||
util::Collection,
|
util::Collection,
|
||||||
widget::*,
|
widget::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::{
|
app::{cache::Cache, view::message::Message},
|
||||||
cache::Cache,
|
|
||||||
view::{message::Message, util::*},
|
|
||||||
},
|
|
||||||
daemon::model::HistoryTransaction,
|
daemon::model::HistoryTransaction,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -180,4 +180,8 @@ impl HistoryTransaction {
|
|||||||
pub fn is_external(&self) -> bool {
|
pub fn is_external(&self) -> bool {
|
||||||
self.coins.is_empty()
|
self.coins.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_self_send(&self) -> bool {
|
||||||
|
!self.coins.is_empty() && self.outgoing_amount == Amount::from_sat(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,3 +9,5 @@ edition = "2021"
|
|||||||
iced = { version = "0.7", features = ["svg", "image"] }
|
iced = { version = "0.7", features = ["svg", "image"] }
|
||||||
iced_native = "0.8"
|
iced_native = "0.8"
|
||||||
iced_lazy = { version = "0.4"}
|
iced_lazy = { version = "0.4"}
|
||||||
|
bitcoin = "0.29"
|
||||||
|
chrono = "0.4"
|
||||||
|
|||||||
@ -9,6 +9,7 @@ edition = "2021"
|
|||||||
iced = "0.7"
|
iced = "0.7"
|
||||||
iced_native = "0.8"
|
iced_native = "0.8"
|
||||||
web-sys = "0.3.61"
|
web-sys = "0.3.61"
|
||||||
|
chrono = "0.4"
|
||||||
liana_ui = { path = "../.." }
|
liana_ui = { path = "../.." }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|||||||
@ -45,6 +45,7 @@ impl Application for DesignSystem {
|
|||||||
Box::new(section::Typography {}),
|
Box::new(section::Typography {}),
|
||||||
Box::new(section::Buttons {}),
|
Box::new(section::Buttons {}),
|
||||||
Box::new(section::HardwareWallets {}),
|
Box::new(section::HardwareWallets {}),
|
||||||
|
Box::new(section::Events {}),
|
||||||
],
|
],
|
||||||
current: 0,
|
current: 0,
|
||||||
};
|
};
|
||||||
@ -123,12 +124,14 @@ impl Application for DesignSystem {
|
|||||||
.height(Length::Fill);
|
.height(Length::Fill);
|
||||||
|
|
||||||
container(row![
|
container(row![
|
||||||
sidebar.width(Length::Units(200)),
|
sidebar.width(Length::FillPortion(2)),
|
||||||
Space::with_width(Length::Units(150)),
|
Space::with_width(Length::FillPortion(1)),
|
||||||
scrollable(column![
|
container(scrollable(column![
|
||||||
Space::with_height(Length::Units(150)),
|
Space::with_height(Length::Units(150)),
|
||||||
container(self.sections[self.current].view()).width(Length::Fill)
|
container(self.sections[self.current].view()).width(Length::Fill)
|
||||||
]),
|
]))
|
||||||
|
.width(Length::FillPortion(8)),
|
||||||
|
Space::with_width(Length::FillPortion(1)),
|
||||||
])
|
])
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use iced::{
|
|||||||
};
|
};
|
||||||
use liana_ui::{
|
use liana_ui::{
|
||||||
color,
|
color,
|
||||||
component::{hw, separation, text::*},
|
component::{amount::Amount, event, hw, separation, text::*},
|
||||||
theme,
|
theme,
|
||||||
widget::Element,
|
widget::Element,
|
||||||
};
|
};
|
||||||
@ -253,3 +253,33 @@ impl Section for HardwareWallets {
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Events {}
|
||||||
|
|
||||||
|
impl Section for Events {
|
||||||
|
fn title(&self) -> &'static str {
|
||||||
|
"Events "
|
||||||
|
}
|
||||||
|
fn view(&self) -> Element<Message> {
|
||||||
|
column![
|
||||||
|
h1(self.title()),
|
||||||
|
column![
|
||||||
|
event::unconfirmed_outgoing_event(&Amount::from_sat(32934234), Message::Ignore),
|
||||||
|
event::confirmed_outgoing_event(
|
||||||
|
chrono::NaiveDate::from_ymd_opt(2023, 04, 19).unwrap(),
|
||||||
|
&Amount::from_sat(32934234),
|
||||||
|
Message::Ignore
|
||||||
|
),
|
||||||
|
event::unconfirmed_incoming_event(&Amount::from_sat(32934234), Message::Ignore),
|
||||||
|
event::confirmed_incoming_event(
|
||||||
|
chrono::NaiveDate::from_ymd_opt(2023, 04, 19).unwrap(),
|
||||||
|
&Amount::from_sat(32934234),
|
||||||
|
Message::Ignore
|
||||||
|
)
|
||||||
|
]
|
||||||
|
.spacing(20)
|
||||||
|
]
|
||||||
|
.spacing(100)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
use liana::miniscript::bitcoin::Amount;
|
pub use bitcoin::Amount;
|
||||||
|
|
||||||
use liana_ui::{color, component::text::*, util::Collection, widget::*};
|
use crate::{color, component::text::*, util::Collection, widget::*};
|
||||||
|
|
||||||
pub fn amount<'a, T: 'a>(a: &Amount) -> impl Into<Element<'a, T>> {
|
pub fn amount<'a, T: 'a>(a: &Amount) -> Row<'a, T> {
|
||||||
amount_with_size(a, P1_SIZE)
|
amount_with_size(a, P1_SIZE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn amount_with_size<'a, T: 'a>(a: &Amount, size: u16) -> impl Into<Element<'a, T>> {
|
pub fn amount_with_size<'a, T: 'a>(a: &Amount, size: u16) -> Row<'a, T> {
|
||||||
let spacing = if size > P1_SIZE { 10 } else { 5 };
|
let spacing = if size > P1_SIZE { 10 } else { 5 };
|
||||||
let sats = format!("{:.8}", a.to_btc());
|
let sats = format!("{:.8}", a.to_btc());
|
||||||
assert!(sats.len() >= 9);
|
assert!(sats.len() >= 9);
|
||||||
106
gui/ui/src/component/event.rs
Normal file
106
gui/ui/src/component/event.rs
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
use crate::{
|
||||||
|
component::{amount, badge, text},
|
||||||
|
theme,
|
||||||
|
widget::*,
|
||||||
|
};
|
||||||
|
use bitcoin::Amount;
|
||||||
|
use iced::{
|
||||||
|
widget::{button, row},
|
||||||
|
Alignment, Length,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn unconfirmed_outgoing_event<'a, T: Clone + 'a>(amount: &Amount, msg: T) -> Container<'a, T> {
|
||||||
|
Container::new(
|
||||||
|
button(
|
||||||
|
row!(
|
||||||
|
row!(badge::spend(), badge::unconfirmed())
|
||||||
|
.spacing(10)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.width(Length::Fill),
|
||||||
|
row!(text::p1_regular("-"), amount::amount(amount))
|
||||||
|
.spacing(5)
|
||||||
|
.align_items(Alignment::Center),
|
||||||
|
)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.padding(10)
|
||||||
|
.spacing(20),
|
||||||
|
)
|
||||||
|
.on_press(msg)
|
||||||
|
.style(theme::Button::TransparentBorder),
|
||||||
|
)
|
||||||
|
.style(theme::Container::Card(theme::Card::Simple))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn confirmed_outgoing_event<'a, T: Clone + 'a>(
|
||||||
|
date: chrono::NaiveDate,
|
||||||
|
amount: &Amount,
|
||||||
|
msg: T,
|
||||||
|
) -> Container<'a, T> {
|
||||||
|
Container::new(
|
||||||
|
button(
|
||||||
|
row!(
|
||||||
|
row!(badge::spend(), text::p2_regular(date.to_string()))
|
||||||
|
.spacing(10)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.width(Length::Fill),
|
||||||
|
row!(text::p1_regular("-"), amount::amount(amount))
|
||||||
|
.spacing(5)
|
||||||
|
.align_items(Alignment::Center),
|
||||||
|
)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.padding(10)
|
||||||
|
.spacing(20),
|
||||||
|
)
|
||||||
|
.on_press(msg)
|
||||||
|
.style(theme::Button::TransparentBorder),
|
||||||
|
)
|
||||||
|
.style(theme::Container::Card(theme::Card::Simple))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unconfirmed_incoming_event<'a, T: Clone + 'a>(amount: &Amount, msg: T) -> Container<'a, T> {
|
||||||
|
Container::new(
|
||||||
|
button(
|
||||||
|
row!(
|
||||||
|
row!(badge::receive(), badge::unconfirmed())
|
||||||
|
.spacing(10)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.width(Length::Fill),
|
||||||
|
row!(text::p1_regular("+"), amount::amount(amount))
|
||||||
|
.spacing(5)
|
||||||
|
.align_items(Alignment::Center),
|
||||||
|
)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.padding(10)
|
||||||
|
.spacing(20),
|
||||||
|
)
|
||||||
|
.on_press(msg)
|
||||||
|
.style(theme::Button::TransparentBorder),
|
||||||
|
)
|
||||||
|
.style(theme::Container::Card(theme::Card::Simple))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn confirmed_incoming_event<'a, T: Clone + 'a>(
|
||||||
|
date: chrono::NaiveDate,
|
||||||
|
amount: &Amount,
|
||||||
|
msg: T,
|
||||||
|
) -> Container<'a, T> {
|
||||||
|
Container::new(
|
||||||
|
button(
|
||||||
|
row!(
|
||||||
|
row!(badge::receive(), text::p2_regular(date.to_string()))
|
||||||
|
.spacing(10)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.width(Length::Fill),
|
||||||
|
row!(text::p1_regular("+"), amount::amount(amount))
|
||||||
|
.spacing(5)
|
||||||
|
.align_items(Alignment::Center),
|
||||||
|
)
|
||||||
|
.align_items(Alignment::Center)
|
||||||
|
.padding(10)
|
||||||
|
.spacing(20),
|
||||||
|
)
|
||||||
|
.on_press(msg)
|
||||||
|
.style(theme::Button::TransparentBorder),
|
||||||
|
)
|
||||||
|
.style(theme::Container::Card(theme::Card::Simple))
|
||||||
|
}
|
||||||
@ -1,7 +1,9 @@
|
|||||||
|
pub mod amount;
|
||||||
pub mod badge;
|
pub mod badge;
|
||||||
pub mod button;
|
pub mod button;
|
||||||
pub mod card;
|
pub mod card;
|
||||||
pub mod collapse;
|
pub mod collapse;
|
||||||
|
pub mod event;
|
||||||
pub mod form;
|
pub mod form;
|
||||||
pub mod hw;
|
pub mod hw;
|
||||||
pub mod modal;
|
pub mod modal;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user