ui: use text size helpers in components
This commit is contained in:
parent
84fb6819ef
commit
34b475a7c8
@ -3,11 +3,11 @@ use liana::miniscript::bitcoin::Amount;
|
||||
use liana_ui::{color, component::text::*, util::Collection, widget::*};
|
||||
|
||||
pub fn amount<'a, T: 'a>(a: &Amount) -> impl Into<Element<'a, T>> {
|
||||
amount_with_size(a, TEXT_REGULAR_SIZE)
|
||||
amount_with_size(a, P1_SIZE)
|
||||
}
|
||||
|
||||
pub fn amount_with_size<'a, T: 'a>(a: &Amount, size: u16) -> impl Into<Element<'a, T>> {
|
||||
let spacing = if size > TEXT_REGULAR_SIZE { 10 } else { 5 };
|
||||
let spacing = if size > P1_SIZE { 10 } else { 5 };
|
||||
let sats = format!("{:.8}", a.to_btc());
|
||||
assert!(sats.len() >= 9);
|
||||
let row = Row::new()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use iced::{widget::tooltip, Length};
|
||||
|
||||
use crate::{component::text::*, icon, theme, widget::*};
|
||||
use crate::{component::text, icon, theme, widget::*};
|
||||
|
||||
pub struct Badge {
|
||||
icon: crate::widget::Text<'static>,
|
||||
@ -64,7 +64,7 @@ pub fn coin<T>() -> Container<'static, T> {
|
||||
pub fn unconfirmed<'a, T: 'a>() -> Container<'a, T> {
|
||||
Container::new(
|
||||
tooltip::Tooltip::new(
|
||||
Container::new(text(" Unconfirmed ").small())
|
||||
Container::new(text::caption(" Unconfirmed "))
|
||||
.padding(3)
|
||||
.style(theme::Container::Pill(theme::Pill::Simple)),
|
||||
"Do not treat this as a payment until it is confirmed",
|
||||
@ -77,7 +77,7 @@ pub fn unconfirmed<'a, T: 'a>() -> Container<'a, T> {
|
||||
pub fn deprecated<'a, T: 'a>() -> Container<'a, T> {
|
||||
Container::new(
|
||||
tooltip::Tooltip::new(
|
||||
Container::new(text(" Deprecated ").small())
|
||||
Container::new(text::caption(" Deprecated "))
|
||||
.padding(3)
|
||||
.style(theme::Container::Pill(theme::Pill::Simple)),
|
||||
"This spend cannot be included anymore in the blockchain",
|
||||
@ -90,7 +90,7 @@ pub fn deprecated<'a, T: 'a>() -> Container<'a, T> {
|
||||
pub fn spent<'a, T: 'a>() -> Container<'a, T> {
|
||||
Container::new(
|
||||
tooltip::Tooltip::new(
|
||||
Container::new(text(" Spent ").small())
|
||||
Container::new(text::caption(" Spent "))
|
||||
.padding(3)
|
||||
.style(theme::Container::Pill(theme::Pill::Simple)),
|
||||
"The spend transaction was included in the blockchain",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use iced::{widget::text_input, Length};
|
||||
|
||||
use crate::{color, component::text::*, theme, util::Collection, widget::*};
|
||||
use crate::{color, component::text, theme, util::Collection, widget::*};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Value<T> {
|
||||
@ -74,7 +74,7 @@ impl<'a, Message: 'a + Clone> From<Form<'a, Message>> for Element<'a, Message> {
|
||||
})
|
||||
.push_maybe(if !form.valid {
|
||||
form.warning
|
||||
.map(|message| text(message).style(color::legacy::ALERT).small())
|
||||
.map(|message| text::caption(message).style(color::legacy::ALERT))
|
||||
} else {
|
||||
None
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use crate::{color, component::text::*, icon, theme, util::*, widget::*};
|
||||
use crate::{color, component::text, icon, theme, util::*, widget::*};
|
||||
use iced::{
|
||||
widget::{column, container, row, tooltip},
|
||||
Alignment, Length,
|
||||
@ -16,13 +16,13 @@ pub fn supported_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>(
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text(kind.to_string()).small())
|
||||
.push_maybe(version.map(|v| text(v.to_string()).small()))
|
||||
.push(text::caption(kind.to_string()))
|
||||
.push_maybe(version.map(|v| text::caption(v.to_string())))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill),
|
||||
@ -41,13 +41,13 @@ pub fn unregistered_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Displa
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text(kind.to_string()).small())
|
||||
.push_maybe(version.map(|v| text(v.to_string()).small()))
|
||||
.push(text::caption(kind.to_string()))
|
||||
.push_maybe(version.map(|v| text::caption(v.to_string())))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
@ -77,20 +77,20 @@ pub fn processing_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text(kind.to_string()).small())
|
||||
.push_maybe(version.map(|v| text(v.to_string()).small()))
|
||||
.push(text::caption(kind.to_string()))
|
||||
.push_maybe(version.map(|v| text::caption(v.to_string())))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
.into(),
|
||||
column(vec![
|
||||
text("Processing...").into(),
|
||||
text("Please check your device").small().into(),
|
||||
text::p1_regular("Processing...").into(),
|
||||
text::p1_regular("Please check your device").into(),
|
||||
])
|
||||
.into(),
|
||||
])
|
||||
@ -110,13 +110,13 @@ pub fn selected_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>(
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text(kind.to_string()).small())
|
||||
.push_maybe(version.map(|v| text(v.to_string()).small()))
|
||||
.push(text::caption(kind.to_string()))
|
||||
.push_maybe(version.map(|v| text::caption(v.to_string())))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
@ -141,13 +141,13 @@ pub fn sign_success_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Displa
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text(kind.to_string()).small())
|
||||
.push_maybe(version.map(|v| text(v.to_string()).small()))
|
||||
.push(text::caption(kind.to_string()))
|
||||
.push_maybe(version.map(|v| text::caption(v.to_string())))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
@ -156,7 +156,9 @@ pub fn sign_success_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Displa
|
||||
icon::circle_check_icon()
|
||||
.style(color::legacy::SUCCESS)
|
||||
.into(),
|
||||
text("Signed").style(color::legacy::SUCCESS).into(),
|
||||
text::p1_regular("Signed")
|
||||
.style(color::legacy::SUCCESS)
|
||||
.into(),
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(5)
|
||||
@ -178,13 +180,13 @@ pub fn registration_success_hardware_wallet<'a, T: 'a, K: Display, V: Display, F
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text(kind.to_string()).small())
|
||||
.push_maybe(version.map(|v| text(v.to_string()).small()))
|
||||
.push(text::caption(kind.to_string()))
|
||||
.push_maybe(version.map(|v| text::caption(v.to_string())))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
@ -193,7 +195,9 @@ pub fn registration_success_hardware_wallet<'a, T: 'a, K: Display, V: Display, F
|
||||
icon::circle_check_icon()
|
||||
.style(color::legacy::SUCCESS)
|
||||
.into(),
|
||||
text("Registered").style(color::legacy::SUCCESS).into(),
|
||||
text::p1_regular("Registered")
|
||||
.style(color::legacy::SUCCESS)
|
||||
.into(),
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(5)
|
||||
@ -213,12 +217,12 @@ pub fn unsupported_hardware_wallet<'a, T: 'a, K: Display, V: Display>(
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text("Connection error").bold())
|
||||
.push(text::p1_bold("Connection error"))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text(kind.to_string()).small())
|
||||
.push_maybe(version.map(|v| text(v.to_string()).small()))
|
||||
.push(text::caption(kind.to_string()))
|
||||
.push_maybe(version.map(|v| text::caption(v.to_string())))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
@ -245,12 +249,12 @@ pub fn sign_success_hot_signer<'a, T: 'a, F: Display>(
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text("This computer").small())
|
||||
.push(text::caption("This computer"))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
@ -259,7 +263,9 @@ pub fn sign_success_hot_signer<'a, T: 'a, F: Display>(
|
||||
icon::circle_check_icon()
|
||||
.style(color::legacy::SUCCESS)
|
||||
.into(),
|
||||
text("Signed").style(color::legacy::SUCCESS).into(),
|
||||
text::p1_regular("Signed")
|
||||
.style(color::legacy::SUCCESS)
|
||||
.into(),
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(5)
|
||||
@ -279,13 +285,15 @@ pub fn selected_hot_signer<'a, T: 'a, F: Display>(
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text("This computer").small())
|
||||
.push(text("(A derived key from a mnemonic stored locally)").small())
|
||||
.push(text::caption("This computer"))
|
||||
.push(text::caption(
|
||||
"(A derived key from a mnemonic stored locally)",
|
||||
))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill)
|
||||
@ -307,13 +315,15 @@ pub fn unselected_hot_signer<'a, T: 'a, F: Display>(
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text("This computer").small())
|
||||
.push(text("(A derived key from a mnemonic stored locally)").small())
|
||||
.push(text::caption("This computer"))
|
||||
.push(text::caption(
|
||||
"(A derived key from a mnemonic stored locally)",
|
||||
))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill),
|
||||
@ -329,12 +339,12 @@ pub fn hot_signer<'a, T: 'a, F: Display>(
|
||||
column(vec![
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push_maybe(alias.map(|a| text(a).bold()))
|
||||
.push(text(format!("#{}", fingerprint)))
|
||||
.push_maybe(alias.map(|a| text::p1_bold(a)))
|
||||
.push(text::p1_regular(format!("#{}", fingerprint)))
|
||||
.into(),
|
||||
Row::new()
|
||||
.spacing(5)
|
||||
.push(text("This computer").small())
|
||||
.push(text::caption("This computer"))
|
||||
.into(),
|
||||
])
|
||||
.width(Length::Fill),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
component::{collapse, text::*},
|
||||
component::{collapse, text},
|
||||
icon, theme,
|
||||
widget::*,
|
||||
};
|
||||
@ -12,14 +12,14 @@ pub fn warning<'a, T: 'a + Clone>(message: String, error: String) -> Container<'
|
||||
Button::new(
|
||||
Row::new()
|
||||
.push(
|
||||
Container::new(text(message_clone.to_string()).small().bold())
|
||||
Container::new(text::p1_bold(message_clone.to_string()))
|
||||
.width(Length::Fill),
|
||||
)
|
||||
.push(
|
||||
Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(10)
|
||||
.push(text("Learn more").small().bold())
|
||||
.push(text::p1_bold("Learn more"))
|
||||
.push(icon::collapse_icon()),
|
||||
),
|
||||
)
|
||||
@ -28,20 +28,18 @@ pub fn warning<'a, T: 'a + Clone>(message: String, error: String) -> Container<'
|
||||
move || {
|
||||
Button::new(
|
||||
Row::new()
|
||||
.push(
|
||||
Container::new(text(message.to_owned()).small().bold()).width(Length::Fill),
|
||||
)
|
||||
.push(Container::new(text::p1_bold(message.to_owned())).width(Length::Fill))
|
||||
.push(
|
||||
Row::new()
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(10)
|
||||
.push(text("Learn more").small().bold())
|
||||
.push(text::p1_bold("Learn more"))
|
||||
.push(icon::collapsed_icon()),
|
||||
),
|
||||
)
|
||||
.style(theme::Button::Transparent)
|
||||
},
|
||||
move || Element::<'a, T>::from(text(error.to_owned()).small()),
|
||||
move || Element::<'a, T>::from(text::p2_regular(error.to_owned())),
|
||||
)))
|
||||
.padding(15)
|
||||
.style(theme::Container::Card(theme::Card::Warning))
|
||||
|
||||
@ -116,12 +116,8 @@ pub fn caption<'a>(
|
||||
.size(CAPTION_SIZE)
|
||||
}
|
||||
|
||||
pub const TEXT_REGULAR_SIZE: u16 = 25;
|
||||
|
||||
pub fn text<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, iced::Renderer<Theme>> {
|
||||
iced::widget::Text::new(content)
|
||||
.font(font::REGULAR)
|
||||
.size(TEXT_REGULAR_SIZE)
|
||||
p1_regular(content)
|
||||
}
|
||||
|
||||
pub trait Text {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user