Allow pure widgets to borrow from Application data 🎉
This commit is contained in:
parent
43a7ad72ef
commit
01c5004959
11 changed files with 103 additions and 98 deletions
|
|
@ -20,7 +20,8 @@
|
|||
pub use iced_pure::{Element as _, *};
|
||||
|
||||
/// A generic, pure [`Widget`].
|
||||
pub type Element<Message> = iced_pure::Element<Message, crate::Renderer>;
|
||||
pub type Element<'a, Message> =
|
||||
iced_pure::Element<'a, Message, crate::Renderer>;
|
||||
|
||||
mod application;
|
||||
mod sandbox;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ pub trait Application: Sized {
|
|||
/// Returns the widgets to display in the [`Application`].
|
||||
///
|
||||
/// These widgets can produce __messages__ based on user interaction.
|
||||
fn view(&self) -> pure::Element<Self::Message>;
|
||||
fn view(&self) -> pure::Element<'_, Self::Message>;
|
||||
|
||||
/// Returns the current [`Application`] mode.
|
||||
///
|
||||
|
|
@ -126,7 +126,7 @@ pub trait Application: Sized {
|
|||
|
||||
struct Instance<A: Application> {
|
||||
application: A,
|
||||
state: pure::State<A::Message, crate::Renderer>,
|
||||
state: pure::State,
|
||||
}
|
||||
|
||||
impl<A> crate::Application for Instance<A>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ pub trait Sandbox {
|
|||
/// Returns the widgets to display in the [`Sandbox`].
|
||||
///
|
||||
/// These widgets can produce __messages__ based on user interaction.
|
||||
fn view(&self) -> pure::Element<Self::Message>;
|
||||
fn view(&self) -> pure::Element<'_, Self::Message>;
|
||||
|
||||
/// Returns the background color of the [`Sandbox`].
|
||||
///
|
||||
|
|
@ -101,7 +101,7 @@ where
|
|||
Subscription::none()
|
||||
}
|
||||
|
||||
fn view(&self) -> pure::Element<T::Message> {
|
||||
fn view(&self) -> pure::Element<'_, T::Message> {
|
||||
T::view(self)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue