diff options
Diffstat (limited to 'src/screens')
-rw-r--r-- | src/screens/main/NotificationsScreen.tsx | 4 | ||||
-rw-r--r-- | src/screens/moments/CameraScreen.tsx | 48 | ||||
-rw-r--r-- | src/screens/moments/TagFriendsScreen.tsx | 104 | ||||
-rw-r--r-- | src/screens/profile/CaptionScreen.tsx | 73 | ||||
-rw-r--r-- | src/screens/suggestedPeople/index.ts | 1 |
5 files changed, 97 insertions, 133 deletions
diff --git a/src/screens/main/NotificationsScreen.tsx b/src/screens/main/NotificationsScreen.tsx index b19107a7..55dd9051 100644 --- a/src/screens/main/NotificationsScreen.tsx +++ b/src/screens/main/NotificationsScreen.tsx @@ -1,4 +1,5 @@ import AsyncStorage from '@react-native-community/async-storage'; +import PushNotificationIOS from '@react-native-community/push-notification-ios'; import {useFocusEffect, useNavigation} from '@react-navigation/native'; import moment from 'moment'; import React, {useCallback, useEffect, useState} from 'react'; @@ -21,7 +22,6 @@ import FindFriendsBlueIcon from '../../assets/icons/findFriends/find-friends-blu import {TabsGradient} from '../../components'; import EmptyContentView from '../../components/common/EmptyContentView'; import {Notification} from '../../components/notifications'; -import {NewChatPrompt} from '../../components/notifications/NotificationPrompts'; import { loadUserNotifications, updateNewNotificationReceived, @@ -29,7 +29,6 @@ import { import {RootState} from '../../store/rootReducer'; import {NotificationType, ScreenType} from '../../types'; import {getDateAge, normalize, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; -import PushNotificationIOS from '@react-native-community/push-notification-ios'; const NotificationsScreen: React.FC = () => { const {newNotificationReceived} = useSelector( @@ -299,7 +298,6 @@ const NotificationsScreen: React.FC = () => { renderItem={renderNotification} renderSectionHeader={renderSectionHeader} renderSectionFooter={renderSectionFooter} - ListHeaderComponent={<NewChatPrompt />} refreshControl={ <RefreshControl refreshing={refreshing} onRefresh={onRefresh} /> } diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx index 27412486..07b697d0 100644 --- a/src/screens/moments/CameraScreen.tsx +++ b/src/screens/moments/CameraScreen.tsx @@ -4,14 +4,14 @@ import {RouteProp} from '@react-navigation/core'; import {useFocusEffect} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import React, {createRef, useCallback, useEffect, useState} from 'react'; -import {StyleSheet, TouchableOpacity, View} from 'react-native'; +import {Modal, StyleSheet, TouchableOpacity, View} from 'react-native'; 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_WIDTH} from '../../utils'; +import {HeaderHeight, SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; import {showGIFFailureAlert, takePicture, takeVideo} from '../../utils/camera'; type CameraScreenRouteProps = RouteProp<MainStackParams, 'CameraScreen'>; @@ -37,6 +37,7 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => { navigation.dangerouslyGetParent()?.setOptions({ tabBarVisible: false, }); + return () => setIsRecording(false); }, [navigation]), ); @@ -84,6 +85,11 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => { return ( <View style={styles.container}> + <Modal + transparent={true} + visible={isRecording && cameraType === 'front' && flashMode === 'on'}> + <View style={styles.flashView} /> + </Modal> <TouchableOpacity style={styles.closeButton} onPress={handleClose}> <CloseIcon height={25} width={25} color={'white'} /> </TouchableOpacity> @@ -92,7 +98,11 @@ const CameraScreen: React.FC<CameraScreenProps> = ({route, navigation}) => { ref={cameraRef} style={styles.camera} type={cameraType} - flashMode={flashMode} + flashMode={ + flashMode === 'on' && isRecording && cameraType === 'back' + ? 'torch' + : flashMode + } onDoubleTap={() => { setCameraType(cameraType === 'front' ? 'back' : 'front'); }} @@ -111,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)); @@ -127,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'} @@ -164,6 +188,12 @@ const styles = StyleSheet.create({ flexDirection: 'column', backgroundColor: 'black', }, + flashView: { + width: SCREEN_WIDTH, + height: SCREEN_HEIGHT, + backgroundColor: '#fff', + opacity: 0.5, + }, captureButtonVideoContainer: { alignSelf: 'center', backgroundColor: 'transparent', diff --git a/src/screens/moments/TagFriendsScreen.tsx b/src/screens/moments/TagFriendsScreen.tsx index d11f8049..c55721ed 100644 --- a/src/screens/moments/TagFriendsScreen.tsx +++ b/src/screens/moments/TagFriendsScreen.tsx @@ -10,15 +10,13 @@ import { View, } from 'react-native'; import Video from 'react-native-video'; -import {MainStackParams} from 'src/routes'; -import BackArrow from '../../assets/icons/back-arrow.svg'; import {MomentTags} from '../../components'; import {TagFriendsFooter} from '../../components/moments'; +import {headerBarOptions, MainStackParams} from '../../routes'; import {MomentTagType} from '../../types'; import { HeaderHeight, isIPhoneX, - normalize, SCREEN_HEIGHT, SCREEN_WIDTH, } from '../../utils'; @@ -48,6 +46,36 @@ const TagFriendsScreen: React.FC<TagFriendsScreenProps> = ({route}) => { setTags(selectedTags ? selectedTags : []); }, [selectedTags]); + useEffect(() => { + const title = media.isVideo + ? '' + : tags.length === 0 + ? 'Tap on photo to tag friends!' + : 'Press and drag to move'; + navigation.setOptions({ + ...headerBarOptions('white', title), + headerRight: () => ( + <TouchableOpacity + style={styles.buttonContainer} + // Altering the opacity style of TouchableOpacity doesn't work, + // so the next two lines are needed + disabled={tags.length === 0} + activeOpacity={tags.length === 0 ? 0 : 1} + onPress={handleDone}> + <Text + style={[ + styles.shareButtonTitle, + // makes the Done buttomn invisible if there are no tags + // eslint-disable-next-line react-native/no-inline-styles + {opacity: tags.length !== 0 ? 1 : 0}, + ]}> + Done + </Text> + </TouchableOpacity> + ), + }); + }, [tags]); + /* * Navigate back to Tag Users Screen, send selected users */ @@ -174,49 +202,8 @@ const TagFriendsScreen: React.FC<TagFriendsScreenProps> = ({route}) => { onLayout={(event) => { const {y, height} = event.nativeEvent.layout; setTopHeight(y + height); - }}> - <TouchableOpacity - onPress={() => { - navigation.goBack(); - }} - style={styles.backArrow}> - <View style={styles.backArrowContainer}> - <BackArrow - height={normalize(18)} - width={normalize(18)} - color={'white'} - /> - </View> - </TouchableOpacity> - {!media.isVideo ? ( - <TouchableWithoutFeedback style={styles.headerContainer}> - {tags.length === 0 ? ( - <Text style={styles.header}>Tap on photo to tag friends!</Text> - ) : ( - <Text style={styles.header}>Press and drag to move</Text> - )} - </TouchableWithoutFeedback> - ) : ( - <View style={styles.headerPlaceholder} /> - )} - <TouchableOpacity - style={styles.buttonContainer} - // Altering the opacity style of TouchableOpacity doesn't work, - // so the next two lines are needed - disabled={tags.length === 0} - activeOpacity={tags.length === 0 ? 0 : 1} - onPress={handleDone}> - <Text - style={[ - styles.shareButtonTitle, - // makes the Done buttomn invisible if there are no tags - // eslint-disable-next-line react-native/no-inline-styles - {opacity: tags.length !== 0 ? 1 : 0}, - ]}> - Done - </Text> - </TouchableOpacity> - </View> + }} + /> {tags.length !== 0 && !media.isVideo && ( <MomentTags tags={tags} @@ -244,34 +231,11 @@ const styles = StyleSheet.create({ height: SCREEN_HEIGHT, alignContent: 'center', }, - backArrow: { - marginTop: isIPhoneX() ? HeaderHeight : '10%', - zIndex: 9999, - }, - backArrowContainer: { - flex: 1, - flexDirection: 'column', - justifyContent: 'center', - alignContent: 'center', - }, button: { zIndex: 9999, }, buttonContainer: { - marginTop: isIPhoneX() ? HeaderHeight : '10%', - right: 0, - zIndex: 9999, - flexDirection: 'row', - justifyContent: 'flex-end', - }, - headerContainer: { - width: SCREEN_WIDTH, - flexDirection: 'row', - justifyContent: 'center', - zIndex: 9999, - }, - headerPlaceholder: { - width: SCREEN_WIDTH * 0.5, + right: 20, }, shareButtonTitle: { fontWeight: 'bold', diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 3ee0bd5b..d329c589 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -30,15 +30,14 @@ import { ERROR_NO_MOMENT_CATEGORY, ERROR_SOMETHING_WENT_WRONG_REFRESH, ERROR_UPLOAD, - SUCCESS_PIC_UPLOAD, } from '../../constants/strings'; import * as RootNavigation from '../../RootNavigation'; import {MainStackParams} from '../../routes'; -import {patchMoment, postMoment, postMomentTags} from '../../services'; +import {patchMoment} from '../../services'; import { + handleImageMomentUpload, handleVideoMomentUpload, loadUserMoments, - updateProfileCompletionStage, } from '../../store/actions'; import {RootState} from '../../store/rootReducer'; import {MomentTagType} from '../../types'; @@ -138,11 +137,6 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { // then switch to the profile tab navigation.popToTop(); RootNavigation.navigate('ProfileTab'); - setTimeout(() => { - if (!isMediaAVideo) { - Alert.alert(SUCCESS_PIC_UPLOAD); - } - }, 500); } else { // if editing, simply go back to profile screen navigation.navigate('Profile', { @@ -167,53 +161,30 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => { handleFailed(true); return; } - let profileCompletionStage; - // separate upload logic for image/video if (isMediaAVideo) { - if (videoDuration) { - dispatch( - handleVideoMomentUpload( - mediaUri, - videoDuration, - momentCategory, - formattedTags(), - ), - ); - } else { - handleFailed(); - return; - } - } else { - const momentResponse = await postMoment( - mediaUri, - caption, - momentCategory, - userId, + dispatch( + handleVideoMomentUpload( + mediaUri, + videoDuration ?? 30, + caption, + momentCategory, + formattedTags(), + ), ); - if (!momentResponse) { - handleFailed(); - return; - } - profileCompletionStage = momentResponse.profile_completion_stage; - const momentId = momentResponse.moment_id; - if (momentId) { - const momentTagResponse = await postMomentTags( - momentId, + } else { + dispatch( + handleImageMomentUpload( + mediaUri, + caption, + momentCategory, + userId, formattedTags(), - ); - if (!momentTagResponse) { - handleFailed(); - return; - } - } - } - if (!isMediaAVideo) { - dispatch(loadUserMoments(userId)); - } - if (profileCompletionStage) { - dispatch(updateProfileCompletionStage(profileCompletionStage)); + ), + ); } - handleSuccess(); + setTimeout(() => { + handleSuccess(); + }, 500); }; const handleSubmitEditChanges = async () => { diff --git a/src/screens/suggestedPeople/index.ts b/src/screens/suggestedPeople/index.ts index 8c06d81e..be2393b5 100644 --- a/src/screens/suggestedPeople/index.ts +++ b/src/screens/suggestedPeople/index.ts @@ -1,2 +1,3 @@ export {default as SuggestedPeopleScreen} from './SuggestedPeopleScreen'; export {default as AnimatedTutorial} from './AnimatedTutorial'; +export {default as MutualBadgeHolders} from './MutualBadgeHolders'; |