diff --git a/iced b/iced index 23397f6fc54..1e48a5c8cf8 160000 --- a/iced +++ b/iced @@ -1 +1 @@ -Subproject commit 23397f6fc541d8d6b98b56999a59ad4f4255be95 +Subproject commit 1e48a5c8cf83bdb38d22494d46d91cac05f50a41 diff --git a/src/theme/style/iced.rs b/src/theme/style/iced.rs index 9b4095e798f..8775e0f460d 100644 --- a/src/theme/style/iced.rs +++ b/src/theme/style/iced.rs @@ -5,6 +5,7 @@ use crate::theme::{CosmicComponent, Theme, TRANSPARENT_COMPONENT}; use cosmic_theme::composite::over; +use iced::color; use iced_core::{Background, Border, Color, Shadow, Vector}; use iced_style::application; use iced_style::button as iced_button; @@ -858,6 +859,29 @@ impl toggler::StyleSheet for Theme { ..self.active(style, is_active) } } + + fn disabled(&self, style: &Self::Style, is_active: bool) -> toggler::Appearance { + let theme = self.cosmic(); + const HANDLE_MARGIN: f32 = 2.0; + let background: Color = if is_active { + theme.accent.base.into() + } else { + theme.palette.neutral_5.into() + }; + let foreground: Color = theme.palette.neutral_2.into(); + toggler::Appearance { + background: Color::from_rgba(background.r, background.g, background.b, 0.5), + background_border: None, + foreground: Color::from_rgba(foreground.r, foreground.g, foreground.b, 0.5), + foreground_border: None, + border_radius: theme.radius_xl().into(), + handle_radius: theme + .radius_xl() + .map(|x| (x - HANDLE_MARGIN).max(0.0)) + .into(), + handle_margin: HANDLE_MARGIN, + } + } } /* diff --git a/src/widget/settings/item.rs b/src/widget/settings/item.rs index 723d53a5941..110cbf55a4b 100644 --- a/src/widget/settings/item.rs +++ b/src/widget/settings/item.rs @@ -123,6 +123,6 @@ impl<'a, Message: 'static> Item<'a, Message> { is_checked: bool, message: impl Fn(bool) -> Message + 'static, ) -> Row<'a, Message> { - self.control(crate::widget::toggler(None, is_checked, message)) + self.control(crate::widget::toggler(None, is_checked, Some(message))) } } diff --git a/src/widget/toggler.rs b/src/widget/toggler.rs index 4e92ffd4cdc..e9554ade8d7 100644 --- a/src/widget/toggler.rs +++ b/src/widget/toggler.rs @@ -7,7 +7,7 @@ use iced_core::text; pub fn toggler<'a, Message, Theme: iced_widget::toggler::StyleSheet, Renderer>( label: impl Into>, is_checked: bool, - f: impl Fn(bool) -> Message + 'a, + f: Option Message + 'a>, ) -> widget::Toggler<'a, Message, Theme, Renderer> where Renderer: iced_core::Renderer + text::Renderer,