From d39ad717ed0ab85acbe935d7ab883166b36e7bc7 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Oct 2021 19:06:53 +0700 Subject: Wire up styling to `Radio` in `iced_native` --- web/src/widget/radio.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'web/src/widget/radio.rs') diff --git a/web/src/widget/radio.rs b/web/src/widget/radio.rs index fbc88d29..5e9eaa3f 100644 --- a/web/src/widget/radio.rs +++ b/web/src/widget/radio.rs @@ -31,17 +31,17 @@ use dodrio::bumpalo; /// /// ![Radio buttons drawn by Coffee's renderer](https://github.com/hecrj/coffee/blob/bda9818f823dfcb8a7ad0ff4940b4d4b387b5208/images/ui/radio.png?raw=true) #[allow(missing_debug_implementations)] -pub struct Radio { +pub struct Radio<'a, Message> { is_selected: bool, on_click: Message, label: String, id: Option, name: Option, #[allow(dead_code)] - style: Box, + style_sheet: &'a dyn StyleSheet, } -impl Radio { +impl<'a, Message> Radio<'a, Message> { /// Creates a new [`Radio`] button. /// /// It expects: @@ -66,13 +66,13 @@ impl Radio { label: label.into(), id: None, name: None, - style: Default::default(), + style_sheet: Default::default(), } } /// Sets the style of the [`Radio`] button. - 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 } @@ -89,7 +89,7 @@ impl Radio { } } -impl Widget for Radio +impl<'a, Message> Widget for Radio<'a, Message> where Message: 'static + Clone, { @@ -142,11 +142,11 @@ where } } -impl<'a, Message> From> for Element<'a, Message> +impl<'a, Message> From> for Element<'a, Message> where Message: 'static + Clone, { - fn from(radio: Radio) -> Element<'a, Message> { + fn from(radio: Radio<'a, Message>) -> Element<'a, Message> { Element::new(radio) } } -- cgit From bd7b086ec1f9d428945f05fb12bda157f9e77dfd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 31 Oct 2021 17:14:10 +0700 Subject: Reintroduce `Box` for `style_sheet` in `Radio` --- web/src/widget/radio.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web/src/widget/radio.rs') diff --git a/web/src/widget/radio.rs b/web/src/widget/radio.rs index 5e9eaa3f..03b2922b 100644 --- a/web/src/widget/radio.rs +++ b/web/src/widget/radio.rs @@ -38,7 +38,7 @@ pub struct Radio<'a, Message> { id: Option, name: Option, #[allow(dead_code)] - style_sheet: &'a dyn StyleSheet, + style_sheet: Box, } impl<'a, Message> Radio<'a, Message> { @@ -71,8 +71,11 @@ impl<'a, Message> Radio<'a, Message> { } /// Sets the style of the [`Radio`] button. - pub fn style(mut self, style_sheet: &'a dyn StyleSheet) -> Self { - self.style_sheet = style_sheet; + pub fn style( + mut self, + style_sheet: impl Into>, + ) -> Self { + self.style_sheet = style_sheet.into(); self } -- cgit