diff options
author | 2020-12-01 11:52:52 +0100 | |
---|---|---|
committer | 2021-06-10 18:28:37 +0700 | |
commit | dbc1181011d579ac1da2546fba08e11094633f4b (patch) | |
tree | 1b5239b76f4040b02bf73cd2b4cf8d88507e1bef /examples/tour/src/main.rs | |
parent | 0e70b11e00e4d8517419a5f09490c9502827d35b (diff) | |
download | iced-dbc1181011d579ac1da2546fba08e11094633f4b.tar.gz iced-dbc1181011d579ac1da2546fba08e11094633f4b.tar.bz2 iced-dbc1181011d579ac1da2546fba08e11094633f4b.zip |
Adds doc comment for disabled button
Makes disabled button behavior consistent in web
Diffstat (limited to '')
-rw-r--r-- | examples/tour/src/main.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 1215f83d..626d2b52 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -70,13 +70,15 @@ impl Sandbox for Tour { controls = controls.push(Space::with_width(Length::Fill)); - if steps.can_continue() { - controls = controls.push( - button(next_button, "Next") - .on_press(Message::NextPressed) - .style(style::Button::Primary), - ); - } + let mut button = button(next_button, "Next"); + button = if steps.can_continue() { + button + .style(style::Button::Primary) + .on_press(Message::NextPressed) + } else { + button.style(style::Button::Disabled) + }; + controls = controls.push(button); let content: Element<_> = Column::new() .max_width(540) @@ -790,6 +792,7 @@ mod style { pub enum Button { Primary, Secondary, + Disabled, } impl button::StyleSheet for Button { @@ -797,7 +800,8 @@ mod style { button::Style { background: Some(Background::Color(match self { Button::Primary => Color::from_rgb(0.11, 0.42, 0.87), - Button::Secondary => Color::from_rgb(0.5, 0.5, 0.5), + Button::Secondary => Color::from_rgb(0.055, 0.21, 0.435), + Button::Disabled => Color::from_rgb(0.5, 0.5, 0.5), })), border_radius: 12.0, shadow_offset: Vector::new(1.0, 1.0), |