diff --git a/locales/en.yml b/locales/en.yml index 2619f46..9ec01dc 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -22,7 +22,7 @@ wallets: await_conf_amount: Awaiting confirmation await_fin_amount: Awaiting finalization locked_amount: Locked - txs_empty: 'To receive or send funds manually or through transport use %{message} or %{transport} buttons at the bottom of the screen, to change wallet settings press %{settings}.' + txs_empty: 'To receive funds manually or over transport use %{message} or %{transport} buttons at the bottom of the screen, to change wallet settings press %{settings} button.' title: Wallets create_desc: Create or import existing wallet from saved recovery phrase. add: Add wallet diff --git a/locales/ru.yml b/locales/ru.yml index 6007c82..a732741 100644 --- a/locales/ru.yml +++ b/locales/ru.yml @@ -22,7 +22,7 @@ wallets: await_conf_amount: Ожидает подтверждения await_fin_amount: Ожидает завершения locked_amount: Заблокировано - txs_empty: 'Для получения или отправки средств вручную или через транспорт используйте кнопки %{message} или %{transport} внизу экрана, для изменения настроек кошелька нажмите %{settings}.' + txs_empty: 'Для получения средств вручную или через транспорт используйте кнопки %{message} или %{transport} внизу экрана, для изменения настроек кошелька нажмите кнопку %{settings}.' title: Кошельки create_desc: Создайте или импортируйте существующий кошелёк из сохранённой фразы восстановления. add: Добавить кошелёк @@ -113,7 +113,7 @@ wallets: settings: Настройки кошелька change_server_confirmation: Для применения изменения настроек соединения необходимо переоткрыть кошелёк. Переоткрыть его сейчас? transport: - desc: 'Используйте транспорт для синхронного получения или отправки сообщений:' + desc: 'Используйте транспорт для синхронных получения или отправки сообщений:' tor_network: Сеть Tor connected: Подключено connecting: Подключение diff --git a/src/gui/views/wallets/wallet/messages.rs b/src/gui/views/wallets/wallet/messages.rs index dd55051..b5c39b9 100644 --- a/src/gui/views/wallets/wallet/messages.rs +++ b/src/gui/views/wallets/wallet/messages.rs @@ -148,7 +148,7 @@ impl WalletMessages { ui.add_space(3.0); // Show creation of request to send or receive funds. - self.request_ui(ui, cb); + self.request_ui(ui, wallet, cb); ui.add_space(12.0); View::horizontal_line(ui, Colors::ITEM_STROKE); @@ -183,48 +183,61 @@ impl WalletMessages { /// Draw creation of request to send or receive funds. fn request_ui(&mut self, ui: &mut egui::Ui, + wallet: &Wallet, cb: &dyn PlatformCallbacks) { ui.label(RichText::new(t!("wallets.create_request_desc")) .size(16.0) .color(Colors::INACTIVE_TEXT)); ui.add_space(7.0); - // Setup spacing between buttons. - ui.spacing_mut().item_spacing = egui::Vec2::new(6.0, 0.0); + // Show send button only if balance is not empty. + let data = wallet.get_data().unwrap(); + if data.info.amount_currently_spendable > 0 { + // Setup spacing between buttons. + ui.spacing_mut().item_spacing = egui::Vec2::new(6.0, 0.0); - ui.columns(2, |columns| { - columns[0].vertical_centered_justified(|ui| { - // Draw send request creation button. - let send_text = format!("{} {}", UPLOAD_SIMPLE, t!("wallets.send")); - View::button(ui, send_text, Colors::BUTTON, || { - // Setup modal values. - self.send_request = true; - self.amount_edit = "".to_string(); - self.request_error = None; - // Show send amount modal. - Modal::new(AMOUNT_MODAL) - .position(ModalPosition::CenterTop) - .title(t!("wallets.send")) - .show(); - cb.show_keyboard(); - }); - }); - columns[1].vertical_centered_justified(|ui| { - // Draw invoice request creation button. - let receive_text = format!("{} {}", DOWNLOAD_SIMPLE, t!("wallets.receive")); - View::button(ui, receive_text, Colors::BUTTON, || { - // Setup modal values. - self.send_request = false; - self.amount_edit = "".to_string(); - self.request_error = None; - // Show receive amount modal. - Modal::new(AMOUNT_MODAL) - .position(ModalPosition::CenterTop) - .title(t!("wallets.receive")) - .show(); - cb.show_keyboard(); + ui.columns(2, |columns| { + columns[0].vertical_centered_justified(|ui| { + // Draw send request creation button. + let send_text = format!("{} {}", UPLOAD_SIMPLE, t!("wallets.send")); + View::button(ui, send_text, Colors::BUTTON, || { + // Setup modal values. + self.send_request = true; + self.amount_edit = "".to_string(); + self.request_error = None; + // Show send amount modal. + Modal::new(AMOUNT_MODAL) + .position(ModalPosition::CenterTop) + .title(t!("wallets.send")) + .show(); + cb.show_keyboard(); + }); + }); + columns[1].vertical_centered_justified(|ui| { + // Draw invoice request creation button. + self.receive_button_ui(ui, cb); }); }); + } else { + // Draw invoice creation button. + self.receive_button_ui(ui, cb); + } + } + + /// Draw invoice request creation button. + fn receive_button_ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks) { + let receive_text = format!("{} {}", DOWNLOAD_SIMPLE, t!("wallets.receive")); + View::button(ui, receive_text, Colors::BUTTON, || { + // Setup modal values. + self.send_request = false; + self.amount_edit = "".to_string(); + self.request_error = None; + // Show receive amount modal. + Modal::new(AMOUNT_MODAL) + .position(ModalPosition::CenterTop) + .title(t!("wallets.receive")) + .show(); + cb.show_keyboard(); }); } diff --git a/src/gui/views/wallets/wallet/transport.rs b/src/gui/views/wallets/wallet/transport.rs index d7c2af7..6dacb84 100644 --- a/src/gui/views/wallets/wallet/transport.rs +++ b/src/gui/views/wallets/wallet/transport.rs @@ -27,6 +27,7 @@ use crate::gui::views::types::{ModalPosition, TextEditOptions}; use crate::gui::views::wallets::wallet::types::{WalletTab, WalletTabType}; use crate::gui::views::wallets::wallet::WalletContent; use crate::tor::Tor; +use crate::wallet::types::WalletData; use crate::wallet::Wallet; /// Wallet transport tab content. @@ -153,20 +154,24 @@ impl WalletTransport { /// Draw Tor transport content. fn tor_ui(&mut self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) { + let data = wallet.get_data().unwrap(); + // Draw header content. self.tor_header_ui(ui, wallet); // Draw receive info content. if wallet.slatepack_address().is_some() { - self.tor_receive_ui(ui, wallet, cb); + self.tor_receive_ui(ui, wallet, &data, cb); } // Draw send content. - self.tor_send_ui(ui, cb); + if data.info.amount_currently_spendable > 0 { + self.tor_send_ui(ui, cb); + } } /// Draw Tor transport header content. - fn tor_header_ui(&self, ui: &mut egui::Ui, wallet: &mut Wallet) { + fn tor_header_ui(&self, ui: &mut egui::Ui, wallet: &Wallet) { // Setup layout size. let mut rect = ui.available_rect_before_wrap(); rect.set_height(78.0); @@ -245,7 +250,7 @@ impl WalletTransport { } /// Draw tor transport settings [`Modal`] content. - fn tor_settings_modal_ui(&self, ui: &mut egui::Ui, wallet: &mut Wallet, modal: &Modal) { + fn tor_settings_modal_ui(&self, ui: &mut egui::Ui, wallet: &Wallet, modal: &Modal) { ui.add_space(6.0); ui.vertical_centered(|ui| { ui.label(RichText::new(t!("transport.tor_autorun_desc")) @@ -268,9 +273,14 @@ impl WalletTransport { } /// Draw Tor send content. - fn tor_receive_ui(&self, ui: &mut egui::Ui, wallet: &mut Wallet, cb: &dyn PlatformCallbacks) { + fn tor_receive_ui(&self, + ui: &mut egui::Ui, + wallet: &Wallet, + data: &WalletData, + cb: &dyn PlatformCallbacks) { let slatepack_addr = wallet.slatepack_address().unwrap(); let service_id = &wallet.identifier(); + let can_send = data.info.amount_currently_spendable > 0; // Setup layout size. let mut rect = ui.available_rect_before_wrap(); @@ -278,13 +288,21 @@ impl WalletTransport { // Draw round background. let bg_rect = rect.clone(); - let item_rounding = View::item_rounding(1, 3, false); + let item_rounding = if can_send { + View::item_rounding(1, 3, false) + } else { + View::item_rounding(1, 2, false) + }; ui.painter().rect(bg_rect, item_rounding, Colors::BUTTON, View::ITEM_STROKE); ui.vertical(|ui| { ui.allocate_ui_with_layout(rect.size(), Layout::right_to_left(Align::Center), |ui| { // Draw button to setup Tor transport. - let button_rounding = View::item_rounding(1, 3, true); + let button_rounding = if can_send { + View::item_rounding(1, 3, true) + } else { + View::item_rounding(1, 2, true) + }; View::item_button(ui, button_rounding, QR_CODE, None, || { //TODO: qr for address });