-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #147
- Loading branch information
Showing
9 changed files
with
346 additions
and
20 deletions.
There are no files selected for viewing
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
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,31 @@ | ||
use std::time::Duration; | ||
|
||
use cushy::value::{Destination, Dynamic}; | ||
use cushy::widget::MakeWidget; | ||
use cushy::widgets::progress::Progressable; | ||
use cushy::{Open, PendingApp, TokioRuntime}; | ||
use tokio::time::sleep; | ||
|
||
fn main() { | ||
let app = PendingApp::new(TokioRuntime::default()); | ||
let progress = Dynamic::new(0_u8); | ||
let progress_bar = progress.clone().progress_bar(); | ||
"Press Me" | ||
.into_button() | ||
.on_click(move |_| { | ||
tokio::spawn(do_something(progress.clone())); | ||
}) | ||
.and(progress_bar) | ||
.into_rows() | ||
.centered() | ||
.expand() | ||
.run_in(app) | ||
.expect("error starting Cushy"); | ||
} | ||
|
||
async fn do_something(progress: Dynamic<u8>) { | ||
for i in 0..u8::MAX { | ||
progress.set(i); | ||
sleep(Duration::from_millis(10)).await | ||
} | ||
} |
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
Oops, something went wrong.