So I am creating a function that returns an Element
. Which works perfectly fine, it has the trait restrictions:
where
Message: 'a + Clone,
Theme: 'a + button::Catalog + iced::widget::text::Catalog,
Renderer: 'a + iced::advanced::Renderer + iced::advanced::text::Renderer,
And when I attempt to apply some of my custom styles, like this:
pub fn punge_button_style(status: Status) -> Style {
match status {
Status::Disabled => Style {
background: None,
text_color: Color {
r: 0.85,
g: 0.85,
b: 0.85,
a: 1.0,
},
border: Border {
color: Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 0.0,
},
radius: Radius::default(),
width: 1.0,
},
shadow: Shadow::default(),
},
_ => Style::default(),
}
}
I get an error:
.style(|_t, status| punge_button_style(status))
^^^^^ the trait `From<std::boxed::Box<dyn for<'a> std::ops::Fn(&'a Theme, iced::widget::button::Status) -> iced::widget::button::Style>>` is not implemented for `<Theme as iced::widget::button::Catalog>::Class<'_>`
note: required by a bound in `iced::widget::Button::<'a, Message, Theme, Renderer>::style`
I’ve searched through to try to find examples of people doing similar things, but I haven’t found many projects that have upgraded to the new styling api. (given it hasn’t had a release yet).
Again, this works fine when I use my styling in my view
function, but doesn’t seem to like being in a regular function. Any help would be great!