mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-21 06:15:15 +00:00
Add uri loading
This commit is contained in:
@@ -87,7 +87,12 @@ public class ImageShadowNode extends PathShadowNode {
|
||||
return;
|
||||
}
|
||||
|
||||
if (src.hasKey("width") && src.hasKey("height")) {
|
||||
mImageRatio = (float)src.getInt("width") / (float)src.getInt("height");
|
||||
}
|
||||
else {
|
||||
mImageRatio = (float)0.0;
|
||||
}
|
||||
mUri = Uri.parse(uriString);
|
||||
}
|
||||
}
|
||||
@@ -170,7 +175,7 @@ public class ImageShadowNode extends PathShadowNode {
|
||||
float rectRatio = rectWidth / rectHeight;
|
||||
RectF renderRect;
|
||||
|
||||
if (mImageRatio == rectRatio) {
|
||||
if (mImageRatio == 0.0 || mImageRatio == rectRatio) {
|
||||
renderRect = new RectF(rect);
|
||||
} else if (mImageRatio < rectRatio) {
|
||||
renderRect = new RectF(0, 0, (int)(rectHeight * mImageRatio), (int)rectHeight);
|
||||
|
||||
@@ -16,7 +16,12 @@ class Image extends Shape {
|
||||
y: numberProp,
|
||||
width: numberProp.isRequired,
|
||||
height: numberProp.isRequired,
|
||||
href: PropTypes.number.isRequired,
|
||||
href: PropTypes.oneOfType([
|
||||
PropTypes.number,
|
||||
PropTypes.shape({
|
||||
uri: PropTypes.string.isRequired
|
||||
})
|
||||
]).isRequired,
|
||||
preserveAspectRatio: PropTypes.string
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user