ui + wallets: wallet connection settings, reopen wallet on connection change, recreate wallet instance on opening, update translations, wallet instance refactoring

This commit is contained in:
ardocrat
2023-08-12 04:24:23 +03:00
parent f5d213bb4c
commit e86cba50ca
18 changed files with 509 additions and 193 deletions
+8 -6
View File
@@ -46,6 +46,8 @@ impl WalletContent {
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
// Show wallet tabs panel.
let not_show_tabs =
wallet.is_closing() || (wallet.get_data().is_none() && !wallet.load_error());
egui::TopBottomPanel::bottom("wallet_tabs")
.frame(egui::Frame {
fill: Colors::FILL,
@@ -57,7 +59,7 @@ impl WalletContent {
},
..Default::default()
})
.show_inside(ui, |ui| {
.show_animated_inside(ui, !not_show_tabs, |ui| {
ui.vertical_centered(|ui| {
// Setup tabs width.
let available_width = ui.available_width();
@@ -172,7 +174,7 @@ impl WalletContent {
}
});
return true
} else if wallet.loading_error()
} else if wallet.load_error()
&& Node::get_sync_status() == Some(SyncStatus::NoSync) {
Self::loading_error_ui(ui, wallet);
return true;
@@ -181,7 +183,7 @@ impl WalletContent {
return true;
}
} else if wallet.get_data().is_none() {
if wallet.loading_error() {
if wallet.load_error() {
Self::loading_error_ui(ui, wallet);
} else {
Self::loading_progress_ui(ui, wallet);
@@ -199,7 +201,7 @@ impl WalletContent {
ui.add_space(8.0);
let retry_text = format!("{} {}", REPEAT, t!("retry"));
View::button(ui, retry_text, Colors::GOLD, || {
wallet.set_loading_error(false);
wallet.set_load_error(false);
});
});
}
@@ -211,7 +213,7 @@ impl WalletContent {
ui.add_space(18.0);
// Setup loading progress text.
let text = {
let info_progress = wallet.info_loading_progress();
let info_progress = wallet.info_load_progress();
if wallet.is_closing() {
t!("wallets.wallet_closing")
} else if info_progress != 100 {
@@ -221,7 +223,7 @@ impl WalletContent {
format!("{}: {}%", t!("wallets.wallet_loading"), info_progress)
}
} else {
let tx_progress = wallet.txs_loading_progress();
let tx_progress = wallet.txs_load_progress();
if tx_progress == 0 {
t!("wallets.tx_loading")
} else {
+3 -1
View File
@@ -32,6 +32,8 @@ impl WalletTab for WalletInfo {
frame: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
WalletContent::loading_ui(ui, frame, wallet);
if WalletContent::loading_ui(ui, frame, wallet) {
return;
}
}
}
+4
View File
@@ -14,6 +14,7 @@
use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::wallets::wallet::types::{WalletTab, WalletTabType};
use crate::gui::views::wallets::wallet::WalletContent;
use crate::wallet::Wallet;
/// Receive funds tab content.
@@ -30,5 +31,8 @@ impl WalletTab for WalletReceive {
frame: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
if WalletContent::loading_ui(ui, frame, wallet) {
return;
}
}
}
+4
View File
@@ -14,6 +14,7 @@
use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::wallets::wallet::types::{WalletTab, WalletTabType};
use crate::gui::views::wallets::wallet::WalletContent;
use crate::wallet::Wallet;
/// Send funds tab content.
@@ -30,5 +31,8 @@ impl WalletTab for WalletSend {
frame: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
if WalletContent::loading_ui(ui, frame, wallet) {
return;
}
}
}
+18 -2
View File
@@ -15,15 +15,25 @@
use crate::gui::platform::PlatformCallbacks;
use crate::gui::views::wallets::setup::ConnectionSetup;
use crate::gui::views::wallets::wallet::types::{WalletTab, WalletTabType};
use crate::wallet::Wallet;
use crate::gui::views::wallets::wallet::WalletContent;
use crate::wallet::{ExternalConnection, Wallet};
/// Wallet settings tab content.
#[derive(Default)]
pub struct WalletSettings {
/// Connection setup content.
conn_setup: ConnectionSetup
}
impl Default for WalletSettings {
fn default() -> Self {
// Check external connections availability on first tab opening.
ExternalConnection::start_ext_conn_availability_check();
Self {
conn_setup: ConnectionSetup::default(),
}
}
}
impl WalletTab for WalletSettings {
fn get_type(&self) -> WalletTabType {
WalletTabType::Settings
@@ -34,6 +44,12 @@ impl WalletTab for WalletSettings {
frame: &mut eframe::Frame,
wallet: &mut Wallet,
cb: &dyn PlatformCallbacks) {
// Show progress if wallet is loading after opening without an error.
if wallet.is_closing() || (wallet.get_data().is_none() && !wallet.load_error()) {
WalletContent::loading_progress_ui(ui, wallet);
return;
}
self.conn_setup.wallet_ui(ui, frame, wallet, cb);
}
}