Skip to content

Instantly share code, notes, and snippets.

@michaelnagy
Created March 6, 2017 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelnagy/55043364774eb72ada2db98cdd63c6c6 to your computer and use it in GitHub Desktop.
Save michaelnagy/55043364774eb72ada2db98cdd63c6c6 to your computer and use it in GitHub Desktop.
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