diff options
Diffstat (limited to 'src/application.rs')
| -rw-r--r-- | src/application.rs | 32 | 
1 files changed, 20 insertions, 12 deletions
| diff --git a/src/application.rs b/src/application.rs index 87c2607a..be0fa0de 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,7 +1,9 @@  //! Build interactive cross-platform applications.  use crate::{Command, Element, Executor, Settings, Subscription}; -pub use crate::style::application::{Appearance, StyleSheet}; +use crate::shell::application; + +pub use application::{default, Appearance, DefaultStyle};  /// An interactive cross-platform application.  /// @@ -91,7 +93,10 @@ pub use crate::style::application::{Appearance, StyleSheet};  ///     }  /// }  /// ``` -pub trait Application: Sized { +pub trait Application: Sized +where +    Self::Theme: DefaultStyle, +{      /// The [`Executor`] that will run commands and subscriptions.      ///      /// The [default executor] can be a good starting point! @@ -104,7 +109,7 @@ pub trait Application: Sized {      type Message: std::fmt::Debug + Send;      /// The theme of your [`Application`]. -    type Theme: Default + StyleSheet; +    type Theme: Default;      /// The data needed to initialize your [`Application`].      type Flags; @@ -148,11 +153,9 @@ pub trait Application: Sized {          Self::Theme::default()      } -    /// Returns the current `Style` of the [`Theme`]. -    /// -    /// [`Theme`]: Self::Theme -    fn style(&self) -> <Self::Theme as StyleSheet>::Style { -        <Self::Theme as StyleSheet>::Style::default() +    /// Returns the current [`Appearance`] of the [`Application`]. +    fn style(&self, theme: &Self::Theme) -> Appearance { +        theme.default_style()      }      /// Returns the event [`Subscription`] for the current state of the @@ -228,11 +231,15 @@ pub trait Application: Sized {      }  } -struct Instance<A: Application>(A); +struct Instance<A>(A) +where +    A: Application, +    A::Theme: DefaultStyle;  impl<A> crate::runtime::Program for Instance<A>  where      A: Application, +    A::Theme: DefaultStyle,  {      type Message = A::Message;      type Theme = A::Theme; @@ -247,9 +254,10 @@ where      }  } -impl<A> crate::shell::Application for Instance<A> +impl<A> application::Application for Instance<A>  where      A: Application, +    A::Theme: DefaultStyle,  {      type Flags = A::Flags; @@ -267,8 +275,8 @@ where          self.0.theme()      } -    fn style(&self) -> <A::Theme as StyleSheet>::Style { -        self.0.style() +    fn style(&self, theme: &A::Theme) -> Appearance { +        self.0.style(theme)      }      fn subscription(&self) -> Subscription<Self::Message> { | 
