Skip to content

Commit bfa01f0

Browse files
javacheFacebook Github Bot 4
authored andcommitted
Rename RCTImageView source to imageSources
Reviewed By: majak Differential Revision: D3754991 fbshipit-source-id: 9794af94b51b331df1209ae63d053dcef2cf4a97
1 parent 5a5c56c commit bfa01f0

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Libraries/Image/RCTImageView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@property (nonatomic, assign) UIEdgeInsets capInsets;
2121
@property (nonatomic, strong) UIImage *defaultImage;
2222
@property (nonatomic, assign) UIImageRenderingMode renderingMode;
23-
@property (nonatomic, copy) NSArray<RCTImageSource *> *source;
23+
@property (nonatomic, copy) NSArray<RCTImageSource *> *imageSources;
2424
@property (nonatomic, assign) CGFloat blurRadius;
2525
@property (nonatomic, assign) RCTResizeMode resizeMode;
2626

Libraries/Image/RCTImageView.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ - (void)setRenderingMode:(UIImageRenderingMode)renderingMode
163163
}
164164
}
165165

166-
- (void)setSource:(NSArray<RCTImageSource *> *)source
166+
- (void)setImageSources:(NSArray<RCTImageSource *> *)imageSources
167167
{
168-
if (![source isEqual:_source]) {
169-
_source = [source copy];
168+
if (![imageSources isEqual:_imageSources]) {
169+
_imageSources = [imageSources copy];
170170
[self reloadImage];
171171
}
172172
}
@@ -221,13 +221,13 @@ - (void)clearImageIfDetached
221221

222222
- (BOOL)hasMultipleSources
223223
{
224-
return _source.count > 1;
224+
return _imageSources.count > 1;
225225
}
226226

227227
- (RCTImageSource *)imageSourceForSize:(CGSize)size
228228
{
229229
if (![self hasMultipleSources]) {
230-
return _source.firstObject;
230+
return _imageSources.firstObject;
231231
}
232232
// Need to wait for layout pass before deciding.
233233
if (CGSizeEqualToSize(size, CGSizeZero)) {
@@ -238,7 +238,7 @@ - (RCTImageSource *)imageSourceForSize:(CGSize)size
238238

239239
RCTImageSource *bestSource = nil;
240240
CGFloat bestFit = CGFLOAT_MAX;
241-
for (RCTImageSource *source in _source) {
241+
for (RCTImageSource *source in _imageSources) {
242242
CGSize imgSize = source.size;
243243
const CGFloat imagePixels =
244244
imgSize.width * imgSize.height * source.scale * source.scale;
@@ -261,7 +261,8 @@ - (void)reloadImage
261261
{
262262
[self cancelImageLoad];
263263

264-
_imageSource = [self imageSourceForSize:self.frame.size];
264+
RCTImageSource *source = [self imageSourceForSize:self.frame.size];
265+
_imageSource = source;
265266

266267
if (_imageSource && self.frame.size.width > 0 && self.frame.size.height > 0) {
267268
if (_onLoadStart) {
@@ -286,7 +287,6 @@ - (void)reloadImage
286287
imageScale = _imageSource.scale;
287288
}
288289

289-
RCTImageSource *source = _imageSource;
290290
__weak RCTImageView *weakSelf = self;
291291
RCTImageLoaderCompletionBlock completionHandler = ^(NSError *error, UIImage *loadedImage) {
292292
[weakSelf imageLoaderLoadedImage:loadedImage error:error forImageSource:source];

Libraries/Image/RCTImageViewManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ - (UIView *)view
3434
RCT_EXPORT_VIEW_PROPERTY(onLoad, RCTDirectEventBlock)
3535
RCT_EXPORT_VIEW_PROPERTY(onLoadEnd, RCTDirectEventBlock)
3636
RCT_EXPORT_VIEW_PROPERTY(resizeMode, RCTResizeMode)
37-
RCT_EXPORT_VIEW_PROPERTY(source, NSArray<RCTImageSource *>)
37+
RCT_REMAP_VIEW_PROPERTY(source, imageSources, NSArray<RCTImageSource *>);
3838
RCT_CUSTOM_VIEW_PROPERTY(tintColor, UIColor, RCTImageView)
3939
{
4040
// Default tintColor isn't nil - it's inherited from the superView - but we

0 commit comments

Comments
 (0)