drawer: Set paddings to base to support override drawer body paddings. (#413)

Co-authored-by: Jason Lee <huacnlee@gmail.com>
This commit is contained in:
ihavecoke 2024-11-13 14:38:47 +08:00 committed by GitHub
parent 40345f1e42
commit d53b30ff9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 11 deletions

View file

@ -19,10 +19,7 @@ use ui::{
theme::ActiveTheme as _,
v_flex,
webview::WebView,
ContextModal as _,
Icon,
IconName,
Placement
ContextModal as _, Icon, IconName, Placement,
};
actions!(modal_story, [TestAction]);
@ -499,18 +496,18 @@ impl Render for ModalStory {
WebView::new(cx, webview)
});
webview.update(cx, |webview, _| {
webview.load_url("https://github.com");
webview.load_url("https://github.com/explore");
});
cx.open_drawer(move |drawer, cx| {
let height = cx.window_bounds().get_bounds().size.height;
let webview_bounds = webview.read(cx).bounds();
let buffer_height = px(12.);
drawer
.title("WebView Title")
.p_0()
.child(
div()
.h(height - webview_bounds.origin.y - buffer_height)
.h(height - webview_bounds.origin.y)
.child(webview.clone())
)
});

View file

@ -48,7 +48,7 @@ impl Drawer {
resizable: true,
title: None,
footer: None,
content: v_flex(),
content: v_flex().px_4().py_3(),
margin_top: TITLE_BAR_HEIGHT,
overlay: true,
on_close: Rc::new(|_, _| {}),
@ -189,7 +189,7 @@ impl RenderOnce for Drawer {
h_flex()
.justify_between()
.px_4()
.py_3()
.py_2()
.w_full()
.child(self.title.unwrap_or(div().into_any_element()))
.child(
@ -204,10 +204,9 @@ impl RenderOnce for Drawer {
),
)
.child(
// Body
div().flex_1().overflow_hidden().child(
v_flex()
.p_4()
.pt_0()
.scrollable(
cx.parent_view_id().unwrap_or_default(),
ScrollbarAxis::Vertical,
@ -216,6 +215,7 @@ impl RenderOnce for Drawer {
),
)
.when_some(self.footer, |this, footer| {
// Footer
this.child(
h_flex()
.justify_between()