Reintroduce Box for style_sheet in Container

This commit is contained in:
Héctor Ramón Jiménez 2021-10-31 17:02:59 +07:00
parent fcc282bd76
commit 40a5de5811
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
12 changed files with 51 additions and 30 deletions

View file

@ -164,7 +164,7 @@ impl Sandbox for ScrollableDemo {
Container::new(scrollable)
.width(Length::Fill)
.height(Length::Fill)
.style(theme.clone().into()),
.style(*theme),
)
.push(ProgressBar::new(
0.0..=1.0,
@ -190,7 +190,7 @@ impl Sandbox for ScrollableDemo {
.height(Length::Fill)
.center_x()
.center_y()
.style(self.theme.into())
.style(self.theme)
.into()
}
}

View file

@ -16,11 +16,11 @@ impl Default for Theme {
}
}
impl From<Theme> for &'static dyn container::StyleSheet {
impl<'a> From<Theme> for Box<dyn container::StyleSheet + 'a> {
fn from(theme: Theme) -> Self {
match theme {
Theme::Light => Default::default(),
Theme::Dark => &dark::Container,
Theme::Dark => dark::Container.into(),
}
}
}