summaryrefslogtreecommitdiffstats
path: root/examples/pokedex
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-14 01:47:55 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-05-14 01:56:32 +0200
commit664251f3f5c7b76f69a97683af1468094bba887f (patch)
treef43a495036ed117ce5dbb479c62652d872a6d273 /examples/pokedex
parent5de337f214530faab1d5fe47784afd7006c3f7f0 (diff)
downloadiced-664251f3f5c7b76f69a97683af1468094bba887f.tar.gz
iced-664251f3f5c7b76f69a97683af1468094bba887f.tar.bz2
iced-664251f3f5c7b76f69a97683af1468094bba887f.zip
Draft first-class `Theme` support
RFC: https://github.com/iced-rs/rfcs/pull/6
Diffstat (limited to 'examples/pokedex')
-rw-r--r--examples/pokedex/src/main.rs36
1 files changed, 8 insertions, 28 deletions
diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs
index 85c26987..4b0e913d 100644
--- a/examples/pokedex/src/main.rs
+++ b/examples/pokedex/src/main.rs
@@ -1,6 +1,9 @@
+use iced::button;
+use iced::futures;
+use iced::image;
use iced::{
- button, futures, image, Alignment, Application, Button, Column, Command,
- Container, Element, Length, Row, Settings, Text,
+ Alignment, Application, Button, Column, Command, Container, Element,
+ Length, Row, Settings, Text, Theme,
};
pub fn main() -> iced::Result {
@@ -26,8 +29,9 @@ enum Message {
}
impl Application for Pokedex {
- type Executor = iced::executor::Default;
type Message = Message;
+ type Theme = Theme;
+ type Executor = iced::executor::Default;
type Flags = ();
fn new(_flags: ()) -> (Pokedex, Command<Message>) {
@@ -238,29 +242,5 @@ impl From<reqwest::Error> for Error {
}
fn button<'a>(state: &'a mut button::State, text: &str) -> Button<'a, Message> {
- Button::new(state, Text::new(text))
- .padding(10)
- .style(style::Button::Primary)
-}
-
-mod style {
- use iced::{button, Background, Color, Vector};
-
- 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.0,
- shadow_offset: Vector::new(1.0, 1.0),
- text_color: Color::WHITE,
- ..button::Style::default()
- }
- }
- }
+ Button::new(state, Text::new(text)).padding(10)
}