From 803ee5cf24e1f254158a199e1ef6f25a0bc8d4bb Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Wed, 20 Mar 2024 12:36:30 +0200 Subject: [PATCH] Add toggle for expanding farm details --- Cargo.toml | 2 +- src/frontend/running.rs | 13 +++++++++++++ src/frontend/running/farm.rs | 13 ++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3090e6d..84e345d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ pallet-balances = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b parity-scale-codec = "3.6.9" parking_lot = "0.12.1" relm4 = "0.7.0-rc.1" -relm4-icons = { version = "0.7.0-alpha.2", features = ["checkmark", "cross", "menu-large", "processor", "puzzle-piece", "size-horizontally", "ssd", "wallet2", "warning"] } +relm4-icons = { version = "0.7.0-alpha.2", features = ["checkmark", "cross", "grid-filled", "menu-large", "processor", "puzzle-piece", "size-horizontally", "ssd", "wallet2", "warning"] } relm4-components = { version = "0.7.0-rc.1", default-features = false } reqwest = { version = "0.11.25", default-features = false, features = ["json", "rustls-tls"] } sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false } diff --git a/src/frontend/running.rs b/src/frontend/running.rs index dcb8355..c5fa023 100644 --- a/src/frontend/running.rs +++ b/src/frontend/running.rs @@ -10,6 +10,7 @@ use crate::frontend::running::node::{NodeInput, NodeView}; use gtk::prelude::*; use relm4::factory::FactoryHashMap; use relm4::prelude::*; +use relm4_icons::icon_name; use subspace_core_primitives::BlockNumber; use subspace_runtime_primitives::{Balance, SSC}; @@ -25,6 +26,7 @@ pub enum RunningInput { }, NodeNotification(NodeNotification), FarmerNotification(FarmerNotification), + ToggleFarmDetails, } #[derive(Debug, Default)] @@ -67,11 +69,19 @@ impl Component for RunningView { set_spacing: 10, gtk::Box { + set_spacing: 10, + gtk::Label { add_css_class: "heading", set_halign: gtk::Align::Start, set_label: "Farmer", }, + gtk::ToggleButton { + connect_clicked => RunningInput::ToggleFarmDetails, + set_has_frame: false, + set_icon_name: icon_name::GRID_FILLED, + set_tooltip: "Expand details about each farm", + }, gtk::Box { set_halign: gtk::Align::End, set_hexpand: true, @@ -296,6 +306,9 @@ impl RunningView { self.farmer_state.piece_cache_sync_progress = progress; } }, + RunningInput::ToggleFarmDetails => { + self.farms.broadcast(FarmWidgetInput::ToggleFarmDetails); + } } } } diff --git a/src/frontend/running/farm.rs b/src/frontend/running/farm.rs index 8d3524c..90e638b 100644 --- a/src/frontend/running/farm.rs +++ b/src/frontend/running/farm.rs @@ -87,6 +87,7 @@ pub(super) enum FarmWidgetInput { FarmingNotification(FarmingNotification), OpenFarmFolder, NodeSynced(bool), + ToggleFarmDetails, } #[derive(Debug)] @@ -103,6 +104,7 @@ pub(super) struct FarmWidget { sector_rows: gtk::Box, sectors: HashMap, non_fatal_farming_error: Option>, + farm_details: bool, } #[relm4::factory(pub(super))] @@ -288,7 +290,12 @@ impl FactoryComponent for FarmWidget { }, }, - self.sector_rows.clone(), + gtk::Box { + #[watch] + set_visible: self.farm_details, + + self.sector_rows.clone(), + }, }, } @@ -328,6 +335,7 @@ impl FactoryComponent for FarmWidget { sector_rows, sectors: HashMap::from_iter((SectorIndex::MIN..).zip(sectors)), non_fatal_farming_error: None, + farm_details: false, } } @@ -423,6 +431,9 @@ impl FarmWidget { FarmWidgetInput::NodeSynced(synced) => { self.is_node_synced = synced; } + FarmWidgetInput::ToggleFarmDetails => { + self.farm_details = !self.farm_details; + } } }