Change statusbar color on dark theme

master
Skylar Ittner 4 years ago
parent 3ce58c84ce
commit f0d3b2b4f6

@ -62,13 +62,11 @@ router.on("pageInit", function (pagedata) {
} }
}); });
if (localStorage.getItem("darktheme") == "true") {
$("#app").addClass("theme-dark");
}
// Run platform-specific setup code for Cordova or NW.js // Run platform-specific setup code for Cordova or NW.js
initPlatform(); initPlatform();
// Switch to dark theme if requested by user setting
setAppTheme();
if (localStorage.getItem("configured") == null) { if (localStorage.getItem("configured") == null) {
// Open the setup page // Open the setup page

@ -22,6 +22,14 @@ var removeTrayMenu = function () {
} }
var setAppTheme = function () {
if (localStorage.getItem("darktheme") == "true") {
$("#app").addClass("theme-dark");
} else {
$("#app").removeClass("theme-dark");
}
}
function initCordova() { function initCordova() {
platform_type = "cordova"; platform_type = "cordova";
@ -46,6 +54,21 @@ function initCordova() {
openBrowser = function (url) { openBrowser = function (url) {
cordova.InAppBrowser.open(url, '_blank', 'location=yes'); cordova.InAppBrowser.open(url, '_blank', 'location=yes');
} }
setAppTheme = function () {
if (localStorage.getItem("darktheme") == "true") {
$("#app").addClass("theme-dark");
if (cordova.platformId == 'android') {
StatusBar.styleDefault();
}
} else {
$("#app").removeClass("theme-dark");
if (cordova.platformId == 'android') {
StatusBar.backgroundColorByHexString("#D32F2F");
StatusBar.styleLightContent();
}
}
}
} }
function initNW() { function initNW() {

@ -14,9 +14,5 @@ $('.item-content[data-setting=darktheme] .toggle input').on("change", function (
var checked = $(this).prop('checked'); var checked = $(this).prop('checked');
localStorage.setItem("darktheme", checked); localStorage.setItem("darktheme", checked);
if (localStorage.getItem("darktheme") == "true") { setAppTheme();
$("#app").addClass("theme-dark");
} else {
$("#app").removeClass("theme-dark");
}
}); });
Loading…
Cancel
Save