-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [ReactServer] Fix graph update | Amjad Masad - Added RCTStatusBarManager module | Andrew McCloud
- Loading branch information
Showing
11 changed files
with
231 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
* | ||
* @providesModule StatusBarIOSExample | ||
*/ | ||
'use strict'; | ||
|
||
var React = require('react-native'); | ||
var { | ||
StyleSheet, | ||
View, | ||
Text, | ||
TouchableHighlight, | ||
StatusBarIOS, | ||
} = React; | ||
|
||
exports.framework = 'React'; | ||
exports.title = 'StatusBarIOS'; | ||
exports.description = 'Module for controlling iOS status bar'; | ||
exports.examples = [{ | ||
title: 'Status Bar Style', | ||
render() { | ||
return ( | ||
<View> | ||
{Object.keys(StatusBarIOS.Style).map((key) => | ||
<TouchableHighlight style={styles.wrapper} | ||
onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key])}> | ||
<View style={styles.button}> | ||
<Text>setStyle(StatusBarIOS.Style.{key})</Text> | ||
</View> | ||
</TouchableHighlight> | ||
)} | ||
</View> | ||
); | ||
}, | ||
}, { | ||
title: 'Status Bar Style Animated', | ||
render() { | ||
return ( | ||
<View> | ||
{Object.keys(StatusBarIOS.Style).map((key) => | ||
<TouchableHighlight style={styles.wrapper} | ||
onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key], true)}> | ||
<View style={styles.button}> | ||
<Text>setStyle(StatusBarIOS.Style.{key}, true)</Text> | ||
</View> | ||
</TouchableHighlight> | ||
)} | ||
</View> | ||
); | ||
}, | ||
}, { | ||
title: 'Status Bar Hidden', | ||
render() { | ||
return ( | ||
<View> | ||
{Object.keys(StatusBarIOS.Animation).map((key) => | ||
<View> | ||
<TouchableHighlight style={styles.wrapper} | ||
onPress={() => StatusBarIOS.setHidden(true, StatusBarIOS.Animation[key])}> | ||
<View style={styles.button}> | ||
<Text>setHidden(true, StatusBarIOS.Animation.{key})</Text> | ||
</View> | ||
</TouchableHighlight> | ||
<TouchableHighlight style={styles.wrapper} | ||
onPress={() => StatusBarIOS.setHidden(false, StatusBarIOS.Animation[key])}> | ||
<View style={styles.button}> | ||
<Text>setHidden(false, StatusBarIOS.Animation.{key})</Text> | ||
</View> | ||
</TouchableHighlight> | ||
</View> | ||
)} | ||
</View> | ||
); | ||
}, | ||
}]; | ||
|
||
var styles = StyleSheet.create({ | ||
wrapper: { | ||
borderRadius: 5, | ||
marginBottom: 5, | ||
}, | ||
button: { | ||
backgroundColor: '#eeeeee', | ||
padding: 10, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
* | ||
* @providesModule StatusBarIOS | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
var { RKStatusBarManager } = require('NativeModules'); | ||
|
||
var StatusBarIOS = { | ||
|
||
Style: { | ||
default: RKStatusBarManager.Style.default, | ||
lightContent: RKStatusBarManager.Style.lightContent | ||
}, | ||
|
||
Animation: { | ||
none: RKStatusBarManager.Animation.none, | ||
fade: RKStatusBarManager.Animation.fade, | ||
slide: RKStatusBarManager.Animation.slide, | ||
}, | ||
|
||
setStyle(style: number, animated: boolean) { | ||
animated = animated || false; | ||
RKStatusBarManager.setStyle(style, animated); | ||
}, | ||
|
||
setHidden(hidden: boolean, animation: number) { | ||
animation = animation || StatusBarIOS.Animation.none; | ||
RKStatusBarManager.setHidden(hidden, animation); | ||
}, | ||
}; | ||
|
||
module.exports = StatusBarIOS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import "RCTBridgeModule.h" | ||
|
||
@interface RCTStatusBarManager : NSObject <RCTBridgeModule> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
#import "RCTStatusBarManager.h" | ||
|
||
#import "RCTLog.h" | ||
|
||
@implementation RCTStatusBarManager | ||
|
||
static BOOL RCTViewControllerBasedStatusBarAppearance() | ||
{ | ||
static BOOL value; | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
value = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIViewControllerBasedStatusBarAppearance"] boolValue]; | ||
}); | ||
|
||
return value; | ||
} | ||
|
||
- (void)setStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated | ||
{ | ||
RCT_EXPORT(); | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
|
||
if (RCTViewControllerBasedStatusBarAppearance()) { | ||
RCTLogError(@"RCTStatusBarManager module requires that the \ | ||
UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); | ||
} else { | ||
[[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle | ||
animated:animated]; | ||
} | ||
}); | ||
} | ||
|
||
- (void)setHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation | ||
{ | ||
RCT_EXPORT(); | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
|
||
if (RCTViewControllerBasedStatusBarAppearance()) { | ||
RCTLogError(@"RCTStatusBarManager module requires that the \ | ||
UIViewControllerBasedStatusBarAppearance key in the Info.plist is set to NO"); | ||
} else { | ||
[[UIApplication sharedApplication] setStatusBarHidden:hidden | ||
withAnimation:animation]; | ||
} | ||
}); | ||
} | ||
|
||
+ (NSDictionary *)constantsToExport | ||
{ | ||
return @{ | ||
@"Style": @{ | ||
@"default": @(UIStatusBarStyleDefault), | ||
@"lightContent": @(UIStatusBarStyleLightContent), | ||
}, | ||
@"Animation": @{ | ||
@"none": @(UIStatusBarAnimationNone), | ||
@"fade": @(UIStatusBarAnimationFade), | ||
@"slide": @(UIStatusBarAnimationSlide), | ||
}, | ||
}; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters