mirror of
https://github.com/zoriya/expo-vector-icons.git
synced 2026-06-05 02:59:16 +00:00
Initial commit
fbshipit-source-id: 21ada2db87c55eb346aa4da5b67d25cb1c8fd081
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
import { View } from 'react-native';
|
||||
import { Font } from 'exponent';
|
||||
import createIconSet from 'react-native-vector-icons/lib/create-icon-set';
|
||||
|
||||
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');
|
||||
|
||||
class Icon extends React.Component {
|
||||
static propTypes = OriginalIcon.propTypes;
|
||||
static defaultProps = OriginalIcon.defaultProps;
|
||||
|
||||
state = {
|
||||
fontIsLoaded: Font.isLoaded(fontName),
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
if (!this.state.fontIsLoaded) {
|
||||
await Font.loadAsync(fontId);
|
||||
this.setState({fontIsLoaded: true});
|
||||
}
|
||||
}
|
||||
|
||||
setNativeProps(props) {
|
||||
if (this._icon) {
|
||||
this._icon.setNativeProps(props);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.state.fontIsLoaded) {
|
||||
return <View />;
|
||||
}
|
||||
|
||||
return (
|
||||
<OriginalIcon
|
||||
ref={view => { this._icon = view; }}
|
||||
{...this.props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Icon;
|
||||
}
|
||||
Reference in New Issue
Block a user