mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-01-19 01:12:49 +08:00
added checks for running on windows when StatusBar is NOT available
This commit is contained in:
parent
251e904492
commit
c89fdd4617
@ -19,16 +19,20 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var isSupported = true; // we assume
|
||||||
|
|
||||||
function getViewStatusBar() {
|
function getViewStatusBar() {
|
||||||
return Windows.UI.ViewManagement.StatusBar.getForCurrentView();
|
if(isSupported) {
|
||||||
}
|
var ViewMan = Windows.UI.ViewManagement; // quick alias to save char
|
||||||
|
if( ViewMan.StatusBar &&
|
||||||
function darkForeground () {
|
ViewMan.StatusBar.getForCurrentView ) {
|
||||||
|
return ViewMan.StatusBar.getForCurrentView();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
function lightForeground() {
|
isSupported = false; // so we won't check again
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hexToRgb(hex) {
|
function hexToRgb(hex) {
|
||||||
@ -78,8 +82,10 @@ module.exports = {
|
|||||||
backgroundColorByHexString: function (win, fail, args) {
|
backgroundColorByHexString: function (win, fail, args) {
|
||||||
var rgb = hexToRgb(args[0]);
|
var rgb = hexToRgb(args[0]);
|
||||||
var statusBar = getViewStatusBar();
|
var statusBar = getViewStatusBar();
|
||||||
statusBar.backgroundColor = { a: 0, r: rgb.r, g: rgb.g, b: rgb.b };
|
if(statusBar) {
|
||||||
statusBar.backgroundOpacity = 1;
|
statusBar.backgroundColor = { a: 0, r: rgb.r, g: rgb.g, b: rgb.b };
|
||||||
|
statusBar.backgroundOpacity = 1;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function (win, fail) {
|
show: function (win, fail) {
|
||||||
|
Loading…
Reference in New Issue
Block a user