import {useNavigation} from '@react-navigation/native'; import React, {useMemo} from 'react'; import { Image, ScrollView, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; import {ProfilePreview} from '..'; import {MomentTagType, ProfilePreviewType, ScreenType} from '../../types'; import {normalize, SCREEN_HEIGHT} from '../../utils/layouts'; interface TagFriendsFooterProps { tags: MomentTagType[]; setTags: (tags: MomentTagType[]) => void; } const TagFriendsFooter: React.FC = ({tags, setTags}) => { const navigation = useNavigation(); const handleRemoveTag = (user: ProfilePreviewType) => { setTags(tags.filter((tag) => tag.user.id !== user.id)); }; const goToSelectionScreen = () => { navigation.navigate('TagSelectionScreen', { selectedTags: tags, }); }; const taggMoreButton = useMemo( () => ( {'Tag More'} ), [tags], ); const TaggedUser = (user: ProfilePreviewType) => ( handleRemoveTag(user)}> ); /* * Title/Button depending on the number of users inside taggedUsers list * If taggUsers is empty, title acts as a button * Else, gets disabled and TaggMore button appears */ const tagFriendsTitle = useMemo( () => ( navigation.navigate('TagSelectionScreen', { selectedTags: tags, }) }> Tag Friends ), [tags.length], ); return ( <> {tagFriendsTitle} {tags.map((tag) => ( ))} {tags.length !== 0 && taggMoreButton} ); }; const styles = StyleSheet.create({ tagIcon: {width: 20, height: 20, marginRight: '3%'}, tagFriendsTitle: { color: 'white', fontSize: normalize(12), lineHeight: normalize(16.71), letterSpacing: normalize(0.3), fontWeight: '600', }, tagFriendsContainer: { height: SCREEN_HEIGHT * 0.1, marginTop: 2, marginBottom: 5, }, tagMoreLabel: { fontWeight: '500', fontSize: normalize(9), lineHeight: normalize(10), letterSpacing: normalize(0.2), color: 'white', textAlign: 'center', }, closeIconContainer: { width: 20, height: 20, right: -20, zIndex: 1, }, tagMoreContainer: { width: 60, alignItems: 'center', justifyContent: 'flex-start', marginTop: -12, }, tagMoreIcon: { width: 38, height: 38, marginTop: 13, marginBottom: '10%', }, taggedUserContainer: { marginTop: -12, }, closeIcon: { width: 20, height: 20, left: 15, top: 10, }, tagFriendsTitleContainer: { flexDirection: 'row', }, }); export default TagFriendsFooter;