From 45bed4c2d0c74407a13476f1db08b387fe7078dc Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Fri, 21 May 2021 16:16:57 -0700 Subject: Replace tag component on current caption screen --- src/screens/profile/CaptionScreen.tsx | 70 +++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx index 146ad86c..f41487c9 100644 --- a/src/screens/profile/CaptionScreen.tsx +++ b/src/screens/profile/CaptionScreen.tsx @@ -1,6 +1,6 @@ import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import React, {Fragment, useEffect, useState} from 'react'; +import React, {Fragment, useCallback, useEffect, useState} from 'react'; import { Alert, Image, @@ -16,7 +16,7 @@ import { import {MentionInput} from 'react-native-controlled-mentions'; import {Button, normalize} from 'react-native-elements'; import {useDispatch, useSelector} from 'react-redux'; -import {ProfilePreview, SearchBackground} from '../../components'; +import {SearchBackground} from '../../components'; import {CaptionScreenHeader} from '../../components/'; import TaggLoadingIndicator from '../../components/common/TaggLoadingIndicator'; import {TAGG_LIGHT_BLUE_2} from '../../constants'; @@ -28,9 +28,10 @@ import { updateProfileCompletionStage, } from '../../store/actions'; import {RootState} from '../../store/rootReducer'; -import {ProfilePreviewType, ScreenType} from '../../types'; +import {ProfilePreviewType} from '../../types'; import {SCREEN_WIDTH, StatusBarHeight} from '../../utils'; import {mentionPartTypes} from '../../utils/comments'; +import FrontArrow from '../../assets/icons/front-arrow.svg'; /** * Upload Screen to allow users to upload posts to Tagg @@ -54,11 +55,26 @@ const CaptionScreen: React.FC = ({route, navigation}) => { const [caption, setCaption] = useState(''); const [loading, setLoading] = useState(false); const [taggedUsers, setTaggedUsers] = useState([]); - + const [taggedList, setTaggedList] = useState(''); useEffect(() => { setTaggedUsers(selectedUsers ? selectedUsers : []); }, [route.params]); + useEffect(() => { + const getTaggedUsersListString = () => { + let listString = ''; + for (let i = 0; i < taggedUsers.length; i++) { + if (listString.length < 21) { + listString = listString.concat(`@${taggedUsers[i].username} `); + } else { + break; + } + } + setTaggedList(listString); + }; + getTaggedUsersListString(); + }, [taggedUsers]); + const navigateToProfile = () => { //Since the logged In User is navigating to own profile, useXId is not required navigation.navigate('Profile', { @@ -126,28 +142,42 @@ const CaptionScreen: React.FC = ({route, navigation}) => { onChange={setCaption} partTypes={mentionPartTypes('blue')} /> - + + + Tag Friends + + {taggedList} + {taggedList.length > 21 ? '. . .' : ''} + - navigation.navigate('TagSelectionScreen', { + navigation.navigate('TagFriendsScreen', { + image: image, + screenType: screenType, selectedUsers: taggedUsers, }) }> - Tag Friends + - - {taggedUsers.map((user) => ( - - {/* TODO: Add Icon for Tag Friends */} - - - ))} - -- cgit v1.2.3-70-g09d2