Export the button component

fbshipit-source-id: cf0b223
This commit is contained in:
Brent Vatne
2016-07-10 03:27:59 +00:00
committed by Exponent GitHub Bot
parent 6bd475399a
commit 5f91b3f62d
+11 -6
View File
@@ -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 (
<OriginalIcon
<RNVIconComponent
ref={view => { 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;
}