diff --git a/crates/onboarding/src/basics_page.rs b/crates/onboarding/src/basics_page.rs index eaf9c41a53dc6c4b0d8ef9a93a9ed8423ddf2db6..198871c9eb55b41c44a5f0db162eb446c1760ba9 100644 --- a/crates/onboarding/src/basics_page.rs +++ b/crates/onboarding/src/basics_page.rs @@ -5,7 +5,7 @@ use fs::Fs; use gpui::{Action, App, IntoElement}; use settings::{BaseKeymap, Settings, update_settings_file}; use theme::{ - Appearance, SystemAppearance, ThemeMode, ThemeName, ThemeRegistry, ThemeSelection, + Appearance, SystemAppearance, ThemeAppearanceMode, ThemeName, ThemeRegistry, ThemeSelection, ThemeSettings, }; use ui::{ @@ -44,8 +44,8 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement let theme_mode = theme_selection .mode() .unwrap_or_else(|| match *system_appearance { - Appearance::Light => ThemeMode::Light, - Appearance::Dark => ThemeMode::Dark, + Appearance::Light => ThemeAppearanceMode::Light, + Appearance::Dark => ThemeAppearanceMode::Dark, }); return v_flex() @@ -54,7 +54,12 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement h_flex().justify_between().child(Label::new("Theme")).child( ToggleButtonGroup::single_row( "theme-selector-onboarding-dark-light", - [ThemeMode::Light, ThemeMode::Dark, ThemeMode::System].map(|mode| { + [ + ThemeAppearanceMode::Light, + ThemeAppearanceMode::Dark, + ThemeAppearanceMode::System, + ] + .map(|mode| { const MODE_NAMES: [SharedString; 3] = [ SharedString::new_static("Light"), SharedString::new_static("Dark"), @@ -100,13 +105,13 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement let theme_mode = theme_selection .mode() .unwrap_or_else(|| match *system_appearance { - Appearance::Light => ThemeMode::Light, - Appearance::Dark => ThemeMode::Dark, + Appearance::Light => ThemeAppearanceMode::Light, + Appearance::Dark => ThemeAppearanceMode::Dark, }); let appearance = match theme_mode { - ThemeMode::Light => Appearance::Light, - ThemeMode::Dark => Appearance::Dark, - ThemeMode::System => *system_appearance, + ThemeAppearanceMode::Light => Appearance::Light, + ThemeAppearanceMode::Dark => Appearance::Dark, + ThemeAppearanceMode::System => *system_appearance, }; let current_theme_name: SharedString = theme_selection.name(appearance).0.into(); @@ -164,7 +169,7 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement } }) .map(|this| { - if theme_mode == ThemeMode::System { + if theme_mode == ThemeAppearanceMode::System { let (light, dark) = ( theme_registry.get(LIGHT_THEMES[index]).unwrap(), theme_registry.get(DARK_THEMES[index]).unwrap(), @@ -189,23 +194,27 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement }) } - fn write_mode_change(mode: ThemeMode, cx: &mut App) { + fn write_mode_change(mode: ThemeAppearanceMode, cx: &mut App) { let fs = ::global(cx); update_settings_file(fs, cx, move |settings, _cx| { theme::set_mode(settings, mode); }); } - fn write_theme_change(theme: impl Into>, theme_mode: ThemeMode, cx: &mut App) { + fn write_theme_change( + theme: impl Into>, + theme_mode: ThemeAppearanceMode, + cx: &mut App, + ) { let fs = ::global(cx); let theme = theme.into(); update_settings_file(fs, cx, move |settings, cx| { - if theme_mode == ThemeMode::System { + if theme_mode == ThemeAppearanceMode::System { let (light_theme, dark_theme) = get_theme_family_themes(&theme).unwrap_or((theme.as_ref(), theme.as_ref())); settings.theme.theme = Some(settings::ThemeSelection::Dynamic { - mode: ThemeMode::System, + mode: ThemeAppearanceMode::System, light: ThemeName(light_theme.into()), dark: ThemeName(dark_theme.into()), }); diff --git a/crates/settings/src/settings_content/theme.rs b/crates/settings/src/settings_content/theme.rs index 80b543a20aa389ca05b13371f235ebc0dda9c82e..8b87cc15196b7a562a794eb4a1effeb5cb102ef6 100644 --- a/crates/settings/src/settings_content/theme.rs +++ b/crates/settings/src/settings_content/theme.rs @@ -157,7 +157,7 @@ pub enum ThemeSelection { Dynamic { /// The mode used to determine which theme to use. #[serde(default)] - mode: ThemeMode, + mode: ThemeAppearanceMode, /// The theme to use for light mode. light: ThemeName, /// The theme to use for dark mode. @@ -186,7 +186,7 @@ pub enum IconThemeSelection { Dynamic { /// The mode used to determine which theme to use. #[serde(default)] - mode: ThemeMode, + mode: ThemeAppearanceMode, /// The icon theme to use for light mode. light: IconThemeName, /// The icon theme to use for dark mode. @@ -194,7 +194,6 @@ pub enum IconThemeSelection { }, } -// TODO: Rename ThemeMode -> ThemeAppearanceMode /// The mode use to select a theme. /// /// `Light` and `Dark` will select their respective themes. @@ -215,7 +214,7 @@ pub enum IconThemeSelection { strum::VariantNames, )] #[serde(rename_all = "snake_case")] -pub enum ThemeMode { +pub enum ThemeAppearanceMode { /// Use the specified `light` theme. Light, diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index 392796c091d379429f2ae787b14a75841bef12fa..e3165fbc79850484950e90bdcdbb81338df9974d 100644 --- a/crates/settings_ui/src/page_data.rs +++ b/crates/settings_ui/src/page_data.rs @@ -300,9 +300,9 @@ pub(crate) fn settings_data(cx: &App) -> Vec { settings::ThemeSelection::Static(_) => return, settings::ThemeSelection::Dynamic { mode, light, dark } => { match mode { - theme::ThemeMode::Light => light.clone(), - theme::ThemeMode::Dark => dark.clone(), - theme::ThemeMode::System => dark.clone(), // no cx, can't determine correct choice + theme::ThemeAppearanceMode::Light => light.clone(), + theme::ThemeAppearanceMode::Dark => dark.clone(), + theme::ThemeAppearanceMode::System => dark.clone(), // no cx, can't determine correct choice } }, }; @@ -315,7 +315,7 @@ pub(crate) fn settings_data(cx: &App) -> Vec { }; settings::ThemeSelection::Dynamic { - mode: settings::ThemeMode::System, + mode: settings::ThemeAppearanceMode::System, light: static_name.clone(), dark: static_name, } @@ -470,9 +470,9 @@ pub(crate) fn settings_data(cx: &App) -> Vec { settings::IconThemeSelection::Static(_) => return, settings::IconThemeSelection::Dynamic { mode, light, dark } => { match mode { - theme::ThemeMode::Light => light.clone(), - theme::ThemeMode::Dark => dark.clone(), - theme::ThemeMode::System => dark.clone(), // no cx, can't determine correct choice + theme::ThemeAppearanceMode::Light => light.clone(), + theme::ThemeAppearanceMode::Dark => dark.clone(), + theme::ThemeAppearanceMode::System => dark.clone(), // no cx, can't determine correct choice } }, }; @@ -485,7 +485,7 @@ pub(crate) fn settings_data(cx: &App) -> Vec { }; settings::IconThemeSelection::Dynamic { - mode: settings::ThemeMode::System, + mode: settings::ThemeAppearanceMode::System, light: static_name.clone(), dark: static_name, } diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index ea0e8760116c254f7777ecdd2fab1e956be6fe6a..6a561086f2d614eb8fc06c5be146b5e02dc05b3d 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -486,7 +486,7 @@ fn init_renderers(cx: &mut App) { .add_basic_renderer::(render_dropdown) .add_basic_renderer::(render_dropdown) .add_basic_renderer::(render_dropdown) - .add_basic_renderer::(render_dropdown) + .add_basic_renderer::(render_dropdown) .add_basic_renderer::(render_theme_picker) .add_basic_renderer::(render_dropdown) .add_basic_renderer::(render_icon_theme_picker) diff --git a/crates/theme/src/settings.rs b/crates/theme/src/settings.rs index 024eca7a5c7d82e9306468e30b53fa897f470adf..a753859d52677974902a36a5d67ea86611e47006 100644 --- a/crates/theme/src/settings.rs +++ b/crates/theme/src/settings.rs @@ -11,7 +11,7 @@ use gpui::{ use refineable::Refineable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -pub use settings::{FontFamilyName, IconThemeName, ThemeMode, ThemeName}; +pub use settings::{FontFamilyName, IconThemeName, ThemeAppearanceMode, ThemeName}; use settings::{RegisterSetting, Settings, SettingsContent}; use std::sync::Arc; @@ -208,7 +208,7 @@ pub enum ThemeSelection { Dynamic { /// The mode used to determine which theme to use. #[serde(default)] - mode: ThemeMode, + mode: ThemeAppearanceMode, /// The theme to use for light mode. light: ThemeName, /// The theme to use for dark mode. @@ -233,9 +233,9 @@ impl ThemeSelection { match self { Self::Static(theme) => theme.clone(), Self::Dynamic { mode, light, dark } => match mode { - ThemeMode::Light => light.clone(), - ThemeMode::Dark => dark.clone(), - ThemeMode::System => match system_appearance { + ThemeAppearanceMode::Light => light.clone(), + ThemeAppearanceMode::Dark => dark.clone(), + ThemeAppearanceMode::System => match system_appearance { Appearance::Light => light.clone(), Appearance::Dark => dark.clone(), }, @@ -244,7 +244,7 @@ impl ThemeSelection { } /// Returns the [ThemeMode] for the [ThemeSelection]. - pub fn mode(&self) -> Option { + pub fn mode(&self) -> Option { match self { ThemeSelection::Static(_) => None, ThemeSelection::Dynamic { mode, .. } => Some(*mode), @@ -260,7 +260,7 @@ pub enum IconThemeSelection { /// A dynamic icon theme selection, which can change based on the [`ThemeMode`]. Dynamic { /// The mode used to determine which theme to use. - mode: ThemeMode, + mode: ThemeAppearanceMode, /// The icon theme to use for light mode. light: IconThemeName, /// The icon theme to use for dark mode. @@ -285,9 +285,9 @@ impl IconThemeSelection { match self { Self::Static(theme) => theme.clone(), Self::Dynamic { mode, light, dark } => match mode { - ThemeMode::Light => light.clone(), - ThemeMode::Dark => dark.clone(), - ThemeMode::System => match system_appearance { + ThemeAppearanceMode::Light => light.clone(), + ThemeAppearanceMode::Dark => dark.clone(), + ThemeAppearanceMode::System => match system_appearance { Appearance::Light => light.clone(), Appearance::Dark => dark.clone(), }, @@ -296,7 +296,7 @@ impl IconThemeSelection { } /// Returns the [`ThemeMode`] for the [`IconThemeSelection`]. - pub fn mode(&self) -> Option { + pub fn mode(&self) -> Option { match self { IconThemeSelection::Static(_) => None, IconThemeSelection::Dynamic { mode, .. } => Some(*mode), @@ -315,9 +315,9 @@ pub fn set_theme( let theme_to_update = match selection { settings::ThemeSelection::Static(theme) => theme, settings::ThemeSelection::Dynamic { mode, light, dark } => match mode { - ThemeMode::Light => light, - ThemeMode::Dark => dark, - ThemeMode::System => match appearance { + ThemeAppearanceMode::Light => light, + ThemeAppearanceMode::Dark => dark, + ThemeAppearanceMode::System => match appearance { Appearance::Light => light, Appearance::Dark => dark, }, @@ -342,9 +342,9 @@ pub fn set_icon_theme( let icon_theme_to_update = match selection { settings::IconThemeSelection::Static(theme) => theme, settings::IconThemeSelection::Dynamic { mode, light, dark } => match mode { - ThemeMode::Light => light, - ThemeMode::Dark => dark, - ThemeMode::System => match appearance { + ThemeAppearanceMode::Light => light, + ThemeAppearanceMode::Dark => dark, + ThemeAppearanceMode::System => match appearance { Appearance::Light => light, Appearance::Dark => dark, }, @@ -358,7 +358,7 @@ pub fn set_icon_theme( } /// Sets the mode for the theme. -pub fn set_mode(content: &mut SettingsContent, mode: ThemeMode) { +pub fn set_mode(content: &mut SettingsContent, mode: ThemeAppearanceMode) { let theme = content.theme.as_mut(); if let Some(selection) = theme.theme.as_mut() {