diff --git a/examples/energy-monitor/Cargo.toml b/examples/energy-monitor/Cargo.toml index f12a89c085f..b05d0a4e9da 100644 --- a/examples/energy-monitor/Cargo.toml +++ b/examples/energy-monitor/Cargo.toml @@ -19,7 +19,7 @@ crate-type = ["cdylib", "lib"] [dependencies] slint = { path = "../../api/rs/slint", default-features = false, features = ["compat-1-2"] } mcu-board-support = { path = "../mcu-board-support", optional = true } -chrono = { version = "0.4.23", optional = true, default-features = false, features = ["clock", "std", "wasmbind"] } +chrono = { version = "0.4.34", optional = true, default-features = false, features = ["clock", "std", "wasmbind"] } weer_api = { version = "0.1", optional = true } tokio = { version = "1.25", optional = true, features = ["full"] } futures = { version = "0.3.26", optional = true } diff --git a/examples/energy-monitor/src/controllers/weather.rs b/examples/energy-monitor/src/controllers/weather.rs index e0388aa3e69..e3e70d37f3c 100644 --- a/examples/energy-monitor/src/controllers/weather.rs +++ b/examples/energy-monitor/src/controllers/weather.rs @@ -40,14 +40,19 @@ async fn weather_worker_loop(window_weak: Weak) { let mut forecast_days = vec![]; let client = Client::new(&api_key, true); - let mut forecast_list = - future::join_all((0..FORECAST_DAYS).map(|i| { - let client = client.clone(); - async move { - current_forecast(client.clone(), lat, long, now + chrono::Duration::days(i)).await - } - })) - .await; + let mut forecast_list = future::join_all((0..FORECAST_DAYS).map(|i| { + let client = client.clone(); + async move { + current_forecast( + client.clone(), + lat, + long, + now + chrono::TimeDelta::try_days(i).unwrap_or_default(), + ) + .await + } + })) + .await; for i in 0..forecast_list.len() { if let Some((date, forecast)) = forecast_list.remove(0) { diff --git a/examples/energy-monitor/ui/widgets/menu.slint b/examples/energy-monitor/ui/widgets/menu.slint index 9ee04553309..171a50df6f2 100644 --- a/examples/energy-monitor/ui/widgets/menu.slint +++ b/examples/energy-monitor/ui/widgets/menu.slint @@ -119,33 +119,37 @@ export component MobileMenu { root.open = false; } - menu := Rectangle { - x: root.menu-x; - y: -self.height; - width: root.menu-width; - height: root.height / 2; - visible: visibility > 0.0; + Rectangle { + clip: true; + menu := Rectangle { + x: root.menu-x; + y: -self.height; + width: root.menu-width; + height: root.height / 2; + visible: visibility > 0.0; + + private property visibility; + + MenuBackground { + // avoid click-through + TouchArea {} + + @children + } - private property visibility; + states [ + open when root.open : { + menu.y: end-y; + visibility: 1.0; - MenuBackground { - // avoid click-through - TouchArea {} + out { + animate visibility { duration: Theme.durations.medium; } + } + } + ] - @children + animate y { duration: Theme.durations.fast; } } - states [ - open when root.open : { - menu.y: end-y; - visibility: 1.0; - - out { - animate visibility { duration: Theme.durations.medium; } - } - } - ] - - animate y { duration: Theme.durations.slow; } } -} \ No newline at end of file +}