-
Notifications
You must be signed in to change notification settings - Fork 34
/
Icon.js
44 lines (35 loc) · 1.12 KB
/
Icon.js
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
import React, { Component } from 'react';
import { Text, StyleSheet } from 'react-native';
import { SolidIcons, RegularIcons, BrandIcons, parseIconFromClassName } from './FontAwesomeIcons';
class Icon extends Component {
setNativeProps(nativeProps) {
this._root.setNativeProps(nativeProps);
}
render() {
const { style, color, icon, pro, ...props } = this.props;
const [code, type] = (icon || '').split('|')
const IconType = type === 'brand' ? BrandIcons :
type === 'regular' ? RegularIcons
: SolidIcons
const font = { fontFamily: IconType._fontFamily || '' }
if (pro) {
font.fontFamily = font.fontFamily.replace('Free', 'Pro')
}
return (
<Text
{...props}
style={[styles.icon, { color }, style, font]}
ref={component => this._root = component}
>
{code}
</Text>
);
}
}
const styles = StyleSheet.create({
icon: {
backgroundColor: 'transparent'
},
});
export { SolidIcons, RegularIcons, BrandIcons, parseIconFromClassName };
export default Icon;