Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transfer screen frontend stuff #74

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions harbor-ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -183,6 +186,10 @@ pub struct HarborWallet {
// Mints
peek_federation_item: Option<FederationItem>,
mint_invite_code_str: 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 @@ -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 {
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", "Rebalance your funds."), list]
.spacing(48)
.width(Length::Fill)
.max_width(512)
Expand Down