2015-02-06 updates

- [ReactServer] Fix graph update | Amjad Masad
- Added RCTStatusBarManager module | Andrew McCloud
This commit is contained in:
Christopher Chedeau 2015-02-06 15:46:31 -08:00
parent 4f613e20d2
commit 9674c99a33
11 changed files with 231 additions and 10 deletions

View File

@ -28,6 +28,8 @@
<array> <array>
<string>armv7</string> <string>armv7</string>
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>

View File

@ -34,5 +34,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict> </dict>
</plist> </plist>

View File

@ -34,5 +34,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict> </dict>
</plist> </plist>

View File

@ -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,
},
});

View File

@ -25,6 +25,7 @@ var EXAMPLES = [
require('./ImageExample'), require('./ImageExample'),
require('./ListViewSimpleExample'), require('./ListViewSimpleExample'),
require('./NavigatorIOSExample'), require('./NavigatorIOSExample'),
require('./StatusBarIOSExample'),
require('./PointerEventsExample'), require('./PointerEventsExample'),
require('./TouchableExample'), require('./TouchableExample'),
require('./SpinnerExample'), require('./SpinnerExample'),

View File

@ -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;

View File

@ -11,6 +11,7 @@ var Image = require('Image');
var ListView = require('ListView'); var ListView = require('ListView');
var ListViewDataSource = require('ListViewDataSource'); var ListViewDataSource = require('ListViewDataSource');
var NavigatorIOS = require('NavigatorIOS'); var NavigatorIOS = require('NavigatorIOS');
var StatusBarIOS = require('StatusBarIOS');
var PixelRatio = require('PixelRatio'); var PixelRatio = require('PixelRatio');
var React = require('React'); var React = require('React');
var ScrollView = require('ScrollView'); var ScrollView = require('ScrollView');
@ -34,6 +35,7 @@ var ReactNative = {
ListView, ListView,
ListViewDataSource, ListViewDataSource,
NavigatorIOS, NavigatorIOS,
StatusBarIOS,
PixelRatio, PixelRatio,
ScrollView, ScrollView,
SpinnerIOS, SpinnerIOS,

View File

@ -0,0 +1,9 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import <UIKit/UIKit.h>
#import "RCTBridgeModule.h"
@interface RCTStatusBarManager : NSObject <RCTBridgeModule>
@end

View File

@ -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

View File

@ -16,6 +16,7 @@
137029491A698FF000575408 /* RCTNetworkImageViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137029401A698FF000575408 /* RCTNetworkImageViewManager.m */; }; 137029491A698FF000575408 /* RCTNetworkImageViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137029401A698FF000575408 /* RCTNetworkImageViewManager.m */; };
137029501A6990A100575408 /* RCTNetworkImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1370294F1A6990A100575408 /* RCTNetworkImageView.m */; }; 137029501A6990A100575408 /* RCTNetworkImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1370294F1A6990A100575408 /* RCTNetworkImageView.m */; };
137029531A69923600575408 /* RCTImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 137029521A69923600575408 /* RCTImageDownloader.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 */; }; 13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = 13A1F71D1A75392D00D3D453 /* RCTKeyCommands.m */; };
13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FE81A69327A00A75B9A /* RCTAlertManager.m */; }; 13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FE81A69327A00A75B9A /* RCTAlertManager.m */; };
13B07FF01A69327A00A75B9A /* RCTExceptionsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FEA1A69327A00A75B9A /* RCTExceptionsManager.m */; }; 13B07FF01A69327A00A75B9A /* RCTExceptionsManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FEA1A69327A00A75B9A /* RCTExceptionsManager.m */; };
@ -82,6 +83,8 @@
137029521A69923600575408 /* RCTImageDownloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageDownloader.m; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 13B07FC71A68125100A75B9A /* Layout.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Layout.c; sourceTree = "<group>"; };
@ -206,6 +209,8 @@
13B07FEE1A69327A00A75B9A /* RCTTiming.m */, 13B07FEE1A69327A00A75B9A /* RCTTiming.m */,
13E067481A70F434002CDEE1 /* RCTUIManager.h */, 13E067481A70F434002CDEE1 /* RCTUIManager.h */,
13E067491A70F434002CDEE1 /* RCTUIManager.m */, 13E067491A70F434002CDEE1 /* RCTUIManager.m */,
13723B4E1A82FD3C00F88898 /* RCTStatusBarManager.h */,
13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */,
); );
path = Modules; path = Modules;
sourceTree = "<group>"; sourceTree = "<group>";
@ -403,6 +408,7 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */,
13B0801E1A69489C00A75B9A /* RCTTextField.m in Sources */, 13B0801E1A69489C00A75B9A /* RCTTextField.m in Sources */,
13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */, 13B07FEF1A69327A00A75B9A /* RCTAlertManager.m in Sources */,
83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */, 83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */,

View File

@ -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) { DependecyGraph.prototype._updateGraphWithModule = function(module) {
if (this._graph[module.path]) {
this._deleteModule(this._graph[module.path]);
}
this._graph[module.path] = module; this._graph[module.path] = module;
if (this._moduleById[module.id]) { if (this._moduleById[module.id]) {
@ -389,15 +405,7 @@ DependecyGraph.prototype._processFileChange = function(eventType, filePath, root
return; return;
} }
delete this._graph[module]; this._deleteModule(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];
}
} else if (!(stat && stat.isDirectory())) { } else if (!(stat && stat.isDirectory())) {
var self = this; var self = this;
this._loading = this._loading.then(function() { this._loading = this._loading.then(function() {