diff --git a/android/src/main/java/com/horcrux/svg/RNSVGImageShadowNode.java b/android/src/main/java/com/horcrux/svg/RNSVGImageShadowNode.java index 5f7a29ab..8991b471 100644 --- a/android/src/main/java/com/horcrux/svg/RNSVGImageShadowNode.java +++ b/android/src/main/java/com/horcrux/svg/RNSVGImageShadowNode.java @@ -11,35 +11,18 @@ package com.horcrux.svg; import android.content.ContentResolver; import android.content.Context; -import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.graphics.BitmapShader; import android.graphics.Canvas; import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.graphics.Shader; import android.net.Uri; import android.os.AsyncTask; import android.provider.MediaStore; import android.util.Log; -import com.facebook.common.logging.FLog; import com.facebook.common.util.UriUtil; -import com.facebook.drawee.interfaces.DraweeController; -import com.facebook.imagepipeline.request.ImageRequest; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.annotations.ReactProp; -import com.facebook.imagepipeline.request.ImageRequestBuilder; -import android.graphics.drawable.Drawable; -import android.widget.ImageView; - - -import java.lang.ref.WeakReference; import java.net.URL; import javax.annotation.Nullable; @@ -49,7 +32,10 @@ import javax.annotation.Nullable; */ public class RNSVGImageShadowNode extends RNSVGPathShadowNode { - private ReadableMap mLayout; + private String mX; + private String mY; + private String mW; + private String mH; private ReadableMap mSrc; private Uri mUri; private boolean mLocalImage; @@ -78,7 +64,6 @@ public class RNSVGImageShadowNode extends RNSVGPathShadowNode { bitmap = BitmapFactory.decodeStream(url.openConnection().getInputStream()); } } catch (Exception e) { - Log.e("URI", "" + e); } return bitmap; @@ -96,9 +81,27 @@ public class RNSVGImageShadowNode extends RNSVGPathShadowNode { } } - @ReactProp(name = "layout") - public void setLayout(@Nullable ReadableMap layout) { - mLayout = layout; + @ReactProp(name = "x") + public void setX(String x) { + mX = x; + markUpdated(); + } + + @ReactProp(name = "y") + public void setY(String y) { + mY = y; + markUpdated(); + } + + @ReactProp(name = "width") + public void setWidth(String width) { + mW = width; + markUpdated(); + } + + @ReactProp(name = "height") + public void seHeight(String height) { + mH = height; markUpdated(); } @@ -132,7 +135,6 @@ public class RNSVGImageShadowNode extends RNSVGPathShadowNode { @Override public void draw(Canvas canvas, Paint paint, float opacity) { canvas.saveLayer(0f, 0f, 0f, 0f, paint, Canvas.ALL_SAVE_FLAG); - Log.e("Count", "" + canvas.getSaveCount()); loadBitmap(getResourceDrawableId(getThemedContext(), null), canvas, paint); } diff --git a/lib/attributes.js b/lib/attributes.js deleted file mode 100644 index fbf2a068..00000000 --- a/lib/attributes.js +++ /dev/null @@ -1,137 +0,0 @@ -import _ from 'lodash'; -import ReactNativeViewAttributes from 'react-native/Libraries/Components/View/ReactNativeViewAttributes'; - -function arrayDiffer(a, b) { - if (_.isNil(a)) { - return true; - } - - if (a.length !== b.length) { - return true; - } - for (let i = 0; i < a.length; i++) { - if (a[i] !== b[i]) { - return true; - } - } - return false; -} - -function percentageDiffer(a, b) { - if (a === b) { - return false; - } - for (let key in a) { - if (a.hasOwnProperty(key)) { - if (key === 'type' && a.type !== b.type) { - return true; - } else if (a[key].percentage !== b[key].percentage || a[key].value !== b[key].value) { - return true; - } - } - } - return false; -} - -function fontAndLinesDiffer(a, b) { - if (a === b) { - return false; - } - - if (a.font !== b.font) { - if (a.font === null) { - return true; - } - if (b.font === null) { - return true; - } - - if ( - a.font.fontFamily !== b.font.fontFamily || - a.font.fontSize !== b.font.fontSize || - a.font.fontWeight !== b.font.fontWeight || - a.font.fontStyle !== b.font.fontStyle - ) { - return true; - } - } - return arrayDiffer(a.lines, b.lines); -} - -const NodeAttributes = { - ...ReactNativeViewAttributes.UIView, - transform: { - diff: arrayDiffer - }, - opacity: true, - clipPath: { - diff: arrayDiffer - }, - clipPathId: true, - clipRule: true -}; - -const GroupAttributes = { - asClipPath: true, - ...NodeAttributes -}; - -const RenderableAttributes = { - fill: { - diff: arrayDiffer - }, - fillRule: true, - stroke: { - diff: arrayDiffer - }, - strokeWidth: true, - strokeLinecap: true, - strokeLinejoin: true, - strokeDasharray: { - diff: arrayDiffer - }, - strokeDashoffset: true, - ...NodeAttributes -}; - -const PathAttributes = { - d: { - diff: arrayDiffer - }, - ...RenderableAttributes -}; - -const TextAttributes = { - alignment: true, - frame: { - diff: fontAndLinesDiffer - }, - path: { - diff: arrayDiffer - }, - ...RenderableAttributes -}; - -const ShapeAttributes = { - shape: { - diff: percentageDiffer - }, - ...RenderableAttributes -}; - -const ImageAttributes = { - ...NodeAttributes, - layout: { - diff: percentageDiffer - }, - src: true -}; - -export { - GroupAttributes, - PathAttributes, - TextAttributes, - ShapeAttributes, - ImageAttributes -}; -