aboutsummaryrefslogtreecommitdiff
path: root/src/screens/moments/CameraScreen.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-07-30 11:31:32 -0400
committerGitHub <noreply@github.com>2021-07-30 11:31:32 -0400
commit452f3fb44838c367f40e8aa57db2e274a357afd2 (patch)
tree4a3487413b8773f120271380e5c2902dadf690d8 /src/screens/moments/CameraScreen.tsx
parenteabc3c82f0ac2ffa2dfb26ee7bc792fd6a48491a (diff)
parente50a0321d73df5169b79dded7a57cfa3a9b62adc (diff)
Merge pull request #539 from IvanIFChen/tma1035-bugfix-camera-timer-animation
[TMA-1035] [BUGFIX] Record Video Animation Issues
Diffstat (limited to 'src/screens/moments/CameraScreen.tsx')
-rw-r--r--src/screens/moments/CameraScreen.tsx27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx
index 40db1191..07b697d0 100644
--- a/src/screens/moments/CameraScreen.tsx
+++ b/src/screens/moments/CameraScreen.tsx
@@ -9,7 +9,7 @@ import {CameraType, FlashMode, RNCamera} from 'react-native-camera';
import {AnimatedCircularProgress} from 'react-native-circular-progress';
import CloseIcon from '../../assets/ionicons/close-outline.svg';
import {FlashButton, FlipButton, GalleryIcon} from '../../components';
-import {TAGG_PURPLE} from '../../constants';
+import {MAX_VIDEO_RECORDING_DURATION, TAGG_PURPLE} from '../../constants';
import {MainStackParams} from '../../routes';
import {HeaderHeight, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils';
import {showGIFFailureAlert, takePicture, takeVideo} from '../../utils/camera';
@@ -37,6 +37,7 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
navigation.dangerouslyGetParent()?.setOptions({
tabBarVisible: false,
});
+ return () => setIsRecording(false);
}, [navigation]),
);
@@ -120,10 +121,24 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
setIsRecording(true);
}}
onPressOut={async () => {
- if (await cameraRef.current?.isRecording()) {
- cameraRef.current?.stopRecording();
- setIsRecording(false);
- }
+ const cancelRecording = async () => {
+ if (await cameraRef.current?.isRecording()) {
+ cameraRef.current?.stopRecording();
+ setIsRecording(false);
+ }
+ };
+ cancelRecording();
+ // tmp fix for when the animation glitches during the beginning of
+ // recording causing onPressOut to not be detected.
+ setTimeout(() => {
+ cancelRecording();
+ }, 500);
+ setTimeout(() => {
+ cancelRecording();
+ }, 1000);
+ setTimeout(() => {
+ cancelRecording();
+ }, 1500);
}}
onPress={() => {
takePicture(cameraRef, (pic) => navigateToEditMedia(pic.uri));
@@ -136,7 +151,7 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => {
width={6}
fill={100}
rotation={0}
- duration={60000 + 1000} // an extra second for UI to load
+ duration={(MAX_VIDEO_RECORDING_DURATION + 1) * 1000} // an extra second for UI to load
tintColor={TAGG_PURPLE}
style={styles.bottomContainer}
lineCap={'round'}