kfiroo / react-native-cached-image

CachedImage component for react-native
MIT License
940 stars 468 forks source link

Support styles for images with tintColor, resizeMode etc. #80

Open torbjorn-kvist opened 7 years ago

torbjorn-kvist commented 7 years ago

Solves #78

Using two modules from the react native core, to make a difference between a ViewStylePropTypes and ImageStylePropTypes.

This will break if React Native stops using @providesModule, ViewStylePropTypes and ImageStylePropTypes isn't exposed via 'react-native'.

kfiroo commented 7 years ago

@Dvidan Thanks so much for this Maybe we can use something like:

const ImageStylePropTypes = ReactNative.Image.propTypes.style;

Would that work? (sorry, I'm not able to test it right now) It would remove the coupling with @providesmodule

torbjorn-kvist commented 7 years ago

@kfiroo Will try and comeback and see if it works. Not able to try right away, its close to midnight in Sweden at the moment but will try in the morning :)

torbjorn-kvist commented 7 years ago

@kfiroo

ReactNative.Image.propTypes.style is a function and can't be used that way. An alternativ way is to use an list of excluded style props, there are three that are unique for Image at the moment.

_.omit(flattenStyle(style), ["resizeMode", "tintColor", "overlayColor"])