2021-11-18 14:41:22 +05:00
|
|
|
const JSONStorage = require("../jsonstorage");
|
2021-09-29 14:02:47 +05:00
|
|
|
const { nativeTheme } = require("electron");
|
2021-08-02 20:44:56 +05:00
|
|
|
|
|
|
|
|
function getTheme() {
|
2021-11-18 14:41:22 +05:00
|
|
|
return JSONStorage.get("theme") || "light";
|
2021-08-02 20:44:56 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setTheme(theme) {
|
2021-09-29 14:02:47 +05:00
|
|
|
nativeTheme.themeSource = theme;
|
|
|
|
|
if (global.win) global.win.setBackgroundColor(getBackgroundColor(theme));
|
2021-11-18 14:41:22 +05:00
|
|
|
return JSONStorage.set("theme", theme);
|
2021-08-02 20:44:56 +05:00
|
|
|
}
|
|
|
|
|
|
2021-12-01 13:07:17 +05:00
|
|
|
function getBackgroundColor() {
|
|
|
|
|
return nativeTheme.shouldUseDarkColors ? "#0f0f0f" : "#ffffff";
|
2021-08-02 20:44:56 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = { getTheme, setTheme, getBackgroundColor };
|