@eohjsc/react-native-smart-city 0.7.48 → 0.7.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
2
3
|
import ImagePickerCrop from 'react-native-image-crop-picker';
|
|
3
4
|
import { RESULTS } from 'react-native-permissions';
|
|
4
5
|
|
|
@@ -28,25 +29,24 @@ const ImagePicker = ({
|
|
|
28
29
|
compressImageMaxHeight: 720,
|
|
29
30
|
compressImageQuality: 0.8,
|
|
30
31
|
};
|
|
31
|
-
permitPermissionFunction(keyPermission.CAMERA
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
32
|
+
const result = await permitPermissionFunction(keyPermission.CAMERA);
|
|
33
|
+
if (result === RESULTS.GRANTED) {
|
|
34
|
+
await ImagePickerCrop.openCamera(options)
|
|
35
|
+
.then((response) => {
|
|
36
|
+
setImageUrl(response);
|
|
37
|
+
setShowImagePicker(false);
|
|
38
|
+
})
|
|
39
|
+
.catch((e) => {
|
|
40
|
+
/* eslint-disable no-console */
|
|
41
|
+
console.log('ERROR ' + e);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (result === RESULTS.BLOCKED) {
|
|
45
|
+
OpenSetting(
|
|
46
|
+
t('camera_request_permission'),
|
|
47
|
+
t('camera_request_permission_des')
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
50
|
},
|
|
51
51
|
[optionsCapture, setImageUrl, setShowImagePicker, t]
|
|
52
52
|
);
|
|
@@ -61,25 +61,27 @@ const ImagePicker = ({
|
|
|
61
61
|
compressImageMaxHeight: 720,
|
|
62
62
|
compressImageQuality: 0.8,
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
let result = RESULTS.GRANTED;
|
|
65
|
+
if (Platform.OS === 'ios') {
|
|
66
|
+
result = await permitPermissionFunction(keyPermission.SELECT_PHOTO);
|
|
67
|
+
}
|
|
68
|
+
if (result === RESULTS.GRANTED || result === RESULTS.LIMITED) {
|
|
69
|
+
await ImagePickerCrop.openPicker(options)
|
|
70
|
+
.then((response) => {
|
|
71
|
+
setImageUrl(response);
|
|
72
|
+
setShowImagePicker(false);
|
|
73
|
+
})
|
|
74
|
+
.catch((e) => {
|
|
75
|
+
/* eslint-disable no-console */
|
|
76
|
+
console.log('ERROR ' + e);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (result === RESULTS.BLOCKED) {
|
|
80
|
+
OpenSetting(
|
|
81
|
+
t('photo_request_permission'),
|
|
82
|
+
t('photo_request_permission_des')
|
|
83
|
+
);
|
|
84
|
+
}
|
|
83
85
|
},
|
|
84
86
|
[optionsSelect, setImageUrl, setShowImagePicker, t]
|
|
85
87
|
);
|
|
@@ -30,22 +30,18 @@ export const OpenSetting = async (alertTitle, alertMessage) => {
|
|
|
30
30
|
]);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export const permitPermissionFunction = (keyPermission
|
|
33
|
+
export const permitPermissionFunction = async (keyPermission) => {
|
|
34
34
|
if (keyPermission) {
|
|
35
|
-
check(keyPermission)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
default:
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
35
|
+
const result = await check(keyPermission);
|
|
36
|
+
switch (result) {
|
|
37
|
+
case RESULTS.DENIED:
|
|
38
|
+
case RESULTS.LIMITED:
|
|
39
|
+
return await request(keyPermission);
|
|
40
|
+
case RESULTS.UNAVAILABLE:
|
|
41
|
+
case RESULTS.BLOCKED:
|
|
42
|
+
case RESULTS.GRANTED:
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
49
45
|
}
|
|
50
46
|
};
|
|
51
47
|
|