Skip to content

Commit

Permalink
Support useNativeDriver animation for all unit-less numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
msand committed Oct 11, 2018
1 parent a2550c3 commit 864d761
Show file tree
Hide file tree
Showing 28 changed files with 922 additions and 242 deletions.
27 changes: 21 additions & 6 deletions android/src/main/java/com/horcrux/svg/CircleShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;

import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.uimanager.annotations.ReactProp;

/**
Expand All @@ -25,20 +28,32 @@ class CircleShadowNode extends RenderableShadowNode {
private String mR;

@ReactProp(name = "cx")
public void setCx(String cx) {
mCx = cx;
public void setCx(Dynamic cx) {
if (cx.getType() == ReadableType.String) {
mCx = cx.asString();
} else {
mCx = String.valueOf(cx.asDouble());
}
markUpdated();
}

@ReactProp(name = "cy")
public void setCy(String cy) {
mCy = cy;
public void setCy(Dynamic cy) {
if (cy.getType() == ReadableType.String) {
mCy = cy.asString();
} else {
mCy = String.valueOf(cy.asDouble());
}
markUpdated();
}

@ReactProp(name = "r")
public void setR(String r) {
mR = r;
public void setR(Dynamic r) {
if (r.getType() == ReadableType.String) {
mR = r.asString();
} else {
mR = String.valueOf(r.asDouble());
}
markUpdated();
}

Expand Down
34 changes: 26 additions & 8 deletions android/src/main/java/com/horcrux/svg/EllipseShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import android.graphics.Path;
import android.graphics.RectF;

import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.uimanager.annotations.ReactProp;

/**
Expand All @@ -27,26 +29,42 @@ class EllipseShadowNode extends RenderableShadowNode {
private String mRy;

@ReactProp(name = "cx")
public void setCx(String cx) {
mCx = cx;
public void setCx(Dynamic cx) {
if (cx.getType() == ReadableType.String) {
mCx = cx.asString();
} else {
mCx = String.valueOf(cx.asDouble());
}
markUpdated();
}

@ReactProp(name = "cy")
public void setCy(String cy) {
mCy = cy;
public void setCy(Dynamic cy) {
if (cy.getType() == ReadableType.String) {
mCy = cy.asString();
} else {
mCy = String.valueOf(cy.asDouble());
}
markUpdated();
}

@ReactProp(name = "rx")
public void setRx(String rx) {
mRx = rx;
public void setRx(Dynamic rx) {
if (rx.getType() == ReadableType.String) {
mRx = rx.asString();
} else {
mRx = String.valueOf(rx.asDouble());
}
markUpdated();
}

@ReactProp(name = "ry")
public void setRy(String ry) {
mRy = ry;
public void setRy(Dynamic ry) {
if (ry.getType() == ReadableType.String) {
mRy = ry.asString();
} else {
mRy = String.valueOf(ry.asDouble());
}
markUpdated();
}

Expand Down
36 changes: 26 additions & 10 deletions android/src/main/java/com/horcrux/svg/ImageShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,42 @@ class ImageShadowNode extends RenderableShadowNode {
private Matrix mMatrix = null;

@ReactProp(name = "x")
public void setX(String x) {
mX = x;
public void setX(Dynamic x) {
if (x.getType() == ReadableType.String) {
mX = x.asString();
} else {
mX = String.valueOf(x.asDouble());
}
markUpdated();
}

@ReactProp(name = "y")
public void setY(String y) {
mY = y;
public void setY(Dynamic y) {
if (y.getType() == ReadableType.String) {
mY = y.asString();
} else {
mY = String.valueOf(y.asDouble());
}
markUpdated();
}

@ReactProp(name = "imagewidth")
public void setWidth(String width) {
mW = width;
@ReactProp(name = "width")
public void setWidth(Dynamic width) {
if (width.getType() == ReadableType.String) {
mW = width.asString();
} else {
mW = String.valueOf(width.asDouble());
}
markUpdated();
}

@ReactProp(name = "imageheight")
public void seHeight(String height) {
mH = height;
@ReactProp(name = "height")
public void seHeight(Dynamic height) {
if (height.getType() == ReadableType.String) {
mH = height.asString();
} else {
mH = String.valueOf(height.asDouble());
}
markUpdated();
}

Expand Down
35 changes: 27 additions & 8 deletions android/src/main/java/com/horcrux/svg/LineShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;

import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.uimanager.annotations.ReactProp;

/**
Expand All @@ -25,26 +28,42 @@ class LineShadowNode extends RenderableShadowNode {
private String mY2;

@ReactProp(name = "x1")
public void setX1(String x1) {
mX1 = x1;
public void setX1(Dynamic x1) {
if (x1.getType() == ReadableType.String) {
mX1 = x1.asString();
} else {
mX1 = String.valueOf(x1.asDouble());
}
markUpdated();
}

@ReactProp(name = "y1")
public void setY1(String y1) {
mY1 = y1;
public void setY1(Dynamic y1) {
if (y1.getType() == ReadableType.String) {
mY1 = y1.asString();
} else {
mY1 = String.valueOf(y1.asDouble());
}
markUpdated();
}

@ReactProp(name = "x2")
public void setX2(String x2) {
mX2 = x2;
public void setX2(Dynamic x2) {
if (x2.getType() == ReadableType.String) {
mX2 = x2.asString();
} else {
mX2 = String.valueOf(x2.asDouble());
}
markUpdated();
}

@ReactProp(name = "y2")
public void setY2(String y2) {
mY2 = y2;
public void setY2(Dynamic y2) {
if (y2.getType() == ReadableType.String) {
mY2 = y2.asString();
} else {
mY2 = String.valueOf(y2.asDouble());
}
markUpdated();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.uimanager.annotations.ReactProp;
Expand All @@ -39,27 +41,44 @@ class LinearGradientShadowNode extends DefinitionShadowNode {
};
private Matrix mMatrix = null;


@ReactProp(name = "x1")
public void setX1(String x1) {
mX1 = x1;
public void setX1(Dynamic x1) {
if (x1.getType() == ReadableType.String) {
mX1 = x1.asString();
} else {
mX1 = String.valueOf(x1.asDouble());
}
markUpdated();
}

@ReactProp(name = "y1")
public void setY1(String y1) {
mY1 = y1;
public void setY1(Dynamic y1) {
if (y1.getType() == ReadableType.String) {
mY1 = y1.asString();
} else {
mY1 = String.valueOf(y1.asDouble());
}
markUpdated();
}

@ReactProp(name = "x2")
public void setX2(String x2) {
mX2 = x2;
public void setX2(Dynamic x2) {
if (x2.getType() == ReadableType.String) {
mX2 = x2.asString();
} else {
mX2 = String.valueOf(x2.asDouble());
}
markUpdated();
}

@ReactProp(name = "y2")
public void setY2(String y2) {
mY2 = y2;
public void setY2(Dynamic y2) {
if (y2.getType() == ReadableType.String) {
mY2 = y2.asString();
} else {
mY2 = String.valueOf(y2.asDouble());
}
markUpdated();
}

Expand Down
38 changes: 28 additions & 10 deletions android/src/main/java/com/horcrux/svg/MaskShadowNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import android.graphics.Matrix;

import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.uimanager.annotations.ReactProp;

Expand All @@ -38,26 +40,42 @@ class MaskShadowNode extends GroupShadowNode {
private Matrix mMatrix = null;

@ReactProp(name = "x")
public void setX(String x) {
mX = x;
public void setX(Dynamic x) {
if (x.getType() == ReadableType.String) {
mX = x.asString();
} else {
mX = String.valueOf(x.asDouble());
}
markUpdated();
}

@ReactProp(name = "y")
public void setY(String y) {
mY = y;
public void setY(Dynamic y) {
if (y.getType() == ReadableType.String) {
mY = y.asString();
} else {
mY = String.valueOf(y.asDouble());
}
markUpdated();
}

@ReactProp(name = "maskwidth")
public void setWidth(String width) {
mWidth = width;
@ReactProp(name = "width")
public void setWidth(Dynamic width) {
if (width.getType() == ReadableType.String) {
mWidth = width.asString();
} else {
mWidth = String.valueOf(width.asDouble());
}
markUpdated();
}

@ReactProp(name = "maskheight")
public void setHeight(String height) {
mHeight = height;
@ReactProp(name = "height")
public void setHeight(Dynamic height) {
if (height.getType() == ReadableType.String) {
mHeight = height.asString();
} else {
mHeight = String.valueOf(height.asDouble());
}
markUpdated();
}

Expand Down
Loading

0 comments on commit 864d761

Please sign in to comment.