react-native-dynamic-vector-icons
Version:
Wrapper of react-native-vector-icons to use dynamic types.
41 lines • 2.37 kB
JavaScript
import * as React from "react";
export var IconType;
(function (IconType) {
IconType["FontAwesome"] = "FontAwesome";
IconType["AntDesign"] = "AntDesign";
IconType["MaterialIcons"] = "MaterialIcons";
IconType["EvilIcons"] = "EvilIcons";
IconType["Entypo"] = "Entypo";
IconType["Foundation"] = "Foundation";
IconType["Ionicons"] = "Ionicons";
IconType["MaterialCommunityIcons"] = "MaterialCommunityIcons";
IconType["Zocial"] = "Zocial";
IconType["Octicons"] = "Octicons";
IconType["SimpleLineIcons"] = "SimpleLineIcons";
IconType["Fontisto"] = "Fontisto";
IconType["Feather"] = "Feather";
IconType["FontAwesome5"] = "FontAwesome5";
})(IconType || (IconType = {}));
const iconComponents = {
[IconType.AntDesign]: require("react-native-vector-icons/AntDesign").default,
[IconType.Entypo]: require("react-native-vector-icons/Entypo").default,
[IconType.Ionicons]: require("react-native-vector-icons/Ionicons").default,
[IconType.SimpleLineIcons]: require("react-native-vector-icons/SimpleLineIcons").default,
[IconType.EvilIcons]: require("react-native-vector-icons/EvilIcons").default,
[IconType.MaterialIcons]: require("react-native-vector-icons/MaterialIcons").default,
[IconType.FontAwesome]: require("react-native-vector-icons/FontAwesome").default,
[IconType.FontAwesome5]: require("react-native-vector-icons/FontAwesome5").default,
[IconType.Foundation]: require("react-native-vector-icons/Foundation").default,
[IconType.MaterialCommunityIcons]: require("react-native-vector-icons/MaterialCommunityIcons").default,
[IconType.Zocial]: require("react-native-vector-icons/Zocial").default,
[IconType.Octicons]: require("react-native-vector-icons/Octicons").default,
[IconType.Fontisto]: require("react-native-vector-icons/Fontisto").default,
[IconType.Feather]: require("react-native-vector-icons/Feather").default,
};
const Icon = (props) => {
const { type, name, color = "#757575", size = 20, onPress = null, style = {}, brand, solid, ...textProps } = props;
const IconComponent = iconComponents[type] || iconComponents[IconType.MaterialIcons];
return (<IconComponent {...textProps} name={name} size={size} style={style} color={color} onPress={onPress} brand={brand} solid={solid}/>);
};
export default Icon;
//# sourceMappingURL=Icon.js.map