diff --git a/createIconSet.js b/createIconSet.js index 27c2599..3043f80 100644 --- a/createIconSet.js +++ b/createIconSet.js @@ -2,15 +2,16 @@ import React from 'react'; import { View } from 'react-native'; import { Font } from 'exponent'; import createIconSet from 'react-native-vector-icons/lib/create-icon-set'; +import createIconButtonComponent from 'react-native-vector-icons/lib/icon-button'; export default function(glyphMap, fontName, exponentAssetId) { const exponentFontName = Font.style(fontName, {ignoreWarning: true}).fontFamily; - const fontId = {[fontName]: exponentAssetId}; - let OriginalIcon = createIconSet(glyphMap, exponentFontName, 'n/a'); + const font = {[fontName]: exponentAssetId}; + const RNVIconComponent = createIconSet(glyphMap, exponentFontName, 'n/a'); class Icon extends React.Component { - static propTypes = OriginalIcon.propTypes; - static defaultProps = OriginalIcon.defaultProps; + static propTypes = RNVIconComponent.propTypes; + static defaultProps = RNVIconComponent.defaultProps; state = { fontIsLoaded: Font.isLoaded(fontName), @@ -18,7 +19,7 @@ export default function(glyphMap, fontName, exponentAssetId) { async componentWillMount() { if (!this.state.fontIsLoaded) { - await Font.loadAsync(fontId); + await Font.loadAsync(font); this.setState({fontIsLoaded: true}); } } @@ -35,7 +36,7 @@ export default function(glyphMap, fontName, exponentAssetId) { } return ( - { this._icon = view; }} {...this.props} /> @@ -43,5 +44,9 @@ export default function(glyphMap, fontName, exponentAssetId) { } } + Icon.Button = createIconButtonComponent(Icon); + Icon.glyphMap = glyphMap; + Icon.font = font; + return Icon; }