summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/tour/src/main.rs14
-rw-r--r--style/src/theme.rs9
2 files changed, 15 insertions, 8 deletions
diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs
index a40f0f33..257a4def 100644
--- a/examples/tour/src/main.rs
+++ b/examples/tour/src/main.rs
@@ -57,11 +57,9 @@ impl Sandbox for Tour {
if steps.has_previous() {
controls = controls.push(
- button("Back").on_press(Message::BackPressed).style(
- theme::Button::Custom(Box::new(
- CustomButtonStyle::Secondary,
- )),
- ),
+ button("Back")
+ .on_press(Message::BackPressed)
+ .style(theme::Button::custom(CustomButtonStyle::Secondary)),
);
}
@@ -69,9 +67,9 @@ impl Sandbox for Tour {
if steps.can_continue() {
controls = controls.push(
- button("Next").on_press(Message::NextPressed).style(
- theme::Button::Custom(Box::new(CustomButtonStyle::Primary)),
- ),
+ button("Next")
+ .on_press(Message::NextPressed)
+ .style(theme::Button::custom(CustomButtonStyle::Primary)),
);
}
diff --git a/style/src/theme.rs b/style/src/theme.rs
index c9835ca3..477bd27b 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -139,6 +139,15 @@ pub enum Button {
Custom(Box<dyn button::StyleSheet<Style = Theme>>),
}
+impl Button {
+ /// Creates a custom [`Button`] style variant.
+ pub fn custom(
+ style_sheet: impl button::StyleSheet<Style = Theme> + 'static,
+ ) -> Self {
+ Self::Custom(Box::new(style_sheet))
+ }
+}
+
impl button::StyleSheet for Theme {
type Style = Button;