Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create RNVectorHelper.js #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions js/RNVectorHelper.js
Original file line number Diff line number Diff line change
@@ -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;