diff --git a/README.md b/README.md index cc7795b..a18eb40 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ MVP: - Wallet init, seed verify - cmd line args - arg for DB file +- when polling for RecLN, use original mint, not current (save the mint with the req) Non-MVP: - send EC from multiple mints, select automatically (feature on which level?) diff --git a/parakesh-common/src/pk_app.rs b/parakesh-common/src/pk_app.rs index 0b05c57..bb8b3da 100644 --- a/parakesh-common/src/pk_app.rs +++ b/parakesh-common/src/pk_app.rs @@ -514,6 +514,32 @@ impl PKApp { Err("No selected mint!".to_owned()) } } + + pub fn get_recommended_mint_list() -> Vec<(String, String)> { + return vec![ + ( + "https://mint.minibits.cash/Bitcoin".to_owned(), + "MiniBits".to_owned(), + ), + ("https://21mint.me".to_owned(), "21mint".to_owned()), + ( + "https://mint.lnwallet.app".to_owned(), + "LNWallet".to_owned(), + ), + ( + "https://testnut.cashu.space".to_owned(), + "Test (cashu.space)".to_owned(), + ), + ( + "https://fake.thesimplekid.dev".to_owned(), + "Test (simplekid".to_owned(), + ), + ( + "https://cashu.mutinynet.com".to_owned(), + "Test, on MutinyNet)".to_owned(), + ), + ]; + } } impl MintFromLnIntermediaryResult { diff --git a/parakesh-common/src/pk_app_async.rs b/parakesh-common/src/pk_app_async.rs index 89665ce..fe83e1c 100644 --- a/parakesh-common/src/pk_app_async.rs +++ b/parakesh-common/src/pk_app_async.rs @@ -489,4 +489,7 @@ impl PKAppAsync { pub fn send_ec(&mut self, amount_sats: u64) -> Result<(), String> { self.send_to_incoming(AppRequest::SendEC(amount_sats)) } + pub fn get_recommended_mint_list() -> Vec<(String, String)> { + PKApp::get_recommended_mint_list() + } } diff --git a/parakesh-ui/src/ui.rs b/parakesh-ui/src/ui.rs index c7cd4ad..33da65e 100644 --- a/parakesh-ui/src/ui.rs +++ b/parakesh-ui/src/ui.rs @@ -57,6 +57,7 @@ pub(crate) struct IcedApp { balance: Option, mints_info: Vec, main_tab: UiMainTab, + reccomended_mints: Vec<(String, String)>, amount_input: String, invoice_input: String, @@ -261,33 +262,47 @@ impl IcedApp { .map(|wi| wi.selected_mint_url.to_string()) .unwrap_or("?".to_owned()); - let mints_ui: Column<'_, Message, Theme, Renderer> = - Column::with_children(self.mints_info.iter().map(|mi| { - mouse_area(row![ - text(mi.url.to_string()) - .font(MyFonts::bold_if(mi.url.to_string() == selected_mint)) - .size(15) - .width(300), - text(format!(" {}", mi.balance)) - .font(MyFonts::bold_if(mi.url.to_string() == selected_mint)) - .size(15), - ]) - .on_press(Message::SelectMint(mi.url.to_string())) - .into() - })); - column![ - row![text("Mints:").size(20)], - row![text("Selected: ").size(15), text(selected_mint).size(15),], - row![text("List (click to select)").size(15),], - mints_ui, + let mut contents = Vec::new(); + if self.mints_info.len() == 0 { + contents.push(row![text("No Mint added").size(20)]); + contents.push(row![text("Add a mint").size(20)]); + } else { + contents.push(row![text("Mints:").size(20)]); + contents.push(row![ + text("Selected: ").size(15), + text(selected_mint.clone()).size(15), + ]); + if self.mints_info.len() > 1 { + let mints_ui: Column<'_, Message, Theme, Renderer> = + Column::with_children(self.mints_info.iter().map(|mi| { + mouse_area(row![ + text(mi.url.to_string()) + .font(MyFonts::bold_if(mi.url.to_string() == selected_mint)) + .size(15) + .width(300), + text(format!(" {}", mi.balance)) + .font(MyFonts::bold_if(mi.url.to_string() == selected_mint)) + .size(15), + ]) + .on_press(Message::SelectMint(mi.url.to_string())) + .into() + })); + contents.push(row![text("List (click to select)").size(15),]); + contents.push(row![mints_ui]); + } + } + // Add mint is common + contents.push( row![ button("Add Mint:").on_press(Message::AddMint(self.add_mint_input.clone())), text_input("(mint url)", &self.add_mint_input) .on_input(Message::AddMintInput) .size(20) - .width(200), + .width(400), ] .spacing(10), + ); + contents.push( row![text(match &self.add_mint_state { AddMintState::NotRequested => "-".to_owned(), AddMintState::Requested => "Add in progress...".to_owned(), @@ -296,9 +311,22 @@ impl IcedApp { }) .size(15),] .spacing(10), - ] - .spacing(10) - .into() + ); + contents.push(row![text( + "You can also select a mint for addition from this list:" + ) + .size(15)]); + let recommended_mints_ui: Column<'_, Message, Theme, Renderer> = + Column::with_children(self.reccomended_mints.iter().map(|(url, info)| { + mouse_area(row![text(format!("{} - {}", info, url)).size(15),]) + .on_press(Message::AddMintInput(url.clone())) + .into() + })); + contents.push(row![recommended_mints_ui]); + + Column::with_children(contents.into_iter().map(|e| e.into())) + .spacing(10) + .into() } fn view_settings(&self) -> Element { @@ -383,7 +411,8 @@ impl IcedApp { wallet_info: None, balance: None, mints_info: Vec::new(), - main_tab: UiMainTab::RecLN, + reccomended_mints: PKAppAsync::get_recommended_mint_list(), + main_tab: UiMainTab::Mints, amount_input: "0".to_owned(), invoice_input: "".to_owned(), token_input: "".to_owned(),