fix: context drawer

This commit is contained in:
Ashley Wulber 2024-02-01 14:06:43 -05:00 • committed by Ashley Wulber
parent dbcd927d4b
commit 925f5f0993

View file

@ -38,15 +38,13 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
Drawer: Into<Element<'a, Message>>, Drawer: Into<Element<'a, Message>>,
{ {
let header = row::with_capacity(3) let header = row::with_capacity(3)
.height(Length::Fixed(80.0))
.width(Length::Fixed(480.0))
.padding(Padding { .padding(Padding {
top: 0.0, top: 0.0,
bottom: 0.0, bottom: 0.0,
left: 32.0, left: 32.0,
right: 32.0, right: 32.0,
}) })
.push(Space::new(Length::FillPortion(1), Length::Shrink)) .push(Space::new(Length::FillPortion(1), Length::Fixed(0.0)))
.push( .push(
text::heading(header) text::heading(header)
.width(Length::FillPortion(1)) .width(Length::FillPortion(1))
@ -63,20 +61,30 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
.height(Length::Fill) .height(Length::Fill)
.align_x(alignment::Horizontal::Right) .align_x(alignment::Horizontal::Right)
.center_y(), .center_y(),
); )
// XXX must be done after pushing elements or it may be overwritten by size hints from contents
.height(Length::Fixed(80.0))
.width(Length::Fixed(480.0));
let pane = column::with_capacity(2).push(header).push(scrollable( let pane = column::with_capacity(2)
container(drawer.into()).padding(Padding { .push(header.height(Length::Fixed(80.)))
.push(
scrollable(container(drawer.into()).padding(Padding {
top: 0.0, top: 0.0,
left: 32.0, left: 32.0,
right: 32.0, right: 32.0,
bottom: 32.0, bottom: 32.0,
}), }))
)); .height(Length::Fill)
.width(Length::Shrink),
);
ContextDrawer { ContextDrawer {
content: content.into(), content: content.into(),
drawer: LayerContainer::new(pane) // XXX new limits do not exactly handle the max width well for containers
// XXX this is a hack to get around that
drawer: container(
LayerContainer::new(pane)
.style(crate::style::Container::custom(move |theme| { .style(crate::style::Container::custom(move |theme| {
let palette = theme.cosmic(); let palette = theme.cosmic();
@ -94,7 +102,11 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
.layer(cosmic_theme::Layer::Primary) .layer(cosmic_theme::Layer::Primary)
.width(Length::Fill) .width(Length::Fill)
.height(Length::Fill) .height(Length::Fill)
.max_width(480.0) .max_width(480.0),
)
.width(Length::Fill)
.height(Length::Fill)
.align_x(alignment::Horizontal::Right)
.into(), .into(),
on_close: None, on_close: None,
} }