From 7e9d79ca1b64eacf43b5fbb412852a1a4ab6c114 Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Wed, 21 Aug 2024 10:57:41 +0800 Subject: [PATCH] Improve the loading button (#170) * Set the background opacity when loading * Do not trigger the on click event when loading --- crates/ui/src/button.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui/src/button.rs b/crates/ui/src/button.rs index 2cf41e54..2a915178 100644 --- a/crates/ui/src/button.rs +++ b/crates/ui/src/button.rs @@ -342,7 +342,7 @@ impl RenderOnce for Button { }) .when(focused, |this| this.border_color(cx.theme().ring)) .when_some( - self.on_click.filter(|_| !self.disabled), + self.on_click.filter(|_| !self.disabled && !self.loading), |this, on_click| { this.on_mouse_down(MouseButton::Left, |_, cx| { cx.prevent_default(); @@ -383,6 +383,7 @@ impl RenderOnce for Button { .when_some(self.label, |this, label| this.child(label)) .children(self.children) }) + .when(self.loading, |this| this.bg(normal_style.bg.opacity(0.8))) } }