Implement pure::Responsive in iced_lazy

This commit is contained in:
Héctor Ramón Jiménez 2022-03-07 18:04:13 +07:00
parent 9fd66c820d
commit b50e208f31
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
3 changed files with 398 additions and 3 deletions

View file

@ -1 +1,31 @@
pub mod component;
mod component;
mod responsive;
pub use component::Component;
pub use responsive::Responsive;
use iced_native::Size;
use iced_pure::Element;
/// Turns an implementor of [`Component`] into an [`Element`] that can be
/// embedded in any application.
pub fn component<'a, C, Message, Renderer>(
component: C,
) -> Element<'a, Message, Renderer>
where
C: Component<Message, Renderer> + 'a,
C::State: 'static,
Message: 'a,
Renderer: iced_native::Renderer + 'a,
{
component::view(component)
}
pub fn responsive<'a, Message, Renderer>(
f: impl Fn(Size) -> Element<'a, Message, Renderer> + 'a,
) -> Responsive<'a, Message, Renderer>
where
Renderer: iced_native::Renderer,
{
Responsive::new(f)
}