feat(widget): create list-styled containers with list::container()

This commit is contained in:
Michael Aaron Murphy 2023-09-13 15:43:24 +02:00 committed by Michael Murphy
parent 9963629a4f
commit 51ac288eed
2 changed files with 29 additions and 20 deletions

View file

@ -6,3 +6,30 @@ pub mod column;
pub use self::column::{list_column, ListColumn};
// 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,
}
}