Skip to content

Commit

Permalink
Merge #215: ui: add close_button with icon
Browse files Browse the repository at this point in the history
780629e ui: add close_button with icon (edouard)

Pull request description:

  close #210

ACKs for top commit:
  danielabrozzoni:
    ACK 780629e

Tree-SHA512: 6b24612e5080f25e0c5c58e37e4b16cbe7a950078315b132c974dce4afd29a0ab967bb2ab16896d26268b5f9a36710d7309d8ac7c5a60b7f62a9203074793c06
  • Loading branch information
edouardparis committed Sep 8, 2021
2 parents 58e877c + 780629e commit f6f8338
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 73 deletions.
7 changes: 2 additions & 5 deletions src/app/view/emergency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ impl EmergencyView {
.push(
Row::new().push(Column::new().width(Length::Fill)).push(
Container::new(
button::cancel(
&mut self.close_button,
Container::new(text::simple("X Close")).padding(10),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.close_button)
.on_press(Message::Menu(Menu::Home)),
)
.width(Length::Shrink),
),
Expand Down
67 changes: 14 additions & 53 deletions src/app/view/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ impl ManagerImportTransactionView {
.push(
Row::new().push(Column::new().width(Length::Fill)).push(
Container::new(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close")).padding(10),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
)
.width(Length::Shrink),
),
Expand Down Expand Up @@ -144,14 +141,8 @@ impl ManagerSendWelcomeView {
.push(
Row::new().push(Column::new().width(Length::Fill)).push(
Container::new(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close"))
.padding(10)
.width(Length::Units(100))
.align_x(Align::Center),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
)
.width(Length::Shrink),
),
Expand Down Expand Up @@ -219,14 +210,8 @@ impl ManagerSelectOutputsView {
.push(
Column::new()
.push(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close"))
.padding(10)
.width(Length::Units(100))
.align_x(Align::Center),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
)
.align_items(Align::End)
.width(Length::Fill),
Expand Down Expand Up @@ -437,14 +422,8 @@ impl ManagerSelectInputsView {
.push(
Column::new()
.push(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close"))
.padding(10)
.width(Length::Units(100))
.align_x(Align::Center),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
)
.align_items(Align::End)
.width(Length::Fill),
Expand Down Expand Up @@ -616,14 +595,8 @@ impl ManagerSelectFeeView {
.push(
Column::new()
.push(Container::new(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close"))
.padding(10)
.width(Length::Units(100))
.align_x(Align::Center),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
))
.width(Length::Fill)
.align_items(Align::End),
Expand Down Expand Up @@ -905,14 +878,8 @@ impl ManagerSignView {
.push(
Column::new()
.push(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close"))
.padding(10)
.width(Length::Units(100))
.align_x(Align::Center),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
)
.width(Length::Fill)
.align_items(Align::End),
Expand Down Expand Up @@ -1003,14 +970,8 @@ impl ManagerSpendTransactionCreatedView {
.push(
Column::new()
.push(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close"))
.padding(10)
.width(Length::Units(100))
.align_x(Align::Center),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
)
.width(Length::Fill)
.align_items(Align::End),
Expand Down
7 changes: 2 additions & 5 deletions src/app/view/spend_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ impl SpendTransactionView {
.push(
row.push(
Container::new(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close")).padding(10),
)
.on_press(Message::Menu(Menu::Home)),
button::close_button(&mut self.cancel_button)
.on_press(Message::Menu(Menu::Home)),
)
.width(Length::Shrink),
)
Expand Down
6 changes: 2 additions & 4 deletions src/app/view/stakeholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ impl StakeholderCreateVaultsView {
)
.width(Length::Fill)).push(
Container::new(
button::cancel(
button::close_button(
&mut self.close_button,
Container::new(text::simple("X Close")).padding(10),
)
.on_press(Message::Menu(Menu::Home)),
)
Expand Down Expand Up @@ -242,9 +241,8 @@ impl StakeholderDelegateFundsView {
)
.push(
Container::new(
button::cancel(
button::close_button(
&mut self.close_button,
Container::new(text::simple("X Close")).padding(10),
)
.on_press(Message::Menu(Menu::Home)),
)
Expand Down
7 changes: 2 additions & 5 deletions src/app/view/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ impl VaultModal {
}
let header = Row::new().push(col.width(Length::Fill)).push(
Container::new(
button::cancel(
&mut self.cancel_button,
Container::new(text::simple("X Close")).padding(10),
)
.on_press(Message::SelectVault(vlt.outpoint())),
button::close_button(&mut self.cancel_button)
.on_press(Message::SelectVault(vlt.outpoint())),
)
.width(Length::Shrink),
);
Expand Down
33 changes: 32 additions & 1 deletion src/ui/component/button.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::ui::{color, component::text, icon::clipboard_icon};
use crate::ui::{color, component::text, icon::clipboard_icon, icon::cross_icon};
use iced::{button, Color, Container, Row, Vector};

macro_rules! button {
Expand Down Expand Up @@ -116,3 +116,34 @@ impl button::StyleSheet for WhiteCardButtonStyle {
}
}
}

pub fn close_button<'a, T: 'a + Clone>(state: &'a mut button::State) -> button::Button<'a, T> {
button::Button::new(
state,
Container::new(
Row::new()
.push(cross_icon())
.push(text::simple("Close"))
.spacing(5)
.width(iced::Length::Fill)
.height(iced::Length::Fill)
.align_items(iced::Align::Center),
)
.padding(10),
)
.style(CloseButtonStyle {})
}

struct CloseButtonStyle {}
impl button::StyleSheet for CloseButtonStyle {
fn active(&self) -> button::Style {
button::Style {
shadow_offset: Vector::default(),
background: color::CANCEL.into(),
border_radius: 10.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
text_color: Color::WHITE,
}
}
}
4 changes: 4 additions & 0 deletions src/ui/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ pub fn key_icon() -> Text {
icon('\u{F44F}')
}

pub fn cross_icon() -> Text {
icon('\u{F62A}')
}

#[allow(dead_code)]
pub fn stakeholder_icon() -> Text {
icon('\u{F4AE}')
Expand Down

0 comments on commit f6f8338

Please sign in to comment.