From c22269bff3085012d326a0df77bf27ad5bcb41b7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 16 Mar 2024 05:33:47 +0100 Subject: Introduce `Program` API --- examples/scrollable/src/main.rs | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'examples/scrollable') diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs index 2ad7272b..3e1b0408 100644 --- a/examples/scrollable/src/main.rs +++ b/examples/scrollable/src/main.rs @@ -1,20 +1,23 @@ -use iced::executor; use iced::widget::scrollable::Properties; use iced::widget::{ button, column, container, horizontal_space, progress_bar, radio, row, scrollable, slider, text, vertical_space, Scrollable, }; -use iced::{ - Alignment, Application, Border, Color, Command, Element, Length, Settings, - Theme, -}; +use iced::{Alignment, Border, Color, Command, Element, Length, Theme}; use once_cell::sync::Lazy; static SCROLLABLE_ID: Lazy = Lazy::new(scrollable::Id::unique); pub fn main() -> iced::Result { - ScrollableDemo::run(Settings::default()) + iced::application( + ScrollableDemo::new, + ScrollableDemo::update, + ScrollableDemo::view, + ) + .theme(ScrollableDemo::theme) + .title("Scrollable - Iced") + .run() } struct ScrollableDemo { @@ -45,13 +48,8 @@ enum Message { Scrolled(scrollable::Viewport), } -impl Application for ScrollableDemo { - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (); - - fn new(_flags: Self::Flags) -> (Self, Command) { +impl ScrollableDemo { + fn new() -> (Self, Command) { ( ScrollableDemo { scrollable_direction: Direction::Vertical, @@ -65,10 +63,6 @@ impl Application for ScrollableDemo { ) } - fn title(&self) -> String { - String::from("Scrollable - Iced") - } - fn update(&mut self, message: Message) -> Command { match message { Message::SwitchDirection(direction) => { @@ -340,7 +334,7 @@ impl Application for ScrollableDemo { container(content).padding(20).center_x().center_y().into() } - fn theme(&self) -> Self::Theme { + fn theme(&self) -> Theme { Theme::Dark } } -- cgit