Skip to content

Commit

Permalink
Use theme text methods instead of hard coded colors
Browse files Browse the repository at this point in the history
  • Loading branch information
edouardparis committed Feb 4, 2025
1 parent 3a4df7a commit dc5b57c
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 201 deletions.
60 changes: 40 additions & 20 deletions liana-gui/src/app/view/coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::collections::HashMap;
use iced::{widget::Space, Alignment, Length};

use liana_ui::{
color,
component::{amount::*, badge, button, form, text::*},
icon, theme,
widget::*,
Expand Down Expand Up @@ -84,7 +83,8 @@ fn coin_list_view<'a>(
// It is not possible to know if a coin is a
// change coin or not so for now, From is
// enough
p1_regular("From").color(color::GREY_3),
p1_regular("From")
.style(theme::text::secondary),
)
.push(p1_regular(label)),
)
Expand All @@ -101,7 +101,8 @@ fn coin_list_view<'a>(
// It is not possible to know if a coin is a
// change coin or not so for now, From is
// enough
p1_regular("From").color(color::GREY_3),
p1_regular("From")
.style(theme::text::secondary),
)
.push(p1_regular(label)),
)
Expand Down Expand Up @@ -156,7 +157,7 @@ fn coin_list_view<'a>(
if blockheight > b as u32 + timelock as u32 {
Some(Container::new(
p1_bold("One of the recovery path is available")
.color(color::RED),
.style(theme::text::error),
))
} else {
Some(Container::new(p1_bold(format!(
Expand All @@ -178,25 +179,29 @@ fn coin_list_view<'a>(
.push(
p2_regular("Address label:")
.bold()
.color(color::GREY_2),
.style(theme::text::secondary),
)
.push(if let Some(label) = labels.get(&address) {
p2_regular(label).color(color::GREY_2)
p2_regular(label).style(theme::text::secondary)
} else {
p2_regular("No label").color(color::GREY_2)
p2_regular("No label").style(theme::text::secondary)
})
.spacing(5),
)
.push(
Row::new()
.align_y(Alignment::Center)
.push(p2_regular("Address:").bold().color(color::GREY_2))
.push(
p2_regular("Address:")
.bold()
.style(theme::text::secondary),
)
.push(
Row::new()
.align_y(Alignment::Center)
.push(
p2_regular(address.clone())
.color(color::GREY_2),
.style(theme::text::secondary),
)
.push(
Button::new(icon::clipboard_icon())
Expand All @@ -214,25 +219,29 @@ fn coin_list_view<'a>(
.push(
p2_regular("Deposit transaction label:")
.bold()
.color(color::GREY_2),
.style(theme::text::secondary),
)
.push(if let Some(label) = labels.get(&txid) {
p2_regular(label).color(color::GREY_2)
p2_regular(label).style(theme::text::secondary)
} else {
p2_regular("No label").color(color::GREY_2)
p2_regular("No label").style(theme::text::secondary)
})
.spacing(5),
)
.push(
Row::new()
.align_y(Alignment::Center)
.push(p2_regular("Outpoint:").bold().color(color::GREY_2))
.push(
p2_regular("Outpoint:")
.bold()
.style(theme::text::secondary),
)
.push(
Row::new()
.align_y(Alignment::Center)
.push(
p2_regular(format!("{}", coin.outpoint))
.color(color::GREY_2),
.style(theme::text::secondary),
)
.push(
Button::new(icon::clipboard_icon())
Expand All @@ -247,17 +256,26 @@ fn coin_list_view<'a>(
.push_maybe(coin.block_height.map(|b| {
Row::new()
.push(
p2_regular("Block height:").bold().color(color::GREY_2),
p2_regular("Block height:")
.bold()
.style(theme::text::secondary),
)
.push(
p2_regular(format!("{}", b))
.style(theme::text::secondary),
)
.push(p2_regular(format!("{}", b)).color(color::GREY_2))
.spacing(5)
})),
)
.push(if let Some(info) = coin.spend_info {
Column::new()
.push(
Row::new()
.push(p2_regular("Spend txid:").bold().color(color::GREY_2))
.push(
p2_regular("Spend txid:")
.bold()
.style(theme::text::secondary),
)
.push(p2_regular(format!("{}", info.txid)))
.spacing(5),
)
Expand All @@ -266,13 +284,15 @@ fn coin_list_view<'a>(
.push(
p2_regular("Spend block height:")
.bold()
.color(color::GREY_2),
.style(theme::text::secondary),
)
.push(p2_regular(format!("{}", height)))
.spacing(5)
} else {
Row::new().push(
p2_regular("Not in a block").bold().color(color::GREY_2),
p2_regular("Not in a block")
.bold()
.style(theme::text::secondary),
)
})
.spacing(5)
Expand Down Expand Up @@ -320,7 +340,7 @@ pub fn coin_sequence_label<'a, T: 'a>(seq: u32, timelock: u32) -> Container<'a,
Row::new()
.spacing(5)
.push(icon::clock_icon().width(Length::Fixed(20.0)))
.push(p2_regular(expire_message(seq)).color(color::GREY_3))
.push(p2_regular(expire_message(seq)).style(theme::text::secondary))
.align_y(Alignment::Center),
)
.padding(10)
Expand Down
25 changes: 14 additions & 11 deletions liana-gui/src/app/view/home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ pub fn home_view<'a>(
SyncStatus::WalletFullScan => text("Syncing"),
_ => text("Checking for new transactions"),
}
.color(color::GREY_2),
.style(theme::text::secondary),
)
.push(spinner::typing_text_carousel(
"...",
true,
Duration::from_millis(2000),
|content| text(content).color(color::GREY_2),
|content| text(content).style(theme::text::secondary),
)),
)
} else {
Expand All @@ -86,9 +86,13 @@ pub fn home_view<'a>(
Some(
Row::new()
.spacing(10)
.push(text("+").size(H3_SIZE).color(color::GREY_3))
.push(text("+").size(H3_SIZE).style(theme::text::secondary))
.push(unconfirmed_amount_with_size(unconfirmed_balance, H3_SIZE))
.push(text("unconfirmed").size(H3_SIZE).color(color::GREY_3)),
.push(
text("unconfirmed")
.size(H3_SIZE)
.style(theme::text::secondary),
),
)
} else {
None
Expand All @@ -111,7 +115,7 @@ pub fn home_view<'a>(
.push(
icon::tooltip_icon()
.size(20)
.color(color::GREY_3)
.style(theme::text::secondary)
.width(Length::Fixed(20.0)),
)
.width(Length::Fill),
Expand Down Expand Up @@ -190,10 +194,9 @@ fn event_list_view(event: &Payment) -> Element<'_, Message> {
let label = if let Some(label) = &event.label {
Some(p1_regular(label))
} else {
event
.address_label
.as_ref()
.map(|label| p1_regular(format!("address label: {}", label)).color(color::GREY_3))
event.address_label.as_ref().map(|label| {
p1_regular(format!("address label: {}", label)).style(theme::text::secondary)
})
};
if event.kind == PaymentKind::Incoming {
if let Some(t) = event.time {
Expand Down Expand Up @@ -298,7 +301,7 @@ pub fn payment_view<'a>(
.push_maybe(tx.fee_amount.map(|fee_amount| {
Row::new()
.align_y(Alignment::Center)
.push(h3("Miner fee: ").color(color::GREY_3))
.push(h3("Miner fee: ").style(theme::text::secondary))
.push(amount_with_size(&fee_amount, H3_SIZE))
.push(text(" ").size(H3_SIZE))
.push(
Expand All @@ -307,7 +310,7 @@ pub fn payment_view<'a>(
fee_amount.to_sat() / tx.tx.vsize() as u64
))
.size(H4_SIZE)
.color(color::GREY_3),
.style(theme::text::secondary),
)
}))
.push(card::simple(
Expand Down
Loading

0 comments on commit dc5b57c

Please sign in to comment.