-
Notifications
You must be signed in to change notification settings - Fork 21
Add dark mode support #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||||||||||||||||||||||||||||||||||||||
| 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 @@ | |||||||||||||||||||||||||||||||||||||||||
| 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 @@ | |||||||||||||||||||||||||||||||||||||||||
| // 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'; | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+320
to
+324
|
||||||||||||||||||||||||||||||||||||||||||
| // 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'; | |
| // Style custom apps according to theme (light/dark/device) | |
| const iframeDoc = iframe.contentDocument || iframe.contentWindow.document; | |
| if (iframeDoc && iframeDoc.body) { | |
| // Determine effective theme: use SETTINGS.theme if available, otherwise default | |
| const currentSettings = (typeof SETTINGS !== "undefined" && SETTINGS) ? SETTINGS : DEFAULTSETTINGS; | |
| const theme = currentSettings && currentSettings.theme ? currentSettings.theme : DEFAULTSETTINGS.theme; | |
| const prefersDark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches; | |
| const isDark = theme === "dark" || (theme === "device" && prefersDark); | |
| const bgColor = isDark ? "#2c2c2c" : "#ffffff"; | |
| const textColor = isDark ? "#FFFFFF" : "#000000"; |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The matchMedia check is duplicated for both bgColor and textColor. Consider storing the result in a variable to avoid checking twice.
| const bgColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#2c2c2c' : '#ffffff'; | |
| const textColor = window.matchMedia('(prefers-color-scheme: dark)').matches ? '#FFFFFF' : '#000000'; | |
| const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | |
| const bgColor = prefersDark ? '#2c2c2c' : '#ffffff'; | |
| const textColor = prefersDark ? '#FFFFFF' : '#000000'; |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'modal-iframe' class is added to the iframe element but is not used anywhere in the codebase (no CSS rules or JavaScript selectors reference it). Consider removing this class if it's not needed, or ensure the corresponding styles are added if it's intended for styling.
| <iframe class="modal-iframe" src="apps/${appTemplate.id}/${appTemplate.custom}" style="width:100%;height:100%;border:0px;"> | |
| <iframe src="apps/${appTemplate.id}/${appTemplate.custom}" style="width:100%;height:100%;border:0px;"> |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This console.log statement appears to be a leftover debug statement and should be removed.
| console.log(prefersDark) |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local variable 'theme' shadows the function parameter with the same name. Consider renaming this variable to something like 'computedTheme' or 'resolvedTheme' to avoid confusion.
| const theme = prefersDark ? 'dark' : 'light'; | |
| document.documentElement.style.colorScheme = theme; | |
| const computedTheme = prefersDark ? 'dark' : 'light'; | |
| document.documentElement.style.colorScheme = computedTheme; |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repaintSite function is defined but never called anywhere in the code. This function should either be removed or integrated into the theme application logic if it's needed.
| function repaintSite(){ | |
| //tricks browser into repainting the site to apply theme changes | |
| const body = document.body; | |
| body.style.display = 'none'; | |
| body.offsetHeight; | |
| body.style.display = ''; | |
| } |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable 'selectTheme' is not declared with 'let', 'const', or 'var', making it an implicit global variable. Add 'const' or 'let' before 'selectTheme' to properly declare it.
| selectTheme = document.getElementById("settings-theme"); | |
| const selectTheme = document.getElementById("settings-theme"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These blank lines appear to be unnecessary and should be removed to maintain code consistency.