Skip to content

Commit

Permalink
Merge branch 'master' into ActivityIndicator/add-size-prop
Browse files Browse the repository at this point in the history
  • Loading branch information
fadils committed Jul 20, 2016
2 parents de373a3 + 700e82f commit 014c24b
Show file tree
Hide file tree
Showing 93 changed files with 2,305 additions and 1,248 deletions.
4 changes: 2 additions & 2 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-8]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-8]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-9]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

unsafe.enable_getters_and_setters=true
Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n$SRCROOT/../../packager/react-native-xcode.sh Examples/UIExplorer/UIExplorerApp.ios.js";
shellScript = "export NODE_BINARY=node\n$SRCROOT/../../packager/react-native-xcode.sh Examples/UIExplorer/js/UIExplorerApp.ios.js";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/UIExplorer/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWith

- (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge
{
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/UIExplorer/UIExplorerApp.ios" fallbackResource:nil];
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/UIExplorer/js/UIExplorerApp.ios" fallbackResource:nil];

if (!getenv("CI_USE_PACKAGER")) {
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ - (void)setUp
if (getenv("CI_USE_PACKAGER")) {
NSString *app = @"IntegrationTests/IntegrationTestsApp";
scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]];
RCTAssert(scriptURL != nil, @"No scriptURL set");
} else {
scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"];
RCTAssert(scriptURL != nil, @"Could not locate main.jsBundle");
}
RCTAssert(scriptURL != nil, @"No scriptURL set");

_bridge = [[RCTBridge alloc] initWithBundleURL:scriptURL moduleProvider:NULL launchOptions:nil];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:60];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import "RCTUtils.h"
#import "RCTUIManager.h"
#import "RCTViewManager.h"
#import "RCTJavaScriptExecutor.h"

#define RUN_RUNLOOP_WHILE(CONDITION) \
{ \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "RCTBridge+Private.h"
#import "RCTBridgeModule.h"
#import "RCTUtils.h"
#import "RCTJavaScriptExecutor.h"

#define RUN_RUNLOOP_WHILE(CONDITION) \
{ \
Expand Down
96 changes: 46 additions & 50 deletions Examples/UIExplorer/UIExplorerUnitTests/RCTShadowViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ - (void)setUp
{
[super setUp];

self.parentView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex_direction = CSS_FLEX_DIRECTION_COLUMN;
style->dimensions[0] = 440;
style->dimensions[1] = 440;
self.parentView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlexDirection(node, CSSFlexDirectionColumn);
CSSNodeStyleSetWidth(node, 440);
CSSNodeStyleSetHeight(node, 440);
}];
self.parentView.reactTag = @1; // must be valid rootView tag
}
Expand All @@ -50,43 +50,43 @@ - (void)setUp
//
- (void)testApplyingLayoutRecursivelyToShadowView
{
RCTShadowView *leftView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex = 1;
RCTShadowView *leftView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
}];

RCTShadowView *centerView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex = 2;
style->margin[0] = 10;
style->margin[2] = 10;
RCTShadowView *centerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 2);
CSSNodeStyleSetMarginLeft(node, 10);
CSSNodeStyleSetMarginRight(node, 10);
}];

RCTShadowView *rightView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex = 1;
RCTShadowView *rightView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
}];

RCTShadowView *mainView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex_direction = CSS_FLEX_DIRECTION_ROW;
style->flex = 2;
style->margin[1] = 10;
style->margin[3] = 10;
RCTShadowView *mainView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlexDirection(node, CSSFlexDirectionRow);
CSSNodeStyleSetFlex(node, 2);
CSSNodeStyleSetMarginTop(node, 10);
CSSNodeStyleSetMarginBottom(node, 10);
}];

[mainView insertReactSubview:leftView atIndex:0];
[mainView insertReactSubview:centerView atIndex:1];
[mainView insertReactSubview:rightView atIndex:2];

RCTShadowView *headerView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex = 1;
RCTShadowView *headerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
}];

