Add desktop options page

This commit is contained in:
Jeremy Soller 2022-12-20 16:02:44 -07:00
parent aa7b66c925
commit 98815f5131
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
3 changed files with 159 additions and 69 deletions

View file

@ -128,6 +128,8 @@ pub enum Button {
Primary,
Secondary,
Text,
Link,
LinkActive,
Transparent,
Custom {
active: fn(&Theme) -> button::Appearance,
@ -150,6 +152,8 @@ impl Button {
Button::Positive => &cosmic.success,
Button::Destructive => &cosmic.destructive,
Button::Text => &cosmic.secondary.component,
Button::Link => &cosmic.accent,
Button::LinkActive => &cosmic.secondary.component,
Button::Transparent => &TRANSPARENT_COMPONENT,
Button::Deactivated => &cosmic.secondary.component,
Button::Custom { .. } => &TRANSPARENT_COMPONENT
@ -168,12 +172,21 @@ impl button::StyleSheet for Theme {
let cosmic = style.cosmic(self);
button::Appearance {
border_radius: 24.0,
border_radius: match style {
Button::Link => 0.0,
_ => 24.0,
},
background: match style {
Button::Text => None,
Button::Link => None,
Button::LinkActive => Some(Background::Color(cosmic.divider.into())),
_ => Some(Background::Color(cosmic.base.into())),
},
text_color: cosmic.on.into(),
text_color: match style {
Button::Link => cosmic.base.into(),
Button::LinkActive => cosmic.selected_text.into(),
_ => cosmic.on.into(),
},
..button::Appearance::default()
}
}
@ -187,7 +200,11 @@ impl button::StyleSheet for Theme {
let cosmic = style.cosmic(self);
button::Appearance {
background: Some(Background::Color(cosmic.hover.into())),
background: match style {
Button::Link => None,
Button::LinkActive => Some(Background::Color(cosmic.divider.into())),
_ => Some(Background::Color(cosmic.hover.into()))
},
..active
}
}
@ -712,6 +729,8 @@ pub enum Svg {
SymbolicActive,
/// Icon fill color will match on primary color
SymbolicPrimary,
/// Icon fill color will use accent color
SymbolicLink,
}
impl Hash for Svg {
@ -722,6 +741,7 @@ impl Hash for Svg {
Svg::Symbolic => 2,
Svg::SymbolicActive => 3,
Svg::SymbolicPrimary => 4,
Svg::SymbolicLink => 5,
};
id.hash(state);
@ -744,6 +764,9 @@ impl svg::StyleSheet for Theme {
Svg::SymbolicPrimary => svg::Appearance {
color: Some(self.cosmic().accent.on.into()),
},
Svg::SymbolicLink => svg::Appearance {
color: Some(self.cosmic().accent.base.into()),
},
}
}
}

View file

@ -12,14 +12,14 @@ pub mod nav_bar {
$crate::iced::widget::Button::new(
$crate::widget::icon($icon, 22)
.style(if $active {
$crate::theme::Svg::SymbolicPrimary
$crate::theme::Svg::SymbolicLink
} else {
$crate::theme::Svg::Symbolic
})
)
.padding(8)
.style(if $active {
$crate::theme::Button::Primary
$crate::theme::Button::LinkActive
} else {
$crate::theme::Button::Text
})
@ -28,7 +28,7 @@ pub mod nav_bar {
$crate::iced::widget::row!(
$crate::widget::icon($icon, 16)
.style(if $active {
$crate::theme::Svg::SymbolicPrimary
$crate::theme::Svg::SymbolicLink
} else {
$crate::theme::Svg::Symbolic
}),
@ -40,7 +40,7 @@ pub mod nav_bar {
.spacing(8)
)
.style(if $active {
$crate::theme::Button::Primary
$crate::theme::Button::LinkActive
} else {
$crate::theme::Button::Text
})