forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathText.js
More file actions
51 lines (43 loc) · 1.04 KB
/
Text.js
File metadata and controls
51 lines (43 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Text as RNText } from 'react-native';
import _ from 'lodash';
import { connectStyle } from 'native-base-shoutem-theme';
import mapPropsToStyleNames from '../utils/mapPropsToStyleNames';
class Text extends Component {
render() {
const { uppercase, children } = this.props;
let text;
if (uppercase) {
text = React.Children.map(children, child => {
if (_.isString(child)) {
return _.toUpper(child);
}
return child;
});
} else {
text = children;
}
return (
<RNText ref={c => (this._root = c)} {...this.props}>
{text}
</RNText>
);
}
}
Text.propTypes = {
...RNText.propTypes,
uppercase: PropTypes.bool,
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.number,
PropTypes.array
])
};
Text.defaultProps = {
uppercase: false
};
const StyledText = connectStyle('NativeBase.Text', {}, mapPropsToStyleNames)(
Text
);
export { StyledText as Text };