diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/screens/moments/CameraScreen.tsx | 34 | ||||
-rw-r--r-- | src/utils/camera.ts | 2 |
2 files changed, 11 insertions, 25 deletions
diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx index c86f2efe..bd94bf63 100644 --- a/src/screens/moments/CameraScreen.tsx +++ b/src/screens/moments/CameraScreen.tsx @@ -33,12 +33,13 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => { const [recordingStarted, setRecordingStarted] = useState<boolean>(false); const [showCaptureButtons, setShowCaptureButtons] = useState<boolean>(false); const [showCamera, setShowCamera] = useState<boolean>(true); + const [videoUri, setVideoUri] = useState<string | undefined>(); - const stopVideoRecording = async () => { - if (await cameraRef.current?.isRecording()) { - cameraRef.current?.stopRecording(); + useEffect(() => { + if (recordingStarted && videoUri) { + navigateToEditMedia(videoUri); } - }; + }, [videoUri]); useFocusEffect( useCallback(() => { @@ -138,28 +139,13 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => { : styles.captureButtonContainer } activeOpacity={1} - onLongPress={async () => { - await stopVideoRecording(); - takeVideo(cameraRef, (vid) => navigateToEditMedia(vid.uri)); - }} - onPressOut={async () => { + onLongPress={() => + takeVideo(cameraRef, (vid) => setVideoUri(vid.uri)) + } + onPressOut={() => cameraRef.current?.stopRecording()} + onPress={() => { setShowCaptureButtons(false); - if ( - recordingStarted && - (await cameraRef.current?.isRecording()) - ) { - cameraRef.current?.stopRecording(); - } else { - takePicture(cameraRef, (pic) => navigateToEditMedia(pic.uri)); - } - setRecordingStarted(false); - }} - onPress={async () => { - if (showCaptureButtons) { - setShowCaptureButtons(false); - } takePicture(cameraRef, (pic) => navigateToEditMedia(pic.uri)); - await stopVideoRecording(); }}> <View style={styles.captureButton} /> </TouchableOpacity> diff --git a/src/utils/camera.ts b/src/utils/camera.ts index ec2615de..5f02f653 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -24,11 +24,11 @@ export const takePicture = ( callback: (pic: TakePictureResponse) => void, ) => { if (cameraRef !== null) { + cameraRef.current?.pausePreview(); const options: TakePictureOptions = { forceUpOrientation: true, orientation: 'portrait', writeExif: false, - pauseAfterCapture: true, }; cameraRef.current?.takePictureAsync(options).then((pic) => { callback(pic); |