From 120f87462f0402c8a056c4af2c318601174bdfb6 Mon Sep 17 00:00:00 2001 From: edouard Date: Thu, 16 Feb 2023 10:41:29 +0100 Subject: [PATCH] Change pending label for unconfirmed close #230 close #231 --- gui/src/app/view/coins.rs | 12 ++------ gui/src/app/view/home.rs | 4 +-- gui/src/app/view/spend/detail.rs | 12 ++------ gui/src/app/view/spend/mod.rs | 12 ++------ gui/src/app/view/spend/step.rs | 12 ++------ gui/src/ui/component/badge.rs | 47 ++++++++++++++++++++++++++++++-- 6 files changed, 54 insertions(+), 45 deletions(-) diff --git a/gui/src/app/view/coins.rs b/gui/src/app/view/coins.rs index a0031298..fb1ede02 100644 --- a/gui/src/app/view/coins.rs +++ b/gui/src/app/view/coins.rs @@ -70,11 +70,7 @@ fn coin_list_view( Row::new() .push(badge::coin()) .push_maybe(if coin.spend_info.is_some() { - Some( - Container::new(text(" Spent ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ) + Some(badge::spent()) } else { let seq = remaining_sequence(coin, blockheight, timelock); if seq == 0 { @@ -116,11 +112,7 @@ fn coin_list_view( } }) .push_maybe(if coin.block_height.is_none() { - Some( - Container::new(text(" Unconfirmed ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ) + Some(badge::unconfirmed()) } else { None }) diff --git a/gui/src/app/view/home.rs b/gui/src/app/view/home.rs index 855ac40c..e55b1ddd 100644 --- a/gui/src/app/view/home.rs +++ b/gui/src/app/view/home.rs @@ -130,9 +130,7 @@ fn event_list_view<'a>(i: usize, event: &HistoryTransaction) -> Element<'a, Mess .small(), ) } else { - Container::new(text(" Pending ").small()) - .padding(3) - .style(badge::PillStyle::Success) + badge::unconfirmed() }) .spacing(10) .align_items(Alignment::Center) diff --git a/gui/src/app/view/spend/detail.rs b/gui/src/app/view/spend/detail.rs index e28316ee..abb339c5 100644 --- a/gui/src/app/view/spend/detail.rs +++ b/gui/src/app/view/spend/detail.rs @@ -210,16 +210,8 @@ fn spend_header<'a>(tx: &SpendTx) -> Element<'a, Message> { .align_items(Alignment::Center), ) .push_maybe(match tx.status { - SpendStatus::Deprecated => Some( - Container::new(text(" Deprecated ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ), - SpendStatus::Broadcast => Some( - Container::new(text(" Broadcast ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ), + SpendStatus::Deprecated => Some(badge::deprecated()), + SpendStatus::Broadcast => Some(badge::unconfirmed()), _ => None, }) .push( diff --git a/gui/src/app/view/spend/mod.rs b/gui/src/app/view/spend/mod.rs index 6fd58bd2..ac2e59b3 100644 --- a/gui/src/app/view/spend/mod.rs +++ b/gui/src/app/view/spend/mod.rs @@ -156,16 +156,8 @@ fn spend_tx_list_view<'a>(i: usize, tx: &SpendTx) -> Element<'a, Message> { .width(Length::Fill), ) .push_maybe(match tx.status { - SpendStatus::Deprecated => Some( - Container::new(text(" Deprecated ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ), - SpendStatus::Broadcast => Some( - Container::new(text(" Broadcast ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ), + SpendStatus::Deprecated => Some(badge::deprecated()), + SpendStatus::Broadcast => Some(badge::unconfirmed()), _ => None, }) .push( diff --git a/gui/src/app/view/spend/step.rs b/gui/src/app/view/spend/step.rs index 2e478d7f..5f69ad97 100644 --- a/gui/src/app/view/spend/step.rs +++ b/gui/src/app/view/spend/step.rs @@ -206,11 +206,7 @@ fn coin_list_view<'a>( }) .push(badge::coin()) .push_maybe(if coin.spend_info.is_some() { - Some( - Container::new(text(" Spent ").small()) - .padding(3) - .style(badge::PillStyle::Success), - ) + Some(badge::spent()) } else { let seq = remaining_sequence(coin, blockheight, timelock); if seq == 0 { @@ -244,11 +240,7 @@ fn coin_list_view<'a>( } }) .push_maybe(if coin.block_height.is_none() { - Some( - Container::new(text(" Unconfirmed ").small()) - .padding(3) - .style(badge::PillStyle::Simple), - ) + Some(badge::unconfirmed()) } else { None }) diff --git a/gui/src/ui/component/badge.rs b/gui/src/ui/component/badge.rs index 3bba0afd..26ef715b 100644 --- a/gui/src/ui/component/badge.rs +++ b/gui/src/ui/component/badge.rs @@ -1,9 +1,13 @@ use iced::{ - widget::{self, Container}, + widget::{self, tooltip, Container}, Element, Length, }; -use crate::ui::{color, icon}; +use crate::ui::{ + color, + component::{card, text::*}, + icon, +}; pub enum Style { Standard, @@ -164,3 +168,42 @@ impl From for iced::theme::Container { iced::theme::Container::Custom(i.into()) } } + +pub fn unconfirmed<'a, T: 'a>() -> widget::container::Container<'a, T> { + Container::new( + tooltip::Tooltip::new( + Container::new(text(" Unconfirmed ").small()) + .padding(3) + .style(PillStyle::Simple), + "Do not treat this as a payment until it is confirmed", + tooltip::Position::Top, + ) + .style(card::SimpleCardStyle), + ) +} + +pub fn deprecated<'a, T: 'a>() -> widget::container::Container<'a, T> { + Container::new( + tooltip::Tooltip::new( + Container::new(text(" Deprecated ").small()) + .padding(3) + .style(PillStyle::Simple), + "This spend cannot be included anymore in the blockchain", + tooltip::Position::Top, + ) + .style(card::SimpleCardStyle), + ) +} + +pub fn spent<'a, T: 'a>() -> widget::container::Container<'a, T> { + Container::new( + tooltip::Tooltip::new( + Container::new(text(" Spent ").small()) + .padding(3) + .style(PillStyle::Simple), + "The spend transaction was included in the blockchain", + tooltip::Position::Top, + ) + .style(card::SimpleCardStyle), + ) +}