summaryrefslogtreecommitdiffstats
path: root/examples/clock
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-27 06:49:20 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-07-27 06:49:20 +0200
commitff2519b1d43d481987351a83b6dd7237524c21f0 (patch)
tree5731eeb7eb1247d4a8951de0d5bc5d8102640559 /examples/clock
parentc44267b85f7aaa2997e3caf1323b837d95818c22 (diff)
downloadiced-ff2519b1d43d481987351a83b6dd7237524c21f0.tar.gz
iced-ff2519b1d43d481987351a83b6dd7237524c21f0.tar.bz2
iced-ff2519b1d43d481987351a83b6dd7237524c21f0.zip
Replace stateful widgets with 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,