Merge pull request #2350 from iced-rs/theming-revolutions

Theming Revolutions
This commit is contained in:
Héctor Ramón 2024-03-25 22:21:22 +01:00 committed by GitHub
commit eae4065300
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 1340 additions and 1053 deletions

View file

@ -73,10 +73,7 @@ mod numeric_input {
impl<Message, Theme> Component<Message, Theme> for NumericInput<Message>
where
Theme: text::DefaultStyle
+ button::DefaultStyle
+ 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::DefaultStyle
+ text_input::DefaultStyle
+ 'static,
Theme: text::Catalog + button::Catalog + text_input::Catalog + 'static,
Message: 'a,
{
fn from(numeric_input: NumericInput<Message>) -> Self {

View file

@ -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);

View file

@ -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)
});

View file

@ -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,

View file

@ -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(),

View file

@ -31,7 +31,7 @@ impl Tiger {
));
let svg = svg(handle).width(Length::Fill).height(Length::Fill).style(
|_theme, _status| svg::Appearance {
|_theme, _status| svg::Style {
color: if self.apply_color_filter {
Some(color!(0x0000ff))
} else {

View file

@ -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)