Rename RCTImageView source to imageSources

Reviewed By: majak

Differential Revision: D3754991

fbshipit-source-id: 9794af94b51b331df1209ae63d053dcef2cf4a97
This commit is contained in:
Pieter De Baets
2016-08-23 11:26:35 -07:00
committed by Facebook Github Bot 4
parent 5a5c56c8a9
commit bfa01f0d15
3 changed files with 10 additions and 10 deletions

View File

@@ -20,7 +20,7 @@
@property (nonatomic, assign) UIEdgeInsets capInsets;
@property (nonatomic, strong) UIImage *defaultImage;
@property (nonatomic, assign) UIImageRenderingMode renderingMode;
@property (nonatomic, copy) NSArray<RCTImageSource *> *source;
@property (nonatomic, copy) NSArray<RCTImageSource *> *imageSources;
@property (nonatomic, assign) CGFloat blurRadius;
@property (nonatomic, assign) RCTResizeMode resizeMode;

View File

@@ -163,10 +163,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
}
}
- (void)setSource:(NSArray<RCTImageSource *> *)source
- (void)setImageSources:(NSArray<RCTImageSource *> *)imageSources
{
if (![source isEqual:_source]) {
_source = [source copy];
if (![imageSources isEqual:_imageSources]) {
_imageSources = [imageSources copy];
[self reloadImage];
}
}
@@ -221,13 +221,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (BOOL)hasMultipleSources
{
return _source.count > 1;
return _imageSources.count > 1;
}
- (RCTImageSource *)imageSourceForSize:(CGSize)size
{
if (![self hasMultipleSources]) {
return _source.firstObject;
return _imageSources.firstObject;
}
// Need to wait for layout pass before deciding.
if (CGSizeEqualToSize(size, CGSizeZero)) {
@@ -238,7 +238,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
RCTImageSource *bestSource = nil;
CGFloat bestFit = CGFLOAT_MAX;
for (RCTImageSource *source in _source) {
for (RCTImageSource *source in _imageSources) {
CGSize imgSize = source.size;
const CGFloat imagePixels =
imgSize.width * imgSize.height * source.scale * source.scale;
@@ -261,7 +261,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
{
[self cancelImageLoad];
_imageSource = [self imageSourceForSize:self.frame.size];
RCTImageSource *source = [self imageSourceForSize:self.frame.size];
_imageSource = source;
if (_imageSource && self.frame.size.width > 0 && self.frame.size.height > 0) {
if (_onLoadStart) {
@@ -286,7 +287,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
imageScale = _imageSource.scale;
}
RCTImageSource *source = _imageSource;
__weak RCTImageView *weakSelf = self;
RCTImageLoaderCompletionBlock completionHandler = ^(NSError *error, UIImage *loadedImage) {
[weakSelf imageLoaderLoadedImage:loadedImage error:error forImageSource:source];

View File

@@ -34,7 +34,7 @@ RCT_EXPORT_VIEW_PROPERTY(onError, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLoadEnd, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(resizeMode, RCTResizeMode)
RCT_EXPORT_VIEW_PROPERTY(source, NSArray<RCTImageSource *>)
RCT_REMAP_VIEW_PROPERTY(source, imageSources, NSArray<RCTImageSource *>);
RCT_CUSTOM_VIEW_PROPERTY(tintColor, UIColor, RCTImageView)
{
// Default tintColor isn't nil - it's inherited from the superView - but we