summaryrefslogtreecommitdiffstats
path: root/examples/todos
diff options
context:
space:
mode:
Diffstat (limited to 'examples/todos')
-rw-r--r--examples/todos/src/main.rs36
1 files changed, 16 insertions, 20 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 4d657cc0..0b889407 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),