Skip to content
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: 1 addition & 1 deletion Examples/Movies/Movies/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
15 changes: 14 additions & 1 deletion Examples/UIExplorer/CameraRollView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ var propTypes = {
* imagesPerRow: Number of images to be shown in each row.
*/
imagesPerRow: React.PropTypes.number,

/**
* The asset type, one of 'Photos', 'Videos' or 'All'
*/
assetType: React.PropTypes.oneOf([
'Photos',
'Videos',
'All',
]),

};

var CameraRollView = React.createClass({
Expand All @@ -69,6 +79,7 @@ var CameraRollView = React.createClass({
groupTypes: 'SavedPhotos',
batchSize: 5,
imagesPerRow: 1,
assetType: 'Photos',
renderImage: function(asset) {
var imageSize = 150;
var imageStyle = [styles.image, {width: imageSize, height: imageSize}];
Expand All @@ -89,6 +100,7 @@ var CameraRollView = React.createClass({
assets: ([]: Array<Image>),
groupTypes: this.props.groupTypes,
lastCursor: (null : ?string),
assetType: this.props.assetType,
noMore: false,
loadingMore: false,
dataSource: ds,
Expand Down Expand Up @@ -124,7 +136,8 @@ var CameraRollView = React.createClass({

var fetchParams: Object = {
first: this.props.batchSize,
groupTypes: this.props.groupTypes
groupTypes: this.props.groupTypes,
assetType: this.props.assetType,
};
if (this.state.lastCursor) {
fetchParams.after = this.state.lastCursor;
Expand Down
4 changes: 3 additions & 1 deletion Examples/UIExplorer/UIExplorerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var {
var { TestModule } = React.addons;
var Settings = require('Settings');

import type { Example, ExampleModule } from 'ExampleTypes';
import type { ExampleModule } from 'ExampleTypes';

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

Expand Down Expand Up @@ -154,7 +154,9 @@ class UIExplorerList extends React.Component {
dataSource={this.state.dataSource}
renderRow={this._renderRow.bind(this)}
renderSectionHeader={this._renderSectionHeader}
keyboardShouldPersistTaps={true}
automaticallyAdjustContentInsets={false}
keyboardDismissMode="onDrag"
/>
</View>
);
Expand Down
15 changes: 15 additions & 0 deletions Libraries/CameraRoll/CameraRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ var GROUP_TYPES_OPTIONS = [
'SavedPhotos', // default
];

var ASSET_TYPE_OPTIONS = [
'All',
'Videos',
'Photos', // default
];


// Flow treats Object and Array as disjoint types, currently.
deepFreezeAndThrowOnMutationInDev((GROUP_TYPES_OPTIONS: any));
deepFreezeAndThrowOnMutationInDev((ASSET_TYPE_OPTIONS: any));

/**
* Shape of the param arg for the `getPhotos` function.
Expand Down Expand Up @@ -58,6 +66,11 @@ var getPhotosParamChecker = createStrictShapeTypeChecker({
* titles.
*/
groupName: ReactPropTypes.string,

/**
* Specifies filter on asset type
*/
assetType: ReactPropTypes.oneOf(ASSET_TYPE_OPTIONS),
});

/**
Expand Down Expand Up @@ -94,6 +107,7 @@ var getPhotosReturnChecker = createStrictShapeTypeChecker({
class CameraRoll {

static GroupTypesOptions: Array<string>;
static AssetTypeOptions: Array<string>;
/**
* Saves the image with tag `tag` to the camera roll.
*
Expand Down Expand Up @@ -154,5 +168,6 @@ class CameraRoll {
}

CameraRoll.GroupTypesOptions = GROUP_TYPES_OPTIONS;
CameraRoll.AssetTypeOptions = ASSET_TYPE_OPTIONS;

module.exports = CameraRoll;
9 changes: 4 additions & 5 deletions Libraries/CustomComponents/ListView/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ var DEFAULT_INITIAL_ROWS = 10;
var DEFAULT_SCROLL_RENDER_AHEAD = 1000;
var DEFAULT_END_REACHED_THRESHOLD = 1000;
var DEFAULT_SCROLL_CALLBACK_THROTTLE = 50;
var RENDER_INTERVAL = 20;
var SCROLLVIEW_REF = 'listviewscroll';


Expand Down Expand Up @@ -258,7 +257,6 @@ var ListView = React.createClass({
// the component is laid out
this.requestAnimationFrame(() => {
this._measureAndUpdateScrollProps();
this.setInterval(this._renderMoreRowsIfNeeded, RENDER_INTERVAL);
});
},

Expand Down Expand Up @@ -329,7 +327,7 @@ var ListView = React.createClass({
totalIndex++;

if (this.props.renderSeparator &&
(rowIdx !== rowIDs.length - 1 || sectionIdx === allRowIDs.length -1)) {
(rowIdx !== rowIDs.length - 1 || sectionIdx === allRowIDs.length - 1)) {
var adjacentRowHighlighted =
this.state.highlightedRow.sectionID === sectionID && (
this.state.highlightedRow.rowID === rowID ||
Expand Down Expand Up @@ -397,6 +395,7 @@ var ListView = React.createClass({
_setScrollVisibleHeight: function(left, top, width, height) {
this.scrollProperties.visibleHeight = height;
this._updateVisibleRows();
this._renderMoreRowsIfNeeded();
},

_renderMoreRowsIfNeeded: function() {
Expand Down Expand Up @@ -443,8 +442,8 @@ var ListView = React.createClass({
}
var updatedFrames = e && e.nativeEvent.updatedChildFrames;
if (updatedFrames) {
updatedFrames.forEach((frame) => {
this._childFrames[frame.index] = merge(frame);
updatedFrames.forEach((newFrame) => {
this._childFrames[newFrame.index] = merge(newFrame);
});
}
var dataSource = this.props.dataSource;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/CustomComponents/Navigator/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ var Navigator = React.createClass({
key={this.state.idStack[i]}
ref={'scene_' + i}
onStartShouldSetResponderCapture={() => {
return i !== this.state.presentedIndex;
return !!this.state.transitionFromIndex || !!this.state.activeGesture;
}}
style={[styles.baseScene, this.props.sceneStyle, disabledSceneStyle]}>
{React.cloneElement(child, {
Expand Down
12 changes: 11 additions & 1 deletion Libraries/Image/RCTCameraRollManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ - (void)callCallback:(RCTResponseSenderBlock)callback withAssets:(NSArray *)asse
NSString *afterCursor = params[@"after"];
NSString *groupTypesStr = params[@"groupTypes"];
NSString *groupName = params[@"groupName"];
NSString *assetType = params[@"assetType"];
ALAssetsGroupType groupTypes;

if ([groupTypesStr isEqualToString:@"Album"]) {
groupTypes = ALAssetsGroupAlbum;
} else if ([groupTypesStr isEqualToString:@"All"]) {
Expand All @@ -93,7 +95,15 @@ - (void)callCallback:(RCTResponseSenderBlock)callback withAssets:(NSArray *)asse

[[RCTImageLoader assetsLibrary] enumerateGroupsWithTypes:groupTypes usingBlock:^(ALAssetsGroup *group, BOOL *stopGroups) {
if (group && (groupName == nil || [groupName isEqualToString:[group valueForProperty:ALAssetsGroupPropertyName]])) {
[group setAssetsFilter:ALAssetsFilter.allPhotos];

if (assetType == nil || [assetType isEqualToString:@"Photos"]) {
[group setAssetsFilter:ALAssetsFilter.allPhotos];
} else if ([assetType isEqualToString:@"Videos"]) {
[group setAssetsFilter:ALAssetsFilter.allVideos];
} else if ([assetType isEqualToString:@"All"]) {
[group setAssetsFilter:ALAssetsFilter.allAssets];
}

[group enumerateAssetsWithOptions:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stopAssets) {
if (result) {
NSString *uri = [(NSURL *)[result valueForProperty:ALAssetPropertyAssetURL] absoluteString];
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/__tests__/resolveAssetSource-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('resolveAssetSource', () => {
isStatic: true,
width: 100,
height: 200,
uri: 'assets_awesomemodule_subdir_logo1_',
uri: 'awesomemodule_subdir_logo1_',
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion Libraries/Image/resolveAssetSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ function getPathInArchive(asset) {
return (assetDir + '/' + asset.name)
.toLowerCase()
.replace(/\//g, '_') // Encode folder structure in file name
.replace(/([^a-z0-9_])/g, ''); // Remove illegal chars
.replace(/([^a-z0-9_])/g, '') // Remove illegal chars
.replace(/^assets_/, ''); // Remove "assets_" prefix
} else {
// E.g. 'assets/AwesomeModule/[email protected]'
return getScaledAssetPath(asset);
Expand Down
35 changes: 18 additions & 17 deletions Libraries/Network/RCTDataManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,35 @@ @implementation RCTDataManager
// Build data task
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError) {

NSHTTPURLResponse *httpResponse = nil;
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
// Might be a local file request
httpResponse = (NSHTTPURLResponse *)response;
}

// Build response
NSDictionary *responseJSON;
NSArray *responseJSON;
if (connectionError == nil) {
NSStringEncoding encoding = NSUTF8StringEncoding;
if (response.textEncodingName) {
CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
encoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding);
}
NSHTTPURLResponse *httpResponse = nil;
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
// Might be a local file request
httpResponse = (NSHTTPURLResponse *)response;
}
responseJSON = @{
@"status": @([httpResponse statusCode] ?: 200),
@"responseHeaders": [httpResponse allHeaderFields] ?: @{},
@"responseText": [[NSString alloc] initWithData:data encoding:encoding] ?: @""
};
responseJSON = @[
@(httpResponse.statusCode ?: 200),
httpResponse.allHeaderFields ?: @{},
[[NSString alloc] initWithData:data encoding:encoding] ?: @"",
];
} else {
responseJSON = @{
@"status": @0,
@"responseHeaders": @{},
@"responseText": [connectionError localizedDescription] ?: [NSNull null]
};
responseJSON = @[
@(httpResponse.statusCode),
httpResponse.allHeaderFields ?: @{},
connectionError.localizedDescription ?: [NSNull null],
];
}

// Send response (won't be sent on same thread as caller)
responseSender(@[RCTJSONStringify(responseJSON, NULL)]);
responseSender(responseJSON);

}];

Expand Down
5 changes: 1 addition & 4 deletions Libraries/Network/XMLHttpRequest.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ class XMLHttpRequest extends XMLHttpRequestBase {
},
// TODO: Do we need this? is it used anywhere?
'h' + crc32(method + '|' + url + '|' + data),
(result) => {
result = JSON.parse(result);
this.callback(result.status, result.responseHeaders, result.responseText);
}
this.callback.bind(this)
);
}

Expand Down
2 changes: 1 addition & 1 deletion Libraries/ReactIOS/InspectorOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var InspectorOverlay = React.createClass({
? 'flex-start'
: 'flex-end';

content.push(<View style={[styles.frame, this.state.frame]} />);
content.push(<View pointerEvents="none" style={[styles.frame, this.state.frame]} />);
content.push(<ElementProperties hierarchy={this.state.hierarchy} />);
}
return (
Expand Down
1 change: 0 additions & 1 deletion Libraries/Text/RCTShadowText.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ extern NSString *const RCTReactTagAttributeName;
@property (nonatomic, strong) UIColor *textBackgroundColor;
@property (nonatomic, assign) NSWritingDirection writingDirection;

- (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width;
- (void)recomputeText;

@end
41 changes: 41 additions & 0 deletions Libraries/Text/RCTShadowText.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
#import "RCTConvert.h"
#import "RCTLog.h"
#import "RCTShadowRawText.h"
#import "RCTSparseArray.h"
#import "RCTText.h"
#import "RCTUtils.h"

NSString *const RCTIsHighlightedAttributeName = @"IsHighlightedAttributeName";
NSString *const RCTReactTagAttributeName = @"ReactTagAttributeName";

@implementation RCTShadowText
{
NSTextStorage *_cachedTextStorage;
CGFloat _cachedTextStorageWidth;
NSAttributedString *_cachedAttributedString;
CGFloat _effectiveLetterSpacing;
}
Expand Down Expand Up @@ -50,8 +54,35 @@ - (instancetype)init
return self;
}

- (NSDictionary *)processUpdatedProperties:(NSMutableSet *)applierBlocks
parentProperties:(NSDictionary *)parentProperties
{
parentProperties = [super processUpdatedProperties:applierBlocks
parentProperties:parentProperties];

NSTextStorage *textStorage = [self buildTextStorageForWidth:self.frame.size.width];
[applierBlocks addObject:^(RCTSparseArray *viewRegistry) {
RCTText *view = viewRegistry[self.reactTag];
view.textStorage = textStorage;
}];

return parentProperties;
}

- (void)applyLayoutNode:(css_node_t *)node
viewsWithNewFrame:(NSMutableSet *)viewsWithNewFrame
absolutePosition:(CGPoint)absolutePosition
{
[super applyLayoutNode:node viewsWithNewFrame:viewsWithNewFrame absolutePosition:absolutePosition];
[self dirtyPropagation];
}

- (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width
{
if (_cachedTextStorage && width == _cachedTextStorageWidth) {
return _cachedTextStorage;
}

NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];

NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedString];
Expand All @@ -69,13 +100,23 @@ - (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width
[layoutManager addTextContainer:textContainer];
[layoutManager ensureLayoutForTextContainer:textContainer];

_cachedTextStorage = textStorage;
_cachedTextStorageWidth = width;

return textStorage;
}

- (void)dirtyText
{
[super dirtyText];
_cachedTextStorage = nil;
}

- (void)recomputeText
{
[self attributedString];
[self setTextComputed];
[self dirtyPropagation];
}

- (NSAttributedString *)attributedString
Expand Down
2 changes: 0 additions & 2 deletions Libraries/Text/RCTTextManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,10 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowText *)shadowVie
{
NSNumber *reactTag = shadowView.reactTag;
UIEdgeInsets padding = shadowView.paddingAsInsets;
NSTextStorage *textStorage = [shadowView buildTextStorageForWidth:shadowView.frame.size.width];

return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
RCTText *text = viewRegistry[reactTag];
text.contentInset = padding;
text.textStorage = textStorage;
};
}

Expand Down
1 change: 1 addition & 0 deletions Libraries/Utilities/Dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (dimensions && dimensions.windowPhysicalPixels) {
width: windowPhysicalPixels.width / windowPhysicalPixels.scale,
height: windowPhysicalPixels.height / windowPhysicalPixels.scale,
scale: windowPhysicalPixels.scale,
fontScale: windowPhysicalPixels.fontScale,
};

// delete so no callers rely on this existing
Expand Down
Loading