From 67f878b8906a7ad2bd708e7c2bc4aa9f1d232d0e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Jan 2022 20:03:18 +0700 Subject: Remove support for old `tokio` crate --- examples/pokedex/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/pokedex/Cargo.toml b/examples/pokedex/Cargo.toml index 05e73992..751e2872 100644 --- a/examples/pokedex/Cargo.toml +++ b/examples/pokedex/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" publish = false [dependencies] -iced = { path = "../..", features = ["image", "debug", "tokio_old"] } +iced = { path = "../..", features = ["image", "debug", "tokio"] } serde_json = "1.0" [dependencies.serde] @@ -14,7 +14,7 @@ version = "1.0" features = ["derive"] [dependencies.reqwest] -version = "0.10.2" +version = "0.11" features = ["json"] [dependencies.rand] -- cgit From aaf2444e9fda16318e56adff9c7c8650a99e6a12 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Jan 2022 20:16:33 +0700 Subject: Replace `chrono` with `time` in `clock` example --- examples/clock/Cargo.toml | 2 +- examples/clock/src/main.rs | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/clock/Cargo.toml b/examples/clock/Cargo.toml index c6e32379..29457c0d 100644 --- a/examples/clock/Cargo.toml +++ b/examples/clock/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] iced = { path = "../..", features = ["canvas", "tokio", "debug"] } -chrono = "0.4" +time = { version = "0.3.5", features = ["local-offset"] } diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs index b317ac00..de9e879a 100644 --- a/examples/clock/src/main.rs +++ b/examples/clock/src/main.rs @@ -1,7 +1,7 @@ use iced::{ canvas::{self, Cache, Canvas, Cursor, Geometry, LineCap, Path, Stroke}, - executor, time, Application, Color, Command, Container, Element, Length, - Point, Rectangle, Settings, Subscription, Vector, + executor, Application, Color, Command, Container, Element, Length, Point, + Rectangle, Settings, Subscription, Vector, }; pub fn main() -> iced::Result { @@ -12,13 +12,13 @@ pub fn main() -> iced::Result { } struct Clock { - now: chrono::DateTime, + now: time::OffsetDateTime, clock: Cache, } #[derive(Debug, Clone, Copy)] enum Message { - Tick(chrono::DateTime), + Tick(time::OffsetDateTime), } impl Application for Clock { @@ -29,7 +29,8 @@ impl Application for Clock { fn new(_flags: ()) -> (Self, Command) { ( Clock { - now: chrono::Local::now(), + now: time::OffsetDateTime::now_local() + .unwrap_or_else(|_| time::OffsetDateTime::now_utc()), clock: Default::default(), }, Command::none(), @@ -56,8 +57,12 @@ impl Application for Clock { } fn subscription(&self) -> Subscription { - time::every(std::time::Duration::from_millis(500)) - .map(|_| Message::Tick(chrono::Local::now())) + iced::time::every(std::time::Duration::from_millis(500)).map(|_| { + Message::Tick( + time::OffsetDateTime::now_local() + .unwrap_or_else(|_| time::OffsetDateTime::now_utc()), + ) + }) } fn view(&mut self) -> Element { @@ -77,8 +82,6 @@ impl Application for Clock { impl canvas::Program for Clock { fn draw(&self, bounds: Rectangle, _cursor: Cursor) -> Vec { - use chrono::Timelike; - let clock = self.clock.draw(bounds.size(), |frame| { let center = frame.center(); let radius = frame.width().min(frame.height()) / 2.0; @@ -126,7 +129,7 @@ impl canvas::Program for Clock { } } -fn hand_rotation(n: u32, total: u32) -> f32 { +fn hand_rotation(n: u8, total: u8) -> f32 { let turns = n as f32 / total as f32; 2.0 * std::f32::consts::PI * turns -- cgit From 5f9cf991a7e2f5393e56b610db119bcedfd5eb42 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 13 Jan 2022 19:55:47 +0700 Subject: Update `reqwest` in examples ... and rely on `rustls` instead of `native-tls` --- examples/download_progress/Cargo.toml | 6 +++++- examples/pokedex/Cargo.toml | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/download_progress/Cargo.toml b/examples/download_progress/Cargo.toml index d3c578b1..5f5eed68 100644 --- a/examples/download_progress/Cargo.toml +++ b/examples/download_progress/Cargo.toml @@ -9,4 +9,8 @@ publish = false iced = { path = "../..", features = ["tokio"] } iced_native = { path = "../../native" } iced_futures = { path = "../../futures" } -reqwest = "0.11" + +[dependencies.reqwest] +version = "0.11" +default-features = false +features = ["rustls-tls"] diff --git a/examples/pokedex/Cargo.toml b/examples/pokedex/Cargo.toml index 751e2872..c64cc85c 100644 --- a/examples/pokedex/Cargo.toml +++ b/examples/pokedex/Cargo.toml @@ -15,7 +15,8 @@ features = ["derive"] [dependencies.reqwest] version = "0.11" -features = ["json"] +default-features = false +features = ["json", "rustls-tls"] [dependencies.rand] version = "0.7" -- cgit