diff --git a/harbor-ui/src/main.rs b/harbor-ui/src/main.rs index 634ab4a..5d1b44a 100644 --- a/harbor-ui/src/main.rs +++ b/harbor-ui/src/main.rs @@ -123,6 +123,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), @@ -183,6 +186,10 @@ pub struct HarborWallet { // Mints peek_federation_item: Option, mint_invite_code_str: String, + // Transfer + transfer_from_federation_selection: Option, + transfer_to_federation_selection: Option, + transfer_amount_input_str: String, // Donate donate_amount_str: String, // Settings @@ -417,6 +424,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..aca4bb5 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", "Rebalance your funds."), list] .spacing(48) .width(Length::Fill) .max_width(512)