diff --git a/js/index.js b/js/index.js index 5c1369f..6aa157f 100644 --- a/js/index.js +++ b/js/index.js @@ -14,6 +14,7 @@ const DEFAULTSETTINGS = { alwaysAllowUpdate : false, // Always show "reinstall app" button regardless of the version autoReload: false, // Automatically reload watch after app App Loader actions (removes "Hold button" prompt) noPackets: false, // Enable File Upload Compatibility mode (disables binary packet upload) + theme: "device" // App Loader theme: light, dark, device }; let SETTINGS = JSON.parse(JSON.stringify(DEFAULTSETTINGS)); // clone @@ -24,6 +25,10 @@ let device = { connected : false, // are we connected via BLE right now? appsInstalled : [] // list of app {id,version} of installed apps }; + + + + // FOR TESTING ONLY /*let LANGUAGE = { "//":"German language translations", @@ -312,6 +317,15 @@ function iframeSetup(options) { // when iframe is loaded, call 'onInit' with info about the device iframe.addEventListener("load", function() { console.log("IFRAME loaded"); + // Style custom apps for dark mode + const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; + if (iframeDoc && iframeDoc.body) { + const bgColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#2c2c2c' : '#ffffff'; + const textColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#FFFFFF' : '#000000'; + iframeDoc.body.style.backgroundColor = bgColor; + iframeDoc.body.style.color = textColor; + } + /* if we get a message from the iframe (eg asking to send data to Puck), handle it otherwise pass to messageHandler because handleCustomApp may want to handle it */ iframe.contentWindow.addEventListener("message",function(event) { @@ -431,7 +445,7 @@ function handleCustomApp(appTemplate) {