-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c353e67
commit d2340f5
Showing
8 changed files
with
153 additions
and
24 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use iced::widget::text::Style; | ||
use iced::widget::{column, text}; | ||
use iced::{Element, Theme}; | ||
|
||
use crate::Message; | ||
|
||
use super::lighten; | ||
|
||
pub fn h_header(title: &'static str, subtitle: &'static str) -> Element<'static, Message> { | ||
column![ | ||
text(title).size(32), | ||
text(subtitle).size(18).style(|theme: &Theme| { | ||
let gray = lighten(theme.palette().background, 0.5); | ||
Style { color: Some(gray) } | ||
}) | ||
] | ||
.spacing(8) | ||
.into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,6 @@ pub use icon::*; | |
|
||
mod input; | ||
pub use input::*; | ||
|
||
mod header; | ||
pub use header::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,61 @@ | ||
use iced::widget::{column, container, scrollable, text, text_input}; | ||
use iced::Length; | ||
use iced::{Alignment, Element}; | ||
use iced::widget::container::Style; | ||
use iced::widget::{column, container, qr_code, scrollable, text}; | ||
use iced::{Border, Element, Padding}; | ||
use iced::{Color, Length}; | ||
|
||
use crate::components::{h_button, SvgIcon}; | ||
use crate::components::{h_button, h_header, h_input, SvgIcon}; | ||
use crate::{HarborWallet, Message}; | ||
|
||
pub fn receive(harbor: &HarborWallet) -> Element<Message> { | ||
let col = if let Some(invoice) = harbor.receive_invoice.as_ref() { | ||
let column = if let Some(invoice) = harbor.receive_invoice.as_ref() { | ||
let header = h_header("Receive", "Scan this QR or copy the string."); | ||
|
||
let data = harbor.receive_qr_data.as_ref().unwrap(); | ||
let qr_code = qr_code(data); | ||
let qr_container = container(qr_code).padding(16).style(|_theme| Style { | ||
background: Some(iced::Background::Color(Color::WHITE)), | ||
border: Border { | ||
radius: (8.).into(), | ||
..Border::default() | ||
}, | ||
..Style::default() | ||
}); | ||
|
||
let first_ten_chars = invoice.to_string().chars().take(10).collect::<String>(); | ||
|
||
column![ | ||
"Here's an invoice!", | ||
text(format!("{invoice}")).size(16), | ||
header, | ||
qr_container, | ||
text(format!("{first_ten_chars}...")).size(16), | ||
h_button("Copy to clipboard", SvgIcon::Copy) | ||
.on_press(Message::CopyToClipboard(invoice.to_string())), | ||
] | ||
} else { | ||
column![ | ||
"How much do you want to receive?", | ||
text_input("how much?", &harbor.receive_amount_str) | ||
.on_input(Message::ReceiveAmountChanged), | ||
h_button("Generate Invoice", SvgIcon::DownLeft).on_press(Message::GenerateInvoice), | ||
] | ||
let header = h_header("Receive", "Receive on-chain or via lightning."); | ||
|
||
let amount_input = h_input( | ||
"Amount", | ||
"420", | ||
&harbor.receive_amount_str, | ||
Message::ReceiveAmountChanged, | ||
Message::Noop, | ||
false, | ||
None, | ||
Some("sats"), | ||
); | ||
|
||
let generate_button = | ||
h_button("Generate Invoice", SvgIcon::DownLeft).on_press(Message::GenerateInvoice); | ||
|
||
column![header, amount_input, generate_button] | ||
}; | ||
|
||
container( | ||
scrollable( | ||
col.spacing(32) | ||
.align_items(Alignment::Center) | ||
.width(Length::Fill), | ||
) | ||
.height(Length::Fill), | ||
) | ||
container(scrollable( | ||
column | ||
.spacing(48) | ||
.width(Length::Fill) | ||
.max_width(512) | ||
.padding(Padding::new(48.)), | ||
)) | ||
.into() | ||
} |