From b260ac420819cb41f8740fa12f65b3a79d69eed3 Mon Sep 17 00:00:00 2001 From: edouard Date: Fri, 25 Nov 2022 11:18:20 +0100 Subject: [PATCH] installer: keep refresh button to list hws --- gui/src/installer/view.rs | 69 +++++++++++++++++++--------------- gui/src/ui/component/button.rs | 4 ++ gui/src/ui/icon.rs | 4 ++ 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/gui/src/installer/view.rs b/gui/src/installer/view.rs index bf578a97..72417d74 100644 --- a/gui/src/installer/view.rs +++ b/gui/src/installer/view.rs @@ -317,9 +317,24 @@ pub fn register_descriptor<'a>( .align_items(Alignment::Center), ) .push_maybe(error.map(|e| card::error("Failed to import xpub", e.to_string()))) - .push(if !hws.is_empty() { + .push( Column::new() - .push(text(format!("{} hardware wallets connected", hws.len())).bold()) + .push( + Row::new() + .spacing(10) + .align_items(Alignment::Center) + .push( + Container::new( + text(format!("{} hardware wallets connected", hws.len())) + .bold(), + ) + .width(Length::Fill), + ) + .push( + button::border(Some(icon::reload_icon()), "Refresh") + .on_press(Message::Reload), + ), + ) .spacing(10) .push( hws.iter() @@ -334,17 +349,8 @@ pub fn register_descriptor<'a>( )) }), ) - .width(Length::Fill) - } else { - Column::new().push(card::simple( - Column::new() - .spacing(20) - .push("No hardware wallet connected") - .push(button::primary(None, "Refresh").on_press(Message::Reload)) - .align_items(Alignment::Center) - .width(Length::Fill), - )) - }) + .width(Length::Fill), + ) .push( button::primary(None, "Next") .on_press(Message::Next) @@ -473,9 +479,24 @@ pub fn hardware_wallet_xpubs_modal<'a>( .size(50), ) .push_maybe(error.map(|e| card::error("Failed to import xpub", e.to_string()))) - .push(if !hws.is_empty() { + .push( Column::new() - .push(text(format!("{} hardware wallets connected", hws.len())).bold()) + .push( + Row::new() + .spacing(10) + .align_items(Alignment::Center) + .push( + Container::new( + text(format!("{} hardware wallets connected", hws.len())) + .bold(), + ) + .width(Length::Fill), + ) + .push( + button::border(Some(icon::reload_icon()), "Refresh") + .on_press(Message::Reload), + ), + ) .spacing(10) .push( hws.iter() @@ -490,22 +511,8 @@ pub fn hardware_wallet_xpubs_modal<'a>( )) }), ) - .width(Length::Fill) - } else { - Column::new() - .push( - card::simple( - Column::new() - .spacing(20) - .width(Length::Fill) - .push("Please connect a hardware wallet") - .push(button::primary(None, "Refresh").on_press(Message::Reload)) - .align_items(Alignment::Center), - ) - .width(Length::Fill), - ) - .width(Length::Fill) - }) + .width(Length::Fill), + ) .width(Length::Fill) .height(Length::Fill) .padding(100) diff --git a/gui/src/ui/component/button.rs b/gui/src/ui/component/button.rs index 7fb50fbf..8f537114 100644 --- a/gui/src/ui/component/button.rs +++ b/gui/src/ui/component/button.rs @@ -16,6 +16,10 @@ pub fn transparent<'a, T: 'a>(icon: Option>, t: &'static str) -> button button::Button::new(content(icon, t)).style(Style::Transparent.into()) } +pub fn border<'a, T: 'a>(icon: Option>, t: &'static str) -> button::Button<'a, T> { + button::Button::new(content(icon, t)).style(Style::Border.into()) +} + pub fn transparent_border<'a, T: 'a>( icon: Option>, t: &'static str, diff --git a/gui/src/ui/icon.rs b/gui/src/ui/icon.rs index 892f76b9..b155a63e 100644 --- a/gui/src/ui/icon.rs +++ b/gui/src/ui/icon.rs @@ -13,6 +13,10 @@ fn icon(unicode: char) -> Text<'static> { .size(20) } +pub fn reload_icon() -> Text<'static> { + icon('\u{F130}') +} + pub fn import_icon() -> Text<'static> { icon('\u{F30A}') }