Skip to content

Commit

Permalink
Merge pull request #1165 from frantic/sync-2015-05-05
Browse files Browse the repository at this point in the history
Sync updates from May 5th, 2015
  • Loading branch information
frantic committed May 6, 2015
2 parents 4a9e1b6 + 735f673 commit 4eece85
Show file tree
Hide file tree
Showing 76 changed files with 2,218 additions and 862 deletions.
4 changes: 2 additions & 2 deletions Examples/SampleApp/SampleAppTests/SampleAppTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ - (void)testRendersWelcomeScreen {
NSString *redboxError = nil;

while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:date];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:date];
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];

redboxError = [[RCTRedBox sharedInstance] currentErrorMessage];

Expand Down
2 changes: 1 addition & 1 deletion Examples/UIExplorer/TabBarIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var TabBarExample = React.createClass({
this.setState({
selectedTab: 'greenTab',
presses: this.state.presses + 1
});
});
}}>
{this._renderContent('#21551C', 'Green Tab')}
</TabBarIOS.Item>
Expand Down
31 changes: 31 additions & 0 deletions Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; };
14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DC67F11AB71876001358AB /* libRCTPushNotification.a */; };
58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; };
834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 834C36D21AF8DA610019C93C /* libRCTSettings.a */; };
D85B829E1AB6D5D7003F4FE2 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -103,6 +104,13 @@
remoteGlobalIDString = 580C376F1AB104AF0015E709;
remoteInfo = RCTTest;
};
834C36D11AF8DA610019C93C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 13CC9D481AEED2B90020D1C2 /* RCTSettings.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTSettings;
};
D85B829B1AB6D5CE003F4FE2 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D85B82911AB6D5CE003F4FE2 /* RCTVibration.xcodeproj */;
Expand All @@ -129,6 +137,7 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = UIExplorer/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = UIExplorer/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = UIExplorer/main.m; sourceTree = "<group>"; };
13CC9D481AEED2B90020D1C2 /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../../Libraries/Settings/RCTSettings.xcodeproj; sourceTree = "<group>"; };
14AADEFF1AC3DB95002390C9 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = "<group>"; };
14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTPushNotification.xcodeproj; path = ../../Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj; sourceTree = "<group>"; };
14E0EEC81AB118F7000DECC3 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../../Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
Expand All @@ -148,6 +157,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */,
14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */,
00D2771A1AB8C3E100DC1E48 /* libRCTWebSocketDebugger.a in Frameworks */,
58005BF21ABA80A60062E044 /* libRCTTest.a in Frameworks */,
Expand Down Expand Up @@ -200,6 +210,7 @@
134A8A201AACED6A00945AAE /* RCTGeolocation.xcodeproj */,
13417FE31AA91428003F314A /* RCTImage.xcodeproj */,
134180261AA91779003F314A /* RCTNetwork.xcodeproj */,
13CC9D481AEED2B90020D1C2 /* RCTSettings.xcodeproj */,
58005BE41ABA80530062E044 /* RCTTest.xcodeproj */,
13417FEA1AA914B8003F314A /* RCTText.xcodeproj */,
00D2770E1AB8C2C700DC1E48 /* RCTWebSocketDebugger.xcodeproj */,
Expand Down Expand Up @@ -293,6 +304,14 @@
name = Products;
sourceTree = "<group>";
};
834C36CE1AF8DA610019C93C /* Products */ = {
isa = PBXGroup;
children = (
834C36D21AF8DA610019C93C /* libRCTSettings.a */,
);
name = Products;
sourceTree = "<group>";
};
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -411,6 +430,10 @@
ProductGroup = 14DC67E81AB71876001358AB /* Products */;
ProjectRef = 14DC67E71AB71876001358AB /* RCTPushNotification.xcodeproj */;
},
{
ProductGroup = 834C36CE1AF8DA610019C93C /* Products */;
ProjectRef = 13CC9D481AEED2B90020D1C2 /* RCTSettings.xcodeproj */;
},
{
ProductGroup = 58005BE51ABA80530062E044 /* Products */;
ProjectRef = 58005BE41ABA80530062E044 /* RCTTest.xcodeproj */;
Expand Down Expand Up @@ -511,6 +534,13 @@
remoteRef = 58005BED1ABA80530062E044 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
834C36D21AF8DA610019C93C /* libRCTSettings.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTSettings.a;
remoteRef = 834C36D11AF8DA610019C93C /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
D85B829C1AB6D5CE003F4FE2 /* libRCTVibration.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
Expand Down Expand Up @@ -632,6 +662,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
11 changes: 10 additions & 1 deletion Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var {
} = React;

var { TestModule } = React.addons;
var Settings = require('Settings');

var createExamplePage = require('./createExamplePage');

Expand Down Expand Up @@ -114,9 +115,14 @@ class UIExplorerList extends React.Component {
components: COMPONENTS,
apis: APIS,
}),
searchText: Settings.get('searchText'),
};
}

componentDidMount() {
this._search(this.state.searchText);
}

render() {
return (
<View style={styles.listContainer}>
Expand All @@ -128,6 +134,7 @@ class UIExplorerList extends React.Component {
onChangeText={this._search.bind(this)}
placeholder="Search..."
style={styles.searchTextInput}
value={this.state.searchText}
/>
</View>
<ListView
Expand Down Expand Up @@ -177,8 +184,10 @@ class UIExplorerList extends React.Component {
dataSource: ds.cloneWithRowsAndSections({
components: COMPONENTS.filter(filter),
apis: APIS.filter(filter),
})
}),
searchText: text,
});
Settings.set({searchText: text});
}

_onPressRow(example) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions Examples/UIExplorer/UIExplorerTests/UIExplorerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ - (void)testAAA_RootViewLoadsAndRenders
NSString *redboxError = nil;

while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:date];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:date];
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];

redboxError = [[RCTRedBox sharedInstance] currentErrorMessage];
foundElement = [self findSubviewInView:vc.view matching:^(UIView *view) {
if ([view respondsToSelector:@selector(attributedText)]) {
Expand Down
19 changes: 14 additions & 5 deletions Examples/UIExplorer/createExamplePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'use strict';

var React = require('react-native');
var ReactIOS = require('ReactIOS');
var UIExplorerBlock = require('./UIExplorerBlock');
var UIExplorerPage = require('./UIExplorerPage');

Expand Down Expand Up @@ -46,20 +47,28 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
getBlock: function(example, i) {
// Hack warning: This is a hack because the www UI explorer requires
// renderComponent to be called.
var originalRenderComponent = React.renderComponent;
var originalRender = React.render;
var originalRenderComponent = React.renderComponent;
var originalIOSRender = ReactIOS.render;
var originalIOSRenderComponent = ReactIOS.renderComponent;
var renderedComponent;
// TODO remove typecasts when Flow bug #6560135 is fixed
// and workaround is removed from react-native.js
(React: Object).render = (React: Object).renderComponent = function(element, container) {
renderedComponent = element;
};
(React: Object).render =
(React: Object).renderComponent =
(ReactIOS: Object).render =
(ReactIOS: Object).renderComponent =
function(element, container) {
renderedComponent = element;
};
var result = example.render(null);
if (result) {
renderedComponent = result;
}
(React: Object).renderComponent = originalRenderComponent;
(React: Object).render = originalRender;
(React: Object).renderComponent = originalRenderComponent;
(ReactIOS: Object).render = originalIOSRender;
(ReactIOS: Object).renderComponent = originalIOSRenderComponent;
return (
<UIExplorerBlock
key={i}
Expand Down
1 change: 0 additions & 1 deletion Libraries/ART/RCTConvert+ART.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
@interface RCTConvert (ART)

+ (CGPathRef)CGPath:(id)json;
+ (CTFontRef)CTFont:(id)json;
+ (CTTextAlignment)CTTextAlignment:(id)json;
+ (ARTTextFrame)ARTTextFrame:(id)json;
+ (ARTCGFloatArray)ARTCGFloatArray:(id)json;
Expand Down
15 changes: 2 additions & 13 deletions Libraries/ART/RCTConvert+ART.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ + (CGPathRef)CGPath:(id)json
return (CGPathRef)CFAutorelease(path);
}

+ (CTFontRef)CTFont:(id)json
{
NSDictionary *dict = [self NSDictionary:json];
if (!dict) {
return nil;
}
CTFontDescriptorRef fontDescriptor = CTFontDescriptorCreateWithAttributes((__bridge CFDictionaryRef)dict);
CTFontRef font = CTFontCreateWithFontDescriptor(fontDescriptor, 0.0, NULL);
CFRelease(fontDescriptor);
return (CTFontRef)CFAutorelease(font);
}

RCT_ENUM_CONVERTER(CTTextAlignment, (@{
@"auto": @(kCTTextAlignmentNatural),
@"left": @(kCTTextAlignmentLeft),
Expand All @@ -98,7 +86,8 @@ + (ARTTextFrame)ARTTextFrame:(id)json
return frame;
}

CTFontRef font = [self CTFont:dict[@"font"]];
NSDictionary *fontDict = dict[@"font"];
CTFontRef font = (__bridge CTFontRef)[self UIFont:nil withFamily:fontDict[@"fontFamily"] size:fontDict[@"fontSize"] weight:fontDict[@"fontWeight"] style:fontDict[@"fontStyle"]];
if (!font) {
return frame;
}
Expand Down
28 changes: 1 addition & 27 deletions Libraries/ART/ReactIOSART.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,11 @@ function fontAndLinesDiffer(a, b) {
return true;
}

var aTraits = a.font.NSCTFontTraitsAttribute;
var bTraits = b.font.NSCTFontTraitsAttribute;

if (
a.font.fontFamily !== b.font.fontFamily ||
a.font.fontSize !== b.font.fontSize ||
a.font.fontWeight !== b.font.fontWeight ||
a.font.fontStyle !== b.font.fontStyle ||
// TODO(6364240): remove iOS-specific attrs
a.font.NSFontFamilyAttribute !== b.font.NSFontFamilyAttribute ||
a.font.NSFontSizeAttribute !== b.font.NSFontSizeAttribute ||
aTraits.NSCTFontSymbolicTrait !== bTraits.NSCTFontSymbolicTrait
a.font.fontStyle !== b.font.fontStyle
) {
return true;
}
Expand Down Expand Up @@ -418,14 +411,6 @@ var Shape = React.createClass({

var cachedFontObjectsFromString = {};

function extractFontTraits(isBold, isItalic) {
var italic = isItalic ? 1 : 0;
var bold = isBold ? 2 : 0;
return {
NSCTFontSymbolicTrait: italic | bold
};
}

var fontFamilyPrefix = /^[\s"']*/;
var fontFamilySuffix = /[\s"']*$/;

Expand Down Expand Up @@ -456,10 +441,6 @@ function parseFontString(font) {
fontSize: fontSize,
fontWeight: isBold ? 'bold' : 'normal',
fontStyle: isItalic ? 'italic' : 'normal',
// TODO(6364240): remove iOS-specific attrs
NSFontFamilyAttribute: fontFamily,
NSFontSizeAttribute: fontSize,
NSCTFontTraitsAttribute: extractFontTraits(isBold, isItalic)
};
return cachedFontObjectsFromString[font];
}
Expand All @@ -479,13 +460,6 @@ function extractFont(font) {
fontSize: fontSize,
fontWeight: font.fontWeight,
fontStyle: font.fontStyle,
// TODO(6364240): remove iOS-specific attrs
NSFontFamilyAttribute: fontFamily,
NSFontSizeAttribute: fontSize,
NSCTFontTraitsAttribute: extractFontTraits(
font.fontWeight === 'bold',
font.fontStyle === 'italic'
)
};
}

