forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIconNB.js
More file actions
135 lines (124 loc) · 3.55 KB
/
IconNB.js
File metadata and controls
135 lines (124 loc) · 3.55 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import React from 'react';
import PropTypes from 'prop-types';
import { connectStyle } from 'native-base-shoutem-theme';
import { get } from 'lodash';
import AntDesign from 'react-native-vector-icons/AntDesign';
import Entypo from 'react-native-vector-icons/Entypo';
import EvilIcons from 'react-native-vector-icons/EvilIcons';
import Feather from 'react-native-vector-icons/Feather';
import FontAwesome from 'react-native-vector-icons/FontAwesome';
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
import Fontisto from 'react-native-vector-icons/Fontisto';
import Foundation from 'react-native-vector-icons/Foundation';
import Ionicons from 'react-native-vector-icons/Ionicons';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import Octicons from 'react-native-vector-icons/Octicons';
import SimpleLineIcons from 'react-native-vector-icons/SimpleLineIcons';
import Zocial from 'react-native-vector-icons/Zocial';
import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
import icoMoonConfig from '../basic/Icon/selection.json';
import mapPropsToStyleNames from '../utils/mapPropsToStyleNames';
const Icomoon = createIconSetFromIcoMoon(icoMoonConfig);
class IconNB extends React.PureComponent {
static contextTypes = {
theme: PropTypes.object,
};
constructor(props) {
super(props);
this.setIcon(props.type);
}
// eslint-disable-next-line camelcase
UNSAFE_componentWillUpdate(nextProps) {
if (nextProps.type && this.props.type !== nextProps.type) {
this.setIcon(nextProps.type);
}
}
setRoot(c){
this._root = c;
}
setIcon(iconType) {
if (iconType === undefined && get(this, 'context.theme')) {
// eslint-disable-next-line
iconType = this.context.theme['@@shoutem.theme/themeStyle'].variables
.iconFamily;
}
switch (iconType) {
case 'AntDesign':
this.Icon = AntDesign;
break;
case 'Entypo':
this.Icon = Entypo;
break;
case 'EvilIcons':
this.Icon = EvilIcons;
break;
case 'Feather':
this.Icon = Feather;
break;
case 'FontAwesome':
this.Icon = FontAwesome;
break;
case 'FontAwesome5':
this.Icon = FontAwesome5;
break;
case 'Fontisto':
this.Icon = Fontisto;
break;
case 'Foundation':
this.Icon = Foundation;
break;
case 'Icomoon':
this.Icon = Icomoon;
break;
case 'Ionicons':
this.Icon = Ionicons;
break;
case 'MaterialCommunityIcons':
this.Icon = MaterialCommunityIcons;
break;
case 'MaterialIcons':
this.Icon = MaterialIcons;
break;
case 'Octicons':
this.Icon = Octicons;
break;
case 'SimpleLineIcons':
this.Icon = SimpleLineIcons;
break;
case 'Zocial':
this.Icon = Zocial;
break;
default:
this.Icon = Ionicons;
}
}
render() {
return <this.Icon ref={this.setRoot} {...this.props} />;
}
}
IconNB.propTypes = {
type: PropTypes.oneOf([
'AntDesign',
'Entypo',
'EvilIcons',
'Feather',
'FontAwesome',
'FontAwesome5',
'Fontisto',
'Foundation',
'Icomoon',
'Ionicons',
'MaterialCommunityIcons',
'MaterialIcons',
'Octicons',
'SimpleLineIcons',
'Zocial',
]),
};
const StyledIconNB = connectStyle(
'NativeBase.IconNB',
{},
mapPropsToStyleNames
)(IconNB);
export { StyledIconNB as IconNB };