Skip to main content

Mountain/IPC/WindServiceHandlers/UI/
ThemesGetActive.rs

1#![allow(unused_variables)]
2
3//! Wire method: `themes:getColorTheme`.
4
5use std::sync::Arc;
6
7use serde_json::{Value, json};
8
9use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
10
11pub async fn Fn(RunTime:Arc<ApplicationRunTime>) -> Result<Value, String> {
12	use CommonLibrary::Configuration::{
13		ConfigurationProvider::ConfigurationProvider,
14		DTO::ConfigurationOverridesDTO::ConfigurationOverridesDTO,
15	};
16
17	let ThemeId = RunTime
18		.Environment
19		.GetConfigurationValue(Some("workbench.colorTheme".to_string()), ConfigurationOverridesDTO::default())
20		.await
21		.map_err(|Error| format!("themes:getActive failed: {}", Error))?;
22
23	let Id = ThemeId.as_str().unwrap_or("Default Dark Modern").to_string();
24
25	let (Kind, TypeNum) = if Id.to_lowercase().contains("high contrast light") {
26		("highContrastLight", 4u8)
27	} else if Id.to_lowercase().contains("high contrast") {
28		("highContrast", 3u8)
29	} else if Id.to_lowercase().contains("light") {
30		("light", 1u8)
31	} else {
32		("dark", 2u8)
33	};
34
35	Ok(json!({
36		"id": Id,
37		"label": Id,
38		"kind": Kind,
39		"type": TypeNum,
40		"semanticHighlighting": false,
41	}))
42}