openFilePicker = () => {
ImagePicker.openPicker({
width: 500,
height: 500,
cropping: true,
}).then(image => {
console.log(image);
let source = {uri: image.path};
this.setState(
{
showNewImage: 1,
newProfileImg: source,
newProfileImgPath: image.path,
},
() => {
console.log(this.state.newProfileImgPath);
console.log(this.state.newProfileImg);
console.log(this.state.showNewImage);
},
);
});
};
<TouchableOpacity onPress={() => this.openFilePicker()}>
{this.state.showNewImage == 0 ? (
<Image
source={HelperConstant.profileImage}
style={styles.ProfileImg}
/>
) : (
<Image
source={{uri: this.state.newProfileImgPath}}
style={styles.ProfileImg}
/>
)}
<Icon
name="plus-circle"
size={25}
color={'blue'}
style={{
alignSelf: 'flex-end',
marginTop: -25,
marginRight: 10,
}}
/>
</TouchableOpacity>
No comments:
Post a Comment