diff --git a/crates/story/src/themes.rs b/crates/story/src/themes.rs index 110c92e5..e6a91fda 100644 --- a/crates/story/src/themes.rs +++ b/crates/story/src/themes.rs @@ -6,7 +6,7 @@ use gpui::{ use gpui_component::{ button::{Button, ButtonVariants}, popup_menu::PopupMenuExt, - IconName, Sizable, Theme, ThemeRegistry, + ActiveTheme, IconName, Sizable, Theme, ThemeRegistry, }; use serde::{Deserialize, Serialize}; @@ -38,6 +38,11 @@ pub fn init(cx: &mut App) { }) { tracing::error!("Failed to watch themes directory: {}", err); } + + cx.observe_global::(|cx| { + AppState::global_mut(cx).theme_name = Some(cx.theme().theme_name().into()); + }) + .detach(); } #[derive(Action, Clone, PartialEq)] diff --git a/crates/ui/src/theme/mod.rs b/crates/ui/src/theme/mod.rs index 6e576c65..61646c83 100644 --- a/crates/ui/src/theme/mod.rs +++ b/crates/ui/src/theme/mod.rs @@ -101,6 +101,15 @@ impl Theme { self.mode.is_dark() } + /// Returns the current theme name. + pub fn theme_name(&self) -> &SharedString { + if self.is_dark() { + &self.dark_theme.name + } else { + &self.light_theme.name + } + } + // /// Sets the theme to default light. // pub fn set_default_light(&mut self) { // self.light_theme = ThemeColor::light();