ui: network loading content
This commit is contained in:
parent
e9a7feb7c3
commit
c66b44db9b
4 changed files with 28 additions and 27 deletions
|
@ -26,7 +26,7 @@ use crate::node::Node;
|
|||
|
||||
/// Network content.
|
||||
pub struct NetworkContent {
|
||||
/// Current tab view to show at ui.
|
||||
/// Current tab content to show.
|
||||
current_tab: Box<dyn NetworkTab>,
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ impl NetworkContent {
|
|||
top: 4.0,
|
||||
bottom: View::get_bottom_inset() + 4.0,
|
||||
},
|
||||
..Default::defaulDrawt()
|
||||
..Default::default()
|
||||
})
|
||||
.show_inside(ui, |ui| {
|
||||
self.tabs_ui(ui);
|
||||
|
@ -156,6 +156,27 @@ impl NetworkContent {
|
|||
});
|
||||
}
|
||||
|
||||
/// Content to draw on loading.
|
||||
pub fn loading_ui(ui: &mut egui::Ui, text: Option<String>) {
|
||||
match text {
|
||||
None => {
|
||||
ui.centered_and_justified(|ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
});
|
||||
}
|
||||
Some(t) => {
|
||||
View::center_content(ui, 162.0, |ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
ui.add_space(18.0);
|
||||
ui.label(RichText::new(t)
|
||||
.size(16.0)
|
||||
.color(Colors::INACTIVE_TEXT)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Draw checkbox to run integrated node on application launch.
|
||||
pub fn autorun_node_ui(ui: &mut egui::Ui) {
|
||||
let autostart = AppConfig::autostart_node();
|
||||
|
|
|
@ -46,23 +46,14 @@ impl NetworkTab for NetworkMetrics {
|
|||
|
||||
// Show loading spinner when node is stopping.
|
||||
if Node::is_stopping() {
|
||||
ui.centered_and_justified(|ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
});
|
||||
NetworkContent::loading_ui(ui, None);
|
||||
return;
|
||||
}
|
||||
|
||||
// Show message when metrics are not available.
|
||||
if server_stats.is_none() || Node::is_restarting()
|
||||
|| server_stats.as_ref().unwrap().diff_stats.height == 0 {
|
||||
View::center_content(ui, 162.0, |ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
ui.add_space(18.0);
|
||||
ui.label(RichText::new(t!("network_metrics.loading"))
|
||||
.size(16.0)
|
||||
.color(Colors::INACTIVE_TEXT)
|
||||
);
|
||||
});
|
||||
NetworkContent::loading_ui(ui, Some(t!("network_metrics.loading")));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,23 +55,14 @@ impl NetworkTab for NetworkMining {
|
|||
|
||||
// Show loading spinner when node is stopping or stratum server is starting.
|
||||
if Node::is_stopping() || Node::is_stratum_starting() {
|
||||
ui.centered_and_justified(|ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
});
|
||||
NetworkContent::loading_ui(ui, None);
|
||||
return;
|
||||
}
|
||||
|
||||
// Show message when mining is not available.
|
||||
if server_stats.is_none() || Node::is_restarting()
|
||||
|| Node::get_sync_status().unwrap() != SyncStatus::NoSync {
|
||||
View::center_content(ui, 162.0, |ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
ui.add_space(18.0);
|
||||
ui.label(RichText::new(t!("network_mining.loading"))
|
||||
.size(16.0)
|
||||
.color(Colors::INACTIVE_TEXT)
|
||||
);
|
||||
});
|
||||
NetworkContent::loading_ui(ui, Some(t!("network_mining.loading")));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,7 @@ impl NetworkTab for NetworkNode {
|
|||
|
||||
// Show loading spinner when stats are not available.
|
||||
if server_stats.is_none() || Node::is_restarting() || Node::is_stopping() {
|
||||
ui.centered_and_justified(|ui| {
|
||||
View::big_loading_spinner(ui);
|
||||
});
|
||||
NetworkContent::loading_ui(ui, None);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue