Use container style helpers directly in toast example
This commit is contained in:
parent
1b40f89fdd
commit
30d9a2ff57
1 changed files with 5 additions and 44 deletions
|
|
@ -169,7 +169,6 @@ mod toast {
|
|||
use iced::advanced::widget::{self, Operation, Tree};
|
||||
use iced::advanced::{Clipboard, Shell, Widget};
|
||||
use iced::mouse;
|
||||
use iced::theme;
|
||||
use iced::time::{self, Duration, Instant};
|
||||
use iced::widget::{button, column, container, row, rule, space, text};
|
||||
use iced::window;
|
||||
|
|
@ -254,11 +253,11 @@ mod toast {
|
|||
.width(Fill)
|
||||
.padding(5)
|
||||
.style(match toast.status {
|
||||
Status::Primary => primary,
|
||||
Status::Secondary => secondary,
|
||||
Status::Success => success,
|
||||
Status::Danger => danger,
|
||||
Status::Warning => warning,
|
||||
Status::Primary => container::primary,
|
||||
Status::Secondary => container::secondary,
|
||||
Status::Success => container::success,
|
||||
Status::Danger => container::danger,
|
||||
Status::Warning => container::warning,
|
||||
}),
|
||||
rule::horizontal(1),
|
||||
container(text(toast.body.as_str()))
|
||||
|
|
@ -640,42 +639,4 @@ mod toast {
|
|||
Element::new(manager)
|
||||
}
|
||||
}
|
||||
|
||||
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) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
styled(palette.primary.weak)
|
||||
}
|
||||
|
||||
fn secondary(theme: &Theme) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
styled(palette.secondary.weak)
|
||||
}
|
||||
|
||||
fn success(theme: &Theme) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
styled(palette.success.weak)
|
||||
}
|
||||
|
||||
fn danger(theme: &Theme) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
styled(palette.danger.weak)
|
||||
}
|
||||
|
||||
fn warning(theme: &Theme) -> container::Style {
|
||||
let palette = theme.extended_palette();
|
||||
|
||||
styled(palette.warning.weak)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue