From b50e208f31e51c2d947aeaf9fea8a9f287f26aa1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 7 Mar 2022 18:04:13 +0700 Subject: Implement `pure::Responsive` in `iced_lazy` --- lazy/src/pure.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'lazy/src/pure.rs') diff --git a/lazy/src/pure.rs b/lazy/src/pure.rs index 9cea807e..dc500e5e 100644 --- a/lazy/src/pure.rs +++ b/lazy/src/pure.rs @@ -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 + '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) +} -- cgit