mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2025-01-18 17:02:49 +08:00
Merge branch 'CB-7986' of https://github.com/MSOpenTech/cordova-plugin-statusbar
This commit is contained in:
commit
83978519ad
@ -132,6 +132,7 @@ Supported Platforms
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
StatusBar.styleLightContent
|
||||
=================
|
||||
@ -147,6 +148,7 @@ Supported Platforms
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
StatusBar.styleBlackTranslucent
|
||||
=================
|
||||
@ -162,6 +164,7 @@ Supported Platforms
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
StatusBar.styleBlackOpaque
|
||||
=================
|
||||
@ -177,6 +180,7 @@ Supported Platforms
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
|
||||
StatusBar.backgroundColorByName
|
||||
@ -197,6 +201,7 @@ Supported Platforms
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
StatusBar.backgroundColorByHexString
|
||||
=================
|
||||
@ -220,6 +225,7 @@ Supported Platforms
|
||||
- iOS
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
StatusBar.hide
|
||||
=================
|
||||
@ -236,6 +242,7 @@ Supported Platforms
|
||||
- Android
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
StatusBar.show
|
||||
=================
|
||||
@ -252,6 +259,7 @@ Supported Platforms
|
||||
- Android
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
|
||||
StatusBar.isVisible
|
||||
@ -271,5 +279,6 @@ Supported Platforms
|
||||
- Android
|
||||
- Windows Phone 7
|
||||
- Windows Phone 8
|
||||
- Windows Phone 8.1
|
||||
|
||||
|
||||
|
@ -82,4 +82,10 @@
|
||||
<source-file src="src/wp/StatusBar.cs" />
|
||||
</platform>
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="src/windows/StatusBar.js" name="StatusBar">
|
||||
<runs />
|
||||
</js-module>
|
||||
</platform>
|
||||
</plugin>
|
||||
|
90
src/windows/StatusBar.js
Normal file
90
src/windows/StatusBar.js
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
var statusBar = Windows.UI.ViewManagement.StatusBar.getForCurrentView();
|
||||
|
||||
function darkForeground () {
|
||||
// dark text ( to be used on a light background )
|
||||
statusBar.foregroundColor = { a: 0, r: 0, g: 0, b: 0 };
|
||||
}
|
||||
|
||||
function lightForeground() {
|
||||
// light text ( to be used on a dark background )
|
||||
statusBar.foregroundColor = { a: 0, r: 255, g: 255, b: 255 };
|
||||
}
|
||||
|
||||
function hexToRgb(hex) {
|
||||
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
|
||||
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
||||
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
|
||||
return r + r + g + g + b + b;
|
||||
});
|
||||
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
}
|
||||
|
||||
var StatusBar = {
|
||||
_ready: function(win, fail) {
|
||||
win(statusBar.occludedRect.height !== 0);
|
||||
},
|
||||
|
||||
overlaysWebView: function () {
|
||||
// not supported
|
||||
},
|
||||
|
||||
styleDefault: function () {
|
||||
darkForeground();
|
||||
},
|
||||
|
||||
styleLightContent: function () {
|
||||
lightForeground();
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
// #88000000 ? Apple says to use lightContent instead
|
||||
lightForeground();
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
// #FF000000 ? Apple says to use lightContent instead
|
||||
lightForeground();
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (win, fail, args) {
|
||||
var rgb = hexToRgb(args[0]);
|
||||
statusBar.backgroundColor = { a: 0, r: rgb.r, g: rgb.g, b: rgb.b };
|
||||
statusBar.backgroundOpacity = 1;
|
||||
},
|
||||
|
||||
show: function (win, fail) {
|
||||
statusBar.showAsync().done(win, fail);
|
||||
},
|
||||
|
||||
hide: function (win, fail) {
|
||||
statusBar.hideAsync().done(win, fail);
|
||||
}
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("StatusBar", StatusBar);
|
@ -21,6 +21,9 @@
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
// Needed for Windows Phone 8.1 as it is initialized after this module
|
||||
var StatusBar = StatusBar || require('org.apache.cordova.statusbar.StatusBar');
|
||||
|
||||
var namedColors = {
|
||||
"black": "#000000",
|
||||
"darkGray": "#A9A9A9",
|
||||
|
Loading…
Reference in New Issue
Block a user