Implement custom helper for theme::Button
This commit is contained in:
parent
59663d2e45
commit
96aa0379d5
2 changed files with 15 additions and 8 deletions
|
|
@ -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)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue