-
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.
Initial implementation of StatusBarIOS module for issue #4
- Loading branch information
Andrew McCloud
committed
Jan 31, 2015
1 parent
41b0b58
commit df93b35
Showing
10 changed files
with
160 additions
and
0 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,82 @@ | ||
/** | ||
* @providesModule StatusBarIOSExample | ||
*/ | ||
'use strict'; | ||
|
||
var React = require('react-native/addons'); | ||
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,31 @@ | ||
/** | ||
* @providesModule StatusBarIOS | ||
*/ | ||
'use strict'; | ||
|
||
var { RCTStatusBarManager } = require('NativeModules'); | ||
|
||
var StatusBarIOS = { | ||
style: { | ||
default: 0, | ||
lightContent: 1 | ||
}, | ||
|
||
animation: { | ||
none: 0, | ||
fade: 1, | ||
slide: 2 | ||
}, | ||
|
||
setStyle(style, animated) { | ||
animated = animated || false; | ||
RCTStatusBarManager.setStatusBarStyle(style, animated); | ||
}, | ||
|
||
setHidden(hidden, animation) { | ||
animation = animation || StatusBarIOS.animation.none; | ||
RCTStatusBarManager.setStatusBarHidden(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,7 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
#import "RCTExport.h" | ||
|
||
@interface RCTStatusBarManager : NSObject <RCTNativeModule> | ||
|
||
@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,25 @@ | ||
#import "RCTStatusBarManager.h" | ||
|
||
@implementation RCTStatusBarManager | ||
|
||
- (void)setStatusBarStyle:(NSNumber *)statusBarStyle animated:(NSNumber *)animated { | ||
RCT_EXPORT(); | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
[[UIApplication sharedApplication] | ||
setStatusBarStyle:[statusBarStyle intValue] | ||
animated:[animated boolValue]]; | ||
}); | ||
} | ||
|
||
- (void)setStatusBarHidden:(NSNumber *)hidden withAnimation:(NSNumber *)animation { | ||
RCT_EXPORT(); | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
[[UIApplication sharedApplication] | ||
setStatusBarHidden:[hidden boolValue] | ||
withAnimation:[animation intValue]]; | ||
}); | ||
} | ||
|
||
@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