From 399d3ccfe92ae249f6929e6f3f5f319d6cb93082 Mon Sep 17 00:00:00 2001 From: Nouman Sakhawat <48842733+NoumanSakhawat@users.noreply.github.com> Date: Wed, 14 Jul 2021 13:32:56 +0500 Subject: [PATCH] Create RNVectorHelper.js --- js/RNVectorHelper.js | 99 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 js/RNVectorHelper.js diff --git a/js/RNVectorHelper.js b/js/RNVectorHelper.js new file mode 100644 index 0000000..b69b4a5 --- /dev/null +++ b/js/RNVectorHelper.js @@ -0,0 +1,99 @@ +import EntypoGlyphMap from "react-native-vector-icons/glyphmaps/Entypo.json"; +import EvilIconsGlyphMap from "react-native-vector-icons/glyphmaps/EvilIcons.json"; +import FeatherGlyphMap from "react-native-vector-icons/glyphmaps/Feather.json"; +import FontAwesomeGlyphMap from "react-native-vector-icons/glyphmaps/FontAwesome.json"; +import FoundationGlyphMap from "react-native-vector-icons/glyphmaps/Foundation.json"; +import IoniconsGlyphMap from "react-native-vector-icons/glyphmaps/Ionicons.json"; +import MaterialCommunityIconsGlyphMap from "react-native-vector-icons/glyphmaps/MaterialCommunityIcons.json"; +import MaterialIconsGlyphMap from "react-native-vector-icons/glyphmaps/MaterialIcons.json"; +import OcticonsGlyphMap from "react-native-vector-icons/glyphmaps/Octicons.json"; +import SimpleLineIconsGlyphMap from "react-native-vector-icons/glyphmaps/SimpleLineIcons.json"; +import ZocialGlyphMap from "react-native-vector-icons/glyphmaps/Zocial.json"; + +class RNVectorHelper { + static Resolve(family, name) { + let glyph; + + switch (family) { + case "Entypo": + glyph = EntypoGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "EvilIcons": + glyph = EvilIconsGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "Feather": + glyph = FeatherGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "FontAwesome": + glyph = FontAwesomeGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "Foundation": + glyph = FoundationGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "Ionicons": + glyph = IoniconsGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "MaterialCommunityIcons": + glyph = MaterialCommunityIconsGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "MaterialIcons": + glyph = MaterialIconsGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "Octicons": + glyph = OcticonsGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "SimpleLineIcons": + glyph = SimpleLineIconsGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + case "Zocial": + glyph = ZocialGlyphMap[name]; + if (typeof glyph === "number") { + glyph = String.fromCharCode(glyph); + } + + return glyph; + } + } +} + +export default RNVectorHelper;