diff options
| author | 2021-11-07 15:15:33 +0700 | |
|---|---|---|
| committer | 2021-11-07 15:15:33 +0700 | |
| commit | eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253 (patch) | |
| tree | 76413948c9c9723075189d51d4c2e02c0f8fdd23 /examples/todos | |
| parent | 61c747b53589d98f477fea95f85d2ea5349666d3 (diff) | |
| parent | 07b5097bc92ced376d09115d787ff1d2ebe00836 (diff) | |
| download | iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.gz iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.tar.bz2 iced-eafad00af2a9bae9f3ed8124e2a6f6e59ee5d253.zip | |
Merge pull request #1110 from iced-rs/remove-renderer-traits
Reduce the surface of the `Renderer` APIs
Diffstat (limited to '')
| -rw-r--r-- | examples/todos/src/main.rs | 36 | 
1 files changed, 16 insertions, 20 deletions
| diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index 11f23fd4..5ad8c208 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -363,8 +363,10 @@ impl Controls {          let filter_button = |state, label, filter, current_filter| {              let label = Text::new(label).size(16);              let button = -                Button::new(state, label).style(style::Button::Filter { -                    selected: filter == current_filter, +                Button::new(state, label).style(if filter == current_filter { +                    style::Button::FilterSelected +                } else { +                    style::Button::FilterActive                  });              button.on_press(Message::FilterChanged(filter)).padding(8) @@ -602,7 +604,8 @@ mod style {      use iced::{button, Background, Color, Vector};      pub enum Button { -        Filter { selected: bool }, +        FilterActive, +        FilterSelected,          Icon,          Destructive,      } @@ -610,20 +613,15 @@ mod style {      impl button::StyleSheet for Button {          fn active(&self) -> button::Style {              match self { -                Button::Filter { selected } => { -                    if *selected { -                        button::Style { -                            background: Some(Background::Color( -                                Color::from_rgb(0.2, 0.2, 0.7), -                            )), -                            border_radius: 10.0, -                            text_color: Color::WHITE, -                            ..button::Style::default() -                        } -                    } else { -                        button::Style::default() -                    } -                } +                Button::FilterActive => button::Style::default(), +                Button::FilterSelected => button::Style { +                    background: Some(Background::Color(Color::from_rgb( +                        0.2, 0.2, 0.7, +                    ))), +                    border_radius: 10.0, +                    text_color: Color::WHITE, +                    ..button::Style::default() +                },                  Button::Icon => button::Style {                      text_color: Color::from_rgb(0.5, 0.5, 0.5),                      ..button::Style::default() @@ -646,9 +644,7 @@ mod style {              button::Style {                  text_color: match self {                      Button::Icon => Color::from_rgb(0.2, 0.2, 0.7), -                    Button::Filter { selected } if !selected => { -                        Color::from_rgb(0.2, 0.2, 0.7) -                    } +                    Button::FilterActive => Color::from_rgb(0.2, 0.2, 0.7),                      _ => active.text_color,                  },                  shadow_offset: active.shadow_offset + Vector::new(0.0, 1.0), | 
