diff options
author | Ivan Chen <ivan@tagg.id> | 2021-08-06 19:13:50 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-08-06 19:13:50 -0400 |
commit | 54ca15a4d68d107be767938a83612843db2d04c2 (patch) | |
tree | eaa05be635a1bc4f9e717e4fef27bc69466bce93 /src/screens/moments/CameraScreen.tsx | |
parent | 3de50e21aa5daf3106d93cf1ac024adc7918ee1f (diff) |
Add pause preview, Cleanup logics
Diffstat (limited to 'src/screens/moments/CameraScreen.tsx')
-rw-r--r-- | src/screens/moments/CameraScreen.tsx | 34 |
1 files changed, 10 insertions, 24 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> |