Add list_row macro to simplify alternative list items
This commit is contained in:
parent
f09a3109e8
commit
153437b3b0
2 changed files with 19 additions and 8 deletions
|
|
@ -3,6 +3,7 @@ use cosmic::{
|
|||
button,
|
||||
icon,
|
||||
list_item,
|
||||
list_row,
|
||||
list_section,
|
||||
list_view,
|
||||
nav_bar,
|
||||
|
|
@ -123,7 +124,7 @@ impl Sandbox for Window {
|
|||
),
|
||||
list_section!(
|
||||
"Buttons",
|
||||
row!(
|
||||
list_row!(
|
||||
button!("Primary")
|
||||
.style(theme::Button::Primary)
|
||||
.on_press(Message::ButtonPressed)
|
||||
|
|
@ -144,8 +145,8 @@ impl Sandbox for Window {
|
|||
.style(theme::Button::Text)
|
||||
.on_press(Message::ButtonPressed)
|
||||
,
|
||||
).spacing(12),
|
||||
row!(
|
||||
),
|
||||
list_row!(
|
||||
button!("Primary")
|
||||
.style(theme::Button::Primary)
|
||||
.padding([8, 16])
|
||||
|
|
@ -166,7 +167,7 @@ impl Sandbox for Window {
|
|||
.style(theme::Button::Text)
|
||||
.padding([8, 16])
|
||||
,
|
||||
).spacing(12),
|
||||
),
|
||||
),
|
||||
list_section!(
|
||||
"Controls",
|
||||
|
|
|
|||
|
|
@ -8,11 +8,21 @@ use iced::{
|
|||
#[macro_export]
|
||||
macro_rules! list_item {
|
||||
($title:expr, $($x:expr),+ $(,)?) => (
|
||||
$crate::iced::widget::Row::with_children(vec![
|
||||
$crate::iced::widget::Text::new($title).into(),
|
||||
$crate::widget::list_row!(
|
||||
$crate::iced::widget::Text::new($title),
|
||||
$crate::iced::widget::horizontal_space(
|
||||
$crate::iced::Length::Fill
|
||||
).into(),
|
||||
),
|
||||
$($x),+
|
||||
)
|
||||
);
|
||||
}
|
||||
pub use list_item;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! list_row {
|
||||
($($x:expr),+ $(,)?) => (
|
||||
$crate::iced::widget::Row::with_children(vec![
|
||||
$($crate::iced::Element::from($x)),+
|
||||
])
|
||||
.align_items(Alignment::Center)
|
||||
|
|
@ -20,7 +30,7 @@ macro_rules! list_item {
|
|||
.spacing(12)
|
||||
);
|
||||
}
|
||||
pub use list_item;
|
||||
pub use list_row;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! list_section {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue