forked from prscX/react-native-image-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRNImageHelper.js
137 lines (117 loc) · 5.16 KB
/
RNImageHelper.js
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
136
137
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";
import { Platform } from "react-native";
class RNImageHelper {
static Resolve(family, name) {
let glyph, fontFamily
switch (family) {
case "Entypo":
glyph = EntypoGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "Entypo"
return { glyph: glyph, family: fontFamily };
case "EvilIcons":
glyph = EvilIconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "EvilIcons"
return { glyph: glyph, family: fontFamily };
case "Feather":
glyph = FeatherGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "Feather"
return { glyph: glyph, family: fontFamily };
case "FontAwesome":
glyph = FontAwesomeGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "FontAwesome";
return { glyph: glyph, family: fontFamily };
case "Foundation":
glyph = FoundationGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
if (Platform.OS === "ios") {
fontFamily = "fontcustom"
} else {
fontFamily = "Foundation";
}
return { glyph: glyph, family: fontFamily };
case "Ionicons":
glyph = IoniconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "Ionicons"
return { glyph: glyph, family: fontFamily };
case "MaterialCommunityIcons":
glyph = MaterialCommunityIconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
if (Platform.OS === "ios") {
fontFamily = "Material Design Icons"
} else {
fontFamily = "MaterialCommunityIcons";
}
return { glyph: glyph, family: fontFamily };
case "MaterialIcons":
glyph = MaterialIconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
if (Platform.OS === "ios") {
fontFamily = "Material Icons"
} else {
fontFamily = "MaterialIcons";
}
return { glyph: glyph, family: fontFamily };
case "Octicons":
glyph = OcticonsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "Octicons";
return { glyph: glyph, family: fontFamily };
case "SimpleLineIcons":
glyph = SimpleLineIconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
if (Platform.OS === 'ios') {
fontFamily = "simple-line-icons";
} else {
fontFamily = "SimpleLineIcons"
}
return { glyph: glyph, family: fontFamily };
case "Zocial":
glyph = ZocialGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
if (Platform.OS === "ios") {
fontFamily = "zocial";
} else {
fontFamily = "Zocial";
}
return { glyph: glyph, family: fontFamily };
}
}
}
export default RNImageHelper;