-
Notifications
You must be signed in to change notification settings - Fork 25k
[CameraRoll] Add assetThumbnail prop #1704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,11 @@ var Image = React.createClass({ | |
| */ | ||
| source: PropTypes.shape({ | ||
| uri: PropTypes.string, | ||
| /** | ||
| * Force display of the ALAsset in thumbnail format | ||
| * This property reduce the memory size and only works with ALAsset | ||
| */ | ||
| assetThumbnail: PropTypes.bool, | ||
| }), | ||
| /** | ||
| * A static image to display while downloading the final image off the | ||
|
|
@@ -154,7 +159,11 @@ var Image = React.createClass({ | |
| tintColor: style.tintColor, | ||
| }); | ||
| if (isStored) { | ||
| nativeProps.imageTag = source.uri; | ||
| if (source.assetThumbnail && source.assetThumbnail === true){ | ||
| nativeProps.assetThumbnail = source.uri; | ||
| }else{ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| nativeProps.imageTag = source.uri; | ||
| } | ||
| } else { | ||
| nativeProps.src = source.uri; | ||
| } | ||
|
|
@@ -178,6 +187,8 @@ var nativeOnlyProps = { | |
| src: true, | ||
| defaultImageSrc: true, | ||
| imageTag: true, | ||
| resizeMode: true, | ||
| assetThumbnail:true, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing a space |
||
| }; | ||
| if (__DEV__) { | ||
| verifyPropTypes(Image, RCTStaticImage.viewConfig, nativeOnlyProps); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,5 @@ | |
| type ImageSource = { | ||
| uri: string; | ||
| isStatic: boolean; | ||
| assetThumbnail: boolean; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ + (ALAssetsLibrary *)assetsLibrary | |
| * Can be called from any thread. | ||
| * Will always call callback on main thread. | ||
| */ | ||
| + (void)loadImageWithTag:(NSString *)imageTag callback:(void (^)(NSError *error, id image))callback | ||
| + (void)loadImageWithTag:(NSString *)imageTag thumb:(BOOL)thumb callback:(void (^)(NSError *error, id image))callback | ||
| { | ||
| if ([imageTag hasPrefix:@"assets-library"]) { | ||
| [[RCTImageLoader assetsLibrary] assetForURL:[NSURL URLWithString:imageTag] resultBlock:^(ALAsset *asset) { | ||
|
|
@@ -72,10 +72,17 @@ + (void)loadImageWithTag:(NSString *)imageTag callback:(void (^)(NSError *error, | |
| dispatch_async(RCTImageLoaderQueue(), ^{ | ||
| // Also make sure the image is released immediately after it's used so it | ||
| // doesn't spike the memory up during the process. | ||
|
|
||
| @autoreleasepool { | ||
| UIImage *image = nil; | ||
| ALAssetRepresentation *representation = [asset defaultRepresentation]; | ||
| ALAssetOrientation orientation = [representation orientation]; | ||
| UIImage *image = [UIImage imageWithCGImage:[representation fullResolutionImage] scale:1.0f orientation:(UIImageOrientation)orientation]; | ||
| if (!thumb){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing space between |
||
| image = [UIImage imageWithCGImage:[representation fullResolutionImage] scale:1.0f orientation:(UIImageOrientation)orientation]; | ||
| }else{ | ||
| image = [UIImage imageWithCGImage:[asset thumbnail]]; | ||
| } | ||
|
|
||
| RCTDispatchCallbackOnMainQueue(callback, nil, image); | ||
| } | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing spaces after
:in both propertiesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How i can take the "Nit" word ?