RCTShadowView *footerView = [self _shadowViewWithStyle:^(css_style_t *style) {
style->flex = 1;
RCTShadowView *footerView = [self _shadowViewWithConfig:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
}];

self.parentView.cssNode->style.padding[0] = 10;
self.parentView.cssNode->style.padding[1] = 10;
self.parentView.cssNode->style.padding[2] = 10;
self.parentView.cssNode->style.padding[3] = 10;
CSSNodeStyleSetPaddingLeft(self.parentView.cssNode, 10);
CSSNodeStyleSetPaddingTop(self.parentView.cssNode, 10);
CSSNodeStyleSetPaddingRight(self.parentView.cssNode, 10);
CSSNodeStyleSetPaddingBottom(self.parentView.cssNode, 10);

[self.parentView insertReactSubview:headerView atIndex:0];
[self.parentView insertReactSubview:mainView atIndex:1];
Expand All @@ -108,54 +108,54 @@ - (void)testApplyingLayoutRecursivelyToShadowView

- (void)testAssignsSuggestedWidthDimension
{
[self _withShadowViewWithStyle:^(css_style_t *style) {
style->position[CSS_LEFT] = 0;
style->position[CSS_TOP] = 0;
style->dimensions[CSS_HEIGHT] = 10;
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetPositionLeft(node, 0);
CSSNodeStyleSetPositionTop(node, 0);
CSSNodeStyleSetHeight(node, 10);
}
assertRelativeLayout:CGRectMake(0, 0, 3, 10)
withIntrinsicContentSize:CGSizeMake(3, UIViewNoIntrinsicMetric)];
}

- (void)testAssignsSuggestedHeightDimension
{
[self _withShadowViewWithStyle:^(css_style_t *style) {
style->position[CSS_LEFT] = 0;
style->position[CSS_TOP] = 0;
style->dimensions[CSS_WIDTH] = 10;
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetPositionLeft(node, 0);
CSSNodeStyleSetPositionTop(node, 0);
CSSNodeStyleSetWidth(node, 10);
}
assertRelativeLayout:CGRectMake(0, 0, 10, 4)
withIntrinsicContentSize:CGSizeMake(UIViewNoIntrinsicMetric, 4)];
}

- (void)testDoesNotOverrideDimensionStyleWithSuggestedDimensions
{
[self _withShadowViewWithStyle:^(css_style_t *style) {
style->position[CSS_LEFT] = 0;
style->position[CSS_TOP] = 0;
style->dimensions[CSS_WIDTH] = 10;
style->dimensions[CSS_HEIGHT] = 10;
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetPositionLeft(node, 0);
CSSNodeStyleSetPositionTop(node, 0);
CSSNodeStyleSetWidth(node, 10);
CSSNodeStyleSetHeight(node, 10);
}
assertRelativeLayout:CGRectMake(0, 0, 10, 10)
withIntrinsicContentSize:CGSizeMake(3, 4)];
}

- (void)testDoesNotAssignSuggestedDimensionsWhenStyledWithFlexAttribute
{
float parentWidth = self.parentView.cssNode->style.dimensions[CSS_WIDTH];
float parentHeight = self.parentView.cssNode->style.dimensions[CSS_HEIGHT];
[self _withShadowViewWithStyle:^(css_style_t *style) {
style->flex = 1;
float parentWidth = CSSNodeStyleGetWidth(self.parentView.cssNode);
float parentHeight = CSSNodeStyleGetHeight(self.parentView.cssNode);
[self _withShadowViewWithStyle:^(CSSNodeRef node) {
CSSNodeStyleSetFlex(node, 1);
}
assertRelativeLayout:CGRectMake(0, 0, parentWidth, parentHeight)
withIntrinsicContentSize:CGSizeMake(3, 4)];
}

- (void)_withShadowViewWithStyle:(void(^)(css_style_t *style))styleBlock
- (void)_withShadowViewWithStyle:(void(^)(CSSNodeRef node))configBlock
assertRelativeLayout:(CGRect)expectedRect
withIntrinsicContentSize:(CGSize)contentSize
{
RCTShadowView *view = [self _shadowViewWithStyle:styleBlock];
RCTShadowView *view = [self _shadowViewWithConfig:configBlock];
[self.parentView insertReactSubview:view atIndex:0];
view.intrinsicContentSize = contentSize;
[self.parentView collectViewsWithUpdatedFrames];
Expand All @@ -166,14 +166,10 @@ - (void)_withShadowViewWithStyle:(void(^)(css_style_t *style))styleBlock
NSStringFromCGRect(actualRect));
}

- (RCTRootShadowView *)_shadowViewWithStyle:(void(^)(css_style_t *style))styleBlock
- (RCTRootShadowView *)_shadowViewWithConfig:(void(^)(CSSNodeRef node))configBlock
{
RCTRootShadowView *shadowView = [RCTRootShadowView new];

css_style_t style = shadowView.cssNode->style;
styleBlock(&style);
shadowView.cssNode->style = style;

configBlock(shadowView.cssNode);
return shadowView;
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/js/CameraRollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ var CameraRollView = React.createClass({

_renderFooterSpinner: function() {
if (!this.state.noMore) {
return <ActivityIndicator style={styles.spinner} />;
return <ActivityIndicator />;
}
return null;
},
Expand Down
4 changes: 2 additions & 2 deletions Examples/UIExplorer/js/ImageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ var MultipleSourcesExample = React.createClass({
},
render: function() {
return (
<View style={styles.container}>
<View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text
style={styles.touchableText}
Expand All @@ -180,7 +180,7 @@ var MultipleSourcesExample = React.createClass({
</View>
<Text>Container image size: {this.state.width}x{this.state.height} </Text>
<View
style={[styles.imageContainer, {height: this.state.height, width: this.state.width}]} >
style={{height: this.state.height, width: this.state.width}} >
<Image
style={{flex: 1}}
source={[
Expand Down
4 changes: 2 additions & 2 deletions Examples/UIExplorer/js/ListViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var ListViewSimpleExample = React.createClass({
dataSource={this.state.dataSource}
renderRow={this._renderRow}
renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
renderSeparator={this._renderSeperator}
renderSeparator={this._renderSeparator}
/>
</UIExplorerPage>
);
Expand Down Expand Up @@ -107,7 +107,7 @@ var ListViewSimpleExample = React.createClass({
)});
},

_renderSeperator: function(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
_renderSeparator: function(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
return (
<View
key={`${sectionID}-${rowID}`}
Expand Down
1 change: 0 additions & 1 deletion Examples/UIExplorer/js/NavigatorIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ const NavigatorIOSExample = React.createClass({
component: NavigatorIOSExamplePage,
passProps: {onExampleExit},
}}
itemWrapperStyle={styles.itemWrapper}
tintColor="#008888"
/>
);
Expand Down
38 changes: 37 additions & 1 deletion Examples/UIExplorer/js/ToastAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,43 @@ var ToastExample = React.createClass({
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.show('This is a toast with long duration', ToastAndroid.LONG)}>
<Text style={styles.text}>Click me too.</Text>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
<UIExplorerBlock title="Toast with top gravity">
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.showWithGravity(
'This is a toast with top gravity',
ToastAndroid.SHORT,
ToastAndroid.TOP,
)
}>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
<UIExplorerBlock title="Toast with center gravity">
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.showWithGravity(
'This is a toast with center gravity',
ToastAndroid.SHORT,
ToastAndroid.CENTER,
)
}>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
<UIExplorerBlock title="Toast with bottom gravity">
<TouchableWithoutFeedback
onPress={() =>
ToastAndroid.showWithGravity(
'This is a toast with bottom gravity',
ToastAndroid.SHORT,
ToastAndroid.BOTTOM,
)
}>
<Text style={styles.text}>Click me.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
</UIExplorerPage>
Expand Down
4 changes: 4 additions & 0 deletions Examples/UIExplorer/js/UIExplorerList.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ var ComponentExamples: Array<UIExplorerExample> = [
key: 'ModalExample',
module: require('./ModalExample'),
},
{
key: 'NativeAnimationsExample',
module: require('./NativeAnimationsExample'),
},
{
key: 'PickerExample',
module: require('./PickerExample'),
Expand Down
4 changes: 2 additions & 2 deletions Examples/UIExplorer/js/WebViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ var Button = React.createClass({
render: function() {
return (
<TouchableWithoutFeedback onPress={this._handlePress}>
<View style={[styles.button, this.props.enabled ? {} : styles.buttonDisabled]}>
<Text style={styles.buttonText}>{this.props.text}</Text>
<View style={styles.button}>
<Text>{this.props.text}</Text>
</View>
</TouchableWithoutFeedback>
);
Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/js/XHRExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class FormUploader extends React.Component {
}
return (
<View>
<View style={[styles.paramRow, styles.photoRow]}>
<View style={styles.paramRow}>
<Text style={styles.photoLabel}>
Random photo from your library
(<Text style={styles.textButton} onPress={this._fetchRandomPhoto}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ Object.keys(RemoteModules).forEach((moduleName) => {
get: () => {
let module = RemoteModules[moduleName];
if (module && typeof module.moduleID === 'number' && global.nativeRequireModuleConfig) {
const json = global.nativeRequireModuleConfig(moduleName);
const config = json && JSON.parse(json);
// The old bridge (still used by iOS) will send the config as
// a JSON string that needs parsing, so we set config according
// to the type of response we got.
const rawConfig = global.nativeRequireModuleConfig(moduleName);
const config = typeof rawConfig === 'string' ? JSON.parse(rawConfig) : rawConfig;
module = config && BatchedBridge.processModuleConfig(config, module.moduleID);
RemoteModules[moduleName] = module;
}
Expand Down
Loading

0 comments on commit 014c24b

Please sign in to comment.