Skip to content

Commit 30d9a2f

Browse files
committed
Use container style helpers directly in toast example
1 parent 1b40f89 commit 30d9a2f

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

examples/toast/src/main.rs

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ mod toast {
169169
use iced::advanced::widget::{self, Operation, Tree};
170170
use iced::advanced::{Clipboard, Shell, Widget};
171171
use iced::mouse;
172-
use iced::theme;
173172
use iced::time::{self, Duration, Instant};
174173
use iced::widget::{button, column, container, row, rule, space, text};
175174
use iced::window;
@@ -254,11 +253,11 @@ mod toast {
254253
.width(Fill)
255254
.padding(5)
256255
.style(match toast.status {
257-
Status::Primary => primary,
258-
Status::Secondary => secondary,
259-
Status::Success => success,
260-
Status::Danger => danger,
261-
Status::Warning => warning,
256+
Status::Primary => container::primary,
257+
Status::Secondary => container::secondary,
258+
Status::Success => container::success,
259+
Status::Danger => container::danger,
260+
Status::Warning => container::warning,
262261
}),
263262
rule::horizontal(1),
264263
container(text(toast.body.as_str()))
@@ -640,42 +639,4 @@ mod toast {
640639
Element::new(manager)
641640
}
642641
}
643-
644-
fn styled(pair: theme::palette::Pair) -> container::Style {
645-
container::Style {
646-
background: Some(pair.color.into()),
647-
text_color: pair.text.into(),
648-
..Default::default()
649-
}
650-
}
651-
652-
fn primary(theme: &Theme) -> container::Style {
653-
let palette = theme.extended_palette();
654-
655-
styled(palette.primary.weak)
656-
}
657-
658-
fn secondary(theme: &Theme) -> container::Style {
659-
let palette = theme.extended_palette();
660-
661-
styled(palette.secondary.weak)
662-
}
663-
664-
fn success(theme: &Theme) -> container::Style {
665-
let palette = theme.extended_palette();
666-
667-
styled(palette.success.weak)
668-
}
669-
670-
fn danger(theme: &Theme) -> container::Style {
671-
let palette = theme.extended_palette();
672-
673-
styled(palette.danger.weak)
674-
}
675-
676-
fn warning(theme: &Theme) -> container::Style {
677-
let palette = theme.extended_palette();
678-
679-
styled(palette.warning.weak)
680-
}
681642
}

0 commit comments

Comments
 (0)