mirror of
https://github.com/zoriya/expo-vector-icons.git
synced 2026-06-06 20:02:30 +00:00
Export the button component
fbshipit-source-id: cf0b223
This commit is contained in:
committed by
Exponent GitHub Bot
parent
6bd475399a
commit
5f91b3f62d
+11
-6
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user