1 | import * as Font from "expo-font";
|
2 | import React from "react";
|
3 | import { Text } from "react-native";
|
4 | import createIconSet from "./vendor/react-native-vector-icons/lib/create-icon-set";
|
5 | import createIconButtonComponent from "./vendor/react-native-vector-icons/lib/icon-button";
|
6 | export { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from "./vendor/react-native-vector-icons/lib/create-icon-set";
|
7 | export default function (glyphMap, fontName, expoAssetId, fontStyle) {
|
8 | var _a;
|
9 | const font = { [fontName]: expoAssetId };
|
10 | const RNVIconComponent = createIconSet(glyphMap, fontName, null, fontStyle);
|
11 | return _a = class Icon extends React.Component {
|
12 | constructor() {
|
13 | super(...arguments);
|
14 | this._mounted = false;
|
15 | this.state = {
|
16 | fontIsLoaded: Font.isLoaded(fontName)
|
17 | };
|
18 | }
|
19 | async componentDidMount() {
|
20 | this._mounted = true;
|
21 | if (!this.state.fontIsLoaded) {
|
22 | await Font.loadAsync(font);
|
23 | this._mounted && this.setState({ fontIsLoaded: true });
|
24 | }
|
25 | }
|
26 | componentWillUnmount() {
|
27 | this._mounted = false;
|
28 | }
|
29 | setNativeProps(props) {
|
30 | if (this._icon) {
|
31 | this._icon.setNativeProps(props);
|
32 | }
|
33 | }
|
34 | render() {
|
35 | if (!this.state.fontIsLoaded) {
|
36 | return <Text />;
|
37 | }
|
38 | return (<RNVIconComponent ref={view => {
|
39 | this._icon = view;
|
40 | }} {...this.props}/>);
|
41 | }
|
42 | },
|
43 | _a.propTypes = RNVIconComponent.propTypes,
|
44 | _a.defaultProps = RNVIconComponent.defaultProps,
|
45 | _a.Button = createIconButtonComponent(_a),
|
46 | _a.glyphMap = glyphMap,
|
47 | _a.getRawGlyphMap = () => glyphMap,
|
48 | _a.getFontFamily = () => fontName,
|
49 | _a.loadFont = () => Font.loadAsync(font),
|
50 | _a.font = font,
|
51 | _a;
|
52 | }
|
53 | //# sourceMappingURL=createIconSet.js.map |
\ | No newline at end of file |