Expose StatusBar height on iOS

Summary:
Following the PR https://github.com/facebook/react-native/pull/6195, this adds a `HEIGHT` constant on `StatusBar` for iOS.

Combined with `statusBarFrameDidChange` and `statusBarFrameWillChange` StatusBar native events, it solves various problems with In-Call cellar bar / Location bar / others 40pt status bars, and offers a correct `keyboardVerticalOffset` value for the KeyboardAvoidingView component.
Closes https://github.com/facebook/react-native/pull/12041

Differential Revision: D4450924

Pulled By: hramos

fbshipit-source-id: 664798260f4226140f3fa3f9222a415a305d0d78
This commit is contained in:
Mathieu Acthernoene 2017-01-23 12:49:17 -08:00 committed by Facebook Github Bot
parent 5e147ab7b0
commit eebfd33b70
3 changed files with 9 additions and 5 deletions

View File

@ -438,11 +438,10 @@ const examples = [{
render() {
return (
<View>
<Text>Height (Android only): {StatusBar.currentHeight} pts</Text>
<Text>Height: {StatusBar.currentHeight} pts</Text>
</View>
);
},
platform: 'android',
}];
exports.examples = examples;

View File

@ -134,7 +134,7 @@ function createStackEntry(props: any): any {
*
* ### Constants
*
* `currentHeight` (Android only) The height of the status bar.
* `currentHeight` The height of the status bar.
*/
class StatusBar extends React.Component {
props: {
@ -169,8 +169,6 @@ class StatusBar extends React.Component {
// discussion in #6195.
/**
* The current height of the status bar on the device.
*
* @platform android
*/
static currentHeight = StatusBarManager.HEIGHT;

View File

@ -132,6 +132,13 @@ RCT_EXPORT_METHOD(setNetworkActivityIndicatorVisible:(BOOL)visible)
RCTSharedApplication().networkActivityIndicatorVisible = visible;
}
- (NSDictionary *)constantsToExport
{
return @{
@"HEIGHT": @([UIApplication sharedApplication].statusBarFrame.size.height)
};
}
#endif //TARGET_OS_TV
@end