feat(widget): add dropdown widget as pick_list replacement
The Dropdown widget is based on the PickList widget from iced.
This commit is contained in:
parent
dbd6c978ba
commit
ca7c17ce21
9 changed files with 1121 additions and 15 deletions
28
src/theme/style/dropdown.rs
Normal file
28
src/theme/style/dropdown.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2023 System76 <info@system76.com>
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::widget::dropdown;
|
||||
use crate::Theme;
|
||||
use iced::{Background, Color};
|
||||
|
||||
impl dropdown::menu::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn appearance(&self, _style: &Self::Style) -> dropdown::menu::Appearance {
|
||||
let cosmic = self.cosmic();
|
||||
|
||||
dropdown::menu::Appearance {
|
||||
text_color: cosmic.on_bg_color().into(),
|
||||
background: Background::Color(cosmic.background.component.base.into()),
|
||||
border_width: 0.0,
|
||||
border_radius: 16.0.into(),
|
||||
border_color: Color::TRANSPARENT,
|
||||
|
||||
hovered_text_color: cosmic.on_bg_color().into(),
|
||||
hovered_background: Background::Color(cosmic.primary.component.hover.into()),
|
||||
|
||||
selected_text_color: cosmic.accent.base.into(),
|
||||
selected_background: Background::Color(cosmic.primary.component.hover.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -364,6 +364,7 @@ pub enum Container {
|
|||
Background,
|
||||
Card,
|
||||
Custom(Box<dyn Fn(&Theme) -> container::Appearance>),
|
||||
Dropdown,
|
||||
HeaderBar,
|
||||
Primary,
|
||||
Secondary,
|
||||
|
|
@ -447,6 +448,19 @@ impl container::StyleSheet for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
Container::Dropdown => {
|
||||
let theme = self.cosmic();
|
||||
|
||||
container::Appearance {
|
||||
icon_color: None,
|
||||
text_color: None,
|
||||
background: Some(iced::Background::Color(theme.primary.base.into())),
|
||||
border_radius: f32::from(theme.space_xxs()).into(),
|
||||
border_width: 1.0,
|
||||
border_color: theme.bg_divider().into(),
|
||||
}
|
||||
}
|
||||
|
||||
Container::Tooltip => {
|
||||
let theme = self.cosmic();
|
||||
|
||||
|
|
@ -593,8 +607,7 @@ impl menu::StyleSheet for Theme {
|
|||
border_width: 0.0,
|
||||
border_radius: 16.0.into(),
|
||||
border_color: Color::TRANSPARENT,
|
||||
selected_text_color: cosmic.on_bg_color().into(),
|
||||
// TODO doesn't seem to be specified
|
||||
selected_text_color: cosmic.accent.base.into(),
|
||||
selected_background: Background::Color(cosmic.background.component.hover.into()),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
mod button;
|
||||
pub use self::button::Button;
|
||||
|
||||
mod dropdown;
|
||||
|
||||
pub mod iced;
|
||||
pub use self::iced::Application;
|
||||
pub use self::iced::Checkbox;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue