libcosmic/src/widget/nav.rs

61 lines
1.6 KiB
Rust
Raw Normal View History

use iced::{
Background,
Color,
Theme,
2022-09-30 09:51:00 -06:00
widget
};
2022-09-30 09:51:00 -06:00
#[macro_export]
macro_rules! nav_bar {
($($x:expr),+ $(,)?) => (
$crate::iced::widget::Container::new(
$crate::iced::widget::scrollable(
$crate::iced::widget::Column::with_children(
vec![$($crate::iced::Element::from($x)),+]
)
.spacing(12)
.padding([0,20,0,0])
)
2022-09-30 09:51:00 -06:00
)
.max_width(300)
.padding(12)
.height(Length::Fill)
2022-09-30 09:51:00 -06:00
.style(theme::Container::Custom(
$crate::widget::nav_bar_style
))
);
}
pub use nav_bar;
pub fn nav_bar_style(theme: &Theme) -> widget::container::Appearance {
let cosmic = &theme.cosmic().primary;
2022-09-30 09:51:00 -06:00
widget::container::Appearance {
text_color: Some(cosmic.on.into()),
background: Some(Background::Color(cosmic.base.into())),
border_radius: 8.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
}
}
2022-09-30 11:14:44 -06:00
#[macro_export]
macro_rules! nav_button {
2022-09-30 12:26:14 -06:00
($icon: expr, $title:expr, $condensed:expr) => ({
if $condensed {
$crate::iced::widget::Button::new(
$crate::widget::icon($icon, 16)
)
.padding(8)
} else {
$crate::widget::button!(
$crate::widget::icon($icon, 16),
$crate::iced::widget::Text::new($title),
$crate::iced::widget::horizontal_space(
$crate::iced::Length::Fill
),
)
}
});
2022-09-30 11:14:44 -06:00
}
pub use nav_button;