react-native-image-picker
Advanced tools
Comparing version 0.6.1 to 0.7.0
@@ -30,3 +30,3 @@ import React from 'react-native'; | ||
chooseFromLibraryButtonHidden: false, | ||
returnBase64Image: true, | ||
returnBase64Image: false, | ||
returnIsVertical: false, | ||
@@ -36,6 +36,13 @@ quality: 0.2 | ||
UIImagePickerManager.showImagePicker(options, (type, response) => { | ||
console.log(type); | ||
if (type !== 'cancel') { | ||
const source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true}; | ||
UIImagePickerManager.showImagePicker(options, (responseType, response) => { | ||
console.log(`Response Type = ${responseType}`); | ||
if (responseType !== 'cancel') { | ||
let source; | ||
if (responseType === 'data') { // New photo taken OR passed returnBase64Image true - response is the 64 bit encoded image data string | ||
source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true}; | ||
} else { // Selected from library - response is the URI to the local file asset | ||
source = {uri: response.replace('file://', ''), isStatic: true}; | ||
} | ||
this.setState({ | ||
@@ -42,0 +49,0 @@ avatarSource: source |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "A React Native module that allows you to use the native UIImagePickerController UI to select a photo from the device library or directly from the camera.", | ||
@@ -10,0 +10,0 @@ "author": "Marc Shilling (marcshilling)", |
@@ -5,2 +5,4 @@ # react-native-image-picker | ||
**Requires iOS 8 or higher** | ||
## Install | ||
@@ -44,15 +46,19 @@ 1. `npm install react-native-image-picker@latest --save` | ||
// The first arg will be the options object for customization, the second is | ||
// your callback which sends string: type, string: response | ||
UIImagePickerManager.showImagePicker(options, (type, response) => { | ||
if (type !== 'cancel') { | ||
var source; | ||
if (type === 'data') { // New photo taken OR passed returnBase64Image true - response is the 64 bit encoded image data string | ||
// your callback which sends string: responseType, string: response. | ||
// responseType will be either 'cancel', 'data', 'uri', or one of your custom button values | ||
UIImagePickerManager.showImagePicker(options, (responseType, response) => { | ||
console.log(`Response Type = ${responseType}`); | ||
if (responseType !== 'cancel') { | ||
let source; | ||
if (responseType === 'data') { // New photo taken OR passed returnBase64Image true - response is the 64 bit encoded image data string | ||
source = {uri: 'data:image/jpeg;base64,' + response, isStatic: true}; | ||
} else { // Selected from library - response is the URI to the local file asset | ||
source = {uri: response}; | ||
} | ||
else if (responseType === 'uri') { // Selected from library - response is the URI to the local file asset | ||
source = {uri: response.replace('file://', ''), isStatic: true}; | ||
} | ||
this.setState({avatarSource:source}); | ||
} else { | ||
console.log('Cancel'); | ||
this.setState({ | ||
avatarSource: source | ||
}); | ||
} | ||
@@ -59,0 +65,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
97622
115
69