ui: optimize loading progress

This commit is contained in:
ardocrat 2023-06-02 02:16:41 +03:00
parent d3e81826e8
commit 7c1699a658
3 changed files with 10 additions and 9 deletions

View file

@ -60,13 +60,13 @@ impl App {
ModalId::Exit => { ModalId::Exit => {
if self.show_exit_progress { if self.show_exit_progress {
if !Node::is_running() { if !Node::is_running() {
modal.close();
Self::exit(frame, cb); Self::exit(frame, cb);
} else {
ui.add_space(10.0);
let text = Node::get_sync_status_text(Node::get_sync_status());
ProgressLoading::new(text).ui(ui);
ui.add_space(10.0);
} }
ui.add_space(12.0);
let text = Node::get_sync_status_text(Node::get_sync_status());
ProgressLoading::new(text).ui(ui);
ui.add_space(12.0);
} else { } else {
ui.add_space(8.0); ui.add_space(8.0);
ui.vertical_centered(|ui| { ui.vertical_centered(|ui| {

View file

@ -215,14 +215,14 @@ impl Modal {
let bg_idx = ui.painter().add(bg_shape); let bg_idx = ui.painter().add(bg_shape);
// Draw main content. // Draw main content.
let mut content_resp_rect = ui.allocate_ui_at_rect(rect, |ui| { let mut content_rect = ui.allocate_ui_at_rect(rect, |ui| {
(add_content)(ui, frame, self); (add_content)(ui, frame, self);
}).response.rect; }).response.rect;
// Setup background shape to be painted behind main content. // Setup background shape to be painted behind main content.
content_resp_rect.min -= egui::emath::vec2(6.0, 0.0); content_rect.min -= egui::emath::vec2(6.0, 0.0);
content_resp_rect.max += egui::emath::vec2(6.0, 0.0); content_rect.max += egui::emath::vec2(6.0, 0.0);
bg_shape.rect = content_resp_rect; bg_shape.rect = content_rect;
ui.painter().set(bg_idx, bg_shape); ui.painter().set(bg_idx, bg_shape);
} }

View file

@ -31,6 +31,7 @@ impl ProgressLoading {
impl Widget for ProgressLoading { impl Widget for ProgressLoading {
fn ui(self, ui: &mut Ui) -> Response { fn ui(self, ui: &mut Ui) -> Response {
ui.vertical_centered_justified(|ui| { ui.vertical_centered_justified(|ui| {
ui.add_space(10.0);
Spinner::new().size(36.0).color(COLOR_DARK).ui(ui); Spinner::new().size(36.0).color(COLOR_DARK).ui(ui);
ui.add_space(10.0); ui.add_space(10.0);
ui.label(RichText::new(self.text).size(18.0).color(COLOR_DARK)); ui.label(RichText::new(self.text).size(18.0).color(COLOR_DARK));