This commit is contained in:
2026-09-12 21:50:09 +01:00
parent b20e03def7
commit b81eb967ee
17 changed files with 468 additions and 14 deletions
+53
View File
@@ -0,0 +1,53 @@
use std::error::Error;
use common::{BarModule, Endpoint, ModuleEffect, Service, WeatherKind, Wire};
use iced::{
widget::{container, mouse_area, text},
Element, Task,
};
pub struct WeatherModule {
text: String,
}
impl Default for WeatherModule {
fn default() -> Self {
Self { text: "hi".into() }
}
}
impl BarModule for WeatherModule {
fn id(&self) -> &'static str {
"weather"
}
fn view(&self, _window_id: Option<iced::window::Id>) -> Element<'_, Wire> {
let me = Endpoint::module(self.id());
container(mouse_area(text(&self.text).size(16)).on_press(Wire::module(
me,
self.id(),
WeatherKind::Poke,
)))
.into()
}
fn update(&mut self, msg: Wire) -> Task<ModuleEffect> {
match msg.downcast::<WeatherKind>() {
Some(WeatherKind::Poke) => {
self.text = "poked".into();
Task::none()
}
None => Task::none(),
}
}
/// Route keys this module subscribes to.
fn services(&self) -> Vec<Service> {
vec![]
}
/// Optional: read `module.weather` from the config table.
fn config(&mut self, _config: toml::Table) -> Result<(), Box<dyn Error>> {
Ok(())
}
}