diff options
author | 2022-03-07 18:04:13 +0700 | |
---|---|---|
committer | 2022-03-07 18:04:13 +0700 | |
commit | b50e208f31e51c2d947aeaf9fea8a9f287f26aa1 (patch) | |
tree | 6d5aef7e1def2287e7412568b2b81aca3a8d730f /lazy/src/pure.rs | |
parent | 9fd66c820d08d3ff193ef04907686774c98d2fec (diff) | |
download | iced-b50e208f31e51c2d947aeaf9fea8a9f287f26aa1.tar.gz iced-b50e208f31e51c2d947aeaf9fea8a9f287f26aa1.tar.bz2 iced-b50e208f31e51c2d947aeaf9fea8a9f287f26aa1.zip |
Implement `pure::Responsive` in `iced_lazy`
Diffstat (limited to 'lazy/src/pure.rs')
-rw-r--r-- | lazy/src/pure.rs | 32 |
1 files changed, 31 insertions, 1 deletions
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<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) +} |