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