feat(widget): create list-styled containers with list::container()
This commit is contained in:
parent
9963629a4f
commit
51ac288eed
2 changed files with 29 additions and 20 deletions
|
|
@ -1,9 +1,7 @@
|
||||||
// Copyright 2022 System76 <info@system76.com>
|
// Copyright 2022 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use crate::{theme, widget::divider, Element};
|
use crate::{widget::divider, Apply, Element};
|
||||||
use apply::Apply;
|
|
||||||
use iced::{Background, Color};
|
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn list_column<'a, Message: 'static>() -> ListColumn<'a, Message> {
|
pub fn list_column<'a, Message: 'static>() -> ListColumn<'a, Message> {
|
||||||
|
|
@ -43,9 +41,7 @@ impl<'a, Message: 'static> ListColumn<'a, Message> {
|
||||||
pub fn into_element(self) -> Element<'a, Message> {
|
pub fn into_element(self) -> Element<'a, Message> {
|
||||||
crate::widget::column::with_children(self.children)
|
crate::widget::column::with_children(self.children)
|
||||||
.spacing(12)
|
.spacing(12)
|
||||||
.apply(crate::widget::container)
|
.apply(super::container)
|
||||||
.padding([16, 6])
|
|
||||||
.style(theme::Container::custom(style))
|
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,17 +51,3 @@ impl<'a, Message: 'static> From<ListColumn<'a, Message>> for Element<'a, Message
|
||||||
column.into_element()
|
column.into_element()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
|
||||||
pub fn style(theme: &crate::Theme) -> crate::widget::container::Appearance {
|
|
||||||
let container = &theme.current_container().component;
|
|
||||||
crate::widget::container::Appearance {
|
|
||||||
icon_color: Some(container.on.into()),
|
|
||||||
text_color: Some(container.on.into()),
|
|
||||||
background: Some(Background::Color(container.base.into())),
|
|
||||||
border_radius: 8.0.into(),
|
|
||||||
border_width: 0.0,
|
|
||||||
border_color: Color::TRANSPARENT,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,30 @@ pub mod column;
|
||||||
|
|
||||||
pub use self::column::{list_column, ListColumn};
|
pub use self::column::{list_column, ListColumn};
|
||||||
// pub use self::item::{ListItem, list_item};
|
// pub use self::item::{ListItem, list_item};
|
||||||
|
|
||||||
|
use crate::widget::Container;
|
||||||
|
use crate::Element;
|
||||||
|
use iced::{Background, Color};
|
||||||
|
|
||||||
|
pub fn container<'a, Message>(
|
||||||
|
content: impl Into<Element<'a, Message>>,
|
||||||
|
) -> Container<'a, Message, crate::Renderer> {
|
||||||
|
super::container(content)
|
||||||
|
.padding([16, 6])
|
||||||
|
.style(crate::theme::Container::custom(style))
|
||||||
|
.width(iced::Length::Fill)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||||
|
pub fn style(theme: &crate::Theme) -> crate::widget::container::Appearance {
|
||||||
|
let container = &theme.current_container().component;
|
||||||
|
crate::widget::container::Appearance {
|
||||||
|
icon_color: Some(container.on.into()),
|
||||||
|
text_color: Some(container.on.into()),
|
||||||
|
background: Some(Background::Color(container.base.into())),
|
||||||
|
border_radius: 8.0.into(),
|
||||||
|
border_width: 0.0,
|
||||||
|
border_color: Color::TRANSPARENT,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue