mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-05 16:04:38 +00:00
[android] Override LayoutShadowNode layout prop handlers.
Fix mergeProperties for groups and text. Some regressions with edge cases of inheritance still remain.
This commit is contained in:
@@ -31,8 +31,8 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
@SuppressLint("ViewConstructor")
|
||||
class GroupView extends RenderableView {
|
||||
@Nullable ReadableMap mFont;
|
||||
private GlyphContext mGlyphContext;
|
||||
public @Nullable ReadableMap mFont;
|
||||
public GlyphContext mGlyphContext;
|
||||
|
||||
public GroupView(ReactContext reactContext) {
|
||||
super(reactContext);
|
||||
|
||||
@@ -59,25 +59,25 @@ abstract public class RenderableView extends VirtualView {
|
||||
private static final int FILL_RULE_EVENODD = 0;
|
||||
static final int FILL_RULE_NONZERO = 1;
|
||||
|
||||
private @Nullable ReadableArray mStroke;
|
||||
private @Nullable String[] mStrokeDasharray;
|
||||
public @Nullable ReadableArray mStroke;
|
||||
public @Nullable String[] mStrokeDasharray;
|
||||
|
||||
private String mStrokeWidth = "1";
|
||||
private float mStrokeOpacity = 1;
|
||||
private float mStrokeMiterlimit = 4;
|
||||
private float mStrokeDashoffset = 0;
|
||||
public String mStrokeWidth = "1";
|
||||
public float mStrokeOpacity = 1;
|
||||
public float mStrokeMiterlimit = 4;
|
||||
public float mStrokeDashoffset = 0;
|
||||
|
||||
private Paint.Cap mStrokeLinecap = Paint.Cap.ROUND;
|
||||
private Paint.Join mStrokeLinejoin = Paint.Join.ROUND;
|
||||
public Paint.Cap mStrokeLinecap = Paint.Cap.ROUND;
|
||||
public Paint.Join mStrokeLinejoin = Paint.Join.ROUND;
|
||||
|
||||
private @Nullable ReadableArray mFill;
|
||||
private float mFillOpacity = 1;
|
||||
private Path.FillType mFillRule = Path.FillType.WINDING;
|
||||
public @Nullable ReadableArray mFill;
|
||||
public float mFillOpacity = 1;
|
||||
public Path.FillType mFillRule = Path.FillType.WINDING;
|
||||
|
||||
private @Nullable ArrayList<String> mLastMergedList;
|
||||
private @Nullable ArrayList<Object> mOriginProperties;
|
||||
private @Nullable ArrayList<String> mPropList;
|
||||
private @Nullable ArrayList<String> mAttributeList;
|
||||
public @Nullable ArrayList<String> mLastMergedList;
|
||||
public @Nullable ArrayList<Object> mOriginProperties;
|
||||
public @Nullable ArrayList<String> mPropList;
|
||||
public @Nullable ArrayList<String> mAttributeList;
|
||||
|
||||
private static final Pattern regex = Pattern.compile("[0-9.-]+");
|
||||
|
||||
|
||||
@@ -16,12 +16,15 @@ import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.uimanager.DisplayMetricsHolder;
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.MatrixMathHelper;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.TransformHelper;
|
||||
import com.facebook.react.uimanager.ViewGroupManager;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -35,6 +38,7 @@ import static com.facebook.react.uimanager.MatrixMathHelper.v3Cross;
|
||||
import static com.facebook.react.uimanager.MatrixMathHelper.v3Dot;
|
||||
import static com.facebook.react.uimanager.MatrixMathHelper.v3Length;
|
||||
import static com.facebook.react.uimanager.MatrixMathHelper.v3Normalize;
|
||||
import static com.facebook.react.uimanager.ViewProps.*;
|
||||
import static com.horcrux.svg.RenderableView.CAP_ROUND;
|
||||
import static com.horcrux.svg.RenderableView.FILL_RULE_NONZERO;
|
||||
import static com.horcrux.svg.RenderableView.JOIN_ROUND;
|
||||
@@ -65,6 +69,86 @@ class RenderableViewManager extends ViewGroupManager<VirtualView> {
|
||||
RNSVGMask,
|
||||
}
|
||||
|
||||
class RenderableShadowNode extends LayoutShadowNode {
|
||||
|
||||
@ReactPropGroup(
|
||||
names = {
|
||||
ALIGN_SELF,
|
||||
ALIGN_ITEMS,
|
||||
COLLAPSABLE,
|
||||
FLEX,
|
||||
FLEX_BASIS,
|
||||
FLEX_DIRECTION,
|
||||
FLEX_GROW,
|
||||
FLEX_SHRINK,
|
||||
FLEX_WRAP,
|
||||
JUSTIFY_CONTENT,
|
||||
OVERFLOW,
|
||||
ALIGN_CONTENT,
|
||||
DISPLAY,
|
||||
|
||||
/* position */
|
||||
POSITION,
|
||||
RIGHT,
|
||||
TOP,
|
||||
BOTTOM,
|
||||
LEFT,
|
||||
START,
|
||||
END,
|
||||
|
||||
/* dimensions */
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
MIN_WIDTH,
|
||||
MAX_WIDTH,
|
||||
MIN_HEIGHT,
|
||||
MAX_HEIGHT,
|
||||
|
||||
/* margins */
|
||||
MARGIN,
|
||||
MARGIN_VERTICAL,
|
||||
MARGIN_HORIZONTAL,
|
||||
MARGIN_LEFT,
|
||||
MARGIN_RIGHT,
|
||||
MARGIN_TOP,
|
||||
MARGIN_BOTTOM,
|
||||
MARGIN_START,
|
||||
MARGIN_END,
|
||||
|
||||
/* paddings */
|
||||
PADDING,
|
||||
PADDING_VERTICAL,
|
||||
PADDING_HORIZONTAL,
|
||||
PADDING_LEFT,
|
||||
PADDING_RIGHT,
|
||||
PADDING_TOP,
|
||||
PADDING_BOTTOM,
|
||||
PADDING_START,
|
||||
PADDING_END,
|
||||
|
||||
BORDER_WIDTH,
|
||||
BORDER_START_WIDTH,
|
||||
BORDER_END_WIDTH,
|
||||
BORDER_TOP_WIDTH,
|
||||
BORDER_BOTTOM_WIDTH,
|
||||
BORDER_LEFT_WIDTH,
|
||||
BORDER_RIGHT_WIDTH,
|
||||
}
|
||||
)
|
||||
public void ignoreLayoutProps(int index, Dynamic value) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LayoutShadowNode createShadowNodeInstance() {
|
||||
return new RenderableShadowNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<RenderableShadowNode> getShadowNodeClass() {
|
||||
return RenderableShadowNode.class;
|
||||
}
|
||||
|
||||
|
||||
private final SVGClass svgClass;
|
||||
private final String mClassName;
|
||||
|
||||
|
||||
@@ -32,15 +32,15 @@ import static com.horcrux.svg.TextProperties.*;
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
class TextView extends GroupView {
|
||||
String mTextLength = null;
|
||||
private String mBaselineShift = null;
|
||||
TextLengthAdjust mLengthAdjust = TextLengthAdjust.spacing;
|
||||
private AlignmentBaseline mAlignmentBaseline;
|
||||
private @Nullable ReadableArray mPositionX;
|
||||
private @Nullable ReadableArray mPositionY;
|
||||
private @Nullable ReadableArray mRotate;
|
||||
private @Nullable ReadableArray mDeltaX;
|
||||
private @Nullable ReadableArray mDeltaY;
|
||||
public String mTextLength = null;
|
||||
public String mBaselineShift = null;
|
||||
public TextLengthAdjust mLengthAdjust = TextLengthAdjust.spacing;
|
||||
public AlignmentBaseline mAlignmentBaseline;
|
||||
public @Nullable ReadableArray mPositionX;
|
||||
public @Nullable ReadableArray mPositionY;
|
||||
public @Nullable ReadableArray mRotate;
|
||||
public @Nullable ReadableArray mDeltaX;
|
||||
public @Nullable ReadableArray mDeltaY;
|
||||
|
||||
public TextView(ReactContext reactContext) {
|
||||
super(reactContext);
|
||||
|
||||
Reference in New Issue
Block a user