fix: add check in RNSVGImage for macos platform (#2324)

# Summary
add check-in RNSVGImage for the Maco platform
This commit is contained in:
Bohdan Artiukhov
2024-07-03 11:22:15 +02:00
committed by GitHub
parent 1ad180cba0
commit fe94bd9439
+14 -9
View File
@@ -210,15 +210,20 @@ using namespace facebook::react;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
self->_image = CGImageRetain(image.CGImage); self->_image = CGImageRetain(image.CGImage);
self->_imageSize = CGSizeMake(CGImageGetWidth(self->_image), CGImageGetHeight(self->_image)); self->_imageSize = CGSizeMake(CGImageGetWidth(self->_image), CGImageGetHeight(self->_image));
if (self->_onLoad) { if (self->_onLoad) {
RCTImageSource *sourceLoaded = [src imageSourceWithSize:image.size scale:image.scale]; RCTImageSource *sourceLoaded;
NSDictionary *dict = @{ #if TARGET_OS_OSX // [macOS]
@"uri" : sourceLoaded.request.URL.absoluteString, sourceLoaded = [src imageSourceWithSize:image.size scale:1];
@"width" : @(sourceLoaded.size.width), #else
@"height" : @(sourceLoaded.size.height), sourceLoaded = [src imageSourceWithSize:image.size scale:image.scale];
}; #endif
self->_onLoad(@{@"source" : dict}); NSDictionary *dict = @{
} @"uri" : sourceLoaded.request.URL.absoluteString,
@"width" : @(sourceLoaded.size.width),
@"height" : @(sourceLoaded.size.height),
};
self->_onLoad(@{@"source" : dict});
}
[self invalidate]; [self invalidate];
}); });
}]; }];