Update mobileapp.txt
Browse files- mobileapp.txt +20 -8
mobileapp.txt
CHANGED
@@ -1,18 +1,30 @@
|
|
1 |
-
import React, { useState } from 'react';
|
2 |
import { View, Image, TouchableOpacity, Text } from 'react-native';
|
3 |
-
import ImagePicker from '
|
4 |
import { ImageEditor } from 'react-native';
|
5 |
|
6 |
const CropImage = () => {
|
7 |
const [croppedImage, setCroppedImage] = useState(null); // State to store the cropped image URI
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
});
|
|
|
|
|
|
|
|
|
16 |
};
|
17 |
|
18 |
const cropImage = (imageUri) => {
|
|
|
1 |
+
import React, { useState, useEffect } from 'react';
|
2 |
import { View, Image, TouchableOpacity, Text } from 'react-native';
|
3 |
+
import * as ImagePicker from 'expo-image-picker';
|
4 |
import { ImageEditor } from 'react-native';
|
5 |
|
6 |
const CropImage = () => {
|
7 |
const [croppedImage, setCroppedImage] = useState(null); // State to store the cropped image URI
|
8 |
|
9 |
+
useEffect(() => {
|
10 |
+
getPermission();
|
11 |
+
}, []);
|
12 |
+
|
13 |
+
const getPermission = async () => {
|
14 |
+
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
15 |
+
if (status !== 'granted') {
|
16 |
+
alert('Permission denied!');
|
17 |
+
}
|
18 |
+
};
|
19 |
+
|
20 |
+
const handleSelectImage = async () => {
|
21 |
+
let result = await ImagePicker.launchImageLibraryAsync({
|
22 |
+
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
23 |
});
|
24 |
+
|
25 |
+
if (!result.cancelled) {
|
26 |
+
cropImage(result.uri);
|
27 |
+
}
|
28 |
};
|
29 |
|
30 |
const cropImage = (imageUri) => {
|