From 7c08c6bd138207b862933ee479752a4f1d18c4f2 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 Oct 2021 18:50:27 +0700 Subject: Remove `Renderer` trait for `Checkbox` --- web/src/widget/checkbox.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'web/src/widget') diff --git a/web/src/widget/checkbox.rs b/web/src/widget/checkbox.rs index 43110aa7..095ef47d 100644 --- a/web/src/widget/checkbox.rs +++ b/web/src/widget/checkbox.rs @@ -24,17 +24,17 @@ use std::rc::Rc; /// /// ![Checkbox drawn by Coffee's renderer](https://github.com/hecrj/coffee/blob/bda9818f823dfcb8a7ad0ff4940b4d4b387b5208/images/ui/checkbox.png?raw=true) #[allow(missing_debug_implementations)] -pub struct Checkbox { +pub struct Checkbox<'a, Message> { is_checked: bool, on_toggle: Rc Message>, label: String, id: Option, width: Length, #[allow(dead_code)] - style: Box, + style_sheet: &'a dyn StyleSheet, } -impl Checkbox { +impl<'a, Message> Checkbox<'a, Message> { /// Creates a new [`Checkbox`]. /// /// It expects: @@ -53,7 +53,7 @@ impl Checkbox { label: label.into(), id: None, width: Length::Shrink, - style: Default::default(), + style_sheet: Default::default(), } } @@ -64,8 +64,8 @@ impl Checkbox { } /// Sets the style of the [`Checkbox`]. - pub fn style(mut self, style: impl Into>) -> Self { - self.style = style.into(); + pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { + self.style_sheet = style_sheet; self } @@ -76,7 +76,7 @@ impl Checkbox { } } -impl Widget for Checkbox +impl<'a, Message> Widget for Checkbox<'a, Message> where Message: 'static, { @@ -137,11 +137,11 @@ where } } -impl<'a, Message> From> for Element<'a, Message> +impl<'a, Message> From> for Element<'a, Message> where Message: 'static, { - fn from(checkbox: Checkbox) -> Element<'a, Message> { + fn from(checkbox: Checkbox<'a, Message>) -> Element<'a, Message> { Element::new(checkbox) } } -- cgit