ui: rename wallets and network content files
This commit is contained in:
parent
00767dd7e0
commit
5add102637
9 changed files with 25 additions and 26 deletions
|
@ -25,14 +25,14 @@ use crate::gui::views::types::{NetworkTab, NetworkTabType};
|
||||||
use crate::node::Node;
|
use crate::node::Node;
|
||||||
|
|
||||||
/// Network content.
|
/// Network content.
|
||||||
pub struct Network {
|
pub struct NetworkContent {
|
||||||
/// Current tab view to show at ui.
|
/// Current tab view to show at ui.
|
||||||
current_tab: Box<dyn NetworkTab>,
|
current_tab: Box<dyn NetworkTab>,
|
||||||
/// [`Modal`] ids allowed at this ui container.
|
/// [`Modal`] ids allowed at this ui container.
|
||||||
modal_ids: Vec<&'static str>,
|
modal_ids: Vec<&'static str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Network {
|
impl Default for NetworkContent {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
current_tab: Box::new(NetworkNode::default()),
|
current_tab: Box::new(NetworkNode::default()),
|
||||||
|
@ -75,13 +75,13 @@ impl Default for Network {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModalContainer for Network {
|
impl ModalContainer for NetworkContent {
|
||||||
fn modal_ids(&self) -> &Vec<&'static str> {
|
fn modal_ids(&self) -> &Vec<&'static str> {
|
||||||
self.modal_ids.as_ref()
|
self.modal_ids.as_ref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Network {
|
impl NetworkContent {
|
||||||
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
pub fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame, cb: &dyn PlatformCallbacks) {
|
||||||
// Show modal content for current ui container.
|
// Show modal content for current ui container.
|
||||||
if self.can_draw_modal() {
|
if self.can_draw_modal() {
|
|
@ -19,7 +19,7 @@ use grin_servers::DiffBlock;
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::icons::{AT, COINS, CUBE_TRANSPARENT, HASH, HOURGLASS_LOW, HOURGLASS_MEDIUM, TIMER};
|
use crate::gui::icons::{AT, COINS, CUBE_TRANSPARENT, HASH, HOURGLASS_LOW, HOURGLASS_MEDIUM, TIMER};
|
||||||
use crate::gui::platform::PlatformCallbacks;
|
use crate::gui::platform::PlatformCallbacks;
|
||||||
use crate::gui::views::{Modal, Network, View};
|
use crate::gui::views::{Modal, NetworkContent, View};
|
||||||
use crate::gui::views::types::{NetworkTab, NetworkTabType};
|
use crate::gui::views::types::{NetworkTab, NetworkTabType};
|
||||||
use crate::node::Node;
|
use crate::node::Node;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ impl NetworkTab for NetworkMetrics {
|
||||||
let server_stats = Node::get_stats();
|
let server_stats = Node::get_stats();
|
||||||
// Show message to enable node when it's not running.
|
// Show message to enable node when it's not running.
|
||||||
if !Node::is_running() {
|
if !Node::is_running() {
|
||||||
Network::disabled_node_ui(ui);
|
NetworkContent::disabled_node_ui(ui);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use grin_servers::WorkerStats;
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::icons::{BARBELL, CLOCK_AFTERNOON, CPU, CUBE, FADERS, FOLDER_DASHED, FOLDER_SIMPLE_MINUS, FOLDER_SIMPLE_PLUS, HARD_DRIVES, PLUGS, PLUGS_CONNECTED, POLYGON};
|
use crate::gui::icons::{BARBELL, CLOCK_AFTERNOON, CPU, CUBE, FADERS, FOLDER_DASHED, FOLDER_SIMPLE_MINUS, FOLDER_SIMPLE_PLUS, HARD_DRIVES, PLUGS, PLUGS_CONNECTED, POLYGON};
|
||||||
use crate::gui::platform::PlatformCallbacks;
|
use crate::gui::platform::PlatformCallbacks;
|
||||||
use crate::gui::views::{Modal, Network, View};
|
use crate::gui::views::{Modal, NetworkContent, View};
|
||||||
use crate::gui::views::network::setup::StratumSetup;
|
use crate::gui::views::network::setup::StratumSetup;
|
||||||
use crate::gui::views::types::{NetworkTab, NetworkTabType};
|
use crate::gui::views::types::{NetworkTab, NetworkTabType};
|
||||||
use crate::node::{Node, NodeConfig};
|
use crate::node::{Node, NodeConfig};
|
||||||
|
@ -41,7 +41,7 @@ impl NetworkTab for NetworkMining {
|
||||||
|
|
||||||
// Show message to enable node when it's not running.
|
// Show message to enable node when it's not running.
|
||||||
if !Node::is_running() {
|
if !Node::is_running() {
|
||||||
Network::disabled_node_ui(ui);
|
NetworkContent::disabled_node_ui(ui);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ pub use node::*;
|
||||||
mod setup;
|
mod setup;
|
||||||
pub use setup::*;
|
pub use setup::*;
|
||||||
|
|
||||||
mod network;
|
mod content;
|
||||||
pub use network::*;
|
pub use content::*;
|
||||||
|
|
||||||
mod connections;
|
mod connections;
|
||||||
pub use connections::*;
|
pub use connections::*;
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use eframe::epaint::Stroke;
|
|
||||||
use egui::{RichText, Rounding, ScrollArea};
|
use egui::{RichText, Rounding, ScrollArea};
|
||||||
use grin_servers::PeerStats;
|
use grin_servers::PeerStats;
|
||||||
|
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::icons::{AT, CUBE, DEVICES, FLOW_ARROW, HANDSHAKE, PACKAGE, PLUGS_CONNECTED, SHARE_NETWORK};
|
use crate::gui::icons::{AT, CUBE, DEVICES, FLOW_ARROW, HANDSHAKE, PACKAGE, PLUGS_CONNECTED, SHARE_NETWORK};
|
||||||
use crate::gui::platform::PlatformCallbacks;
|
use crate::gui::platform::PlatformCallbacks;
|
||||||
use crate::gui::views::{Modal, Network, View};
|
use crate::gui::views::{Modal, NetworkContent, View};
|
||||||
use crate::gui::views::types::{NetworkTab, NetworkTabType};
|
use crate::gui::views::types::{NetworkTab, NetworkTabType};
|
||||||
use crate::node::Node;
|
use crate::node::Node;
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ impl NetworkTab for NetworkNode {
|
||||||
let server_stats = Node::get_stats();
|
let server_stats = Node::get_stats();
|
||||||
// Show message to enable node when it's not running.
|
// Show message to enable node when it's not running.
|
||||||
if !Node::is_running() {
|
if !Node::is_running() {
|
||||||
Network::disabled_node_ui(ui);
|
NetworkContent::disabled_node_ui(ui);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::AppConfig;
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::icons::{CLIPBOARD_TEXT, CLOCK_CLOCKWISE, COMPUTER_TOWER, COPY, PLUG, POWER, SHIELD, SHIELD_SLASH};
|
use crate::gui::icons::{CLIPBOARD_TEXT, CLOCK_CLOCKWISE, COMPUTER_TOWER, COPY, PLUG, POWER, SHIELD, SHIELD_SLASH};
|
||||||
use crate::gui::platform::PlatformCallbacks;
|
use crate::gui::platform::PlatformCallbacks;
|
||||||
use crate::gui::views::{Modal, ModalPosition, Network, View};
|
use crate::gui::views::{Modal, ModalPosition, NetworkContent, View};
|
||||||
use crate::gui::views::network::settings::NetworkSettings;
|
use crate::gui::views::network::settings::NetworkSettings;
|
||||||
use crate::node::{Node, NodeConfig};
|
use crate::node::{Node, NodeConfig};
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ impl NodeSetup {
|
||||||
// Autorun node setup.
|
// Autorun node setup.
|
||||||
ui.vertical_centered(|ui| {
|
ui.vertical_centered(|ui| {
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
Network::autorun_node_ui(ui);
|
NetworkContent::autorun_node_ui(ui);
|
||||||
if Node::is_running() {
|
if Node::is_running() {
|
||||||
ui.add_space(2.0);
|
ui.add_space(2.0);
|
||||||
ui.label(RichText::new(t!("network_settings.restart_node_required"))
|
ui.label(RichText::new(t!("network_settings.restart_node_required"))
|
||||||
|
|
|
@ -20,18 +20,18 @@ use lazy_static::lazy_static;
|
||||||
|
|
||||||
use crate::gui::Colors;
|
use crate::gui::Colors;
|
||||||
use crate::gui::platform::PlatformCallbacks;
|
use crate::gui::platform::PlatformCallbacks;
|
||||||
use crate::gui::views::{Modal, ModalContainer, Network, View, WalletsContent};
|
use crate::gui::views::{Modal, ModalContainer, NetworkContent, View, WalletsContent};
|
||||||
use crate::node::Node;
|
use crate::node::Node;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// Global state to check if [`Network`] panel is open.
|
/// Global state to check if [`NetworkContent`] panel is open.
|
||||||
static ref NETWORK_PANEL_OPEN: AtomicBool = AtomicBool::new(false);
|
static ref NETWORK_PANEL_OPEN: AtomicBool = AtomicBool::new(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Contains main ui content, handles side panel state.
|
/// Contains main ui content, handles side panel state.
|
||||||
pub struct Root {
|
pub struct Root {
|
||||||
/// Side panel [`Network`] content.
|
/// Side panel [`NetworkContent`] content.
|
||||||
network: Network,
|
network: NetworkContent,
|
||||||
/// Central panel [`WalletsContent`] content.
|
/// Central panel [`WalletsContent`] content.
|
||||||
wallets: WalletsContent,
|
wallets: WalletsContent,
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ impl Default for Root {
|
||||||
let os = OperatingSystem::from_target_os();
|
let os = OperatingSystem::from_target_os();
|
||||||
let exit_allowed = os == OperatingSystem::Android || os == OperatingSystem::IOS;
|
let exit_allowed = os == OperatingSystem::Android || os == OperatingSystem::IOS;
|
||||||
Self {
|
Self {
|
||||||
network: Network::default(),
|
network: NetworkContent::default(),
|
||||||
wallets: WalletsContent::default(),
|
wallets: WalletsContent::default(),
|
||||||
exit_allowed,
|
exit_allowed,
|
||||||
show_exit_progress: false,
|
show_exit_progress: false,
|
||||||
|
@ -105,7 +105,7 @@ impl Root {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get [`Network`] panel state and width.
|
/// Get [`NetworkContent`] panel state and width.
|
||||||
fn network_panel_state_width(frame: &mut eframe::Frame) -> (bool, f32) {
|
fn network_panel_state_width(frame: &mut eframe::Frame) -> (bool, f32) {
|
||||||
let dual_panel_mode = Self::is_dual_panel_mode(frame);
|
let dual_panel_mode = Self::is_dual_panel_mode(frame);
|
||||||
let is_panel_open = dual_panel_mode || Self::is_network_panel_open();
|
let is_panel_open = dual_panel_mode || Self::is_network_panel_open();
|
||||||
|
@ -117,7 +117,7 @@ impl Root {
|
||||||
(is_panel_open, panel_width)
|
(is_panel_open, panel_width)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if ui can show [`Network`] and [`WalletsContent`] at same time.
|
/// Check if ui can show [`NetworkContent`] and [`WalletsContent`] at same time.
|
||||||
pub fn is_dual_panel_mode(frame: &mut eframe::Frame) -> bool {
|
pub fn is_dual_panel_mode(frame: &mut eframe::Frame) -> bool {
|
||||||
let w = frame.info().window_info.size.x;
|
let w = frame.info().window_info.size.x;
|
||||||
let h = frame.info().window_info.size.y;
|
let h = frame.info().window_info.size.y;
|
||||||
|
@ -129,13 +129,13 @@ impl Root {
|
||||||
is_wide_screen && w >= (Self::SIDE_PANEL_WIDTH * 2.0) + side_insets
|
is_wide_screen && w >= (Self::SIDE_PANEL_WIDTH * 2.0) + side_insets
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Toggle [`Network`] panel state.
|
/// Toggle [`NetworkContent`] panel state.
|
||||||
pub fn toggle_network_panel() {
|
pub fn toggle_network_panel() {
|
||||||
let is_open = NETWORK_PANEL_OPEN.load(Ordering::Relaxed);
|
let is_open = NETWORK_PANEL_OPEN.load(Ordering::Relaxed);
|
||||||
NETWORK_PANEL_OPEN.store(!is_open, Ordering::Relaxed);
|
NETWORK_PANEL_OPEN.store(!is_open, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if [`Network`] panel is open.
|
/// Check if [`NetworkContent`] panel is open.
|
||||||
pub fn is_network_panel_open() -> bool {
|
pub fn is_network_panel_open() -> bool {
|
||||||
NETWORK_PANEL_OPEN.load(Ordering::Relaxed)
|
NETWORK_PANEL_OPEN.load(Ordering::Relaxed)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,5 +16,5 @@ mod creation;
|
||||||
mod wallet;
|
mod wallet;
|
||||||
mod setup;
|
mod setup;
|
||||||
|
|
||||||
mod wallets;
|
mod content;
|
||||||
pub use wallets::*;
|
pub use content::*;
|
Loading…
Reference in a new issue