drawer: Fix the overlay_closable not working (#1113)
This commit is contained in:
parent
163b540681
commit
16f4fc0456
2 changed files with 13 additions and 2 deletions
|
|
@ -294,10 +294,12 @@ impl DrawerStory {
|
||||||
};
|
};
|
||||||
|
|
||||||
let overlay = self.modal_overlay;
|
let overlay = self.modal_overlay;
|
||||||
|
let overlay_closable = self.overlay_closable;
|
||||||
let input1 = self.input1.clone();
|
let input1 = self.input1.clone();
|
||||||
let date = self.date.clone();
|
let date = self.date.clone();
|
||||||
window.open_drawer_at(placement, cx, move |this, _, cx| {
|
window.open_drawer_at(placement, cx, move |this, _, cx| {
|
||||||
this.overlay(overlay)
|
this.overlay(overlay)
|
||||||
|
.overlay_closable(overlay_closable)
|
||||||
.size(px(400.))
|
.size(px(400.))
|
||||||
.title("Drawer Title")
|
.title("Drawer Title")
|
||||||
.gap_4()
|
.gap_4()
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ pub struct Drawer {
|
||||||
content: Div,
|
content: Div,
|
||||||
margin_top: Pixels,
|
margin_top: Pixels,
|
||||||
overlay: bool,
|
overlay: bool,
|
||||||
|
overlay_closable: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawer {
|
impl Drawer {
|
||||||
|
|
@ -48,6 +49,7 @@ impl Drawer {
|
||||||
content: v_flex().px_4().py_3(),
|
content: v_flex().px_4().py_3(),
|
||||||
margin_top: TITLE_BAR_HEIGHT,
|
margin_top: TITLE_BAR_HEIGHT,
|
||||||
overlay: true,
|
overlay: true,
|
||||||
|
overlay_closable: true,
|
||||||
on_close: Rc::new(|_, _, _| {}),
|
on_close: Rc::new(|_, _, _| {}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,6 +92,12 @@ impl Drawer {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set whether the drawer should be closable by clicking the overlay, default is `true`.
|
||||||
|
pub fn overlay_closable(mut self, overlay_closable: bool) -> Self {
|
||||||
|
self.overlay_closable = overlay_closable;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Listen to the close event of the drawer.
|
/// Listen to the close event of the drawer.
|
||||||
pub fn on_close(
|
pub fn on_close(
|
||||||
mut self,
|
mut self,
|
||||||
|
|
@ -136,7 +144,7 @@ impl RenderOnce for Drawer {
|
||||||
.w(size.width)
|
.w(size.width)
|
||||||
.h(size.height - titlebar_height)
|
.h(size.height - titlebar_height)
|
||||||
.bg(overlay_color(self.overlay, cx))
|
.bg(overlay_color(self.overlay, cx))
|
||||||
.when(self.overlay, |this| {
|
.when(self.overlay_closable, |this| {
|
||||||
this.on_mouse_down(MouseButton::Left, {
|
this.on_mouse_down(MouseButton::Left, {
|
||||||
let on_close = self.on_close.clone();
|
let on_close = self.on_close.clone();
|
||||||
move |_, window, cx| {
|
move |_, window, cx| {
|
||||||
|
|
@ -184,7 +192,8 @@ impl RenderOnce for Drawer {
|
||||||
// TitleBar
|
// TitleBar
|
||||||
h_flex()
|
h_flex()
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.px_4()
|
.pl_4()
|
||||||
|
.pr_3()
|
||||||
.py_2()
|
.py_2()
|
||||||
.w_full()
|
.w_full()
|
||||||
.font_semibold()
|
.font_semibold()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue