Reintroduce Box for style_sheet in Button

This commit is contained in:
Héctor Ramón Jiménez 2021-10-31 16:53:18 +07:00
parent 661cb5736e
commit d36ce33a95
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
10 changed files with 42 additions and 30 deletions

View file

@ -82,7 +82,7 @@ impl Sandbox for Styling {
let button = Button::new(&mut self.button, Text::new("Submit"))
.padding(10)
.on_press(Message::ButtonPressed)
.style(self.theme.into());
.style(self.theme);
let slider = Slider::new(
&mut self.slider,
@ -203,11 +203,11 @@ mod style {
}
}
impl From<Theme> for &'static dyn button::StyleSheet {
impl<'a> From<Theme> for Box<dyn button::StyleSheet + 'a> {
fn from(theme: Theme) -> Self {
match theme {
Theme::Light => &light::Button,
Theme::Dark => &dark::Button,
Theme::Light => light::Button.into(),
Theme::Dark => dark::Button.into(),
}
}
}