Skip to content

Commit

Permalink
Show spinner instead if load or save is in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Jan 31, 2024
1 parent 6f3a03e commit a2b3b4c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl BrowseApp {
let file = rfd::AsyncFileDialog::new().pick_file().await?; // Returns None if file is None
let text = file.read().await;

// Uncomment the following line to simulate taking long to load
// Uncomment the following line to simulate taking long to load, only works on native
// tokio::time::sleep(tokio::time::Duration::from_secs(2)).await;

// If not present screen will not refresh until next paint (comment out to test, works better with the sleep above to demonstrate)
Expand Down Expand Up @@ -63,7 +63,7 @@ impl eframe::App for BrowseApp {
if let Some(text) = result {
self.sample_text = text.clone();
} else {
// User probably cancelled but the promise completed
// User probably cancelled or it was saving but the promise completed either way
}
// Clear promise after we use it
self.promise = None;
Expand All @@ -72,7 +72,11 @@ impl eframe::App for BrowseApp {

egui::CentralPanel::default().show(ctx, |ui| {
ui.text_edit_multiline(&mut self.sample_text);
self.buttons_save_load(ui);
if self.promise.is_none() {
self.buttons_save_load(ui);
} else {
ui.spinner();
}
});
}
}
Expand Down

0 comments on commit a2b3b4c

Please sign in to comment.