tui_lipan/widgets/
theme_provider.rs1use crate::core::element::{Element, ElementKind};
4use crate::style::Theme;
5
6#[derive(Clone)]
8pub struct ThemeProvider {
9 theme: Theme,
10 child: Element,
11}
12
13impl ThemeProvider {
14 pub fn new(theme: Theme) -> Self {
16 Self {
17 theme,
18 child: crate::widgets::Spacer::new().into(),
19 }
20 }
21
22 pub fn child(mut self, child: impl Into<Element>) -> Self {
24 self.child = child.into();
25 self
26 }
27}
28
29impl From<ThemeProvider> for Element {
30 fn from(provider: ThemeProvider) -> Self {
31 use crate::core::element::ThemeProviderElement;
32 Element::new(ElementKind::ThemeProvider(Box::new(ThemeProviderElement {
33 theme: provider.theme,
34 child: provider.child,
35 })))
36 }
37}