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::widget::{self, Operation, Tree};
|
||||||
use iced::advanced::{Clipboard, Shell, Widget};
|
use iced::advanced::{Clipboard, Shell, Widget};
|
||||||
use iced::mouse;
|
use iced::mouse;
|
||||||
use iced::theme;
|
|
||||||
use iced::time::{self, Duration, Instant};
|
use iced::time::{self, Duration, Instant};
|
||||||
use iced::widget::{button, column, container, row, rule, space, text};
|
use iced::widget::{button, column, container, row, rule, space, text};
|
||||||
use iced::window;
|
use iced::window;
|
||||||
|
|
@ -254,11 +253,11 @@ mod toast {
|
||||||
.width(Fill)
|
.width(Fill)
|
||||||
.padding(5)
|
.padding(5)
|
||||||
.style(match toast.status {
|
.style(match toast.status {
|
||||||
Status::Primary => primary,
|
Status::Primary => container::primary,
|
||||||
Status::Secondary => secondary,
|
Status::Secondary => container::secondary,
|
||||||
Status::Success => success,
|
Status::Success => container::success,
|
||||||
Status::Danger => danger,
|
Status::Danger => container::danger,
|
||||||
Status::Warning => warning,
|
Status::Warning => container::warning,
|
||||||
}),
|
}),
|
||||||
rule::horizontal(1),
|
rule::horizontal(1),
|
||||||
container(text(toast.body.as_str()))
|
container(text(toast.body.as_str()))
|
||||||
|
|
@ -640,42 +639,4 @@ mod toast {
|
||||||
Element::new(manager)
|
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