Skip to content

Commit

Permalink
Merge pull request #167 from subspace/toggle-for-farm-details
Browse files Browse the repository at this point in the history
Add toggle for expanding farm details
  • Loading branch information
nazar-pc authored Mar 20, 2024
2 parents 67d1c79 + 803ee5c commit 3aafee3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
13 changes: 13 additions & 0 deletions src/frontend/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -25,6 +26,7 @@ pub enum RunningInput {
},
NodeNotification(NodeNotification),
FarmerNotification(FarmerNotification),
ToggleFarmDetails,
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -296,6 +306,9 @@ impl RunningView {
self.farmer_state.piece_cache_sync_progress = progress;
}
},
RunningInput::ToggleFarmDetails => {
self.farms.broadcast(FarmWidgetInput::ToggleFarmDetails);
}
}
}
}
13 changes: 12 additions & 1 deletion src/frontend/running/farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub(super) enum FarmWidgetInput {
FarmingNotification(FarmingNotification),
OpenFarmFolder,
NodeSynced(bool),
ToggleFarmDetails,
}

#[derive(Debug)]
Expand All @@ -103,6 +104,7 @@ pub(super) struct FarmWidget {
sector_rows: gtk::Box,
sectors: HashMap<SectorIndex, gtk::Box>,
non_fatal_farming_error: Option<Arc<FarmingError>>,
farm_details: bool,
}

#[relm4::factory(pub(super))]
Expand Down Expand Up @@ -288,7 +290,12 @@ impl FactoryComponent for FarmWidget {
},
},

self.sector_rows.clone(),
gtk::Box {
#[watch]
set_visible: self.farm_details,

self.sector_rows.clone(),
},
},
}

Expand Down Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -423,6 +431,9 @@ impl FarmWidget {
FarmWidgetInput::NodeSynced(synced) => {
self.is_node_synced = synced;
}
FarmWidgetInput::ToggleFarmDetails => {
self.farm_details = !self.farm_details;
}
}
}

Expand Down

0 comments on commit 3aafee3

Please sign in to comment.