diff options
Diffstat (limited to 'examples/stopwatch')
| -rw-r--r-- | examples/stopwatch/Cargo.toml | 5 | ||||
| -rw-r--r-- | examples/stopwatch/src/main.rs | 51 | 
2 files changed, 9 insertions, 47 deletions
diff --git a/examples/stopwatch/Cargo.toml b/examples/stopwatch/Cargo.toml index 1dae3b83..075aa111 100644 --- a/examples/stopwatch/Cargo.toml +++ b/examples/stopwatch/Cargo.toml @@ -6,7 +6,4 @@ edition = "2018"  publish = false  [dependencies] -iced = { path = "../.." } -iced_native = { path = "../../native" } -iced_futures = { path = "../../futures", features = ["async-std"] } -async-std = { version = "1.0", features = ["unstable"] } +iced = { path = "../..", features = ["tokio"] } diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs index d84c4817..983cf3e6 100644 --- a/examples/stopwatch/src/main.rs +++ b/examples/stopwatch/src/main.rs @@ -1,10 +1,11 @@  use iced::{ -    button, Align, Application, Button, Column, Command, Container, Element, -    HorizontalAlignment, Length, Row, Settings, Subscription, Text, +    button, executor, time, Align, Application, Button, Column, Command, +    Container, Element, HorizontalAlignment, Length, Row, Settings, +    Subscription, Text,  };  use std::time::{Duration, Instant}; -pub fn main() { +pub fn main() -> iced::Result {      Stopwatch::run(Settings::default())  } @@ -28,10 +29,11 @@ enum Message {  }  impl Application for Stopwatch { -    type Executor = iced_futures::executor::AsyncStd; +    type Executor = executor::Default;      type Message = Message; +    type Flags = (); -    fn new() -> (Stopwatch, Command<Message>) { +    fn new(_flags: ()) -> (Stopwatch, Command<Message>) {          (              Stopwatch {                  duration: Duration::default(), @@ -142,43 +144,6 @@ impl Application for Stopwatch {      }  } -mod time { -    use iced::futures; - -    pub fn every( -        duration: std::time::Duration, -    ) -> iced::Subscription<std::time::Instant> { -        iced::Subscription::from_recipe(Every(duration)) -    } - -    struct Every(std::time::Duration); - -    impl<H, I> iced_native::subscription::Recipe<H, I> for Every -    where -        H: std::hash::Hasher, -    { -        type Output = std::time::Instant; - -        fn hash(&self, state: &mut H) { -            use std::hash::Hash; - -            std::any::TypeId::of::<Self>().hash(state); -            self.0.hash(state); -        } - -        fn stream( -            self: Box<Self>, -            _input: futures::stream::BoxStream<'static, I>, -        ) -> futures::stream::BoxStream<'static, Self::Output> { -            use futures::stream::StreamExt; - -            async_std::stream::interval(self.0) -                .map(|_| std::time::Instant::now()) -                .boxed() -        } -    } -} -  mod style {      use iced::{button, Background, Color, Vector}; @@ -196,7 +161,7 @@ mod style {                      Button::Secondary => Color::from_rgb(0.5, 0.5, 0.5),                      Button::Destructive => Color::from_rgb(0.8, 0.2, 0.2),                  })), -                border_radius: 12, +                border_radius: 12.0,                  shadow_offset: Vector::new(1.0, 1.0),                  text_color: Color::WHITE,                  ..button::Style::default()  | 
