mirror of
https://github.com/jwinterm/grim.git
synced 2026-10-20 15:28:31 +02:00
wallet + ui: optimize loading, retry button for non-success loading, update translations
This commit is contained in:
@@ -18,7 +18,7 @@ use grin_core::global::ChainTypes;
|
||||
|
||||
use crate::AppConfig;
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{ARROW_LEFT, CARET_RIGHT, COMPUTER_TOWER, EYE, EYE_SLASH, FOLDER_LOCK, FOLDER_OPEN, GEAR, GLOBE, GLOBE_SIMPLE, LOCK_KEY, PLUS, SIDEBAR_SIMPLE, SUITCASE};
|
||||
use crate::gui::icons::{ARROW_LEFT, CARET_RIGHT, COMPUTER_TOWER, EYE, EYE_SLASH, FOLDER_LOCK, FOLDER_OPEN, GEAR, GLOBE, GLOBE_SIMPLE, LOCK_KEY, PLUS, SIDEBAR_SIMPLE, SPINNER, SUITCASE, WARNING_CIRCLE};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Modal, Root, TitlePanel, View};
|
||||
use crate::gui::views::types::{ModalContainer, ModalPosition, TitleType};
|
||||
@@ -408,7 +408,15 @@ impl WalletsContent {
|
||||
|
||||
// Setup wallet status text.
|
||||
let status_text = if wallet.is_open() {
|
||||
format!("{} {}", FOLDER_OPEN, t!("wallets.unlocked"))
|
||||
if wallet.get_info().is_none() {
|
||||
if wallet.loading_error() {
|
||||
format!("{} {}", WARNING_CIRCLE, t!("loading_error"))
|
||||
} else {
|
||||
format!("{} {}", SPINNER, t!("loading"))
|
||||
}
|
||||
} else {
|
||||
format!("{} {}", FOLDER_OPEN, t!("wallets.unlocked"))
|
||||
}
|
||||
} else {
|
||||
format!("{} {}", FOLDER_LOCK, t!("wallets.locked"))
|
||||
};
|
||||
@@ -532,7 +540,7 @@ impl WalletsContent {
|
||||
if self.pass_edit.is_empty() {
|
||||
return;
|
||||
}
|
||||
match self.wallets.launch_selected(self.pass_edit.clone()) {
|
||||
match self.wallets.open_selected(self.pass_edit.clone()) {
|
||||
Ok(_) => {
|
||||
// Clear values.
|
||||
self.pass_edit = "".to_string();
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use egui::{Margin, RichText};
|
||||
use grin_chain::SyncStatus;
|
||||
|
||||
use crate::AppConfig;
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::icons::{DOWNLOAD, GEAR_FINE, POWER, UPLOAD, WALLET};
|
||||
use crate::gui::icons::{DOWNLOAD, GEAR_FINE, POWER, REPEAT, UPLOAD, WALLET};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::views::{Root, View};
|
||||
use crate::gui::views::wallets::{WalletInfo, WalletReceive, WalletSend, WalletSettings};
|
||||
@@ -119,48 +121,63 @@ impl WalletContent {
|
||||
});
|
||||
}
|
||||
|
||||
/// Content to draw when wallet is loading.
|
||||
pub fn show_loading_ui(ui: &mut egui::Ui, frame: &mut eframe::Frame, wallet: &Wallet) -> bool {
|
||||
if wallet.config.ext_conn_id.is_none() && !Node::is_running() {
|
||||
let dual_panel_root = Root::is_dual_panel_mode(frame);
|
||||
View::center_content(ui, if !dual_panel_root { 162.0 } else { 96.0 }, |ui| {
|
||||
let text = t!("wallets.enable_node", "settings" => GEAR_FINE);
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::INACTIVE_TEXT));
|
||||
// Show button to enable integrated node at non-dual root panel mode.
|
||||
if !dual_panel_root {
|
||||
/// Content to draw when wallet is loading, returns `true` if wallet is not ready.
|
||||
pub fn loading_ui(ui: &mut egui::Ui, frame: &mut eframe::Frame, wallet: &Wallet) -> bool {
|
||||
if wallet.config.ext_conn_id.is_none() {
|
||||
if !Node::is_running() || Node::is_stopping() {
|
||||
let dual_panel_root = Root::is_dual_panel_mode(frame);
|
||||
View::center_content(ui, if !dual_panel_root { 162.0 } else { 96.0 }, |ui| {
|
||||
let text = t!("wallets.enable_node", "settings" => GEAR_FINE);
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::INACTIVE_TEXT));
|
||||
ui.add_space(8.0);
|
||||
let enable_node_text = format!("{} {}", POWER, t!("network.enable_node"));
|
||||
View::button(ui, enable_node_text, Colors::GOLD, || {
|
||||
Node::start();
|
||||
});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
if wallet.get_info().is_none() || wallet.loading_progress() < 100 {
|
||||
if wallet.loading_error() {
|
||||
View::center_content(ui, 96.0, |ui| {
|
||||
let text = t!("wallets.wallet_loading_err", "settings" => GEAR_FINE);
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::INACTIVE_TEXT));
|
||||
});
|
||||
} else {
|
||||
View::center_content(ui, 162.0, |ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
ui.add_space(18.0);
|
||||
// Setup loading progress text.
|
||||
let progress = wallet.loading_progress();
|
||||
let text = if progress == 0 {
|
||||
t!("wallets.wallet_loading")
|
||||
} else {
|
||||
format!("{}: {}%", t!("wallets.wallet_loading"), progress)
|
||||
};
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::INACTIVE_TEXT));
|
||||
});
|
||||
}
|
||||
// Show button to enable integrated node at non-dual root panel mode
|
||||
// or when network connections are not showing and node is not stopping
|
||||
if (!dual_panel_root || AppConfig::show_connections_network_panel())
|
||||
&& !Node::is_stopping() {
|
||||
let enable_node_text = format!("{} {}", POWER, t!("network.enable_node"));
|
||||
View::button(ui, enable_node_text, Colors::GOLD, || {
|
||||
Node::start();
|
||||
});
|
||||
}
|
||||
});
|
||||
return true
|
||||
} else if wallet.get_info().is_none() {
|
||||
Self::progress_ui(ui, wallet);
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
} else if wallet.get_info().is_none() {
|
||||
// Show error message with button to retry on wallet loading error or loading progress.
|
||||
if wallet.loading_error() {
|
||||
View::center_content(ui, 162.0, |ui| {
|
||||
let text = t!("wallets.wallet_loading_err", "settings" => GEAR_FINE);
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::INACTIVE_TEXT));
|
||||
ui.add_space(8.0);
|
||||
let retry_text = format!("{} {}", REPEAT, t!("retry"));
|
||||
View::button(ui, retry_text, Colors::GOLD, || {
|
||||
wallet.set_loading_error(false);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
Self::progress_ui(ui, wallet);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Draw wallet loading progress.
|
||||
fn progress_ui(ui: &mut egui::Ui, wallet: &Wallet) {
|
||||
View::center_content(ui, 162.0, |ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
ui.add_space(18.0);
|
||||
// Setup loading progress text.
|
||||
let progress = wallet.loading_progress();
|
||||
let text = if progress == 0 {
|
||||
t!("wallets.wallet_loading")
|
||||
} else {
|
||||
format!("{}: {}%", t!("wallets.wallet_loading"), progress)
|
||||
};
|
||||
ui.label(RichText::new(text).size(16.0).color(Colors::INACTIVE_TEXT));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,6 @@ impl WalletTab for WalletInfo {
|
||||
frame: &mut eframe::Frame,
|
||||
wallet: &Wallet,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
WalletContent::show_loading_ui(ui, frame, wallet);
|
||||
WalletContent::loading_ui(ui, frame, wallet);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user