Skip to content

Commit

Permalink
fix: add check in RNSVGImage for macos platform (#2324)
Browse files Browse the repository at this point in the history
# Summary
add check-in RNSVGImage for the Maco platform
  • Loading branch information
bohdanprog authored Jul 3, 2024
1 parent 1ad180c commit fe94bd9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions apple/Elements/RNSVGImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,20 @@ - (void)setSrc:(RCTImageSource *)src
dispatch_async(dispatch_get_main_queue(), ^{
self->_image = CGImageRetain(image.CGImage);
self->_imageSize = CGSizeMake(CGImageGetWidth(self->_image), CGImageGetHeight(self->_image));
if (self->_onLoad) {
RCTImageSource *sourceLoaded = [src imageSourceWithSize:image.size scale:image.scale];
NSDictionary *dict = @{
@"uri" : sourceLoaded.request.URL.absoluteString,
@"width" : @(sourceLoaded.size.width),
@"height" : @(sourceLoaded.size.height),
};
self->_onLoad(@{@"source" : dict});
}
if (self->_onLoad) {
RCTImageSource *sourceLoaded;
#if TARGET_OS_OSX // [macOS]
sourceLoaded = [src imageSourceWithSize:image.size scale:1];
#else
sourceLoaded = [src imageSourceWithSize:image.size scale:image.scale];
#endif
NSDictionary *dict = @{
@"uri" : sourceLoaded.request.URL.absoluteString,
@"width" : @(sourceLoaded.size.width),
@"height" : @(sourceLoaded.size.height),
};
self->_onLoad(@{@"source" : dict});
}
[self invalidate];
});
}];
Expand Down

0 comments on commit fe94bd9

Please sign in to comment.