fix: handling of color/tintColor, fixes #1088 and #1115

This commit is contained in:
Mikael Sand
2019-09-25 16:46:05 +03:00
parent d21213d922
commit 1eaf3a60c5
3 changed files with 9 additions and 4 deletions
@@ -169,7 +169,7 @@ public class SvgView extends ReactViewGroup implements ReactCompoundView, ReactC
} }
} }
@ReactProp(name = "tintColor", customType = "Color") @ReactProp(name = "tintColor")
public void setTintColor(@Nullable Integer tintColor) { public void setTintColor(@Nullable Integer tintColor) {
if (tintColor == null) { if (tintColor == null) {
mTintColor = 0; mTintColor = 0;
@@ -77,12 +77,12 @@ class SvgViewManager extends ReactViewManager {
return true; return true;
} }
@ReactProp(name = "tintColor", customType = "Color") @ReactProp(name = "tintColor")
public void setTintColor(SvgView node, @Nullable Integer tintColor) { public void setTintColor(SvgView node, @Nullable Integer tintColor) {
node.setTintColor(tintColor); node.setTintColor(tintColor);
} }
@ReactProp(name = "color", customType = "Color") @ReactProp(name = "color")
public void setColor(SvgView node, @Nullable Integer color) { public void setColor(SvgView node, @Nullable Integer color) {
node.setTintColor(color); node.setTintColor(color);
} }
+6 -1
View File
@@ -9,6 +9,7 @@ import {
MeasureInWindowOnSuccessCallback, MeasureInWindowOnSuccessCallback,
} from 'react-native'; } from 'react-native';
import { import {
Color,
ClipProps, ClipProps,
FillProps, FillProps,
NumberProp, NumberProp,
@@ -19,6 +20,7 @@ import {
} from '../lib/extract/types'; } from '../lib/extract/types';
import extractResponder from '../lib/extract/extractResponder'; import extractResponder from '../lib/extract/extractResponder';
import extractViewBox from '../lib/extract/extractViewBox'; import extractViewBox from '../lib/extract/extractViewBox';
import extractColor from '../lib/extract/extractColor';
import Shape from './Shape'; import Shape from './Shape';
import G from './G'; import G from './G';
@@ -33,6 +35,7 @@ const styles = StyleSheet.create({
export default class Svg extends Shape< export default class Svg extends Shape<
{ {
color?: Color;
style?: [] | {}; style?: [] | {};
viewBox?: string; viewBox?: string;
opacity?: NumberProp; opacity?: NumberProp;
@@ -148,12 +151,14 @@ export default class Svg extends Shape<
} }
: null; : null;
const tint = extractColor(color);
return ( return (
<RNSVGSvg <RNSVGSvg
{...props} {...props}
bbWidth={width} bbWidth={width}
bbHeight={height} bbHeight={height}
tintColor={color} color={tint}
tintColor={tint}
onLayout={onLayout} onLayout={onLayout}
ref={this.refMethod} ref={this.refMethod}
style={[styles.svg, style, opacityStyle, dimensions]} style={[styles.svg, style, opacityStyle, dimensions]}