summaryrefslogtreecommitdiffstats
path: root/examples/loading_spinners/src/main.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-16 05:33:47 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-16 05:33:47 +0100
commitc22269bff3085012d326a0df77bf27ad5bcb41b7 (patch)
tree1083f21d012ab2bac88fb51537d4dc431bc7f170 /examples/loading_spinners/src/main.rs
parent0524e9b4571d264018656418f02a1f9e27e268d7 (diff)
downloadiced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.gz
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.tar.bz2
iced-c22269bff3085012d326a0df77bf27ad5bcb41b7.zip
Introduce `Program` API
Diffstat (limited to 'examples/loading_spinners/src/main.rs')
-rw-r--r--examples/loading_spinners/src/main.rs46
1 files changed, 15 insertions, 31 deletions
diff --git a/examples/loading_spinners/src/main.rs b/examples/loading_spinners/src/main.rs
index 93a4605e..bf36dc8d 100644
--- a/examples/loading_spinners/src/main.rs
+++ b/examples/loading_spinners/src/main.rs
@@ -1,6 +1,5 @@
-use iced::executor;
use iced::widget::{column, container, row, slider, text};
-use iced::{Application, Command, Element, Length, Settings, Theme};
+use iced::{Element, Length};
use std::time::Duration;
@@ -12,51 +11,28 @@ use circular::Circular;
use linear::Linear;
pub fn main() -> iced::Result {
- LoadingSpinners::run(Settings {
- antialiasing: true,
- ..Default::default()
- })
+ iced::sandbox(LoadingSpinners::update, LoadingSpinners::view)
+ .title("Loading Spinners - Iced")
+ .antialiased()
+ .run()
}
struct LoadingSpinners {
cycle_duration: f32,
}
-impl Default for LoadingSpinners {
- fn default() -> Self {
- Self {
- cycle_duration: 2.0,
- }
- }
-}
-
#[derive(Debug, Clone, Copy)]
enum Message {
CycleDurationChanged(f32),
}
-impl Application for LoadingSpinners {
- type Message = Message;
- type Flags = ();
- type Executor = executor::Default;
- type Theme = Theme;
-
- fn new(_flags: Self::Flags) -> (Self, Command<Message>) {
- (Self::default(), Command::none())
- }
-
- fn title(&self) -> String {
- String::from("Loading Spinners - Iced")
- }
-
- fn update(&mut self, message: Message) -> Command<Message> {
+impl LoadingSpinners {
+ fn update(&mut self, message: Message) {
match message {
Message::CycleDurationChanged(duration) => {
self.cycle_duration = duration;
}
}
-
- Command::none()
}
fn view(&self) -> Element<Message> {
@@ -115,3 +91,11 @@ impl Application for LoadingSpinners {
.into()
}
}
+
+impl Default for LoadingSpinners {
+ fn default() -> Self {
+ Self {
+ cycle_duration: 2.0,
+ }
+ }
+}