From 4c4eadb9cf00222d5becaf79fb31706da70b7065 Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Sat, 14 Sep 2024 11:51:17 -0500 Subject: [PATCH 1/2] chore: wallet receive page only shows qr code after creating invoice --- src/routes/bitcoin_wallet/receive.rs | 69 +++++++++++++++------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/src/routes/bitcoin_wallet/receive.rs b/src/routes/bitcoin_wallet/receive.rs index f1220d2..82ce29f 100644 --- a/src/routes/bitcoin_wallet/receive.rs +++ b/src/routes/bitcoin_wallet/receive.rs @@ -199,30 +199,6 @@ impl Page { .map(|selected_federation| (invoice, selected_federation.federation_id)) }); - container = container - .push( - text_input("Amount to receive", &self.amount_input) - .on_input(|input| { - app::Message::Routes(routes::Message::BitcoinWalletPage( - super::Message::Receive(Message::AmountInputChanged(input)), - )) - }) - .padding(10) - .size(30), - ) - .push(combo_box( - &self.denomination_combo_box_state, - "Denomination", - self.denomination_combo_box_selected_denomination.as_ref(), - Self::on_denomination_combo_box_change, - )) - .push(combo_box( - &self.federation_combo_box_state, - "Federation to receive to", - self.federation_combo_box_selected_federation.as_ref(), - Self::on_federation_combo_box_change, - )); - container = if let Some(loadable_lightning_invoice_data) = &self.loadable_lightning_invoice_data_or { @@ -247,15 +223,42 @@ impl Page { Loadable::Failed => container.push(Text::new("Failed to create invoice")), } } else { - container.push( - icon_button("Create Invoice", SvgIcon::Send, PaletteColor::Primary).on_press_maybe( - parsed_amount_and_selected_federation_id_or.map(|(amount, federation_id)| { - app::Message::Routes(routes::Message::BitcoinWalletPage( - super::Message::Receive(Message::CreateInvoice(amount, federation_id)), - )) - }), - ), - ) + container + .push( + text_input("Amount to receive", &self.amount_input) + .on_input(|input| { + app::Message::Routes(routes::Message::BitcoinWalletPage( + super::Message::Receive(Message::AmountInputChanged(input)), + )) + }) + .padding(10) + .size(30), + ) + .push(combo_box( + &self.denomination_combo_box_state, + "Denomination", + self.denomination_combo_box_selected_denomination.as_ref(), + Self::on_denomination_combo_box_change, + )) + .push(combo_box( + &self.federation_combo_box_state, + "Federation to receive to", + self.federation_combo_box_selected_federation.as_ref(), + Self::on_federation_combo_box_change, + )) + .push( + icon_button("Create Invoice", SvgIcon::Send, PaletteColor::Primary) + .on_press_maybe(parsed_amount_and_selected_federation_id_or.map( + |(amount, federation_id)| { + app::Message::Routes(routes::Message::BitcoinWalletPage( + super::Message::Receive(Message::CreateInvoice( + amount, + federation_id, + )), + )) + }, + )), + ) }; container = container.push( From cc9d829c22646649d9931ec638e3c59068fd7c8d Mon Sep 17 00:00:00 2001 From: Tommy Volk Date: Sat, 14 Sep 2024 11:59:50 -0500 Subject: [PATCH 2/2] chore: wallet send page only shows selection fields before paying --- src/routes/bitcoin_wallet/send.rs | 85 +++++++++++++++---------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/src/routes/bitcoin_wallet/send.rs b/src/routes/bitcoin_wallet/send.rs index 3bc5b3e..5fbec0f 100644 --- a/src/routes/bitcoin_wallet/send.rs +++ b/src/routes/bitcoin_wallet/send.rs @@ -136,52 +136,49 @@ impl Page { .map(|selected_federation| (invoice, selected_federation.federation_id)) }); - container = container - .push( - text_input("Lightning Invoice", &self.lightning_invoice_input) - .on_input(|input| { - app::Message::Routes(routes::Message::BitcoinWalletPage( - super::Message::Send(Message::LightningInvoiceInputChanged(input)), - )) - }) - .padding(10) - .size(30), - ) - .push(combo_box( - &self.federation_combo_box_state, - "Federation to pay from", - self.federation_combo_box_selected_federation.as_ref(), - Self::on_combo_box_change, - )) - .push( - icon_button("Pay Invoice", SvgIcon::Send, PaletteColor::Primary).on_press_maybe( - parsed_invoice_and_selected_federation_id_or.map(|(invoice, federation_id)| { - app::Message::Routes(routes::Message::BitcoinWalletPage( - super::Message::Send(Message::PayInvoice(invoice, federation_id)), - )) - }), - ), - ) - .push( - icon_button("Back", SvgIcon::ArrowBack, PaletteColor::Background).on_press( - app::Message::Routes(routes::Message::Navigate(RouteName::BitcoinWallet( - SubrouteName::List, - ))), + container = match &self.loadable_invoice_payment_or { + Some(Loadable::Loading) => container.push(Text::new("Loading...")), + Some(Loadable::Loaded(())) => container.push(Text::new("Payment successful!")), + Some(Loadable::Failed) => container.push(Text::new("Payment failed")), + None => container + .push( + text_input("Lightning Invoice", &self.lightning_invoice_input) + .on_input(|input| { + app::Message::Routes(routes::Message::BitcoinWalletPage( + super::Message::Send(Message::LightningInvoiceInputChanged(input)), + )) + }) + .padding(10) + .size(30), + ) + .push(combo_box( + &self.federation_combo_box_state, + "Federation to pay from", + self.federation_combo_box_selected_federation.as_ref(), + Self::on_combo_box_change, + )) + .push( + icon_button("Pay Invoice", SvgIcon::Send, PaletteColor::Primary) + .on_press_maybe(parsed_invoice_and_selected_federation_id_or.map( + |(invoice, federation_id)| { + app::Message::Routes(routes::Message::BitcoinWalletPage( + super::Message::Send(Message::PayInvoice( + invoice, + federation_id, + )), + )) + }, + )), ), - ); + }; - match &self.loadable_invoice_payment_or { - Some(Loadable::Loading) => { - container = container.push(Text::new("Loading...")); - } - Some(Loadable::Loaded(())) => { - container = container.push(Text::new("Payment successful!")); - } - Some(Loadable::Failed) => { - container = container.push(Text::new("Payment failed")); - } - None => {} - } + container = container.push( + icon_button("Back", SvgIcon::ArrowBack, PaletteColor::Background).on_press( + app::Message::Routes(routes::Message::Navigate(RouteName::BitcoinWallet( + SubrouteName::List, + ))), + ), + ); container }