From 547bffdff408d172396f5a460e3175f0532f4144 Mon Sep 17 00:00:00 2001 From: John Kokkinidis Date: Tue, 3 Jul 2018 22:21:39 +0300 Subject: [PATCH 1/4] Now exposing the glyph map with Icon.getRawGlyphMap --- lib/create-icon-set.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/create-icon-set.js b/lib/create-icon-set.js index 019313b9b..8dba9fce3 100644 --- a/lib/create-icon-set.js +++ b/lib/create-icon-set.js @@ -163,6 +163,10 @@ export default function createIconSet(glyphMap, fontFamily, fontFile) { return Object.prototype.hasOwnProperty.call(glyphMap, name); } + function getRawGlyphMap() { + return glyphMap; + } + Icon.Button = createIconButtonComponent(Icon); Icon.TabBarItem = createTabBarItemIOSComponent( IconNamePropType, @@ -176,6 +180,7 @@ export default function createIconSet(glyphMap, fontFamily, fontFile) { Icon.getImageSource = getImageSource; Icon.loadFont = loadFont; Icon.hasIcon = hasIcon; + Icon.getRawGlyphMap = getRawGlyphMap; return Icon; } From 2316aba1b7e51841bbaaa8f5d442f51ae28b7523 Mon Sep 17 00:00:00 2001 From: John Kokkinidis Date: Tue, 3 Jul 2018 22:37:17 +0300 Subject: [PATCH 2/4] Now exposing font family with getFontFamily --- lib/create-icon-set.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/create-icon-set.js b/lib/create-icon-set.js index 8dba9fce3..ea8e4bc41 100644 --- a/lib/create-icon-set.js +++ b/lib/create-icon-set.js @@ -167,6 +167,10 @@ export default function createIconSet(glyphMap, fontFamily, fontFile) { return glyphMap; } + function getFontFamily() { + return fontReference; + } + Icon.Button = createIconButtonComponent(Icon); Icon.TabBarItem = createTabBarItemIOSComponent( IconNamePropType, @@ -181,6 +185,7 @@ export default function createIconSet(glyphMap, fontFamily, fontFile) { Icon.loadFont = loadFont; Icon.hasIcon = hasIcon; Icon.getRawGlyphMap = getRawGlyphMap; + Icon.getFontFamily = getFontFamily; return Icon; } From cc0bbf5eb13fd60054caa49192cb626e59ffc821 Mon Sep 17 00:00:00 2001 From: Ioannis Kokkinidis Date: Fri, 20 Jul 2018 16:49:28 +0300 Subject: [PATCH 3/4] Exposed Icon methods to README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 92d53887d..ad14d9fd9 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,15 @@ Any [Text property](http://facebook.github.io/react-native/docs/text.html) and t You can use `Icon.hasIcon(name)` to check if the name is valid in current icon set. + +### Methods + +| Prop | Description | Default | +|---|---|---| +|**`getRawGlyphMap`**|(Advanced Usage) Get's the raw glyph map of the icon set. Usage: `const glyphMap = Icon.getRawGlyphMap()` |*None*| +|**`getFontFamily`**|(Advanced Usage) Get's the font family that is currently used to retrieve icons as text. Usage: `const fontFamily = Icon. getFontFamily()`|*None*| + + ### Styling Since `Icon` builds on top of the `Text` component, most [style properties](http://facebook.github.io/react-native/docs/style.html) will work as expected, you might find it useful to play around with these: From c426eadc6b465707ce96af461c452a37cc7d8fa4 Mon Sep 17 00:00:00 2001 From: Joel Arvidsson Date: Tue, 24 Jul 2018 10:24:17 +0200 Subject: [PATCH 4/4] Fix typo, formatting and add more methods to Static Methods --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ad14d9fd9..9d4f56869 100644 --- a/README.md +++ b/README.md @@ -217,16 +217,14 @@ Any [Text property](http://facebook.github.io/react-native/docs/text.html) and t |**`name`**|What icon to show, see Icon Explorer app or one of the links above. |*None*| |**`color`**|Color of the icon. |*Inherited*| -You can use `Icon.hasIcon(name)` to check if the name is valid in current icon set. - - -### Methods - -| Prop | Description | Default | -|---|---|---| -|**`getRawGlyphMap`**|(Advanced Usage) Get's the raw glyph map of the icon set. Usage: `const glyphMap = Icon.getRawGlyphMap()` |*None*| -|**`getFontFamily`**|(Advanced Usage) Get's the font family that is currently used to retrieve icons as text. Usage: `const fontFamily = Icon. getFontFamily()`|*None*| - +### Static Methods + +| Prop | Description | +|---|---| +|**`getFontFamily`**|Returns the font family that is currently used to retrieve icons as text. Usage: `const fontFamily = Icon.getFontFamily()`| +|**`getImageSource`**|Returns a promise that resolving to the source of a bitmap version of the icon for use with `Image` component et al. Usage: `const source = await Icon.getImageSource(name, size, color)`| +|**`getRawGlyphMap`**|Returns the raw glyph map of the icon set. Usage: `const glyphMap = Icon.getRawGlyphMap()` | +|**`hasIcon`**|Checks if the name is valid in current icon set. Usage: `const isNameValid = Icon.hasIcon(name)`| ### Styling Since `Icon` builds on top of the `Text` component, most [style properties](http://facebook.github.io/react-native/docs/style.html) will work as expected, you might find it useful to play around with these: