feat(app): footer widget
This commit is contained in:
parent
9f11239ea5
commit
100f75f88e
2 changed files with 46 additions and 29 deletions
|
|
@ -421,6 +421,11 @@ where
|
|||
None
|
||||
}
|
||||
|
||||
/// Displays a footer at the bottom of the application window when `Some`.
|
||||
fn footer(&self) -> Option<Element<Self::Message>> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Attaches elements to the start section of the header.
|
||||
fn header_start(&self) -> Vec<Element<Self::Message>> {
|
||||
Vec::new()
|
||||
|
|
@ -705,16 +710,10 @@ impl<App: Application> ApplicationExt for App {
|
|||
widgets.push(main_content);
|
||||
if let Some(context) = self.context_drawer() {
|
||||
widgets.push(
|
||||
context_drawer(
|
||||
crate::widget::ContextDrawer::new_inner(
|
||||
&core.window.context_title,
|
||||
Message::Cosmic(cosmic::Message::ContextDrawer(false)),
|
||||
//TODO: this is a hack to allow toggling overlay
|
||||
horizontal_space(
|
||||
//TODO: this width must be synced with the context drawer width
|
||||
// Manual spacing must be used due to state workarounds below
|
||||
Length::Fixed(context_width + 8.0),
|
||||
),
|
||||
context.map(Message::App),
|
||||
Message::Cosmic(cosmic::Message::ContextDrawer(false)),
|
||||
context_width,
|
||||
)
|
||||
.apply(|drawer| {
|
||||
|
|
@ -733,8 +732,12 @@ impl<App: Application> ApplicationExt for App {
|
|||
|
||||
widgets
|
||||
});
|
||||
let content_col = crate::widget::column::with_capacity(2)
|
||||
.spacing(8)
|
||||
.push(content_row)
|
||||
.push_maybe(self.footer().map(|footer| footer.map(Message::App)));
|
||||
let content: Element<_> = if core.window.content_container {
|
||||
content_row
|
||||
content_col
|
||||
.apply(crate::widget::container)
|
||||
.padding([0, 8, 8, 8])
|
||||
.width(iced::Length::Fill)
|
||||
|
|
@ -743,7 +746,7 @@ impl<App: Application> ApplicationExt for App {
|
|||
.apply(|w| id_container(w, iced_core::id::Id::new("COSMIC_content_container")))
|
||||
.into()
|
||||
} else {
|
||||
content_row.into()
|
||||
content_col.into()
|
||||
};
|
||||
|
||||
let view_column = crate::widget::column::with_capacity(2)
|
||||
|
|
|
|||
|
|
@ -27,16 +27,13 @@ pub struct ContextDrawer<'a, Message> {
|
|||
}
|
||||
|
||||
impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
|
||||
/// Creates an empty [`ContextDrawer`].
|
||||
pub fn new<Content, Drawer>(
|
||||
pub fn new_inner<Drawer>(
|
||||
header: &'a str,
|
||||
content: Content,
|
||||
drawer: Drawer,
|
||||
on_close: Message,
|
||||
max_width: f32,
|
||||
) -> Self
|
||||
) -> Element<'a, Message>
|
||||
where
|
||||
Content: Into<Element<'a, Message>>,
|
||||
Drawer: Into<Element<'a, Message>>,
|
||||
{
|
||||
let header = row::with_capacity(3)
|
||||
|
|
@ -82,23 +79,40 @@ impl<'a, Message: Clone + 'static> ContextDrawer<'a, Message> {
|
|||
.width(Length::Shrink),
|
||||
);
|
||||
|
||||
// XXX new limits do not exactly handle the max width well for containers
|
||||
// XXX this is a hack to get around that
|
||||
container(
|
||||
LayerContainer::new(pane)
|
||||
.layer(cosmic_theme::Layer::Primary)
|
||||
.style(crate::style::Container::ContextDrawer)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.max_width(max_width),
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.align_x(alignment::Horizontal::Right)
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Creates an empty [`ContextDrawer`].
|
||||
pub fn new<Content, Drawer>(
|
||||
header: &'a str,
|
||||
content: Content,
|
||||
drawer: Drawer,
|
||||
on_close: Message,
|
||||
max_width: f32,
|
||||
) -> Self
|
||||
where
|
||||
Content: Into<Element<'a, Message>>,
|
||||
Drawer: Into<Element<'a, Message>>,
|
||||
{
|
||||
let drawer = Self::new_inner(header, drawer, on_close, max_width);
|
||||
|
||||
ContextDrawer {
|
||||
id: None,
|
||||
content: content.into(),
|
||||
// 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)
|
||||
.layer(cosmic_theme::Layer::Primary)
|
||||
.style(crate::style::Container::ContextDrawer)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.max_width(max_width),
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.align_x(alignment::Horizontal::Right)
|
||||
.into(),
|
||||
drawer,
|
||||
on_close: None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue