summaryrefslogtreecommitdiffstats
path: root/examples/pokedex.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-29 10:57:01 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-29 10:57:01 +0100
commitc7b170da6d180f80e539910cccb543720fa3713c (patch)
tree6ef48d17104173f0ac7182d3647bd461e5581bd2 /examples/pokedex.rs
parent4b86c2ff987e334c3454540828c6f8d16d27c670 (diff)
downloadiced-c7b170da6d180f80e539910cccb543720fa3713c.tar.gz
iced-c7b170da6d180f80e539910cccb543720fa3713c.tar.bz2
iced-c7b170da6d180f80e539910cccb543720fa3713c.zip
Draft `Style` and `StyleSheet` for `Button`
Diffstat (limited to '')
-rw-r--r--examples/pokedex.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/examples/pokedex.rs b/examples/pokedex.rs
index 2d595ec4..0dcf6981 100644
--- a/examples/pokedex.rs
+++ b/examples/pokedex.rs
@@ -220,7 +220,26 @@ impl From<surf::Exception> for Error {
fn button<'a>(state: &'a mut button::State, text: &str) -> Button<'a, Message> {
Button::new(state, Text::new(text).color(Color::WHITE))
- .background(Color::from_rgb(0.11, 0.42, 0.87))
- .border_radius(10)
.padding(10)
+ .style(style::Button::Primary)
+}
+
+mod style {
+ use iced::{button, Background, Color};
+
+ pub enum Button {
+ Primary,
+ }
+
+ impl button::StyleSheet for Button {
+ fn active(&self) -> button::Style {
+ button::Style {
+ background: Some(Background::Color(match self {
+ Button::Primary => Color::from_rgb(0.11, 0.42, 0.87),
+ })),
+ border_radius: 12,
+ shadow_offset: 1.0,
+ }
+ }
+ }
}