-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
863963b
commit 3e22619
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "animations" | ||
version = "0.1.0" | ||
authors = ["LazyTanuki"] | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
iced.workspace = true | ||
iced.features = ["animations"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Animations | ||
|
||
An application to showcase Iced widgets that have default animations. | ||
|
||
The __[`main`]__ file contains all the code of the example. | ||
|
||
You can run it with `cargo run`: | ||
``` | ||
cargo run --package animations | ||
``` | ||
|
||
[`main`]: src/main.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use iced::{ | ||
widget::{column, Toggler}, | ||
Element, Task, Theme, | ||
}; | ||
|
||
pub fn main() -> iced::Result { | ||
iced::application("Animated widgets", Animations::update, Animations::view) | ||
.theme(Animations::theme) | ||
.run() | ||
} | ||
|
||
#[derive(Default)] | ||
struct Animations { | ||
toggled: bool, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
enum Message { | ||
Toggle(bool), | ||
} | ||
|
||
impl Animations { | ||
fn update(&mut self, message: Message) -> Task<Message> { | ||
match message { | ||
Message::Toggle(t) => { | ||
self.toggled = t; | ||
Task::none() | ||
} | ||
} | ||
} | ||
|
||
fn view(&self) -> Element<Message> { | ||
let main_text = iced::widget::text( | ||
"You can find all widgets with default animations here.", | ||
); | ||
let toggle = Toggler::new(self.toggled) | ||
.label("Toggle me!") | ||
.on_toggle(Message::Toggle); | ||
column![main_text, toggle] | ||
.spacing(10) | ||
.padding(50) | ||
.max_width(800) | ||
.into() | ||
} | ||
|
||
fn theme(&self) -> Theme { | ||
Theme::Light | ||
} | ||
} |