2022-12-06 16:12:59 +01:00
|
|
|
// Copyright 2022 System76 <info@system76.com>
|
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2022-10-12 19:44:44 -07:00
|
|
|
pub mod nav_bar {
|
2022-10-28 21:59:41 -07:00
|
|
|
use crate::Theme;
|
2022-11-11 05:06:54 +01:00
|
|
|
use iced::{widget, Background, Color};
|
2022-10-12 19:44:44 -07:00
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! nav_button {
|
2022-12-19 15:43:05 -07:00
|
|
|
($icon: expr, $title:expr, $condensed:expr, $active:expr) => {{
|
2022-10-12 19:44:44 -07:00
|
|
|
if $condensed {
|
2022-12-19 15:43:05 -07:00
|
|
|
$crate::iced::widget::Button::new(
|
|
|
|
|
$crate::widget::icon($icon, 22)
|
|
|
|
|
.style(if $active {
|
|
|
|
|
$crate::theme::Svg::SymbolicPrimary
|
|
|
|
|
} else {
|
|
|
|
|
$crate::theme::Svg::Symbolic
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
.padding(8)
|
|
|
|
|
.style(if $active {
|
|
|
|
|
$crate::theme::Button::Primary
|
|
|
|
|
} else {
|
|
|
|
|
$crate::theme::Button::Text
|
|
|
|
|
})
|
2022-10-12 19:44:44 -07:00
|
|
|
} else {
|
2022-12-19 15:43:05 -07:00
|
|
|
$crate::iced::widget::Button::new(
|
|
|
|
|
$crate::iced::widget::row!(
|
|
|
|
|
$crate::widget::icon($icon, 16)
|
|
|
|
|
.style(if $active {
|
|
|
|
|
$crate::theme::Svg::SymbolicPrimary
|
|
|
|
|
} else {
|
|
|
|
|
$crate::theme::Svg::Symbolic
|
|
|
|
|
}),
|
|
|
|
|
$crate::iced::widget::Text::new($title)
|
|
|
|
|
.vertical_alignment($crate::iced::alignment::Vertical::Center),
|
|
|
|
|
$crate::iced::widget::horizontal_space($crate::iced::Length::Fill),
|
|
|
|
|
)
|
|
|
|
|
.padding([0, 16])
|
|
|
|
|
.spacing(8)
|
2022-10-12 19:44:44 -07:00
|
|
|
)
|
2022-12-19 15:43:05 -07:00
|
|
|
.style(if $active {
|
|
|
|
|
$crate::theme::Button::Primary
|
|
|
|
|
} else {
|
|
|
|
|
$crate::theme::Button::Text
|
|
|
|
|
})
|
2022-10-12 19:44:44 -07:00
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-13 02:23:37 -07:00
|
|
|
pub fn nav_bar_sections_style(theme: &Theme) -> widget::container::Appearance {
|
2022-10-12 19:44:44 -07:00
|
|
|
let cosmic = &theme.cosmic().primary;
|
|
|
|
|
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-10-13 02:23:37 -07:00
|
|
|
pub fn nav_bar_pages_style(theme: &Theme) -> widget::container::Appearance {
|
|
|
|
|
let primary = &theme.cosmic().primary;
|
|
|
|
|
let secondary = &theme.cosmic().secondary;
|
|
|
|
|
widget::container::Appearance {
|
|
|
|
|
text_color: Some(primary.on.into()),
|
|
|
|
|
background: Some(Background::Color(secondary.component.base.into())),
|
|
|
|
|
border_radius: 8.0,
|
|
|
|
|
border_width: 0.0,
|
|
|
|
|
border_color: Color::TRANSPARENT,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-12 19:44:44 -07:00
|
|
|
pub use nav_button;
|
|
|
|
|
}
|