Skip to content

Commit 6c447dd

Browse files
authored
fix: make takePhoto native handler compatible with latest expo versions (#2029)
1 parent 6794f62 commit 6c447dd

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

package/expo-package/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"expo-file-system": "*",
2020
"expo-haptics": "*",
2121
"expo-image-manipulator": "*",
22-
"expo-image-picker": "*",
22+
"expo-image-picker": ">=14.1.0",
2323
"expo-media-library": "*",
2424
"expo-sharing": "*"
2525
},
@@ -32,7 +32,7 @@
3232
"expo-file-system": "^11.0.2",
3333
"expo-haptics": "^10.0.0",
3434
"expo-image-manipulator": "^9.1.0",
35-
"expo-image-picker": "^10.1.4",
35+
"expo-image-picker": "14.1.1",
3636
"expo-media-library": "^12.0.2",
3737
"expo-sharing": "^9.1.2"
3838
},

package/expo-package/src/handlers/takePhoto.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ export const takePhoto = async ({ compressImageQuality = 1 }) => {
1616
: await ImagePicker.requestCameraPermissionsAsync();
1717

1818
if (permissionGranted?.status === 'granted' || permissionGranted?.granted === true) {
19-
const photo = await ImagePicker.launchCameraAsync({
19+
const imagePickerSuccessResult = await ImagePicker.launchCameraAsync({
2020
quality: Math.min(Math.max(0, compressImageQuality), 1),
2121
});
22+
const canceled = imagePickerSuccessResult.canceled;
23+
const assets = imagePickerSuccessResult.assets;
24+
// since we only support single photo upload for now we will only be focusing on 0'th element.
25+
const photo = assets && assets[0];
2226

23-
if (photo.cancelled === false && photo.height && photo.width && photo.uri) {
27+
if (canceled === false && photo && photo.height && photo.width && photo.uri) {
2428
let size: Size = {};
2529
if (Platform.OS === 'android') {
2630
// Height and width returned by ImagePicker are incorrect on Android.

package/expo-package/yarn.lock

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,21 +1874,24 @@ expo-haptics@^10.0.0:
18741874
resolved "https://registry.yarnpkg.com/expo-haptics/-/expo-haptics-10.1.0.tgz#2ef5f0c3442f57844f7a7a961d922872e4ea9a71"
18751875
integrity sha512-2rpixkP3LSCwaJAmbbs0CSqbY7lSk7Ytay4UAYWg3YiJ05My7+MGMPbQJARyAMI5JQNuzcdsZN74btSusBvgYQ==
18761876

1877+
expo-image-loader@~4.1.0:
1878+
version "4.1.1"
1879+
resolved "https://registry.yarnpkg.com/expo-image-loader/-/expo-image-loader-4.1.1.tgz#efadbb17de1861106864820194900f336dd641b6"
1880+
integrity sha512-ciEHVokU0f6w0eTxdRxLCio6tskMsjxWIoV92+/ZD37qePUJYMfEphPhu1sruyvMBNR8/j5iyOvPFVGTfO8oxA==
1881+
18771882
expo-image-manipulator@^9.1.0:
18781883
version "9.2.2"
18791884
resolved "https://registry.yarnpkg.com/expo-image-manipulator/-/expo-image-manipulator-9.2.2.tgz#0fc7d2032972961c0a5fb49511d230fe0788fa6f"
18801885
integrity sha512-rnwUpLmySEhclES+632/vl4cBQyjWE16PdR003WxvN/YBynTlYIi7If2FZRFt5lktX0Rz988XVE89EavHPn2ug==
18811886
dependencies:
18821887
expo-modules-core "~0.2.0"
18831888

1884-
expo-image-picker@^10.1.4:
1885-
version "10.2.3"
1886-
resolved "https://registry.yarnpkg.com/expo-image-picker/-/expo-image-picker-10.2.3.tgz#204c83ba0731f2ccdbc42e13f9bf6e37be21c354"
1887-
integrity sha512-8VXLYjclXoQJHbdNLI21rdbnxFisBpZ6TgIifHf9kZ/momFBegUNqEKCjosvxVGVM8f7qaQxJV/znNtW0rDM/w==
1889+
expo-image-picker@14.1.1:
1890+
version "14.1.1"
1891+
resolved "https://registry.yarnpkg.com/expo-image-picker/-/expo-image-picker-14.1.1.tgz#181f1348ba6a43df7b87cee4a601d45c79b7c2d7"
1892+
integrity sha512-SvWtnkLW7jp5Ntvk3lVcRQmhFYja8psmiR7O6P/+7S6f4llt3vaFwb4I3+pUXqJxxpi7BHc2+95qOLf0SFOIag==
18881893
dependencies:
1889-
"@expo/config-plugins" "^3.0.0"
1890-
expo-modules-core "~0.2.0"
1891-
uuid "7.0.2"
1894+
expo-image-loader "~4.1.0"
18921895

18931896
expo-keep-awake@~10.0.2:
18941897
version "10.0.2"
@@ -3175,11 +3178,6 @@ util@^0.10.3:
31753178
dependencies:
31763179
inherits "2.0.3"
31773180

3178-
3179-
version "7.0.2"
3180-
resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.2.tgz#7ff5c203467e91f5e0d85cfcbaaf7d2ebbca9be6"
3181-
integrity sha512-vy9V/+pKG+5ZTYKf+VcphF5Oc6EFiu3W8Nv3P3zIh0EqVI80ZxOzuPfe9EHjkFNvf8+xuTHVeei4Drydlx4zjw==
3182-
31833181
uuid@^3.3.2, uuid@^3.4.0:
31843182
version "3.4.0"
31853183
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"

0 commit comments

Comments
 (0)