diff --git a/ios/FastImage/FFFastImageView.m b/ios/FastImage/FFFastImageView.m index 7dd545f9d..0b32ba28a 100644 --- a/ios/FastImage/FFFastImageView.m +++ b/ios/FastImage/FFFastImageView.m @@ -2,6 +2,8 @@ @implementation FFFastImageView { BOOL hasSentOnLoadStart; + BOOL isComplete; + BOOL hasError; } - (void)setResizeMode:(RCTResizeMode)resizeMode @@ -12,6 +14,20 @@ - (void)setResizeMode:(RCTResizeMode)resizeMode } } +- (void)setOnFastImageLoadEnd:(RCTBubblingEventBlock)onFastImageLoadEnd { + _onFastImageLoadEnd = onFastImageLoadEnd; + if (isComplete) { + _onFastImageLoadEnd(@{}); + } +} + +- (void)setOnFastImageLoad:(RCTBubblingEventBlock)onFastImageLoad { + _onFastImageLoad = onFastImageLoad; + if (isComplete && hasError == NO) { + _onFastImageLoad(@{}); + } +} + - (void)setOnFastImageLoadStart:(RCTBubblingEventBlock)onFastImageLoadStart { if (_source && !hasSentOnLoadStart) { _onFastImageLoadStart = onFastImageLoadStart; @@ -25,6 +41,9 @@ - (void)setOnFastImageLoadStart:(RCTBubblingEventBlock)onFastImageLoadStart { - (void)setSource:(FFFastImageSource *)source { if (_source != source) { + isComplete = NO; + hasError = NO; + _source = source; // Set headers. @@ -70,7 +89,9 @@ - (void)setSource:(FFFastImageSource *)source { NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { + isComplete = YES; if (error) { + hasError = YES; if (_onFastImageError) { _onFastImageError(@{}); if (_onFastImageLoadEnd) {