Leverage DefaultStyle traits instead of Default

This commit is contained in:
Héctor Ramón Jiménez 2024-03-07 20:11:32 +01:00
parent 44f002f64a
commit 833538ee7f
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
30 changed files with 393 additions and 437 deletions

View file

@ -34,12 +34,12 @@ where
/// Creates a new [`Content`] with the provided body.
pub fn new(body: impl Into<Element<'a, Message, Theme, Renderer>>) -> Self
where
container::Style<Theme>: Default,
Theme: container::DefaultStyle,
{
Self {
title_bar: None,
body: body.into(),
style: container::Style::default(),
style: Theme::default_style(),
}
}
@ -114,7 +114,7 @@ where
container::Status::Idle
};
self.style.resolve(theme, status)
(self.style)(theme, status)
};
container::draw_background(renderer, &style, bounds);
@ -403,8 +403,8 @@ impl<'a, T, Message, Theme, Renderer> From<T>
for Content<'a, Message, Theme, Renderer>
where
T: Into<Element<'a, Message, Theme, Renderer>>,
Theme: container::DefaultStyle,
Renderer: crate::core::Renderer,
container::Style<Theme>: Default,
{
fn from(element: T) -> Self {
Self::new(element)

View file

@ -37,14 +37,14 @@ where
content: impl Into<Element<'a, Message, Theme, Renderer>>,
) -> Self
where
container::Style<Theme>: Default,
Theme: container::DefaultStyle,
{
Self {
content: content.into(),
controls: None,
padding: Padding::ZERO,
always_show_controls: false,
style: container::Style::default(),
style: Theme::default_style(),
}
}
@ -138,7 +138,7 @@ where
container::Status::Idle
};
self.style.resolve(theme, status)
(self.style)(theme, status)
};
let inherited_style = renderer::Style {