Created
August 2, 2021 04:18
-
-
Save dilipsuthar97/51bc81f0db63f385506240ea7c5bcc21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --------------- LIBRARIES --------------- | |
import React from 'react'; | |
import { View, StyleSheet, Image } from 'react-native'; | |
import FastImage from 'react-native-fast-image'; | |
// --------------- ASSETS --------------- | |
// --------------- COMPONENT --------------- | |
const MyFastImage = ({ | |
style, | |
placeholder, | |
source, | |
children, | |
placeHolderResizeMode, | |
placeholderStyle, | |
resizeMode, | |
onLoad, | |
imageStyle, | |
}) => { | |
return ( | |
<View style={[{ overflow: 'hidden' }, style]}> | |
<Image | |
source={placeholder} | |
style={[ | |
{ | |
height: '100%', | |
width: '100%', | |
...StyleSheet.absoluteFill, | |
}, | |
placeholderStyle, | |
]} | |
resizeMode={placeHolderResizeMode ?? 'cover'} | |
/> | |
<FastImage | |
style={ | |
imageStyle | |
? imageStyle | |
: { | |
height: '100%', | |
width: '100%', | |
justifyContent: 'center', | |
alignItems: 'center', | |
} | |
} | |
source={{ | |
uri: source ?? 'https://', | |
priority: FastImage.priority.normal, | |
headers: { | |
jwt: global.accesskey, | |
}, | |
}} | |
resizeMode={ | |
resizeMode == 'contain' | |
? FastImage.resizeMode.contain | |
: FastImage.resizeMode.cover | |
} | |
onLoad={onLoad}> | |
{children} | |
</FastImage> | |
</View> | |
); | |
}; | |
export default MyFastImage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment