settings_ui: Add theme settings controls (#15115)

This PR adds settings controls for the theme settings.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-24 16:25:52 -04:00 committed by GitHub
parent 325e6b9fef
commit 740c444089
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 392 additions and 156 deletions

View file

@ -10,9 +10,7 @@ use picker::{Picker, PickerDelegate};
use serde::Deserialize;
use settings::{update_settings_file, SettingsStore};
use std::sync::Arc;
use theme::{
Appearance, Theme, ThemeMeta, ThemeMode, ThemeRegistry, ThemeSelection, ThemeSettings,
};
use theme::{Appearance, Theme, ThemeMeta, ThemeRegistry, ThemeSettings};
use ui::{prelude::*, v_flex, ListItem, ListItemSpacing};
use util::ResultExt;
use workspace::{ui::HighlightedLabel, ModalView, Workspace};
@ -197,23 +195,7 @@ impl PickerDelegate for ThemeSelectorDelegate {
let appearance = Appearance::from(cx.appearance());
update_settings_file::<ThemeSettings>(self.fs.clone(), cx, move |settings, _| {
if let Some(selection) = settings.theme.as_mut() {
let theme_to_update = match selection {
ThemeSelection::Static(theme) => theme,
ThemeSelection::Dynamic { mode, light, dark } => match mode {
ThemeMode::Light => light,
ThemeMode::Dark => dark,
ThemeMode::System => match appearance {
Appearance::Light => light,
Appearance::Dark => dark,
},
},
};
*theme_to_update = theme_name.to_string();
} else {
settings.theme = Some(ThemeSelection::Static(theme_name.to_string()));
}
settings.set_theme(theme_name.to_string(), appearance);
});
self.view