Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of StatusBarIOS #13

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Examples/Movies/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<array>
<string>armv7</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
2 changes: 2 additions & 0 deletions Examples/TicTacToe/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<array>
<string>armv7</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<array>
<string>armv7</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
86 changes: 86 additions & 0 deletions Examples/UIExplorer/StatusBarIOSExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* @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,
},
});

1 change: 1 addition & 0 deletions Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var EXAMPLES = [
require('./ImageExample'),
require('./ListViewSimpleExample'),
require('./NavigatorIOSExample'),
require('./StatusBarIOSExample'),
require('./PointerEventsExample'),
require('./TouchableExample'),
require('./SpinnerExample'),
Expand Down
31 changes: 31 additions & 0 deletions Libraries/Components/StatusBar/StatusBarIOS.ios.js
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;
2 changes: 2 additions & 0 deletions Libraries/react-native/react-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var Image = require('Image');
var ListView = require('ListView');
var ListViewDataSource = require('ListViewDataSource');
var NavigatorIOS = require('NavigatorIOS');
var StatusBarIOS = require('StatusBarIOS');
var PixelRatio = require('PixelRatio');
var React = require('React');
var ScrollView = require('ScrollView');
Expand All @@ -34,6 +35,7 @@ var ReactNative = {
ListView,
ListViewDataSource,
NavigatorIOS,
StatusBarIOS,
PixelRatio,
ScrollView,
SpinnerIOS,
Expand Down
7 changes: 7 additions & 0 deletions ReactKit/Modules/RCTStatusBarManager.h
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
25 changes: 25 additions & 0 deletions ReactKit/Modules/RCTStatusBarManager.m
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
6 changes: 6 additions & 0 deletions ReactKit/ReactKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
13E067571A70F44B002CDEE1 /* RCTView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E067501A70F44B002CDEE1 /* RCTView.m */; };
13E067581A70F44B002CDEE1 /* RCTViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E067521A70F44B002CDEE1 /* RCTViewManager.m */; };
13E067591A70F44B002CDEE1 /* UIView+ReactKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E067541A70F44B002CDEE1 /* UIView+ReactKit.m */; };
396767821A7C247E003BFF0E /* RCTStatusBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 396767811A7C247E003BFF0E /* RCTStatusBarManager.m */; };
830A229E1A66C68A008503DA /* RCTRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = 830A229D1A66C68A008503DA /* RCTRootView.m */; };
832348161A77A5AA00B55238 /* Layout.c in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FC71A68125100A75B9A /* Layout.c */; };
83CBBA511A601E3B00E9B192 /* RCTAssert.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CBBA4B1A601E3B00E9B192 /* RCTAssert.m */; };
Expand Down Expand Up @@ -142,6 +143,8 @@
13E067521A70F44B002CDEE1 /* RCTViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTViewManager.m; sourceTree = "<group>"; };
13E067531A70F44B002CDEE1 /* UIView+ReactKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+ReactKit.h"; sourceTree = "<group>"; };
13E067541A70F44B002CDEE1 /* UIView+ReactKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+ReactKit.m"; sourceTree = "<group>"; };
396767801A7C247E003BFF0E /* RCTStatusBarManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTStatusBarManager.h; sourceTree = "<group>"; };
396767811A7C247E003BFF0E /* RCTStatusBarManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTStatusBarManager.m; sourceTree = "<group>"; };
830213F31A654E0800B993E6 /* RCTExport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTExport.h; sourceTree = "<group>"; };
830213F41A65574D00B993E6 /* RCTExport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTExport.m; sourceTree = "<group>"; };
830A229C1A66C68A008503DA /* RCTRootView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRootView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -225,6 +228,8 @@
13B07FEE1A69327A00A75B9A /* RCTTiming.m */,
13E067481A70F434002CDEE1 /* RCTUIManager.h */,
13E067491A70F434002CDEE1 /* RCTUIManager.m */,
396767801A7C247E003BFF0E /* RCTStatusBarManager.h */,
396767811A7C247E003BFF0E /* RCTStatusBarManager.m */,
);
path = Modules;
sourceTree = "<group>";
Expand Down Expand Up @@ -474,6 +479,7 @@
83CBBA871A60202500E9B192 /* RCTJavaScriptAppEngine.m in Sources */,
134FCB3E1A6E7F0800051CC8 /* RCTWebViewExecutor.m in Sources */,
83EEC2EE1A604AB200C39218 /* RCTModuleMethod.m in Sources */,
396767821A7C247E003BFF0E /* RCTStatusBarManager.m in Sources */,
13B0801C1A69489C00A75B9A /* RCTNavItem.m in Sources */,
137029331A69659C00575408 /* RCTExport.m in Sources */,
83CBBA691A601EF300E9B192 /* RCTJavaScriptEventDispatcher.m in Sources */,
Expand Down