Reference theme2 colors in ThemeColor

This commit is contained in:
Marshall Bowers 2023-10-25 15:58:56 +02:00
parent dd34bb273e
commit 8043d0d8a9
2 changed files with 51 additions and 51 deletions

View file

@ -178,9 +178,7 @@ where
element_state: Option<Self::ElementState>,
cx: &mut ViewContext<Self::ViewState>,
) -> Self::ElementState {
cx.default_global::<ThemeStack>()
.0
.push(self.theme.clone());
cx.default_global::<ThemeStack>().0.push(self.theme.clone());
let element_state = self.child.initialize(view_state, element_state, cx);
cx.default_global::<ThemeStack>().0.pop();
element_state
@ -195,9 +193,7 @@ where
where
Self: Sized,
{
cx.default_global::<ThemeStack>()
.0
.push(self.theme.clone());
cx.default_global::<ThemeStack>().0.push(self.theme.clone());
let layout_id = self.child.layout(view_state, element_state, cx);
cx.default_global::<ThemeStack>().0.pop();
layout_id
@ -212,9 +208,7 @@ where
) where
Self: Sized,
{
cx.default_global::<ThemeStack>()
.0
.push(self.theme.clone());
cx.default_global::<ThemeStack>().0.push(self.theme.clone());
self.child.paint(bounds, view_state, frame_state, cx);
cx.default_global::<ThemeStack>().0.pop();
}
@ -223,3 +217,7 @@ where
pub fn theme(cx: &WindowContext) -> Arc<Theme> {
Arc::new(cx.global::<Theme>().clone())
}
pub fn theme2(cx: &WindowContext) -> Arc<theme2::Theme> {
cx.global::<Arc<theme2::Theme>>().clone()
}