diff options
Diffstat (limited to 'src/pure/sandbox.rs')
-rw-r--r-- | src/pure/sandbox.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/pure/sandbox.rs b/src/pure/sandbox.rs index fbd1d7a8..207a32bd 100644 --- a/src/pure/sandbox.rs +++ b/src/pure/sandbox.rs @@ -1,5 +1,5 @@ use crate::pure; -use crate::{Color, Command, Error, Settings, Subscription}; +use crate::{Color, Command, Error, Settings, Subscription, Theme}; /// A pure version of [`Sandbox`]. /// @@ -34,6 +34,16 @@ pub trait Sandbox { /// These widgets can produce __messages__ based on user interaction. fn view(&self) -> pure::Element<'_, Self::Message>; + /// Returns the current [`Theme`] of the [`Sandbox`]. + /// + /// If you want to use your own custom theme type, you will have to use an + /// [`Application`]. + /// + /// By default, it returns [`Theme::default`]. + fn theme(&self) -> Theme { + Theme::default() + } + /// Returns the background color of the [`Sandbox`]. /// /// By default, it returns [`Color::WHITE`]. @@ -82,6 +92,7 @@ where type Executor = iced_futures::backend::null::Executor; type Flags = (); type Message = T::Message; + type Theme = Theme; fn new(_flags: ()) -> (Self, Command<T::Message>) { (T::new(), Command::none()) @@ -97,14 +108,18 @@ where Command::none() } - fn subscription(&self) -> Subscription<T::Message> { - Subscription::none() - } - fn view(&self) -> pure::Element<'_, T::Message> { T::view(self) } + fn theme(&self) -> Self::Theme { + T::theme(self) + } + + fn subscription(&self) -> Subscription<T::Message> { + Subscription::none() + } + fn background_color(&self) -> Color { T::background_color(self) } |