aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml2
-rw-r--r--examples/styling.rs35
-rw-r--r--src/lib.rs4
-rw-r--r--src/pick_list.rs8
4 files changed, 17 insertions, 32 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 0175937..052d0ff 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ rust-version = "1.92"
[features]
default = []
# Provides `serde` support.
-serde = ["dep:serde"]
+serde = ["serde/derive"]
# Provides support for animating with `iced_anim`.
animate = ["dep:iced_anim"]
# Provides support for `iced_dialog`.
diff --git a/examples/styling.rs b/examples/styling.rs
index 6336da3..2bfd36f 100644
--- a/examples/styling.rs
+++ b/examples/styling.rs
@@ -3,11 +3,8 @@ use iced::widget::{
Button, center, checkbox, column, container, pick_list, progress_bar, row,
rule, scrollable, slider, space, text, text_input, toggler,
};
-use iced::{Center, Fill, Subscription, border};
-use iced_material::{
- Theme, button,
- utils::{disabled_container, disabled_text},
-};
+use iced::{Center, Fill, Subscription};
+use iced_material::{Theme, button};
type Element<'a, Message> = iced::Element<'a, Message, Theme>;
@@ -93,30 +90,12 @@ impl Styling {
text("Theme:"),
row![
if self.system_theme {
- Element::from(
- container(text(self.theme.to_string()))
- .padding([5, 10])
- .width(Fill)
- .style(|theme: &Theme| {
- let color = theme.colors().surface.text;
- container::Style {
- background: Some(
- disabled_container(color).into(),
- ),
- text_color: Some(disabled_text(color)),
- border: border::rounded(4),
- ..Default::default()
- }
- }),
- )
+ pick_list(Some(&self.theme), Theme::ALL, Theme::to_string)
+ .width(Fill)
} else {
- pick_list(
- Theme::ALL,
- Some(&self.theme),
- Message::ThemeChanged,
- )
- .width(Fill)
- .into()
+ pick_list(Some(&self.theme), Theme::ALL, Theme::to_string)
+ .on_select(Message::ThemeChanged)
+ .width(Fill)
},
checkbox(self.system_theme)
.label("Use system theme")
diff --git a/src/lib.rs b/src/lib.rs
index 33134eb..21c04b8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -138,10 +138,10 @@ impl Base for Theme {
}
}
- fn palette(&self) -> Option<iced_widget::theme::Palette> {
+ fn seed(&self) -> Option<iced_widget::theme::palette::Seed> {
let colors = self.colors();
- Some(iced_widget::theme::Palette {
+ Some(iced_widget::theme::palette::Seed {
background: colors.surface.color,
text: colors.surface.text,
primary: colors.primary.color,
diff --git a/src/pick_list.rs b/src/pick_list.rs
index c4d8a68..cbe8efa 100644
--- a/src/pick_list.rs
+++ b/src/pick_list.rs
@@ -2,6 +2,7 @@ use iced_widget::core::{Background, border};
use iced_widget::pick_list::{Catalog, Status, Style, StyleFn};
use super::Theme;
+use crate::utils::{disabled_container, disabled_text};
impl Catalog for Theme {
type Class<'a> = StyleFn<'a, Self>;
@@ -26,7 +27,7 @@ pub fn default(theme: &Theme, status: Status) -> Style {
text_color: surface.text,
placeholder_color: surface.text_variant,
handle_color: surface.text_variant,
- background: Background::Color(surface.container.highest),
+ background: Background::Color(surface.container.high),
border: border::rounded(4),
};
@@ -41,5 +42,10 @@ pub fn default(theme: &Theme, status: Status) -> Style {
border: border::rounded(4),
..active
},
+ Status::Disabled => Style {
+ text_color: disabled_text(surface.text),
+ background: disabled_container(surface.text).into(),
+ ..active
+ },
}
}