Created
March 6, 2017 19:53
-
-
Save michaelnagy/55043364774eb72ada2db98cdd63c6c6 to your computer and use it in GitHub Desktop.
This file contains 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
var ImagePicker = require('react-native-image-picker'); | |
// More info on all the options is below in the README...just some common use cases shown here | |
var options = { | |
title: 'Alterar Perfil', | |
cancelButtonTitle:'Cancelar', | |
takePhotoButtonTitle:'Tirar foto', | |
chooseFromLibraryButtonTitle:'Escolher foto', | |
storageOptions: { | |
skipBackup: true | |
} | |
}; | |
/** | |
* The first arg is the options object for customization (it can also be null or omitted for default options), | |
* The second arg is the callback which sends object: response (more info below in README) | |
*/ | |
() ImagePicker.showImagePicker(options, (response) => { | |
console.log('Response = ', response); | |
if (response.didCancel) { | |
console.log('User cancelled image picker'); | |
} | |
else if (response.error) { | |
console.log('ImagePicker Error: ', response.error); | |
} | |
else if (response.customButton) { | |
console.log('User tapped custom button: ', response.customButton); | |
} | |
else { | |
let source = { uri: response.uri }; | |
// You can also display the image using data: | |
// let source = { uri: 'data:image/jpeg;base64,' + response.data }; | |
this.setState({ | |
avatarSource: source | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment