diff --git a/src/gui/views/network/metrics.rs b/src/gui/views/network/metrics.rs index 2129a14..f5f97bf 100644 --- a/src/gui/views/network/metrics.rs +++ b/src/gui/views/network/metrics.rs @@ -20,7 +20,7 @@ use crate::gui::Colors; use crate::gui::icons::{AT, COINS, CUBE_TRANSPARENT, HASH, HOURGLASS_LOW, HOURGLASS_MEDIUM, TIMER}; use crate::gui::platform::PlatformCallbacks; use crate::gui::views::{Modal, Network, View}; -use crate::gui::views::network::{NetworkTab, NetworkTabType}; +use crate::gui::views::types::{NetworkTab, NetworkTabType}; use crate::node::Node; /// Chain metrics tab content. diff --git a/src/gui/views/network/mining.rs b/src/gui/views/network/mining.rs index e0d6af1..86e5475 100644 --- a/src/gui/views/network/mining.rs +++ b/src/gui/views/network/mining.rs @@ -21,8 +21,8 @@ use crate::gui::Colors; use crate::gui::icons::{BARBELL, CLOCK_AFTERNOON, CPU, CUBE, FADERS, FOLDER_DASHED, FOLDER_NOTCH_MINUS, FOLDER_NOTCH_PLUS, HARD_DRIVES, PLUGS, PLUGS_CONNECTED, POLYGON}; use crate::gui::platform::PlatformCallbacks; use crate::gui::views::{Modal, Network, View}; -use crate::gui::views::network::{NetworkTab, NetworkTabType}; use crate::gui::views::network::setup::StratumSetup; +use crate::gui::views::types::{NetworkTab, NetworkTabType}; use crate::node::{Node, NodeConfig}; /// Mining tab content. diff --git a/src/gui/views/network/mod.rs b/src/gui/views/network/mod.rs index c716bd1..ac162d0 100644 --- a/src/gui/views/network/mod.rs +++ b/src/gui/views/network/mod.rs @@ -30,6 +30,7 @@ pub use setup::*; mod network; pub use network::*; - mod connections; -pub use connections::*; \ No newline at end of file +pub use connections::*; + +pub mod types; \ No newline at end of file diff --git a/src/gui/views/network/network.rs b/src/gui/views/network/network.rs index 0b2a647..e06b593 100644 --- a/src/gui/views/network/network.rs +++ b/src/gui/views/network/network.rs @@ -21,35 +21,9 @@ use crate::gui::icons::{CARDHOLDER, DATABASE, DOTS_THREE_OUTLINE_VERTICAL, FACTO use crate::gui::platform::PlatformCallbacks; use crate::gui::views::{Modal, ModalContainer, NetworkMetrics, NetworkMining, NetworkNode, NetworkSettings, Root, TitlePanel, TitleType, View}; use crate::gui::views::network::setup::{DandelionSetup, NodeSetup, P2PSetup, PoolSetup, StratumSetup}; +use crate::gui::views::types::{NetworkTab, NetworkTabType}; use crate::node::Node; -/// Network tab content interface. -pub trait NetworkTab { - fn get_type(&self) -> NetworkTabType; - fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks); - fn on_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks); -} - -/// Type of [`NetworkTab`] content. -#[derive(PartialEq)] -pub enum NetworkTabType { - Node, - Metrics, - Mining, - Settings -} - -impl NetworkTabType { - pub fn title(&self) -> String { - match *self { - NetworkTabType::Node => { t!("network.node") } - NetworkTabType::Metrics => { t!("network.metrics") } - NetworkTabType::Mining => { t!("network.mining") } - NetworkTabType::Settings => { t!("network.settings") } - } - } -} - /// Network content. pub struct Network { /// Current tab view to show at ui. diff --git a/src/gui/views/network/node.rs b/src/gui/views/network/node.rs index 0539ff7..704393d 100644 --- a/src/gui/views/network/node.rs +++ b/src/gui/views/network/node.rs @@ -19,8 +19,8 @@ use grin_servers::PeerStats; use crate::gui::Colors; use crate::gui::icons::{AT, CUBE, DEVICES, FLOW_ARROW, HANDSHAKE, PACKAGE, PLUGS_CONNECTED, SHARE_NETWORK}; use crate::gui::platform::PlatformCallbacks; -use crate::gui::views::{Modal, View}; -use crate::gui::views::network::{Network, NetworkTab, NetworkTabType}; +use crate::gui::views::{Modal, Network, View}; +use crate::gui::views::types::{NetworkTab, NetworkTabType}; use crate::node::Node; /// Integrated node tab content. diff --git a/src/gui/views/network/settings.rs b/src/gui/views/network/settings.rs index ff9d314..625c678 100644 --- a/src/gui/views/network/settings.rs +++ b/src/gui/views/network/settings.rs @@ -18,8 +18,8 @@ use crate::gui::Colors; use crate::gui::icons::ARROW_COUNTER_CLOCKWISE; use crate::gui::platform::PlatformCallbacks; use crate::gui::views::{Modal, ModalPosition, View}; -use crate::gui::views::network::{NetworkTab, NetworkTabType}; use crate::gui::views::network::setup::{DandelionSetup, NodeSetup, P2PSetup, PoolSetup, StratumSetup}; +use crate::gui::views::types::{NetworkTab, NetworkTabType}; use crate::node::{Node, NodeConfig}; /// Integrated node settings tab content. diff --git a/src/gui/views/network/types.rs b/src/gui/views/network/types.rs new file mode 100644 index 0000000..b809f6e --- /dev/null +++ b/src/gui/views/network/types.rs @@ -0,0 +1,43 @@ +// Copyright 2023 The Grim Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::gui::platform::PlatformCallbacks; +use crate::gui::views::Modal; + +/// Network tab content interface. +pub trait NetworkTab { + fn get_type(&self) -> NetworkTabType; + fn ui(&mut self, ui: &mut egui::Ui, cb: &dyn PlatformCallbacks); + fn on_modal_ui(&mut self, ui: &mut egui::Ui, modal: &Modal, cb: &dyn PlatformCallbacks); +} + +/// Type of [`NetworkTab`] content. +#[derive(PartialEq)] +pub enum NetworkTabType { + Node, + Metrics, + Mining, + Settings +} + +impl NetworkTabType { + pub fn title(&self) -> String { + match *self { + NetworkTabType::Node => { t!("network.node") } + NetworkTabType::Metrics => { t!("network.metrics") } + NetworkTabType::Mining => { t!("network.mining") } + NetworkTabType::Settings => { t!("network.settings") } + } + } +} \ No newline at end of file