2018-07-10 13:40:32 +00:00
|
|
|
import { Platform } from 'react-native';
|
|
|
|
import Ionicons from 'react-native-vector-icons/Ionicons';
|
|
|
|
|
|
|
|
const isIOS = Platform.OS === 'ios';
|
|
|
|
const prefix = isIOS ? 'ios' : 'md';
|
|
|
|
|
|
|
|
// icon name from provider: [ size of the uri, icon provider, name to be used later ]
|
|
|
|
const icons = {
|
|
|
|
[`${ prefix }-search`]: [30, Ionicons, 'search'],
|
|
|
|
[`${ prefix }-menu`]: [30, Ionicons, 'menu'],
|
|
|
|
[`${ prefix }-star`]: [30, Ionicons, 'star'],
|
|
|
|
[`${ prefix }-star-outline`]: [30, Ionicons, 'starOutline'],
|
2018-08-10 17:26:36 +00:00
|
|
|
[isIOS ? 'ios-create' : 'md-create']: [30, Ionicons, 'create'],
|
2018-07-10 13:40:32 +00:00
|
|
|
[`${ prefix }-more`]: [30, Ionicons, 'more'],
|
2018-08-10 17:26:36 +00:00
|
|
|
[`${ prefix }-add`]: [30, Ionicons, 'add'],
|
|
|
|
[`${ prefix }-close`]: [30, 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];
|
|
|
|
return Provider.getImageSource(icon, icons[icon][0]);
|
|
|
|
});
|
|
|
|
const sources = await Promise.all(promises);
|
|
|
|
Object.keys(icons).forEach((icon, i) => (iconsMap[icons[icon][2]] = sources[i]));
|
|
|
|
};
|
|
|
|
|
|
|
|
export { iconsLoaded, iconsMap };
|