Merge remote-tracking branch 'uxbert/5.5.1-load-image-from-url' into fix-display-none

# Conflicts:
#	android/src/main/java/com/horcrux/svg/ImageShadowNode.java
#	ios/Elements/RNSVGImage.m
This commit is contained in:
Mikael Sand
2018-03-18 23:14:29 +02:00
4 changed files with 33 additions and 5 deletions
+2
View File
@@ -8,11 +8,13 @@
#import <Foundation/Foundation.h>
#import <React/RCTBridge.h>
#import "RNSVGRenderable.h"
#import "RNSVGVBMOS.h"
@interface RNSVGImage : RNSVGRenderable
@property (nonatomic, weak) RCTBridge *bridge;
@property (nonatomic, assign) id src;
@property (nonatomic, strong) NSString* x;
@property (nonatomic, strong) NSString* y;
+17 -1
View File
@@ -9,6 +9,9 @@
#import "RNSVGImage.h"
#import "RCTConvert+RNSVG.h"
#import <React/RCTImageSource.h>
#import <React/RCTImageView.h>
#import <React/RCTImageLoader.h>
#import <React/RCTImageViewManager.h>
#import <React/RCTLog.h>
#import "RNSVGViewBox.h"
@@ -16,6 +19,7 @@
{
CGImageRef _image;
CGSize _imageSize;
RCTImageLoaderCancellationBlock _reloadImageCancellationBlock;
}
- (void)setSrc:(id)src
@@ -32,7 +36,19 @@
} else {
_imageSize = CGSizeMake(CGImageGetWidth(_image), CGImageGetHeight(_image));
}
[self invalidate];
RCTImageLoaderCancellationBlock previousCancellationBlock = _reloadImageCancellationBlock;
if (previousCancellationBlock) {
previousCancellationBlock();
_reloadImageCancellationBlock = nil;
}
_reloadImageCancellationBlock = [self.bridge.imageLoader loadImageWithURLRequest:[RCTConvert NSURLRequest:src] callback:^(NSError *error, UIImage *image) {
dispatch_async(dispatch_get_main_queue(), ^{
_image = CGImageRetain(image.CGImage);
[self invalidate];
});
}];
}
- (void)setX:(NSString *)x