1 | import React from 'react';
|
2 | import extractProps, { propsAndStyles } from '../lib/extract/extractProps';
|
3 | import { extractFont } from '../lib/extract/extractText';
|
4 | import extractTransform from '../lib/extract/extractTransform';
|
5 | import { TransformProps } from '../lib/extract/types';
|
6 | import Shape from './Shape';
|
7 | import { RNSVGGroup } from './NativeComponents';
|
8 |
|
9 | export default class G<P> extends Shape<P> {
|
10 | static displayName = 'G';
|
11 |
|
12 | setNativeProps = (
|
13 | props: Object & {
|
14 | matrix?: number[];
|
15 | } & TransformProps,
|
16 | ) => {
|
17 | const matrix = !props.matrix && extractTransform(props);
|
18 | if (matrix) {
|
19 | props.matrix = matrix;
|
20 | }
|
21 | this.root && this.root.setNativeProps(props);
|
22 | };
|
23 |
|
24 | render() {
|
25 | const { props } = this;
|
26 | const prop = propsAndStyles(props);
|
27 | const extractedProps = extractProps(prop, this);
|
28 | const font = extractFont(prop);
|
29 | if (hasProps(font)) {
|
30 | extractedProps.font = font;
|
31 | }
|
32 | return (
|
33 | <RNSVGGroup ref={this.refMethod} {...extractedProps}>
|
34 | {props.children}
|
35 | </RNSVGGroup>
|
36 | );
|
37 | }
|
38 | }
|
39 |
|
40 | const hasProps = (obj: {}) => {
|
41 | for (let _ in obj) {
|
42 | return true;
|
43 | }
|
44 | return false;
|
45 | };
|