From 2697a10f65f84eb44757bc3b37c09bdc1989de5d Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 7 Jul 2021 14:38:10 -0400 Subject: Remove title, Cleanup caption screen route props, Add new screen --- src/components/comments/ZoomInCropper.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/components/comments') diff --git a/src/components/comments/ZoomInCropper.tsx b/src/components/comments/ZoomInCropper.tsx index 7fa88f6e..4de82418 100644 --- a/src/components/comments/ZoomInCropper.tsx +++ b/src/components/comments/ZoomInCropper.tsx @@ -25,7 +25,7 @@ export const ZoomInCropper: React.FC = ({ route, navigation, }) => { - const {screenType, title, media} = route.params; + const {screenType, media} = route.params; const [aspectRatio, setAspectRatio] = useState(1); // Stores the coordinates of the cropped image @@ -77,7 +77,6 @@ export const ZoomInCropper: React.FC = ({ .then((croppedURL) => { navigation.navigate('CaptionScreen', { screenType, - title: title, media: { uri: croppedURL, isVideo: false, @@ -93,7 +92,6 @@ export const ZoomInCropper: React.FC = ({ ) { navigation.navigate('CaptionScreen', { screenType, - title: title, media, }); } -- cgit v1.2.3-70-g09d2 From 12d92de8b9c93a4615952134ca4973049e45952f Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 8 Jul 2021 15:42:50 -0400 Subject: Cleanup tabbar visibility status --- src/components/comments/ZoomInCropper.tsx | 13 ------------- src/screens/moments/CameraScreen.tsx | 5 ----- 2 files changed, 18 deletions(-) (limited to 'src/components/comments') diff --git a/src/components/comments/ZoomInCropper.tsx b/src/components/comments/ZoomInCropper.tsx index 4de82418..6f2d7c21 100644 --- a/src/components/comments/ZoomInCropper.tsx +++ b/src/components/comments/ZoomInCropper.tsx @@ -34,19 +34,6 @@ export const ZoomInCropper: React.FC = ({ const [y0, setY0] = useState(); const [y1, setY1] = useState(); - useFocusEffect( - useCallback(() => { - navigation.dangerouslyGetParent()?.setOptions({ - tabBarVisible: false, - }); - return () => { - navigation.dangerouslyGetParent()?.setOptions({ - tabBarVisible: true, - }); - }; - }, [navigation]), - ); - // Setting original aspect ratio of image useEffect(() => { if (media.uri) { diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx index be153d0c..07c9b059 100644 --- a/src/screens/moments/CameraScreen.tsx +++ b/src/screens/moments/CameraScreen.tsx @@ -45,11 +45,6 @@ const CameraScreen: React.FC = ({route, navigation}) => { navigation.dangerouslyGetParent()?.setOptions({ tabBarVisible: false, }); - return () => { - navigation.dangerouslyGetParent()?.setOptions({ - tabBarVisible: true, - }); - }; }, [navigation]), ); -- cgit v1.2.3-70-g09d2 From 74d0ad5bab6f0d058fc03095fa0a313499162579 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 9 Jul 2021 01:38:04 -0400 Subject: Lint, Update service code to allow category edition --- src/components/comments/ZoomInCropper.tsx | 3 +-- src/components/profile/MomentMoreInfoDrawer.tsx | 1 + src/screens/profile/CaptionScreen.tsx | 19 ++++++++++--------- src/services/MomentService.ts | 4 +++- 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src/components/comments') diff --git a/src/components/comments/ZoomInCropper.tsx b/src/components/comments/ZoomInCropper.tsx index 6f2d7c21..8b87d137 100644 --- a/src/components/comments/ZoomInCropper.tsx +++ b/src/components/comments/ZoomInCropper.tsx @@ -1,7 +1,6 @@ import {RouteProp} from '@react-navigation/core'; -import {useFocusEffect} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import React, {useCallback, useEffect, useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {Image, StyleSheet, TouchableOpacity} from 'react-native'; import {normalize} from 'react-native-elements'; import ImageZoom, {IOnMove} from 'react-native-image-pan-zoom'; diff --git a/src/components/profile/MomentMoreInfoDrawer.tsx b/src/components/profile/MomentMoreInfoDrawer.tsx index 910aa095..493f6238 100644 --- a/src/components/profile/MomentMoreInfoDrawer.tsx +++ b/src/components/profile/MomentMoreInfoDrawer.tsx @@ -129,6 +129,7 @@ const MomentMoreInfoDrawer: React.FC = (props) => { screenType: screenType, selectedTags: tags, moment: moment, + selectedCategory: moment.moment_category, }); }; diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 15566555..9a1878aa 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -20,13 +20,12 @@ import {useDispatch, useSelector} from 'react-redux'; import FrontArrow from '../../assets/icons/front-arrow.svg'; import { MentionInputControlled, - MomentPostButton, SearchBackground, TaggSquareButton, } from '../../components'; import {CaptionScreenHeader} from '../../components/'; import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; -import {TAGG_LIGHT_BLUE, TAGG_LIGHT_BLUE_2} from '../../constants'; +import {TAGG_LIGHT_BLUE_2} from '../../constants'; import { ERROR_NO_MOMENT_CATEGORY, ERROR_SOMETHING_WENT_WRONG_REFRESH, @@ -66,7 +65,8 @@ interface CaptionScreenProps { } const CaptionScreen: React.FC = ({route, navigation}) => { - const {screenType, moment} = route.params; + // moment is only present when editing + const {moment} = route.params; const { user: {userId}, } = useSelector((state: RootState) => state.user); @@ -205,12 +205,13 @@ const CaptionScreen: React.FC = ({route, navigation}) => { handleSuccess(); }; - const handleDoneEditing = async () => { + const handleSubmitEditChanges = async () => { setLoading(true); - if (moment?.moment_id) { + if (moment?.moment_id && momentCategory) { const success = await patchMoment( moment.moment_id, caption, + momentCategory, formattedTags(), ); if (success) { @@ -315,8 +316,8 @@ const CaptionScreen: React.FC = ({route, navigation}) => { /> {momentCategory ? ( = ({route, navigation}) => { ) : ( Date: Fri, 9 Jul 2021 18:40:30 -0400 Subject: Allow preselect category from profile screen --- src/components/comments/ZoomInCropper.tsx | 4 +++- src/components/moments/Moment.tsx | 11 +++++++++-- src/routes/main/MainStackNavigator.tsx | 2 ++ src/screens/moments/CameraScreen.tsx | 6 +++++- src/screens/profile/CaptionScreen.tsx | 6 ++++++ 5 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src/components/comments') diff --git a/src/components/comments/ZoomInCropper.tsx b/src/components/comments/ZoomInCropper.tsx index 8b87d137..e624c81c 100644 --- a/src/components/comments/ZoomInCropper.tsx +++ b/src/components/comments/ZoomInCropper.tsx @@ -24,7 +24,7 @@ export const ZoomInCropper: React.FC = ({ route, navigation, }) => { - const {screenType, media} = route.params; + const {screenType, media, selectedCategory} = route.params; const [aspectRatio, setAspectRatio] = useState(1); // Stores the coordinates of the cropped image @@ -67,6 +67,7 @@ export const ZoomInCropper: React.FC = ({ uri: croppedURL, isVideo: false, }, + selectedCategory, }); }) .catch((err) => console.log('err: ', err)); @@ -79,6 +80,7 @@ export const ZoomInCropper: React.FC = ({ navigation.navigate('CaptionScreen', { screenType, media, + selectedCategory, }); } }; diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx index 12c1fda4..087b343f 100644 --- a/src/components/moments/Moment.tsx +++ b/src/components/moments/Moment.tsx @@ -1,3 +1,4 @@ +import {useNavigation} from '@react-navigation/native'; import React from 'react'; import {StyleProp, StyleSheet, View, ViewStyle} from 'react-native'; import {Text} from 'react-native-animatable'; @@ -8,7 +9,6 @@ import DownIcon from '../../assets/icons/down_icon.svg'; import BigPlusIcon from '../../assets/icons/plus-icon-white.svg'; import UpIcon from '../../assets/icons/up_icon.svg'; import {TAGG_LIGHT_BLUE} from '../../constants'; -import * as RootNavigation from '../../RootNavigation'; import {MomentType, ScreenType} from '../../types'; import {normalize, SCREEN_WIDTH} from '../../utils'; import MomentTile from './MomentTile'; @@ -38,6 +38,7 @@ const Moment: React.FC = ({ move, externalStyles, }) => { + const navigation = useNavigation(); return ( @@ -97,7 +98,13 @@ const Moment: React.FC = ({ /> ))} {(images === undefined || images.length === 0) && !userXId && ( - RootNavigation.navigate('Upload')}> + + navigation.navigate('CameraScreen', { + screenType: ScreenType.Profile, + selectedCategory: title, + }) + }> diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx index 2dac1777..c569d2d6 100644 --- a/src/routes/main/MainStackNavigator.tsx +++ b/src/routes/main/MainStackNavigator.tsx @@ -37,10 +37,12 @@ export type MainStackParams = { }; CameraScreen: { screenType: ScreenType; + selectedCategory?: string; }; ZoomInCropper: { media: {uri: string; isVideo: boolean}; screenType: ScreenType; + selectedCategory?: string; }; CaptionScreen: { screenType: ScreenType; diff --git a/src/screens/moments/CameraScreen.tsx b/src/screens/moments/CameraScreen.tsx index 07c9b059..5f9412fb 100644 --- a/src/screens/moments/CameraScreen.tsx +++ b/src/screens/moments/CameraScreen.tsx @@ -30,7 +30,7 @@ interface CameraScreenProps { navigation: CameraScreenNavigationProps; } const CameraScreen: React.FC = ({route, navigation}) => { - const {screenType} = route.params; + const {screenType, selectedCategory} = route.params; const cameraRef = createRef(); const tabBarHeight = useBottomTabBarHeight(); const [cameraType, setCameraType] = useState('front'); @@ -71,6 +71,7 @@ const CameraScreen: React.FC = ({route, navigation}) => { uri, isVideo: false, }, + selectedCategory, }); }; @@ -94,6 +95,9 @@ const CameraScreen: React.FC = ({route, navigation}) => { setShowSaveButton(false); setMediaFromGallery(''); } else { + navigation.dangerouslyGetParent()?.setOptions({ + tabBarVisible: true, + }); navigation.goBack(); } }; diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 484070d2..1232eb66 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -115,6 +115,9 @@ const CaptionScreen: React.FC = ({route, navigation}) => { const handleFailed = (noCategory = false) => { setLoading(false); + navigation.dangerouslyGetParent()?.setOptions({ + tabBarVisible: true, + }); setTimeout(() => { if (noCategory) { Alert.alert(ERROR_NO_MOMENT_CATEGORY); @@ -125,6 +128,9 @@ const CaptionScreen: React.FC = ({route, navigation}) => { }; const handleSuccess = () => { setLoading(false); + navigation.dangerouslyGetParent()?.setOptions({ + tabBarVisible: true, + }); if (!moment) { // if posting, pop all screens until at camera screen (default upload screen) // then switch to the profile tab -- cgit v1.2.3-70-g09d2