summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-24 05:03:09 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-24 05:03:09 +0100
commitf0ae9a0c38c2532220a7460916604914db94c078 (patch)
treea1f0d1732108fa87ce4a63e76def9c38c8804d5d /examples
parente657dc2ecd2ffa72c0abd87f9a59dcc1acbc7083 (diff)
downloadiced-f0ae9a0c38c2532220a7460916604914db94c078.tar.gz
iced-f0ae9a0c38c2532220a7460916604914db94c078.tar.bz2
iced-f0ae9a0c38c2532220a7460916604914db94c078.zip
Use `Catalog` approach for all widgets
Diffstat (limited to 'examples')
-rw-r--r--examples/component/src/main.rs10
-rw-r--r--examples/gradient/src/main.rs2
-rw-r--r--examples/layout/src/main.rs8
-rw-r--r--examples/pane_grid/src/main.rs28
-rw-r--r--examples/scrollable/src/main.rs4
-rw-r--r--examples/toast/src/main.rs24
6 files changed, 23 insertions, 53 deletions
diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs
index d5626087..b2c71b3f 100644
--- a/examples/component/src/main.rs
+++ b/examples/component/src/main.rs
@@ -73,10 +73,7 @@ mod numeric_input {
impl<Message, Theme> Component<Message, Theme> for NumericInput<Message>
where
- Theme: text::DefaultStyle
- + button::Catalog
- + text_input::DefaultStyle
- + 'static,
+ Theme: text::Catalog + button::Catalog + text_input::Catalog + 'static,
{
type State = ();
type Event = Event;
@@ -151,10 +148,7 @@ mod numeric_input {
impl<'a, Message, Theme> From<NumericInput<Message>>
for Element<'a, Message, Theme>
where
- Theme: text::DefaultStyle
- + button::Catalog
- + text_input::DefaultStyle
- + 'static,
+ Theme: text::Catalog + button::Catalog + text_input::Catalog + 'static,
Message: 'a,
{
fn from(numeric_input: NumericInput<Message>) -> Self {
diff --git a/examples/gradient/src/main.rs b/examples/gradient/src/main.rs
index 22c21cdd..2b906c32 100644
--- a/examples/gradient/src/main.rs
+++ b/examples/gradient/src/main.rs
@@ -60,7 +60,7 @@ impl Gradient {
} = *self;
let gradient_box = container(horizontal_space())
- .style(move |_theme, _status| {
+ .style(move |_theme| {
let gradient = gradient::Linear::new(angle)
.add_stop(0.0, start)
.add_stop(1.0, end);
diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs
index 713e2b70..66d79091 100644
--- a/examples/layout/src/main.rs
+++ b/examples/layout/src/main.rs
@@ -81,10 +81,10 @@ impl Layout {
} else {
self.example.view()
})
- .style(|theme, _status| {
+ .style(|theme| {
let palette = theme.extended_palette();
- container::Appearance::default()
+ container::Style::default()
.with_border(palette.background.strong.color, 4.0)
})
.padding(4)
@@ -245,10 +245,10 @@ fn application<'a>() -> Element<'a, Message> {
.padding(10)
.align_items(Alignment::Center),
)
- .style(|theme, _status| {
+ .style(|theme| {
let palette = theme.extended_palette();
- container::Appearance::default()
+ container::Style::default()
.with_border(palette.background.strong.color, 1)
});
diff --git a/examples/pane_grid/src/main.rs b/examples/pane_grid/src/main.rs
index 829996d8..17112785 100644
--- a/examples/pane_grid/src/main.rs
+++ b/examples/pane_grid/src/main.rs
@@ -338,39 +338,30 @@ mod style {
use iced::widget::container;
use iced::{Border, Theme};
- pub fn title_bar_active(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn title_bar_active(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
text_color: Some(palette.background.strong.text),
background: Some(palette.background.strong.color.into()),
..Default::default()
}
}
- pub fn title_bar_focused(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn title_bar_focused(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
text_color: Some(palette.primary.strong.text),
background: Some(palette.primary.strong.color.into()),
..Default::default()
}
}
- pub fn pane_active(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn pane_active(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
background: Some(palette.background.weak.color.into()),
border: Border {
width: 2.0,
@@ -381,13 +372,10 @@ mod style {
}
}
- pub fn pane_focused(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ pub fn pane_focused(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
- container::Appearance {
+ container::Style {
background: Some(palette.background.weak.color.into()),
border: Border {
width: 2.0,
diff --git a/examples/scrollable/src/main.rs b/examples/scrollable/src/main.rs
index 240ae908..c02e754b 100644
--- a/examples/scrollable/src/main.rs
+++ b/examples/scrollable/src/main.rs
@@ -341,8 +341,8 @@ impl Default for ScrollableDemo {
}
}
-fn progress_bar_custom_style(theme: &Theme) -> progress_bar::Appearance {
- progress_bar::Appearance {
+fn progress_bar_custom_style(theme: &Theme) -> progress_bar::Style {
+ progress_bar::Style {
background: theme.extended_palette().background.strong.color.into(),
bar: Color::from_rgb8(250, 85, 134).into(),
border: Border::default(),
diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs
index fdae1dc1..9968962c 100644
--- a/examples/toast/src/main.rs
+++ b/examples/toast/src/main.rs
@@ -651,45 +651,33 @@ mod toast {
}
}
- fn styled(pair: theme::palette::Pair) -> container::Appearance {
- container::Appearance {
+ fn styled(pair: theme::palette::Pair) -> container::Style {
+ container::Style {
background: Some(pair.color.into()),
text_color: pair.text.into(),
..Default::default()
}
}
- fn primary(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn primary(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.primary.weak)
}
- fn secondary(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn secondary(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.secondary.weak)
}
- fn success(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn success(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.success.weak)
}
- fn danger(
- theme: &Theme,
- _status: container::Status,
- ) -> container::Appearance {
+ fn danger(theme: &Theme) -> container::Style {
let palette = theme.extended_palette();
styled(palette.danger.weak)