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,39 +61,53 @@ 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.)))
top: 0.0, .push(
left: 32.0, scrollable(container(drawer.into()).padding(Padding {
right: 32.0, top: 0.0,
bottom: 32.0, left: 32.0,
}), right: 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
.style(crate::style::Container::custom(move |theme| { // XXX this is a hack to get around that
let palette = theme.cosmic(); drawer: container(
LayerContainer::new(pane)
.style(crate::style::Container::custom(move |theme| {
let palette = theme.cosmic();
container::Appearance { container::Appearance {
icon_color: Some(Color::from(palette.primary.on)), icon_color: Some(Color::from(palette.primary.on)),
text_color: Some(Color::from(palette.primary.on)), text_color: Some(Color::from(palette.primary.on)),
background: Some(iced::Background::Color(palette.primary.base.into())), background: Some(iced::Background::Color(palette.primary.base.into())),
border: Border { border: Border {
radius: palette.corner_radii.radius_s.into(), radius: palette.corner_radii.radius_s.into(),
..Default::default()
},
..Default::default() ..Default::default()
}, }
..Default::default() }))
} .layer(cosmic_theme::Layer::Primary)
})) .width(Length::Fill)
.layer(cosmic_theme::Layer::Primary) .height(Length::Fill)
.width(Length::Fill) .max_width(480.0),
.height(Length::Fill) )
.max_width(480.0) .width(Length::Fill)
.into(), .height(Length::Fill)
.align_x(alignment::Horizontal::Right)
.into(),
on_close: None, on_close: None,
} }
} }