diff options
author | Ivan Chen <ivan@tagg.id> | 2021-07-02 16:14:30 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-07-02 16:14:30 -0400 |
commit | f62eaec4f70ffaf1c5bf82a831acff542eec4957 (patch) | |
tree | 956c5fc2f9708be934c0db8d7699cee61d4086de /src/utils/camera.ts | |
parent | 80f52fa900817d614680a60f0c35592cf48310b0 (diff) |
Support picking video from gallery
Diffstat (limited to 'src/utils/camera.ts')
-rw-r--r-- | src/utils/camera.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/utils/camera.ts b/src/utils/camera.ts index 7fa18b7c..d178fe94 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -8,7 +8,11 @@ import { TakePictureOptions, TakePictureResponse, } from 'react-native-camera'; -import ImagePicker, {Image, Video} from 'react-native-image-crop-picker'; +import ImagePicker, { + Image, + ImageOrVideo, + Video, +} from 'react-native-image-crop-picker'; import {ERROR_UPLOAD} from '../constants/strings'; /* @@ -52,7 +56,9 @@ export const saveImageToGallery = (capturedImageURI: string) => { .catch((_err) => Alert.alert('Failed to save to device!')); }; -export const navigateToImagePicker = (callback: (pic: Image) => void) => { +export const navigateToImagePicker = ( + callback: (media: ImageOrVideo) => void, +) => { ImagePicker.openPicker({ smartAlbums: [ 'Favorites', @@ -61,10 +67,10 @@ export const navigateToImagePicker = (callback: (pic: Image) => void) => { 'Screenshots', 'UserLibrary', ], - mediaType: 'photo', + mediaType: 'any', }) - .then((pic) => { - callback(pic); + .then((media) => { + callback(media); }) .catch((err) => { if (err.code && err.code !== 'E_PICKER_CANCELLED') { |