From 45b7ef6732e820aadd224ef1231f73b5ff9e5df2 Mon Sep 17 00:00:00 2001 From: xinkai Date: Mon, 5 Jan 2015 02:31:54 +0800 Subject: [PATCH] add definitions for cordova StatusBar plugin. --- cordova/cordova.d.ts | 5 +- cordova/plugins/StatusBar-tests.ts | 16 +++++++ cordova/plugins/StatusBar.d.ts | 75 ++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 cordova/plugins/StatusBar-tests.ts create mode 100644 cordova/plugins/StatusBar.d.ts diff --git a/cordova/cordova.d.ts b/cordova/cordova.d.ts index 06d13e8cfd..bdfa643da3 100644 --- a/cordova/cordova.d.ts +++ b/cordova/cordova.d.ts @@ -2,9 +2,9 @@ // Project: http://cordova.apache.org // Definitions by: Microsoft Open Technologies Inc. // Definitions: https://github.com/borisyankov/DefinitelyTyped -// +// // Copyright (c) Microsoft Open Technologies, Inc. -// Licensed under the MIT license. +// Licensed under the MIT license. /// /// @@ -22,6 +22,7 @@ /// /// /// +/// /// /// diff --git a/cordova/plugins/StatusBar-tests.ts b/cordova/plugins/StatusBar-tests.ts new file mode 100644 index 0000000000..92eac303e9 --- /dev/null +++ b/cordova/plugins/StatusBar-tests.ts @@ -0,0 +1,16 @@ +// Licensed under the MIT license. + +/// + +var statusBar: StatusBar = window.StatusBar; +statusBar.overlaysWebView(true); +statusBar.overlaysWebView(false); +statusBar.styleDefault(); +statusBar.styleLightContent(); +statusBar.styleBlackTranslucent(); +statusBar.styleBlackOpaque(); +statusBar.backgroundColorByName("red"); +statusBar.backgroundColorByHexString("#aaa"); +statusBar.hide(); +statusBar.show(); +var visible: boolean = statusBar.isVisible; diff --git a/cordova/plugins/StatusBar.d.ts b/cordova/plugins/StatusBar.d.ts new file mode 100644 index 0000000000..8b52996267 --- /dev/null +++ b/cordova/plugins/StatusBar.d.ts @@ -0,0 +1,75 @@ +// Type definitions for Apache Cordova StatusBar plugin. +// Project: https://github.com/apache/cordova-plugin-statusbar +// Definitions by: Xinkai Chen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** +* Global object StatusBar. +*/ +interface Window { + StatusBar: StatusBar; +} + + +/** +* The StatusBar object provides some functions to customize the iOS and Android StatusBar. +*/ +interface StatusBar { + /** + * On iOS 7, make the statusbar overlay or not overlay the WebView. + * @param isOverlay On iOS 7, set to false to make the statusbar appear like iOS 6. + * Set the style and background color to suit using the other functions. + */ + overlaysWebView: (isOverlay: boolean) => void; + + /** + * Use the default statusbar (dark text, for light backgrounds). + */ + styleDefault: () => void; + + /** + * Use the lightContent statusbar (light text, for dark backgrounds). + */ + styleLightContent: () => void; + + /** + * Use the blackTranslucent statusbar (light text, for dark backgrounds). + */ + styleBlackTranslucent: () => void; + + /** + * Use the blackOpaque statusbar (light text, for dark backgrounds). + */ + styleBlackOpaque: () => void; + + /** + * On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, + * you can set the background color of the statusbar by color name. + * @param color Supported color names are: + * black, darkGray, lightGray, white, gray, red, green, blue, cyan, yellow, magenta, orange, purple, brown + */ + backgroundColorByName: (color: string) => void; + + /** + * Sets the background color of the statusbar by a hex string. + * @param color CSS shorthand properties are also supported. + * On iOS 7, when you set StatusBar.statusBarOverlaysWebView to false, you can set the background color of the statusbar by a hex string (#RRGGBB). + * On WP7 and WP8 you can also specify values as #AARRGGBB, where AA is an alpha value + */ + backgroundColorByHexString: (color: string) => void; + + /** + * Hide the statusbar. + */ + hide: () => void; + + /** + * Show the statusbar. + */ + show: () => void; + + /** + * Read this property to see if the statusbar is visible or not. + */ + isVisible: boolean; +}