mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-27 12:41:49 +00:00
fix #111
reset ownedPropList everytime mergeProperties method is called.
This commit is contained in:
@@ -42,7 +42,7 @@ public class RNSVGGroupShadowNode extends RNSVGPathShadowNode {
|
||||
RNSVGVirtualNode child = (RNSVGVirtualNode) getChildAt(i);
|
||||
child.setupDimensions(canvas);
|
||||
|
||||
child.mergeProperties(this, mPropList, true);
|
||||
child.mergeProperties(this, mOwnedPropList, true);
|
||||
child.draw(canvas, paint, opacity * mOpacity);
|
||||
|
||||
if (child.isResponsible()) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.common.executors.UiThreadImmediateExecutorService;
|
||||
import com.facebook.common.logging.FLog;
|
||||
|
||||
@@ -72,6 +72,7 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
private ArrayList<String> mChangedList;
|
||||
private ArrayList<Object> mOriginProperties;
|
||||
protected ReadableArray mPropList = new JavaOnlyArray();
|
||||
protected WritableArray mOwnedPropList = new JavaOnlyArray();
|
||||
|
||||
@ReactProp(name = "d")
|
||||
public void setPath(@Nullable ReadableArray shapePath) {
|
||||
@@ -196,8 +197,11 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
|
||||
if (propList != null) {
|
||||
for (int i = 0; i < propList.size(); i++) {
|
||||
copy.pushString(propertyNameToFieldName(propList.getString(i)));
|
||||
String fieldName = propertyNameToFieldName(propList.getString(i));
|
||||
copy.pushString(fieldName);
|
||||
mOwnedPropList.pushString(fieldName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mPropList = copy;
|
||||
@@ -404,6 +408,7 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
for (int i = 0; i < mPropList.size(); i++) {
|
||||
propList.pushString(mPropList.getString(i));
|
||||
}
|
||||
mOwnedPropList = propList;
|
||||
|
||||
for (int i = 0, size = mergeList.size(); i < size; i++) {
|
||||
try {
|
||||
@@ -425,11 +430,6 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (inherited) {
|
||||
mPropList = propList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -467,8 +467,8 @@ public class RNSVGPathShadowNode extends RNSVGVirtualNode {
|
||||
}
|
||||
|
||||
private boolean hasOwnProperty(String propName) {
|
||||
for (int i = mPropList.size() - 1; i >= 0; i--) {
|
||||
if (mPropList.getString(i).equals(propName)) {
|
||||
for (int i = mOwnedPropList.size() - 1; i >= 0; i--) {
|
||||
if (mOwnedPropList.getString(i).equals(propName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,11 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.ReactRootView;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.common.SystemClock;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
||||
import com.facebook.react.uimanager.events.TouchEvent;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class RNSVGUseShadowNode extends RNSVGPathShadowNode {
|
||||
int count = saveAndSetupCanvas(canvas);
|
||||
|
||||
clip(canvas, paint);
|
||||
template.mergeProperties(this, mPropList);
|
||||
template.mergeProperties(this, mOwnedPropList);
|
||||
template.draw(canvas, paint, opacity * mOpacity);
|
||||
template.resetProperties();
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
}
|
||||
return YES;
|
||||
}];
|
||||
|
||||
|
||||
[self traverseSubviews:^(RNSVGNode *node) {
|
||||
[node mergeProperties:self mergeList:self.propList inherited:YES];
|
||||
[node mergeProperties:self mergeList:self.ownedPropList inherited:YES];
|
||||
[node renderTo:context];
|
||||
return YES;
|
||||
}];
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
if (template) {
|
||||
[self beginTransparencyLayer:context];
|
||||
[self clip:context];
|
||||
[template mergeProperties:self mergeList:self.propList];
|
||||
[template mergeProperties:self mergeList:self.ownedPropList];
|
||||
[template renderTo:context];
|
||||
[template resetProperties];
|
||||
[self endTransparencyLayer:context];
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
@property (nonatomic, assign) CGFloat strokeDashoffset;
|
||||
@property (nonatomic, assign) CGPathRef hitArea;
|
||||
@property (nonatomic, copy) NSArray<NSString *> *propList;
|
||||
@property (nonatomic, strong) NSMutableArray<NSString *> *ownedPropList;
|
||||
|
||||
- (void)setBoundingBox:(CGRect)boundingBox;
|
||||
- (CGFloat)getWidthRelatedValue:(NSString *)string;
|
||||
|
||||
@@ -149,6 +149,7 @@
|
||||
return;
|
||||
}
|
||||
_propList = propList;
|
||||
self.ownedPropList = [propList mutableCopy];
|
||||
[self invalidate];
|
||||
}
|
||||
|
||||
@@ -253,12 +254,14 @@
|
||||
if (mergeList.count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
self.ownedPropList = [self.propList mutableCopy];
|
||||
|
||||
if (!inherited) {
|
||||
_originProperties = [[NSMutableDictionary alloc] init];
|
||||
_changedList = mergeList;
|
||||
}
|
||||
|
||||
|
||||
for (NSString *key in mergeList) {
|
||||
if (inherited) {
|
||||
[self inheritProperty:target propName:key];
|
||||
@@ -281,12 +284,9 @@
|
||||
|
||||
- (void)inheritProperty:(__kindof RNSVGNode *)parent propName:(NSString *)propName
|
||||
{
|
||||
if (![self.propList containsObject:propName]) {
|
||||
// add prop to propList
|
||||
NSMutableArray *copy = [self.propList mutableCopy];
|
||||
[copy addObject:propName];
|
||||
self.propList = [copy copy];
|
||||
|
||||
if (![self.ownedPropList containsObject:propName]) {
|
||||
// add prop to props
|
||||
[self.ownedPropList addObject:propName];
|
||||
[self setValue:[parent valueForKey:propName] forKey:propName];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user