diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index c42d99a..b03d8b8 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -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), @@ -171,6 +174,10 @@ pub struct HarborWallet { peek_federation_item: Option, mint_invite_code_str: String, add_federation_failure_reason: Option, + // Transfer + transfer_from_federation_selection: Option, + transfer_to_federation_selection: Option, + transfer_amount_input_str: String, // Donate donate_amount_str: String, // Settings @@ -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 { diff --git a/harbor-ui/src/routes/transfer.rs b/harbor-ui/src/routes/transfer.rs index 8184df7..1fb25cd 100644 --- a/harbor-ui/src/routes/transfer.rs +++ b/harbor-ui/src/routes/transfer.rs @@ -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 { +pub fn transfer(harbor: &HarborWallet) -> Element { + 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)