Expand Down
6 changes: 4 additions & 2 deletions Libraries/Animation/AnimationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ module.exports = {

var tickCount = Math.round(duration * ticksPerSecond / 1000);
var samples = [];
for (var i = 0; i <= tickCount; i++) {
samples.push(easing.call(defaults, i / tickCount));
if (tickCount > 0) {
for (var i = 0; i <= tickCount; i++) {
samples.push(easing.call(defaults, i / tickCount));
}
}

return samples;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animation/RCTAnimationExperimentalManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static void RCTInvalidAnimationProp(RCTSparseArray *callbacks, NSNumber *tag, NS
animationTag:(NSNumber *)animationTag
duration:(NSTimeInterval)duration
delay:(NSTimeInterval)delay
easingSample:(NSArray *)easingSample
easingSample:(NSNumberArray *)easingSample
properties:(NSDictionary *)properties
callback:(RCTResponseSenderBlock)callback)
{
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ var ScrollResponderMixin = {

/**
* A helper function to zoom to a specific rect in the scrollview.
* @param {object} rect Should have shape {x, y, w, h}
* @param {object} rect Should have shape {x, y, width, height}
*/
scrollResponderZoomTo: function(rect: { x: number; y: number; width: number; height: number; }) {
RCTUIManagerDeprecated.zoomToRect(this.getNodeHandle(), rect);
Expand Down
20 changes: 14 additions & 6 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,19 @@ var ScrollView = React.createClass({
},

scrollTo: function(destY?: number, destX?: number) {
RCTUIManager.scrollTo(
this.getNodeHandle(),
destX || 0,
destY || 0
);
if (Platform.OS === 'android') {
RCTUIManager.dispatchViewManagerCommand(
this.getNodeHandle(),
RCTUIManager.RCTScrollView.Commands.scrollTo,
[destX || 0, destY || 0]
);
} else {
RCTUIManager.scrollTo(
this.getNodeHandle(),
destX || 0,
destY || 0
);
}
},

scrollWithoutAnimationTo: function(destY?: number, destX?: number) {
Expand Down Expand Up @@ -364,7 +372,7 @@ var validAttributes = {
if (Platform.OS === 'android') {
var AndroidScrollView = createReactIOSNativeComponentClass({
validAttributes: validAttributes,
uiViewClassName: 'AndroidScrollView',
uiViewClassName: 'RCTScrollView',
});
var AndroidHorizontalScrollView = createReactIOSNativeComponentClass({
validAttributes: validAttributes,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ var TextInput = React.createClass({
var counter = event.nativeEvent.eventCounter;
if (counter > this.state.mostRecentEventCounter) {
this.setState({mostRecentEventCounter: counter});
}
}
},
});

Expand Down
Loading

0 comments on commit 4eece85

Please sign in to comment.