| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
use egui; |
| 14 |
|
| 15 |
use super::theme; |
| 16 |
use crate::state::BrowserState; |
| 17 |
|
| 18 |
|
| 19 |
pub fn draw_layout_strip(ui: &mut egui::Ui, state: &mut BrowserState) { |
| 20 |
let Some(progress) = state.layout_migration else { |
| 21 |
return; |
| 22 |
}; |
| 23 |
|
| 24 |
ui.add_space(theme::space::hair()); |
| 25 |
ui.horizontal(|ui| { |
| 26 |
ui.label( |
| 27 |
egui::RichText::new("Optimising storage layout") |
| 28 |
.small() |
| 29 |
.color(theme::content_secondary()), |
| 30 |
); |
| 31 |
ui.label( |
| 32 |
egui::RichText::new(format!("{} / {} files", progress.completed, progress.total)) |
| 33 |
.small() |
| 34 |
.color(theme::content_muted()), |
| 35 |
); |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { |
| 40 |
if ui |
| 41 |
.small_button("Pause") |
| 42 |
.on_hover_text("Stop for now. Resumes the next time this vault opens.") |
| 43 |
.clicked() |
| 44 |
{ |
| 45 |
if let Err(e) = state.backend.cancel_layout_migration() { |
| 46 |
tracing::warn!("failed to cancel layout migration: {e}"); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
state.layout_migration = None; |
| 53 |
} |
| 54 |
ui.add( |
| 55 |
egui::ProgressBar::new(progress.fraction()) |
| 56 |
.desired_height(theme::space::peer()) |
| 57 |
.show_percentage(), |
| 58 |
); |
| 59 |
}); |
| 60 |
}); |
| 61 |
ui.add_space(theme::space::hair()); |
| 62 |
} |
| 63 |
|