aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/camera/GalleryIcon.tsx4
-rw-r--r--src/screens/moments/CameraScreen.tsx14
-rw-r--r--src/utils/camera.ts16
3 files changed, 22 insertions, 12 deletions
diff --git a/src/components/camera/GalleryIcon.tsx b/src/components/camera/GalleryIcon.tsx
index 8d396550..ca2d2559 100644
--- a/src/components/camera/GalleryIcon.tsx
+++ b/src/components/camera/GalleryIcon.tsx
@@ -1,12 +1,12 @@
import React from 'react';
import {Image, Text, TouchableOpacity, View} from 'react-native';
import {navigateToImagePicker} from '../../utils/camera';
-import {Image as ImageType} from 'react-native-image-crop-picker';
+import {ImageOrVideo} from 'react-native-image-crop-picker';
import {styles} from './styles';
interface GalleryIconProps {
mostRecentPhotoUri: string;
- callback: (pic: ImageType) => void;
+ callback: (media: ImageOrVideo) => void;
}
/*
diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx
index 0f2e3b5d..c759e5db 100644
--- a/src/screens/moments/CameraScreen.tsx
+++ b/src/screens/moments/CameraScreen.tsx
@@ -129,7 +129,6 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
onPressOut={async () => {
if (await cameraRef.current?.isRecording()) {
cameraRef.current?.stopRecording();
- } else {
}
}}
onPress={() => {
@@ -155,15 +154,20 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
) : (
<GalleryIcon
mostRecentPhotoUri={mostRecentPhoto}
- callback={(pic) => {
- const filename = pic.filename;
+ callback={(media) => {
+ const filename = media.filename;
if (
filename &&
(filename.endsWith('gif') || filename.endsWith('GIF'))
) {
- showGIFFailureAlert(() => navigateToCropper(pic.path));
+ showGIFFailureAlert(() => navigateToCropper(media.path));
} else {
- navigateToCropper(pic.path);
+ // is this a video?
+ if (media.duration !== null) {
+ navigateToCaptionScreen(true, media.path);
+ } else {
+ navigateToCropper(media.path);
+ }
}
}}
/>
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') {