summaryrefslogtreecommitdiffstats
path: root/examples/styling
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-04 03:26:53 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-04 03:26:53 +0200
commit835877fc636d71c1faaa4826cbfde8e09b3c82ba (patch)
tree018b28dd724c7585932753b27eb7a0980cc99cf4 /examples/styling
parent1388d71f0368731e7efd799ee274ede9b8d3c690 (diff)
downloadiced-835877fc636d71c1faaa4826cbfde8e09b3c82ba.tar.gz
iced-835877fc636d71c1faaa4826cbfde8e09b3c82ba.tar.bz2
iced-835877fc636d71c1faaa4826cbfde8e09b3c82ba.zip
Implement theme styling for `Checkbox`
Diffstat (limited to 'examples/styling')
-rw-r--r--examples/styling/src/main.rs43
1 files changed, 3 insertions, 40 deletions
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs
index e19b4279..8cd17a6c 100644
--- a/examples/styling/src/main.rs
+++ b/examples/styling/src/main.rs
@@ -105,8 +105,7 @@ impl Sandbox for Styling {
self.checkbox_value,
"Check me!",
Message::CheckboxToggled,
- )
- .style(self.theme);
+ );
let toggler = Toggler::new(
self.toggler_value,
@@ -158,7 +157,7 @@ impl Sandbox for Styling {
}
mod style {
- use iced::{checkbox, scrollable, text_input};
+ use iced::{scrollable, text_input};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Theme {
@@ -194,17 +193,8 @@ mod style {
}
}
- impl<'a> From<Theme> for Box<dyn checkbox::StyleSheet + 'a> {
- fn from(theme: Theme) -> Self {
- match theme {
- Theme::Light => Default::default(),
- Theme::Dark => dark::Checkbox.into(),
- }
- }
- }
-
mod dark {
- use iced::{checkbox, scrollable, text_input, Color};
+ use iced::{scrollable, text_input, Color};
const SURFACE: Color = Color::from_rgb(
0x40 as f32 / 255.0,
@@ -314,32 +304,5 @@ mod style {
}
}
}
-
- pub struct Checkbox;
-
- impl checkbox::StyleSheet for Checkbox {
- fn active(&self, is_checked: bool) -> checkbox::Style {
- checkbox::Style {
- background: if is_checked { ACTIVE } else { SURFACE }
- .into(),
- checkmark_color: Color::WHITE,
- border_radius: 2.0,
- border_width: 1.0,
- border_color: ACTIVE,
- text_color: None,
- }
- }
-
- fn hovered(&self, is_checked: bool) -> checkbox::Style {
- checkbox::Style {
- background: Color {
- a: 0.8,
- ..if is_checked { ACTIVE } else { SURFACE }
- }
- .into(),
- ..self.active(is_checked)
- }
- }
- }
}
}