2018-07-10 13:40:32 +00:00
|
|
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
2019-01-29 19:52:56 +00:00
|
|
|
import { isIOS } from './utils/deviceInfo';
|
2018-07-10 13:40:32 +00:00
|
|
|
|
|
|
|
const prefix = isIOS ? 'ios' : 'md';
|
|
|
|
|
|
|
|
// icon name from provider: [ size of the uri, icon provider, name to be used later ]
|
|
|
|
const icons = {
|
2018-10-18 17:56:15 +00:00
|
|
|
[`${ prefix }-star`]: [25, Ionicons, 'star'],
|
|
|
|
[`${ prefix }-star-outline`]: [25, Ionicons, 'starOutline'],
|
|
|
|
[`${ prefix }-more`]: [25, Ionicons, 'more'],
|
2018-10-23 21:39:48 +00:00
|
|
|
[isIOS ? 'ios-create' : 'md-create']: [25, Ionicons, 'create'],
|
|
|
|
[`${ prefix }-close`]: [25, Ionicons, 'close']
|
2018-07-10 13:40:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const iconsMap = {};
|
|
|
|
const iconsLoaded = async() => {
|
|
|
|
const promises = Object.keys(icons).map((icon) => {
|
|
|
|
const Provider = icons[icon][1];
|
2018-10-23 21:39:48 +00:00
|
|
|
return Provider.getImageSource(icon, icons[icon][0], '#FFF');
|
2018-07-10 13:40:32 +00:00
|
|
|
});
|
|
|
|
const sources = await Promise.all(promises);
|
|
|
|
Object.keys(icons).forEach((icon, i) => (iconsMap[icons[icon][2]] = sources[i]));
|
|
|
|
};
|
|
|
|
|
|
|
|
export { iconsLoaded, iconsMap };
|