Skip to content

Commit

Permalink
transfer screen frontend stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed Nov 16, 2024
1 parent 929007e commit d696491
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
19 changes: 19 additions & 0 deletions harbor-ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ pub enum Message {
AddToast(Toast),
CloseToast(usize),
CancelAddFederation,
SetTransferFrom(String),
SetTransferTo(String),
TransferAmountInputChanged(String),
// Async commands we fire from the UI to core
Noop,
Send(String),
Expand Down Expand Up @@ -171,6 +174,10 @@ pub struct HarborWallet {
peek_federation_item: Option<FederationItem>,
mint_invite_code_str: String,
add_federation_failure_reason: Option<String>,
// Transfer
transfer_from_federation_selection: Option<String>,
transfer_to_federation_selection: Option<String>,
transfer_amount_input_str: String,
// Donate
donate_amount_str: String,
// Settings
Expand Down Expand Up @@ -403,6 +410,18 @@ impl HarborWallet {

Task::none()
}
Message::SetTransferFrom(s) => {
self.transfer_from_federation_selection = Some(s);
Task::none()
}
Message::SetTransferTo(s) => {
self.transfer_to_federation_selection = Some(s);
Task::none()
}
Message::TransferAmountInputChanged(input) => {
self.transfer_amount_input_str = input;
Task::none()
}
// Async commands we fire from the UI to core
Message::Noop => Task::none(),
Message::Send(invoice_str) => match self.send_status {
Expand Down
54 changes: 50 additions & 4 deletions harbor-ui/src/routes/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,59 @@
use iced::widget::{column, container, scrollable};
use iced::widget::{column, container, pick_list, scrollable, text, PickList};
use iced::Element;
use iced::{Length, Padding};

use crate::components::h_header;
use crate::components::{h_button, h_header, h_input, SvgIcon};
use crate::{HarborWallet, Message};

pub fn transfer(_harbor: &HarborWallet) -> Element<Message> {
pub fn transfer(harbor: &HarborWallet) -> Element<Message> {
let federation_names: Vec<&str> = harbor
.federation_list
.iter()
.map(|f| f.name.as_str())
.collect();

let source_list: PickList<'_, &str, Vec<&str>, &str, Message> = pick_list(
federation_names.clone(),
harbor.transfer_from_federation_selection.as_deref(),
|s| Message::SetTransferFrom(s.to_string()),
)
.padding(Padding::from(16))
.handle(pick_list::Handle::Arrow {
size: Some(iced::Pixels(24.)),
});

let source = column![text("Source").size(24), source_list].spacing(16);

let destination_list: PickList<'_, &str, Vec<&str>, &str, Message> = pick_list(
federation_names,
harbor.transfer_to_federation_selection.as_deref(),
|s| Message::SetTransferTo(s.to_string()),
)
.padding(Padding::from(16))
.handle(pick_list::Handle::Arrow {
size: Some(iced::Pixels(24.)),
});

let destination = column![text("Destination").size(24), destination_list].spacing(16);

let amount_input = h_input(
"Amount",
"420",
&harbor.transfer_amount_input_str,
Message::TransferAmountInputChanged,
None,
false,
None,
Some("sats"),
);

// TODO: atually transfer
let transfer_button = h_button("Transfer", SvgIcon::LeftRight, false).on_press(Message::Noop);

let list = column![source, destination, amount_input, transfer_button].spacing(48);

container(scrollable(
column![h_header("Transfer", "Coming soon!")]
column![h_header("Transfer", "Coming soon!"), list]
.spacing(48)
.width(Length::Fill)
.max_width(512)
Expand Down

0 comments on commit d696491

Please sign in to comment.