From abdae3a7ec1413df86fca93699fb2448226e2da5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 6 Feb 2020 00:31:52 +0100 Subject: Expose styling types for `checkbox` in `iced_web` --- web/src/widget/checkbox.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index 7c7b805c..5160e221 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -1,5 +1,7 @@ //! Show toggle controls using checkboxes. -use crate::{Bus, Color, Css, Element, Widget}; +use crate::{Bus, Css, Element, Length, Widget}; + +pub use iced_style::checkbox::{Style, StyleSheet}; use dodrio::bumpalo; use std::rc::Rc; @@ -26,7 +28,8 @@ pub struct Checkbox { is_checked: bool, on_toggle: Rc Message>, label: String, - label_color: Option, + width: Length, + style: Box, } impl Checkbox { @@ -48,15 +51,24 @@ impl Checkbox { is_checked, on_toggle: Rc::new(f), label: String::from(label), - label_color: None, + width: Length::Shrink, + style: Default::default(), } } - /// Sets the color of the label of the [`Checkbox`]. + /// Sets the width of the [`Checkbox`]. /// /// [`Checkbox`]: struct.Checkbox.html - pub fn label_color>(mut self, color: C) -> Self { - self.label_color = Some(color.into()); + pub fn width(mut self, width: Length) -> Self { + self.width = width; + self + } + + /// Sets the style of the [`Checkbox`]. + /// + /// [`Checkbox`]: struct.Checkbox.html + pub fn style(mut self, style: impl Into>) -> Self { + self.style = style.into(); self } } @@ -79,7 +91,8 @@ where let on_toggle = self.on_toggle.clone(); let is_checked = self.is_checked; - // TODO: Complete styling + // TODO: Styling + label(bump) .children(vec![ input(bump) -- cgit