modal: Add scrollbar to modal again. (#971)
This commit is contained in:
parent
0e3b61a704
commit
64e3653bc9
1 changed files with 36 additions and 13 deletions
|
|
@ -355,6 +355,15 @@ impl RenderOnce for Modal {
|
||||||
let x = bounds.center().x - self.width / 2.;
|
let x = bounds.center().x - self.width / 2.;
|
||||||
let border_radius = (cx.theme().radius * 2.).min(px(20.));
|
let border_radius = (cx.theme().radius * 2.).min(px(20.));
|
||||||
|
|
||||||
|
let mut padding_right = px(16.);
|
||||||
|
let mut padding_left = px(16.);
|
||||||
|
if let Some(pl) = self.style.padding.left {
|
||||||
|
padding_left = pl.to_pixels(self.width.into(), window.rem_size());
|
||||||
|
}
|
||||||
|
if let Some(pr) = self.style.padding.right {
|
||||||
|
padding_right = pr.to_pixels(self.width.into(), window.rem_size());
|
||||||
|
}
|
||||||
|
|
||||||
anchored()
|
anchored()
|
||||||
.position(point(window_paddings.left, window_paddings.top))
|
.position(point(window_paddings.left, window_paddings.top))
|
||||||
.snap_to_window()
|
.snap_to_window()
|
||||||
|
|
@ -391,9 +400,10 @@ impl RenderOnce for Modal {
|
||||||
.rounded(border_radius)
|
.rounded(border_radius)
|
||||||
.shadow_xl()
|
.shadow_xl()
|
||||||
.min_h_24()
|
.min_h_24()
|
||||||
.p_4()
|
.py_4()
|
||||||
.gap_4()
|
.gap_4()
|
||||||
.refine_style(&self.style)
|
.refine_style(&self.style)
|
||||||
|
.px_0()
|
||||||
.key_context(CONTEXT)
|
.key_context(CONTEXT)
|
||||||
.track_focus(&self.focus_handle)
|
.track_focus(&self.focus_handle)
|
||||||
.when(self.keyboard, |this| {
|
.when(self.keyboard, |this| {
|
||||||
|
|
@ -426,6 +436,7 @@ impl RenderOnce for Modal {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
// There style is high priority, can't be overridden.
|
||||||
.absolute()
|
.absolute()
|
||||||
.occlude()
|
.occlude()
|
||||||
.relative()
|
.relative()
|
||||||
|
|
@ -435,7 +446,12 @@ impl RenderOnce for Modal {
|
||||||
.when_some(self.max_width, |this, w| this.max_w(w))
|
.when_some(self.max_width, |this, w| this.max_w(w))
|
||||||
.when_some(self.title, |this, title| {
|
.when_some(self.title, |this, title| {
|
||||||
this.child(
|
this.child(
|
||||||
div().font_semibold().line_height(relative(1.)).child(title),
|
div()
|
||||||
|
.font_semibold()
|
||||||
|
.pl(padding_left)
|
||||||
|
.pr(padding_right)
|
||||||
|
.line_height(relative(1.))
|
||||||
|
.child(title),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.when(self.show_close, |this| {
|
.when(self.show_close, |this| {
|
||||||
|
|
@ -455,21 +471,28 @@ impl RenderOnce for Modal {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
div()
|
div().w_full().flex_1().overflow_hidden().child(
|
||||||
.w_full()
|
v_flex()
|
||||||
.flex_1()
|
.pl(padding_left)
|
||||||
.overflow_hidden()
|
.pr(padding_right)
|
||||||
.child(self.content),
|
.scrollable(
|
||||||
|
window.current_view(),
|
||||||
|
crate::scroll::ScrollbarAxis::Vertical,
|
||||||
|
)
|
||||||
|
.child(self.content),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.when(self.footer.is_some(), |this| {
|
.when(self.footer.is_some(), |this| {
|
||||||
let footer = self.footer.unwrap();
|
let footer = self.footer.unwrap();
|
||||||
|
|
||||||
this.child(h_flex().gap_2().justify_end().children(footer(
|
this.child(
|
||||||
render_ok,
|
h_flex()
|
||||||
render_cancel,
|
.gap_2()
|
||||||
window,
|
.pl(padding_left)
|
||||||
cx,
|
.pr(padding_right)
|
||||||
)))
|
.justify_end()
|
||||||
|
.children(footer(render_ok, render_cancel, window, cx)),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
.with_animation(
|
.with_animation(
|
||||||
"slide-down",
|
"slide-down",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue