summaryrefslogtreecommitdiffstats
path: root/examples/scrollable/src/main.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 03:26:48 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 03:26:48 +0200
commitde21a651c0616307bb6bfd36da1a06119e629b10 (patch)
treef565bfa3e75d57f6a4be1369d25dfd701b51c4ea /examples/scrollable/src/main.rs
parentce53d3933c860cd958636cce415ac97c04aee746 (diff)
downloadiced-de21a651c0616307bb6bfd36da1a06119e629b10.tar.gz
iced-de21a651c0616307bb6bfd36da1a06119e629b10.tar.bz2
iced-de21a651c0616307bb6bfd36da1a06119e629b10.zip
Implement theme styling for `Scrollable`
Diffstat (limited to 'examples/scrollable/src/main.rs')
-rw-r--r--examples/scrollable/src/main.rs27
1 files changed, 12 insertions, 15 deletions
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs
index e95f296c..f66d2180 100644
--- a/examples/scrollable/src/main.rs
+++ b/examples/scrollable/src/main.rs
@@ -1,8 +1,8 @@
-mod style;
-
+use iced::button;
+use iced::scrollable;
use iced::{
- button, scrollable, Button, Column, Container, Element, Length,
- ProgressBar, Radio, Row, Rule, Sandbox, Scrollable, Settings, Space, Text,
+ Button, Column, Container, Element, Length, ProgressBar, Radio, Row, Rule,
+ Sandbox, Scrollable, Settings, Space, Text, Theme,
};
pub fn main() -> iced::Result {
@@ -10,13 +10,13 @@ pub fn main() -> iced::Result {
}
struct ScrollableDemo {
- theme: style::Theme,
+ theme: Theme,
variants: Vec<Variant>,
}
#[derive(Debug, Clone)]
enum Message {
- ThemeChanged(style::Theme),
+ ThemeChanged(Theme),
ScrollToTop(usize),
ScrollToBottom(usize),
Scrolled(usize, f32),
@@ -66,7 +66,7 @@ impl Sandbox for ScrollableDemo {
theme, variants, ..
} = self;
- let choose_theme = style::Theme::ALL.iter().fold(
+ let choose_theme = [Theme::Light, Theme::Dark].iter().fold(
Column::new().spacing(10).push(Text::new("Choose a theme:")),
|column, option| {
column.push(Radio::new(
@@ -92,7 +92,6 @@ impl Sandbox for ScrollableDemo {
.on_scroll(move |offset| {
Message::Scrolled(i, offset)
})
- .style(*theme)
.push(Text::new(variant.title))
.push(
Button::new(
@@ -157,12 +156,7 @@ impl Sandbox for ScrollableDemo {
.width(Length::Fill)
.height(Length::Fill)
.spacing(10)
- .push(
- Container::new(scrollable)
- .width(Length::Fill)
- .height(Length::Fill)
- .style(*theme),
- )
+ .push(scrollable)
.push(ProgressBar::new(
0.0..=1.0,
variant.latest_offset,
@@ -187,9 +181,12 @@ impl Sandbox for ScrollableDemo {
.height(Length::Fill)
.center_x()
.center_y()
- .style(self.theme)
.into()
}
+
+ fn theme(&self) -> Theme {
+ self.theme
+ }
}
/// A version of a scrollable