Make component example generic over Theme

This commit is contained in:
Héctor Ramón Jiménez 2024-03-09 12:24:40 +01:00
parent e236bd695a
commit 628df69538
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -81,7 +81,10 @@ mod numeric_input {
}
}
impl<Message> Component<Message> for NumericInput<Message> {
impl<Message, Theme> Component<Message, Theme> for NumericInput<Message>
where
Theme: button::DefaultStyle + text_input::DefaultStyle + 'static,
{
type State = ();
type Event = Event;
@ -111,7 +114,7 @@ mod numeric_input {
}
}
fn view(&self, _state: &Self::State) -> Element<Event> {
fn view(&self, _state: &Self::State) -> Element<'_, Event, Theme> {
let button = |label, on_press| {
button(
text(label)
@ -152,8 +155,10 @@ mod numeric_input {
}
}
impl<'a, Message> From<NumericInput<Message>> for Element<'a, Message>
impl<'a, Message, Theme> From<NumericInput<Message>>
for Element<'a, Message, Theme>
where
Theme: button::DefaultStyle + text_input::DefaultStyle + 'static,
Message: 'a,
{
fn from(numeric_input: NumericInput<Message>) -> Self {