refac ui: expose badge_pill width
This commit is contained in:
parent
66f392c754
commit
e05e421368
@ -139,9 +139,9 @@ fn spend_tx_list_view(i: usize, tx: &SpendTx) -> Element<'_, Message> {
|
||||
None
|
||||
})
|
||||
.push_maybe(match tx.status {
|
||||
SpendStatus::Deprecated => Some(badge::deprecated_sized(120.0)),
|
||||
SpendStatus::Broadcast => Some(badge::unconfirmed_sized(120.0)),
|
||||
SpendStatus::Spent => Some(badge::spent_sized(120.0)),
|
||||
SpendStatus::Deprecated => Some(badge::deprecated().width(120.0)),
|
||||
SpendStatus::Broadcast => Some(badge::unconfirmed().width(120.0)),
|
||||
SpendStatus::Spent => Some(badge::spent().width(120.0)),
|
||||
_ => None,
|
||||
})
|
||||
.push(
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
use iced::{widget::tooltip, Length};
|
||||
|
||||
use crate::util::Collection;
|
||||
use crate::{component::text, icon, image, theme, widget::*};
|
||||
|
||||
pub struct Badge {
|
||||
@ -76,50 +75,24 @@ pub fn coin<T>() -> Container<'static, T> {
|
||||
}
|
||||
|
||||
pub fn recovery<'a, T: 'a>() -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Recovery ",
|
||||
"This transaction is using a recovery path",
|
||||
None,
|
||||
)
|
||||
badge_pill(" Recovery ", "This transaction is using a recovery path")
|
||||
}
|
||||
|
||||
pub fn unconfirmed<'a, T: 'a>() -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Unconfirmed ",
|
||||
"Do not treat this as a payment until it is confirmed",
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn unconfirmed_sized<'a, T: 'a>(width: f32) -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Unconfirmed ",
|
||||
"Do not treat this as a payment until it is confirmed",
|
||||
Some(width),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn batch<'a, T: 'a>() -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Batch ",
|
||||
"This transaction contains multiple payments",
|
||||
None,
|
||||
)
|
||||
badge_pill(" Batch ", "This transaction contains multiple payments")
|
||||
}
|
||||
|
||||
pub fn deprecated<'a, T: 'a>() -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Deprecated ",
|
||||
"This transaction cannot be included in the blockchain anymore.",
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn deprecated_sized<'a, T: 'a>(width: f32) -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Deprecated ",
|
||||
"This transaction cannot be included in the blockchain anymore.",
|
||||
Some(width),
|
||||
)
|
||||
}
|
||||
|
||||
@ -127,37 +100,20 @@ pub fn spent<'a, T: 'a>() -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Spent ",
|
||||
"The transaction was included in the blockchain.",
|
||||
None,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn spent_sized<'a, T: 'a>(width: f32) -> Container<'a, T> {
|
||||
badge_pill(
|
||||
" Spent ",
|
||||
"The transaction was included in the blockchain.",
|
||||
Some(width),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn badge_pill<'a, T: 'a>(
|
||||
label: &'a str,
|
||||
tooltip: &'a str,
|
||||
width: Option<f32>,
|
||||
) -> Container<'a, T> {
|
||||
pub fn badge_pill<'a, T: 'a>(label: &'a str, tooltip: &'a str) -> Container<'a, T> {
|
||||
Container::new({
|
||||
let mut pill: Container<'a, T> = Container::new(
|
||||
Row::new()
|
||||
.push_maybe(width.map(|_| iced::widget::Space::with_width(Length::Fill)))
|
||||
.push(text::p2_regular(label))
|
||||
.push_maybe(width.map(|_| iced::widget::Space::with_width(Length::Fill))),
|
||||
tooltip::Tooltip::new(
|
||||
Container::new(text::p2_regular(label))
|
||||
.padding(10)
|
||||
.width(Length::Fill)
|
||||
.center_x()
|
||||
.style(theme::Container::Pill(theme::Pill::Simple)),
|
||||
tooltip,
|
||||
tooltip::Position::Top,
|
||||
)
|
||||
.padding(10)
|
||||
.style(theme::Container::Pill(theme::Pill::Simple));
|
||||
if let Some(w) = width {
|
||||
pill = pill.width(Length::Fixed(w));
|
||||
}
|
||||
|
||||
tooltip::Tooltip::new(pill, tooltip, tooltip::Position::Top)
|
||||
.style(theme::Container::Card(theme::Card::Simple))
|
||||
.style(theme::Container::Card(theme::Card::Simple))
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user