Skip to content

Commit

Permalink
add a prettier txid output to receive success
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed May 17, 2024
1 parent ee60537 commit 2d53f70
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 131 deletions.
4 changes: 4 additions & 0 deletions assets/icons/restart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 10 additions & 24 deletions src/components/button.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use iced::{
widget::{
button::{self, Status},
center, horizontal_space, row, text, Button, Svg,
center, horizontal_space, row, text, Button,
},
Border, Color, Element, Length, Shadow, Theme,
};
Expand All @@ -12,16 +12,13 @@ use super::{darken, lighten, map_icon, the_spinner, SvgIcon};

pub fn h_button(text_str: &str, icon: SvgIcon, loading: bool) -> Button<'_, Message, Theme> {
let spinner: Element<'static, Message, Theme> = the_spinner();
let svg: Svg<'_, Theme> = map_icon(icon);
let svg = map_icon(icon, 24., 24.);
let content = if loading {
row![spinner].align_items(iced::Alignment::Center)
} else {
row![
svg.width(Length::Fixed(24.)).height(Length::Fixed(24.)),
text(text_str).size(24.)
]
.align_items(iced::Alignment::Center)
.spacing(16)
row![svg, text(text_str).size(24.)]
.align_items(iced::Alignment::Center)
.spacing(16)
};

Button::new(center(content))
Expand Down Expand Up @@ -62,22 +59,11 @@ pub fn sidebar_button(
active_route: Route,
) -> Button<'_, Message, Theme> {
let is_active = self_route == active_route;
let svg: Svg<'_, Theme> = map_icon(icon);
let content = row!(
svg.width(Length::Fixed(24.)).height(Length::Fixed(24.)),
text(text_str).size(24.),
horizontal_space(),
// .font(Font {

// family: iced::font::Family::default(),
// weight: iced::font::Weight::Bold,
// stretch: iced::font::Stretch::Normal,
// style: iced::font::Style::Normal,
// })
)
.align_items(iced::Alignment::Center)
.spacing(16)
.padding(16);
let svg = map_icon(icon, 24., 24.);
let content = row!(svg, text(text_str).size(24.), horizontal_space(),)
.align_items(iced::Alignment::Center)
.spacing(16)
.padding(16);

Button::new(content)
.style(move |theme, status| {
Expand Down
11 changes: 9 additions & 2 deletions src/components/icon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use iced::{widget::Svg, Theme};
use iced::{widget::Svg, Element, Theme};

use crate::Message;

pub enum SvgIcon {
ChevronDown,
Expand All @@ -13,9 +15,10 @@ pub enum SvgIcon {
Copy,
Plus,
Qr,
Restart,
}

pub fn map_icon(icon: SvgIcon) -> Svg<'static, Theme> {
pub fn map_icon(icon: SvgIcon, width: f32, height: f32) -> Element<'static, Message, Theme> {
match icon {
SvgIcon::ChevronDown => Svg::from_path("assets/icons/chevron_down.svg"),
SvgIcon::DownLeft => Svg::from_path("assets/icons/down_left.svg"),
Expand All @@ -29,5 +32,9 @@ pub fn map_icon(icon: SvgIcon) -> Svg<'static, Theme> {
SvgIcon::Copy => Svg::from_path("assets/icons/copy.svg"),
SvgIcon::Plus => Svg::from_path("assets/icons/plus.svg"),
SvgIcon::Qr => Svg::from_path("assets/icons/qr.svg"),
SvgIcon::Restart => Svg::from_path("assets/icons/restart.svg"),
}
.width(width)
.height(height)
.into()
}
12 changes: 9 additions & 3 deletions src/components/layout.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
use iced::widget::{container, scrollable, Column};
use iced::widget::{container, horizontal_space, row, scrollable, Column};
use iced::Length;
use iced::{Element, Padding};

use crate::Message;

pub fn basic_layout(column: Column<Message>) -> Element<Message> {
container(
scrollable(column.width(Length::Fixed(512.)).padding(Padding::new(48.)))
.height(Length::Fill),
scrollable(row![
column
.width(Length::Fixed(512.))
.padding(Padding::new(48.))
.max_width(512),
horizontal_space(),
])
.height(Length::Fill),
)
.into()
}
39 changes: 39 additions & 0 deletions src/components/mini_copy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use iced::{
widget::{
button::{self, Status}, Button,
},
Border, Color, Length, Shadow, Theme,
};

use crate::Message;

use super::{darken, lighten, map_icon, SvgIcon};

pub fn mini_copy(text: String) -> Button<'static, Message, Theme> {
let icon = map_icon(SvgIcon::Copy, 24., 24.);

Button::new(icon)
.on_press(Message::CopyToClipboard(text.to_string()))
.style(|theme: &Theme, status| {
let border = Border {
color: Color::WHITE,
width: 0.,
radius: (8.).into(),
};

let background = match status {
Status::Hovered => lighten(theme.palette().background, 0.1),
Status::Pressed => darken(Color::BLACK, 0.1),
_ => theme.palette().background,
};
button::Style {
background: Some(background.into()),
text_color: Color::WHITE,
border,
shadow: Shadow::default(),
}
})
.padding(6)
.width(Length::Fixed(32.))
.height(Length::Fixed(32.))
}
3 changes: 3 additions & 0 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ pub use rules::*;

mod layout;
pub use layout::*;

mod mini_copy;
pub use mini_copy::*;
2 changes: 1 addition & 1 deletion src/components/screen_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::{hr, map_icon, vr, FederationItem, SvgIcon};
pub fn h_screen_header(harbor: &HarborWallet, show_balance: bool) -> Element<Message> {
if let Some(item) = harbor.federation_list.first() {
let FederationItem { name, id: _id } = item;
let people_icon = map_icon(SvgIcon::People).width(24).height(24);
let people_icon = map_icon(SvgIcon::People, 24., 24.);
let current_federation = row![people_icon, text(name).size(24)]
.align_items(Alignment::Center)
.spacing(16)
Expand Down
Loading

0 comments on commit 2d53f70

Please sign in to comment.