Skip to content

Commit

Permalink
fix liana-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Jan 27, 2025
1 parent 0305551 commit 6a1f240
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 67 deletions.
86 changes: 47 additions & 39 deletions liana-ui/src/component/hw.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::{color, component::text, icon, image, theme, widget::*};
use iced::{
widget::{column, container, row, text::IntoFragment, tooltip},
widget::{column, container, row, tooltip},
Alignment, Length,
};
use std::borrow::Cow;
use std::fmt::Display;

pub fn locked_hardware_wallet<'a, T: 'a, K: Display>(
kind: K,
pairing_code: Option<impl IntoFragment<'a>>,
pairing_code: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
Container::new(
column(vec![
Expand Down Expand Up @@ -37,7 +38,7 @@ pub fn supported_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>(
kind: K,
version: Option<V>,
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
Container::new(
column(vec![
Expand All @@ -61,8 +62,8 @@ pub fn warning_hardware_wallet<'a, T: 'static, K: Display, V: Display, F: Displa
kind: K,
version: Option<V>,
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
warning: &'static str,
alias: Option<impl Into<Cow<'a, str>> + Display>,
warning: &'a str,
) -> Container<'a, T> {
container(
row(vec![
Expand All @@ -82,7 +83,7 @@ pub fn warning_hardware_wallet<'a, T: 'static, K: Display, V: Display, F: Displa
.into(),
column(vec![tooltip::Tooltip::new(
icon::warning_icon(),
warning,
iced::widget::text!("{}", warning),
tooltip::Position::Bottom,
)
.style(theme::card::simple)
Expand Down Expand Up @@ -155,7 +156,7 @@ pub fn processing_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>
kind: K,
version: Option<V>,
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
container(
row(vec![
Expand Down Expand Up @@ -184,36 +185,43 @@ pub fn processing_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>
.padding(10)
}

pub fn selected_hardware_wallet<T: 'static, K: Display, V: Display, F: Display>(
pub fn selected_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>(
kind: K,
version: Option<V>,
fingerprint: F,
alias: Option<impl IntoFragment<'static>>,
warning: Option<&'static str>,
) -> Container<'static, T> {
alias: Option<impl Into<Cow<'a, str>> + Display>,
warning: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
container(
Row::new()
.push(
column(vec![
Row::new()
.spacing(5)
.push_maybe(alias.map(|a| text::p1_bold(a)))
.push(text::p1_regular(format!("#{}", fingerprint)))
.into(),
Row::new()
.spacing(5)
.push(text::caption(kind.to_string()))
.push_maybe(version.map(|v| text::caption(v.to_string())))
.into(),
])
.width(Length::Fill),
)
.push_maybe(warning.map(|w| {
tooltip::Tooltip::new(icon::warning_icon(), w, tooltip::Position::Bottom)
.style(theme::card::simple)
}))
.push(image::success_mark_icon().width(Length::Fixed(50.0)))
.align_y(Alignment::Center),
row(vec![
column(vec![
Row::new()
.spacing(5)
.push_maybe(alias.map(text::p1_bold))
.push(text::p1_regular(format!("#{}", fingerprint)))
.into(),
Row::new()
.spacing(5)
.push(text::caption(kind.to_string()))
.push_maybe(version.map(|v| text::caption(v)))
.into(),
])
.width(Length::Fill)
.into(),
// if let Some(w) = warning {
// tooltip::Tooltip::new(
// icon::warning_icon(),
// iced::widget::text!("{}", w),
// tooltip::Position::Bottom,
// )
// .style(theme::card::simple)
// .into()
// } else {
// Row::new().into()
// },
image::success_mark_icon().width(Length::Fixed(50.0)).into(),
])
.align_y(Alignment::Center),
)
.padding(10)
}
Expand All @@ -222,7 +230,7 @@ pub fn sign_success_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Displa
kind: K,
version: Option<V>,
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
container(
row(vec![
Expand Down Expand Up @@ -257,7 +265,7 @@ pub fn registration_success_hardware_wallet<'a, T: 'a, K: Display, V: Display, F
kind: K,
version: Option<V>,
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
container(
row(vec![
Expand Down Expand Up @@ -385,7 +393,7 @@ pub fn unsupported_version_hardware_wallet<'a, T: 'static, K: Display, V: Displa

pub fn sign_success_hot_signer<'a, T: 'a, F: Display>(
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
container(
row(vec![
Expand Down Expand Up @@ -417,7 +425,7 @@ pub fn sign_success_hot_signer<'a, T: 'a, F: Display>(

pub fn selected_hot_signer<'a, T: 'a, F: Display>(
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
container(
row(vec![
Expand Down Expand Up @@ -446,7 +454,7 @@ pub fn selected_hot_signer<'a, T: 'a, F: Display>(

pub fn unselected_hot_signer<'a, T: 'a, F: Display>(
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
Container::new(
column(vec![
Expand All @@ -470,7 +478,7 @@ pub fn unselected_hot_signer<'a, T: 'a, F: Display>(

pub fn hot_signer<'a, T: 'a, F: Display>(
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<impl Into<Cow<'a, str>> + Display>,
) -> Container<'a, T> {
Container::new(
column(vec![
Expand Down
2 changes: 1 addition & 1 deletion liana-ui/src/component/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn processing_hardware_wallet<'a, T: 'a, K: Display, V: Display, F: Display>
kind: K,
version: Option<V>,
fingerprint: F,
alias: Option<impl IntoFragment<'a>>,
alias: Option<&'a str>,
) -> Container<'a, T> {
container(
row(vec![
Expand Down
55 changes: 28 additions & 27 deletions liana-ui/src/component/text.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{font, theme::Theme};
use iced::advanced::text::{IntoFragment, Shaping};
use std::fmt::Display;

pub const H1_SIZE: u16 = 40;
pub const H2_SIZE: u16 = 29;
Expand All @@ -10,98 +11,98 @@ pub const P1_SIZE: u16 = 16;
pub const P2_SIZE: u16 = 14;
pub const CAPTION_SIZE: u16 = 12;

pub fn h1<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn h1<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::BOLD)
.size(H1_SIZE)
}

pub fn h2<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn h2<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::BOLD)
.size(H2_SIZE)
}

pub fn h3<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn h3<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::BOLD)
.size(H3_SIZE)
}

pub fn h4_bold<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn h4_bold<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::BOLD)
.size(H4_SIZE)
}

pub fn h4_regular<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn h4_regular<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::REGULAR)
.size(H4_SIZE)
}

pub fn h5_medium<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn h5_medium<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::MEDIUM)
.size(H5_SIZE)
}

pub fn h5_regular<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn h5_regular<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::REGULAR)
.size(H5_SIZE)
}

pub fn p1_bold<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn p1_bold<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::BOLD)
.size(P1_SIZE)
}

pub fn p1_medium<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn p1_medium<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::MEDIUM)
.size(P1_SIZE)
}

pub fn p1_regular<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn p1_regular<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::REGULAR)
.size(P1_SIZE)
}

pub fn p2_medium<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn p2_medium<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::MEDIUM)
.size(P2_SIZE)
}

pub fn p2_regular<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn p2_regular<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::REGULAR)
.size(P2_SIZE)
}

pub fn caption<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
iced::widget::Text::new(content)
pub fn caption<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
iced::widget::text!("{}", content)
.shaping(Shaping::Advanced)
.font(font::REGULAR)
.size(CAPTION_SIZE)
}

pub fn text<'a>(content: impl IntoFragment<'a>) -> iced::widget::Text<'a, Theme> {
pub fn text<'a>(content: impl Display) -> iced::widget::Text<'a, Theme> {
p1_regular(content)
}

Expand Down

0 comments on commit 6a1f240

Please sign in to comment.