summaryrefslogtreecommitdiffstats
path: root/examples/clock
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-08-06 00:32:57 +0200
committerLibravatar GitHub <noreply@github.com>2022-08-06 00:32:57 +0200
commit1923dbf7f0769d55e5283f572fde0ce752e28b86 (patch)
tree7be9b36f941f6e13ddc8884f715c04555b1e77db /examples/clock
parent1b4f38c71f6e05e26599ee75ea9c91dde96e71ae (diff)
parentc23ed7e4a0a2b62a0d7cabe6e35d7323eac543d2 (diff)
downloadiced-1923dbf7f0769d55e5283f572fde0ce752e28b86.tar.gz
iced-1923dbf7f0769d55e5283f572fde0ce752e28b86.tar.bz2
iced-1923dbf7f0769d55e5283f572fde0ce752e28b86.zip
Merge pull request #1393 from iced-rs/deprecate-stateful-widgets
Replace stateful widgets with the new `iced_pure` API
Diffstat (limited to 'examples/clock')
-rw-r--r--examples/clock/src/main.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs
index 48b4cd7b..8818fb54 100644
--- a/examples/clock/src/main.rs
+++ b/examples/clock/src/main.rs
@@ -1,10 +1,9 @@
-use iced::canvas::{
- self, Cache, Canvas, Cursor, Geometry, LineCap, Path, Stroke,
-};
use iced::executor;
+use iced::widget::canvas::{Cache, Cursor, Geometry, LineCap, Path, Stroke};
+use iced::widget::{canvas, container};
use iced::{
- Application, Color, Command, Container, Element, Length, Point, Rectangle,
- Settings, Subscription, Theme, Vector,
+ Application, Color, Command, Element, Length, Point, Rectangle, Settings,
+ Subscription, Theme, Vector,
};
pub fn main() -> iced::Result {
@@ -69,10 +68,12 @@ impl Application for Clock {
})
}
- fn view(&mut self) -> Element<Message> {
- let canvas = Canvas::new(self).width(Length::Fill).height(Length::Fill);
+ fn view(&self) -> Element<Message> {
+ let canvas = canvas(self as &Self)
+ .width(Length::Fill)
+ .height(Length::Fill);
- Container::new(canvas)
+ container(canvas)
.width(Length::Fill)
.height(Length::Fill)
.padding(20)
@@ -81,8 +82,11 @@ impl Application for Clock {
}
impl<Message> canvas::Program<Message> for Clock {
+ type State = ();
+
fn draw(
&self,
+ _state: &Self::State,
_theme: &Theme,
bounds: Rectangle,
_cursor: Cursor,