Files
react-native-svg/elements/Text.js
Horcrux 74b9917bd3 flattern text into several spans
flattern text into several spans (step 1, not finish yet)
2016-09-02 10:24:33 +08:00

47 lines
1.2 KiB
JavaScript

import React, {PropTypes} from 'react';
import createReactNativeComponentClass from 'react/lib/createReactNativeComponentClass';
import extractText from '../lib/extract/extractText';
import {numberProp, pathProps} from '../lib/props';
import {TextAttributes} from '../lib/attributes';
import Shape from './Shape';
class Text extends Shape {
static displayName = 'Text';
static propTypes = {
...pathProps,
dx: numberProp,
dy: numberProp,
textAnchor: PropTypes.oneOf(['start', 'middle', 'end']),
fontFamily: PropTypes.string,
fontSize: numberProp,
fontWeight: PropTypes.string,
fontStyle: PropTypes.string,
font: PropTypes.object
};
setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};
render() {
let props = this.props;
return <RNSVGText
ref={ele => {this.root = ele;}}
{...this.extractProps({
...props,
x: null,
y: null
})}
{...extractText(props)}
/>;
}
}
const RNSVGText = createReactNativeComponentClass({
validAttributes: TextAttributes,
uiViewClassName: 'RNSVGText'
});
export default Text;