react-native-form-builder
react-native-form-builder copied to clipboard
Support icon type
Native base now supports icon type
Icon.propTypes = {
...IconNB.propTypes,
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.number,
PropTypes.array
]),
name: PropTypes.string,
ios: PropTypes.string,
android: PropTypes.string,
active: PropTypes.bool,
type: PropTypes.string
};
which can be set to one of
setIcon(iconType) {
if (iconType === undefined && 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 'Foundation':
this.Icon = Foundation;
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;
}
}
and used like this
<Icon name="exchange" type="FontAwesome" />
native-base
already checks for iconType === undefined
and also has a default in the switch
default:
this.Icon = Ionicons;