UNPKG

1.62 kBJavaScriptView Raw
1import React, { Component } from 'react';
2import { TextInput, View } from 'react-native';
3import PropTypes from 'prop-types';
4
5export default class TextArea extends Component {
6 static propTypes = {
7 placeholder: PropTypes.string,
8 onChange: PropTypes.func,
9 selectionColor: PropTypes.string,
10 value: PropTypes.string,
11 max: PropTypes.number,
12 textColor: PropTypes.string,
13 placeholderColor: PropTypes.string,
14 backgroundColor: PropTypes.string,
15 height: PropTypes.number,
16 marginTop: PropTypes.number,
17 name: PropTypes.string
18 };
19
20 static defaultProps = {
21 placeholder: '',
22 onChange: () => {},
23 selectionColor: '#4d4d4d',
24 value: '',
25 max: 500,
26 textColor: '#4d4d4d',
27 placeholderColor: '#3c4f5e',
28 backgroundColor: '#f6f6f6',
29 height: 200,
30 marginTop: 0,
31 name: ''
32 };
33
34 onChange = (value) => {
35 this.props.onChange(value, this.props.name);
36 };
37
38 render() {
39 return (
40 <View style={{ height: this.props.height, marginTop: this.props.marginTop }}>
41 <TextInput
42 selectionColor={this.props.selectionColor}
43 multiline
44 autoCorrect={false}
45 autoCapitalizer="none"
46 placeholder={this.props.placeholder}
47 style={{ backgroundColor: this.props.backgroundColor, flex: 1, color: this.props.textColor, padding: 12, fontSize: 14 }}
48 placeholderTextColor={this.props.placeholderColor}
49 onChangeText={this.onChange}
50 value={this.props.value}
51 maxLength={this.props.max}
52 underlineColorAndroid="transparent"
53 />
54 </View>
55 );
56 }
57}