List hierarchy changes
This commit is contained in:
parent
5d25af14a9
commit
ae3f5b9b2e
2 changed files with 60 additions and 43 deletions
|
|
@ -9,6 +9,7 @@ use iced::{
|
|||
macro_rules! list_item {
|
||||
($($x:expr),+ $(,)?) => (
|
||||
$crate::iced::widget::Row::with_children(vec![$($crate::iced::Element::from($x)),+])
|
||||
.align_items(Alignment::Center)
|
||||
.padding([0, 8])
|
||||
.spacing(12)
|
||||
);
|
||||
|
|
@ -16,30 +17,38 @@ macro_rules! list_item {
|
|||
pub use list_item;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! list_view {
|
||||
($($x:expr),+ $(,)?) => (
|
||||
$crate::iced::widget::Container::new({
|
||||
let mut children = vec![$($crate::iced::Element::from($x)),+];
|
||||
macro_rules! list_section {
|
||||
($heading:expr, $($x:expr),+ $(,)?) => (
|
||||
$crate::iced::widget::Column::with_children(vec![
|
||||
$crate::iced::widget::Text::new($heading)
|
||||
.font($crate::font::FONT_SEMIBOLD)
|
||||
.into()
|
||||
,
|
||||
$crate::iced::widget::Container::new({
|
||||
let mut children = vec![$($crate::iced::Element::from($x)),+];
|
||||
|
||||
//TODO: more efficient method for adding separators
|
||||
let mut i = 1;
|
||||
while i < children.len() {
|
||||
children.insert(i, $crate::iced::widget::horizontal_rule(12).into());
|
||||
i += 2;
|
||||
}
|
||||
//TODO: more efficient method for adding separators
|
||||
let mut i = 1;
|
||||
while i < children.len() {
|
||||
children.insert(i, $crate::iced::widget::horizontal_rule(12).into());
|
||||
i += 2;
|
||||
}
|
||||
|
||||
$crate::iced::widget::Column::with_children(children)
|
||||
.spacing(12)
|
||||
})
|
||||
.padding([12, 16])
|
||||
.style(theme::Container::Custom(
|
||||
$crate::widget::list_view_style
|
||||
))
|
||||
$crate::iced::widget::Column::with_children(children)
|
||||
.spacing(12)
|
||||
})
|
||||
.padding([12, 16])
|
||||
.style(theme::Container::Custom(
|
||||
$crate::widget::list_section_style
|
||||
))
|
||||
.into()
|
||||
])
|
||||
.spacing(8)
|
||||
);
|
||||
}
|
||||
pub use list_view;
|
||||
pub use list_section;
|
||||
|
||||
pub fn list_view_style(theme: &Theme) -> widget::container::Appearance {
|
||||
pub fn list_section_style(theme: &Theme) -> widget::container::Appearance {
|
||||
widget::container::Appearance {
|
||||
text_color: None,
|
||||
background: Some(Background::Color(
|
||||
|
|
@ -53,3 +62,16 @@ pub fn list_view_style(theme: &Theme) -> widget::container::Appearance {
|
|||
border_color: Color::TRANSPARENT,
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! list_view {
|
||||
($($x:expr),+ $(,)?) => (
|
||||
$crate::iced::widget::Column::with_children(
|
||||
vec![$($crate::iced::Element::from($x)),+]
|
||||
)
|
||||
.spacing(24)
|
||||
.padding(24)
|
||||
.max_width(600)
|
||||
);
|
||||
}
|
||||
pub use list_view;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue