Skip to content

Commit

Permalink
Merge pull request #32 from nodetec/wallet_page_cleanup
Browse files Browse the repository at this point in the history
chore: cleanup wallet page and subroutes
  • Loading branch information
tvolk131 authored Sep 14, 2024
2 parents 3cb178a + cc9d829 commit 389dc96
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 77 deletions.
69 changes: 36 additions & 33 deletions src/routes/bitcoin_wallet/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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(
Expand Down
85 changes: 41 additions & 44 deletions src/routes/bitcoin_wallet/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 389dc96

Please sign in to comment.