Skip to content

Commit 3386e5b

Browse files
committed
fix: update status bar color
1 parent c7235ed commit 3386e5b

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
navigator.serviceWorker.register("scripts/serviceworker.js");
109109
}
110110

111+
// Check theme to set status bar color
112+
changeThemeColor("#ffffff", "#000000");
113+
111114
// Check if location permission is given
112115
navigator.permissions.query({ name: "geolocation" }).then(result => {
113116
if (result.state === "granted") {

scripts/extras.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ function parseMillisecondsIntoTripTime(milliseconds, showSeconds = true) {
9494
return (absoluteHours > 0 ? h + "h" : "") + m + "m" + (showSeconds ? s + "s" : "");
9595
}
9696

97-
98-
function changeThemeColor(color) {
99-
metaThemeColor = document.querySelector("meta[name=theme-color]").setAttribute("content", color);
97+
function changeThemeColor(color, darkModeColor = null) {
98+
isDarkMode() && darkModeColor
99+
? document.querySelector("meta[name=theme-color]").setAttribute("content", darkModeColor)
100+
: document.querySelector("meta[name=theme-color]").setAttribute("content", color);
100101
}
101102

102103
function downloadObjectAsJson(exportObj, exportName) {
@@ -108,3 +109,7 @@ function downloadObjectAsJson(exportObj, exportName) {
108109
downloadAnchorNode.click();
109110
downloadAnchorNode.remove();
110111
}
112+
113+
function isDarkMode() {
114+
return window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
115+
}

scripts/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function hideUserSettings() {
220220
userSettings.classList.add("smooth-slide-to-bottom");
221221
setTimeout(() => userSettings.remove(), 300); // remove element after animation end
222222
}
223-
changeThemeColor("#ffffff"); // Set status bar color in PWA
223+
changeThemeColor("#ffffff", "#000000"); // Set status bar color in PWA
224224
}
225225

226226
function openSetProxyPrompt() {
@@ -414,7 +414,7 @@ function openStatisticsMenu() {
414414
updateStatisticsChart();
415415

416416
// Set status bar color in PWA
417-
changeThemeColor("#231f20");
417+
changeThemeColor("#231f20", "#1a1517");
418418
}
419419

420420
function hideStatisticsMenu() {

0 commit comments

Comments
 (0)