Enhnace Themer to allow derivation from current Theme

This commit is contained in:
Héctor Ramón Jiménez 2024-03-04 19:32:20 +01:00
parent 4130ae4be9
commit db92e1c942
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 80 additions and 66 deletions

View file

@ -15,7 +15,6 @@ use crate::rule::{self, Rule};
use crate::runtime::Command;
use crate::scrollable::{self, Scrollable};
use crate::slider::{self, Slider};
use crate::style::application;
use crate::text::{self, Text};
use crate::text_editor::{self, TextEditor};
use crate::text_input::{self, TextInput};
@ -440,13 +439,13 @@ where
}
/// A widget that applies any `Theme` to its contents.
pub fn themer<'a, Message, Theme, Renderer>(
theme: Theme,
content: impl Into<Element<'a, Message, Theme, Renderer>>,
) -> Themer<'a, Message, Theme, Renderer>
pub fn themer<'a, Message, OldTheme, NewTheme, F, Renderer>(
to_theme: F,
content: impl Into<Element<'a, Message, NewTheme, Renderer>>,
) -> Themer<'a, Message, OldTheme, NewTheme, F, Renderer>
where
F: Fn(&OldTheme) -> NewTheme,
Renderer: core::Renderer,
Theme: application::StyleSheet,
{
Themer::new(theme, content)
Themer::new(to_theme, content)
}