diff --git a/App.js b/App.js
index 8de881a..2a79130 100644
--- a/App.js
+++ b/App.js
@@ -184,9 +184,7 @@ export default class App extends Component {
handlerColor="rgba(20,150,160, 1)"
enablePanStrict={false}
/>
-
- CROP IMAGE
-
+
)
}
diff --git a/ImageCrop.js b/ImageCrop.js
new file mode 100644
index 0000000..b1d79f7
--- /dev/null
+++ b/ImageCrop.js
@@ -0,0 +1,96 @@
+
+
+import CustomCrop from "react-native-perspective-image-cropper";
+import ImagePicker from 'react-native-image-picker'
+
+class App extends Component {
+
+ constructor(props) {
+ super(props)
+
+ this.state = {
+ image: null,
+ path: '',
+ rectangleCoordinates: {
+ topLeft: { x: 50, y: 50 },
+ topRight: { x: 50, y: 50 },
+ bottomRight: { x: 50, y: 50 },
+ bottomLeft: { x: 50, y: 50 }
+ }
+ }
+ }
+
+ componentDidMount() {
+
+ const imagePickerOptions = {
+ title: 'Selectionner une image',
+ takePhotoButtonTitle: 'Prendre une photo',
+ chooseFromLibraryButtonTitle: 'Choisir de la librairie',
+ cancelButtonTitle: 'Annuler',
+ noData: true,
+ mediaType: 'photo'
+ }
+
+
+ ImagePicker.launchCamera(imagePickerOptions, 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.camera);
+
+ else {
+
+ const path = Platform.OS === 'android' ? response.path : response.uri //try without file://
+
+ this.setState({
+ path,
+ imageWidth: response.width,
+ imageHeight: response.height,
+ image: response.uri,
+ })
+ }
+
+ })
+
+ }
+
+ updateImage(image, newCoordinates) {
+ image = `data:image/jpeg;base64,${image}`
+ Image.getSize(image, () => {
+
+ })
+ this.setState({
+ image,
+ rectangleCoordinates: newCoordinates
+ });
+ }
+
+ crop() {
+ this.customCrop.crop();
+ }
+
+ render() {
+ const { image, imageHeight, imageWidth, path } = this.state
+
+ if (!image || !imageWidth || !imageHeight || !path) return null
+
+ return (
+
+ (this.customCrop = ref)}
+ overlayColor="rgba(18,190,210, 1)"
+ overlayStrokeColor="rgba(20,190,210, 1)"
+ handlerColor="rgba(20,150,160, 1)"
+ enablePanStrict={false}
+ />
+
+ )
+ }
+}
+
diff --git a/android/build.gradle b/android/build.gradle
index a225ba1..d017ad3 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -3,7 +3,7 @@
buildscript {
ext {
buildToolsVersion = "29.0.2"
- minSdkVersion = 16
+ minSdkVersion = 19
compileSdkVersion = 29
targetSdkVersion = 29
}