Skip to content

Commit

Permalink
2015-02-06 updates
Browse files Browse the repository at this point in the history
- [ReactServer] Fix graph update | Amjad Masad
- Added RCTStatusBarManager module | Andrew McCloud
  • Loading branch information
vjeux committed Feb 7, 2015
1 parent 4f613e2 commit 9674c99
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 10 deletions.
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 @@ -34,5 +34,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions Examples/UIExplorer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
87 changes: 87 additions & 0 deletions Examples/UIExplorer/StatusBarIOSExample.js
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,
},
});
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
35 changes: 35 additions & 0 deletions Libraries/Components/StatusBar/StatusBarIOS.js
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;
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
9 changes: 9 additions & 0 deletions ReactKit/Modules/RCTStatusBarManager.h
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
67 changes: 67 additions & 0 deletions ReactKit/Modules/RCTStatusBarManager.m
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
6 changes: 6 additions & 0 deletions ReactKit/ReactKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
137029491A698FF000575408 /* RCTNetworkImageViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137029401A698FF000575408 /* RCTNetworkImageViewManager.m */; };
137029501A6990A100575408 /* RCTNetworkImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1370294F1A6990A100575408 /* RCTNetworkImageView.m */; };
137029531A69923600575408 /* RCTImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 137029521A69923600575408 /* RCTImageDownloader.m */; };
13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */; };
13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */; };
13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FE81A69327A00A75B9A /* RCTAlertManager.m */; };
13B07FF01A69327A00A75B9A /* RCTExceptionsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FEA1A69327A00A75B9A /* RCTExceptionsManager.m */; };
Expand Down Expand Up @@ -82,6 +83,8 @@
137029521A69923600575408 /* RCTImageDownloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageDownloader.m; sourceTree = "<group>"; };
137029571A6C197000575408 /* RCTRawTextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRawTextManager.h; sourceTree = "<group>"; };
137029581A6C197000575408 /* RCTRawTextManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRawTextManager.m; sourceTree = "<group>"; };
13723B4E1A82FD3C00F88898 /* RCTStatusBarManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTStatusBarManager.h; sourceTree = "<group>"; };
13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTStatusBarManager.m; sourceTree = "<group>"; };
13A1F71C1A75392D00D3D453 /* RCTKeyCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTKeyCommands.h; sourceTree = "<group>"; };
13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTKeyCommands.m; sourceTree = "<group>"; };
13B07FC71A68125100A75B9A /* Layout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Layout.c; sourceTree = "<group>"; };
Expand Down Expand Up @@ -206,6 +209,8 @@
13B07FEE1A69327A00A75B9A /* RCTTiming.m */,
13E067481A70F434002CDEE1 /* RCTUIManager.h */,
13E067491A70F434002CDEE1 /* RCTUIManager.m */,
13723B4E1A82FD3C00F88898 /* RCTStatusBarManager.h */,
13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */,
);
path = Modules;
sourceTree = "<group>";
Expand Down Expand Up @@ -403,6 +408,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */,
13B0801E1A69489C00A75B9A /* RCTTextField.m in Sources */,
13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */,
83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,26 @@ DependecyGraph.prototype._lookupName = function(modulePath) {
}
};

DependecyGraph.prototype._deleteModule = function(module) {
delete this._graph[module.path];

// Others may keep a reference so we mark it as deleted.
module.deleted = true;

// Haste allows different module to have the same id.
if (this._moduleById[module.id] === module) {
delete this._moduleById[module.id];
}
};

/**
* Update the graph and idices with the module.
* Update the graph and indices with the module.
*/
DependecyGraph.prototype._updateGraphWithModule = function(module) {
if (this._graph[module.path]) {
this._deleteModule(this._graph[module.path]);
}

this._graph[module.path] = module;

if (this._moduleById[module.id]) {
Expand Down Expand Up @@ -389,15 +405,7 @@ DependecyGraph.prototype._processFileChange = function(eventType, filePath, root
return;
}

delete this._graph[module];

// Others may keep a reference so we mark it as deleted.
module.deleted = true;

// Modules may have same id.
if (this._moduleById[module.id] === module) {
delete this._moduleById[module.id];
}
this._deleteModule(module);
} else if (!(stat && stat.isDirectory())) {
var self = this;
this._loading = this._loading.then(function() {
Expand Down

0 comments on commit 9674c99

Please sign in to comment.