Leverage DefaultStyle traits instead of Default
This commit is contained in:
parent
44f002f64a
commit
833538ee7f
30 changed files with 393 additions and 437 deletions
|
|
@ -3,7 +3,7 @@ use crate::{Command, Element, Executor, Settings, Subscription};
|
|||
|
||||
use crate::shell::application;
|
||||
|
||||
pub use application::{default, Appearance, Style};
|
||||
pub use application::{default, Appearance, DefaultStyle};
|
||||
|
||||
/// An interactive cross-platform application.
|
||||
///
|
||||
|
|
@ -95,7 +95,7 @@ pub use application::{default, Appearance, Style};
|
|||
/// ```
|
||||
pub trait Application: Sized
|
||||
where
|
||||
Style<Self::Theme>: Default,
|
||||
Self::Theme: DefaultStyle,
|
||||
{
|
||||
/// The [`Executor`] that will run commands and subscriptions.
|
||||
///
|
||||
|
|
@ -153,11 +153,9 @@ where
|
|||
Self::Theme::default()
|
||||
}
|
||||
|
||||
/// Returns the current `Style` of the [`Theme`].
|
||||
///
|
||||
/// [`Theme`]: Self::Theme
|
||||
/// Returns the current [`Appearance`] of the [`Application`].
|
||||
fn style(&self, theme: &Self::Theme) -> Appearance {
|
||||
Style::default().resolve(theme)
|
||||
theme.default_style()
|
||||
}
|
||||
|
||||
/// Returns the event [`Subscription`] for the current state of the
|
||||
|
|
@ -221,12 +219,12 @@ where
|
|||
struct Instance<A>(A)
|
||||
where
|
||||
A: Application,
|
||||
application::Style<A::Theme>: Default;
|
||||
A::Theme: DefaultStyle;
|
||||
|
||||
impl<A> crate::runtime::Program for Instance<A>
|
||||
where
|
||||
A: Application,
|
||||
application::Style<A::Theme>: Default,
|
||||
A::Theme: DefaultStyle,
|
||||
{
|
||||
type Message = A::Message;
|
||||
type Theme = A::Theme;
|
||||
|
|
@ -244,7 +242,7 @@ where
|
|||
impl<A> application::Application for Instance<A>
|
||||
where
|
||||
A: Application,
|
||||
application::Style<A::Theme>: Default,
|
||||
A::Theme: DefaultStyle,
|
||||
{
|
||||
type Flags = A::Flags;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use crate::window;
|
||||
use crate::{Command, Element, Executor, Settings, Subscription};
|
||||
|
||||
pub use crate::application::{default, Appearance, Style};
|
||||
pub use crate::application::{Appearance, DefaultStyle};
|
||||
|
||||
/// An interactive cross-platform multi-window application.
|
||||
///
|
||||
|
|
@ -67,7 +67,7 @@ pub use crate::application::{default, Appearance, Style};
|
|||
/// [`Sandbox`]: crate::Sandbox
|
||||
pub trait Application: Sized
|
||||
where
|
||||
Style<Self::Theme>: Default,
|
||||
Self::Theme: DefaultStyle,
|
||||
{
|
||||
/// The [`Executor`] that will run commands and subscriptions.
|
||||
///
|
||||
|
|
@ -133,7 +133,7 @@ where
|
|||
///
|
||||
/// [`Theme`]: Self::Theme
|
||||
fn style(&self, theme: &Self::Theme) -> Appearance {
|
||||
Style::default().resolve(theme)
|
||||
Self::Theme::default_style(theme)
|
||||
}
|
||||
|
||||
/// Returns the event [`Subscription`] for the current state of the
|
||||
|
|
@ -198,12 +198,12 @@ where
|
|||
struct Instance<A>(A)
|
||||
where
|
||||
A: Application,
|
||||
Style<A::Theme>: Default;
|
||||
A::Theme: DefaultStyle;
|
||||
|
||||
impl<A> crate::runtime::multi_window::Program for Instance<A>
|
||||
where
|
||||
A: Application,
|
||||
Style<A::Theme>: Default,
|
||||
A::Theme: DefaultStyle,
|
||||
{
|
||||
type Message = A::Message;
|
||||
type Theme = A::Theme;
|
||||
|
|
@ -224,7 +224,7 @@ where
|
|||
impl<A> crate::shell::multi_window::Application for Instance<A>
|
||||
where
|
||||
A: Application,
|
||||
Style<A::Theme>: Default,
|
||||
A::Theme: DefaultStyle,
|
||||
{
|
||||
type Flags = A::Flags;
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,9 @@ pub trait Sandbox {
|
|||
|
||||
/// Returns the current [`application::Appearance`].
|
||||
fn style(&self, theme: &Theme) -> application::Appearance {
|
||||
crate::shell::application::default(theme)
|
||||
use application::DefaultStyle;
|
||||
|
||||
theme.default_style()
|
||||
}
|
||||
|
||||
/// Returns the scale factor of the [`Sandbox`].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue