summaryrefslogtreecommitdiffstats
path: root/examples/tour/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tour/src/main.rs')
-rw-r--r--examples/tour/src/main.rs57
1 files changed, 15 insertions, 42 deletions
diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs
index 2024d25a..d85f2916 100644
--- a/examples/tour/src/main.rs
+++ b/examples/tour/src/main.rs
@@ -1,7 +1,13 @@
+use iced::alignment;
+use iced::button;
+use iced::scrollable;
+use iced::slider;
+use iced::text_input;
+use iced::theme;
use iced::{
- alignment, button, scrollable, slider, text_input, Button, Checkbox, Color,
- Column, Container, ContentFit, Element, Image, Length, Radio, Row, Sandbox,
- Scrollable, Settings, Slider, Space, Text, TextInput, Toggler,
+ Button, Checkbox, Color, Column, Container, ContentFit, Element, Image,
+ Length, Radio, Row, Sandbox, Scrollable, Settings, Slider, Space, Text,
+ TextInput, Toggler,
};
pub fn main() -> iced::Result {
@@ -64,7 +70,7 @@ impl Sandbox for Tour {
controls = controls.push(
button(back_button, "Back")
.on_press(Message::BackPressed)
- .style(style::Button::Secondary),
+ .style(theme::Button::Secondary),
);
}
@@ -74,7 +80,7 @@ impl Sandbox for Tour {
controls = controls.push(
button(next_button, "Next")
.on_press(Message::NextPressed)
- .style(style::Button::Primary),
+ .style(theme::Button::Primary),
);
}
@@ -132,7 +138,7 @@ impl Steps {
size_slider: slider::State::new(),
size: 30,
color_sliders: [slider::State::new(); 3],
- color: Color::BLACK,
+ color: Color::from_rgb(0.5, 0.5, 0.5),
},
Step::Radio { selection: None },
Step::Toggler {
@@ -528,7 +534,7 @@ impl<'a> Step {
.padding(20)
.spacing(20)
.push(Text::new("And its color:"))
- .push(Text::new(format!("{:?}", color)).color(color))
+ .push(Text::new(format!("{:?}", color)).style(color))
.push(color_sliders);
Self::container("Text")
@@ -710,7 +716,7 @@ impl<'a> Step {
.push(if cfg!(target_arch = "wasm32") {
Element::new(
Text::new("Not available on web yet!")
- .color([0.7, 0.7, 0.7])
+ .style(Color::from([0.7, 0.7, 0.7]))
.horizontal_alignment(alignment::Horizontal::Center),
)
} else {
@@ -770,7 +776,7 @@ fn color_slider(
state: &mut slider::State,
component: f32,
update: impl Fn(f32) -> Color + 'static,
-) -> Slider<f64, StepMessage> {
+) -> Slider<f64, StepMessage, iced::Renderer> {
Slider::new(state, 0.0..=1.0, f64::from(component), move |c| {
StepMessage::TextColorChanged(update(c as f32))
})
@@ -818,36 +824,3 @@ pub enum Layout {
Row,
Column,
}
-
-mod style {
- use iced::button;
- use iced::{Background, Color, Vector};
-
- pub enum Button {
- Primary,
- Secondary,
- }
-
- 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),
- Button::Secondary => Color::from_rgb(0.5, 0.5, 0.5),
- })),
- border_radius: 12.0,
- shadow_offset: Vector::new(1.0, 1.0),
- text_color: Color::from_rgb8(0xEE, 0xEE, 0xEE),
- ..button::Style::default()
- }
- }
-
- fn hovered(&self) -> button::Style {
- button::Style {
- text_color: Color::WHITE,
- shadow_offset: Vector::new(1.0, 2.0),
- ..self.active()
- }
- }
- }
-}