From 66d69b5c9a183091e05e82bbe21b3203f75c1b18 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 11 Feb 2022 17:51:33 +0700 Subject: Expose `iced_pure` through a `pure` feature in `iced` Besides exposing the `iced_pure` crate, enabling the `pure` feature also provides pure versions of both the `Application` and `Sandbox` traits! :tada: --- examples/pure/counter/src/main.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'examples/pure/counter/src') diff --git a/examples/pure/counter/src/main.rs b/examples/pure/counter/src/main.rs index e2746d40..00cb3fc7 100644 --- a/examples/pure/counter/src/main.rs +++ b/examples/pure/counter/src/main.rs @@ -1,5 +1,5 @@ -use iced::{Alignment, Element, Sandbox, Settings}; -use iced_pure::{Button, Column, Pure, State, Text}; +use iced::pure::{Button, Column, Element, Sandbox, Text}; +use iced::{Alignment, Settings}; pub fn main() -> iced::Result { Counter::run(Settings::default()) @@ -7,7 +7,6 @@ pub fn main() -> iced::Result { struct Counter { value: i32, - state: State, } #[derive(Debug, Clone, Copy)] @@ -20,10 +19,7 @@ impl Sandbox for Counter { type Message = Message; fn new() -> Self { - Self { - value: 0, - state: State::new(), - } + Self { value: 0 } } fn title(&self) -> String { @@ -41,14 +37,13 @@ impl Sandbox for Counter { } } - fn view(&mut self) -> Element<'_, Message> { - let content = Column::new() + fn view(&self) -> Element { + Column::new() .padding(20) .align_items(Alignment::Center) .push(Button::new("Increment").on_press(Message::IncrementPressed)) .push(Text::new(self.value.to_string()).size(50)) - .push(Button::new("Decrement").on_press(Message::DecrementPressed)); - - Pure::new(&mut self.state, content).into() + .push(Button::new("Decrement").on_press(Message::DecrementPressed)) + .into() } } -- cgit