Skip to content

Commit

Permalink
- upgrading RNVectorIcons
Browse files Browse the repository at this point in the history
- iOS: hot fix for font family
  • Loading branch information
prscms committed Aug 20, 2018
1 parent b475ea4 commit e9ba1bf
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react": "16.3.1",
"react-native": "0.55.3",
"react-native-bottom-action-sheet": "../",
"react-native-vector-icons": "4.6.0"
"react-native-vector-icons": "5.0.0"
},
"devDependencies": {
"babel-jest": "22.1.0",
Expand Down
4 changes: 2 additions & 2 deletions js/GridView.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class GridView extends PureComponent {
if (element.icon && element.icon.props) {
element.icon = element.icon.props;

let glyph = RNVectorHelper.Resolve(
let vectorIcon = RNVectorHelper.Resolve(
element.icon.family,
element.icon.name
);
element.icon = Object.assign({}, element.icon, { glyph: glyph });
element.icon = Object.assign({}, element.icon, vectorIcon);
} else if (element.icon !== undefined) {
element.icon = {
name: element.icon,
Expand Down
63 changes: 51 additions & 12 deletions js/RNVectorHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,127 @@ 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 RNVectorHelper {
static Resolve(family, name) {
let glyph;
let glyph, fontFamily

switch (family) {
case "Entypo":
glyph = EntypoGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "Entypo"

return glyph;
return { glyph: glyph, family: fontFamily };
case "EvilIcons":
glyph = EvilIconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "EvilIcons"

return glyph;
return { glyph: glyph, family: fontFamily };
case "Feather":
glyph = FeatherGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "Feather"

return glyph;
return { glyph: glyph, family: fontFamily };
case "FontAwesome":
glyph = FontAwesomeGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}
fontFamily = "FontAwesome";

return glyph;
return { glyph: glyph, family: fontFamily };
case "Foundation":
glyph = FoundationGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}

return 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;
return { glyph: glyph, family: fontFamily };
case "MaterialCommunityIcons":
glyph = MaterialCommunityIconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}

return 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);
}

return 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;
return { glyph: glyph, family: fontFamily };
case "SimpleLineIcons":
glyph = SimpleLineIconsGlyphMap[name];
if (typeof glyph === "number") {
glyph = String.fromCharCode(glyph);
}

return 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);
}

return glyph;
if (Platform.OS === "ios") {
fontFamily = "zocial";
} else {
fontFamily = "Zocial";
}

return { glyph: glyph, family: fontFamily };
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions js/SheetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class SheetView extends PureComponent {
if (element.icon && element.icon.props) {
element.icon = element.icon.props;

let glyph = RNVectorHelper.Resolve(element.icon.family, element.icon.name);
element.icon = Object.assign({}, element.icon, { glyph: glyph });
let vectorIcon = RNVectorHelper.Resolve(element.icon.family, element.icon.name);
element.icon = Object.assign({}, element.icon, vectorIcon);
} else if (element.icon !== undefined) {
element.icon = { name: element.icon, family: "", glyph: "", color: "", size: 0 };
} else {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-bottom-action-sheet",
"version": "0.0.17",
"version": "0.0.18",
"description": "React Native: Native Bottom Action Sheet",
"main": "js/index.js",
"repository": {
Expand All @@ -16,10 +16,10 @@
],
"author": "Pranav Raj Singh Chauhan",
"dependencies": {
"react-native-vector-icons": "4.6.0"
"react-native-vector-icons": "5.0.0"
},
"devDependencies": {
"prettier-pack": "0.0.6"
"prettier-pack": "0.0.7"
},
"license": "Apache License 2.0"
}

0 comments on commit e9ba1bf

Please sign in to comment.