Skip to content

Commit 07c6786

Browse files
committed
add functions to icon-images.js to look up an icon from an ios icon name
1 parent 34bf01e commit 07c6786

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

images/icon-images.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
// @flow
22

33
export const icons = {
4-
oldMain: require('./about/IconTrans.png'),
5-
windmill: require('../ios/AllAboutOlaf/windmill-icon/windmill.png'),
4+
oldMain: require('./about/IconTrans.png'),
5+
windmill: require('../ios/AllAboutOlaf/windmill-icon/windmill.png'),
6+
}
7+
8+
export const defaultIcon = icons.oldMain
9+
10+
// eslint-disable camelcase
11+
export const iosToNamedIconsMap: {[key: string]: $Keys<typeof icons>} = {
12+
icon_type_windmill: 'windmill',
13+
default: 'oldMain',
14+
}
15+
// eslint-enable camelcase
16+
17+
export function lookup(iosIconName: $Keys<typeof iosToNamedIconsMap>): number {
18+
const iconName = iosToNamedIconsMap[iosIconName]
19+
if (!iconName) {
20+
return defaultIcon
21+
}
22+
23+
const icon = icons[iconName]
24+
if (!icon) {
25+
return defaultIcon
26+
}
27+
28+
return icon
629
}

0 commit comments

Comments
 (0)