MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / apply

Function apply

src/theme/list.js:81–143  ·  view source on GitHub ↗
(id, init)

Source from the content-addressed store, hash-verified

79 * @param {boolean} init Whether or not this is the first time the theme is being applied
80 */
81export async function apply(id, init) {
82 if (!DOES_SUPPORT_THEME) {
83 id = "default";
84 }
85
86 themeApplied = true;
87 const theme = get(id);
88 const $style = document.head.get("style#app-theme") ?? (
89 <style id="app-theme"></style>
90 );
91 const update = {
92 appTheme: id,
93 };
94
95 if (id === "custom") {
96 update.customTheme = theme.toJSON();
97 }
98
99 if (init && theme.preferredEditorTheme) {
100 update.editorTheme = theme.preferredEditorTheme;
101 if (editorManager != null && editorManager.editor != null) {
102 editorManager.editor.setTheme(theme.preferredEditorTheme);
103 }
104 }
105
106 if (init && theme.preferredFont) {
107 update.editorFont = theme.preferredFont;
108 fonts.setFont(theme.preferredFont);
109 }
110
111 if (init && firstTime && theme.preferredTerminalTheme) {
112 update.terminalSettings = {
113 ...(settings.value.terminalSettings || {}),
114 theme: theme.preferredTerminalTheme,
115 };
116 }
117
118 settings.update(update, false);
119
120 if (init && firstTime && theme.preferredTerminalTheme) {
121 if (editorManager != null) {
122 updateActiveTerminals("theme", theme.preferredTerminalTheme);
123 }
124 }
125
126 localStorage.__primary_color = theme.primaryColor;
127 document.body.setAttribute("theme-type", theme.type);
128 $style.textContent = theme.css;
129 document.head.append($style);
130
131 const primaryColor = color(theme.primaryColor).hex.toString();
132 const scheme = theme.toJSON("hex");
133 // Set status bar and navigation bar color
134 system.setUiTheme(primaryColor, scheme);
135
136 if (firstTime) {
137 // To make sure system bars are updated
138 setTimeout(() => {

Callers 2

updateSystemThemeFunction · 0.90
addFunction · 0.70

Calls 9

updateActiveTerminalsFunction · 0.90
colorFunction · 0.85
appendMethod · 0.80
getFunction · 0.70
setUiThemeMethod · 0.65
getMethod · 0.45
toJSONMethod · 0.45
updateMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected