import {useNavigation} from '@react-navigation/native'; import React, {useEffect, useRef} from 'react'; import { Image, StyleSheet, Text, TouchableOpacity, TouchableWithoutFeedback, View, } from 'react-native'; import {ProfilePreviewType, ScreenType, UserType} from '../../types'; import {normalize} from '../../utils'; import Avatar from '../../components/common/Avatar'; import {navigateToProfile} from '../../utils/users'; import {useDispatch, useSelector} from 'react-redux'; import {RootState} from 'src/store/rootReducer'; interface TaggDraggableProps { taggedUser: ProfilePreviewType; editingView: boolean; deleteFromList: () => void; setStart: Function; } const TaggDraggable: React.FC = ( props: TaggDraggableProps, ) => { const navigation = useNavigation(); const gotoTaggedProfile = (userID: string) => { //Since the logged In User is navigating to own profile, useXId is not required navigation.navigate('Profile', { ScreenType, userXId: userID, }); }; const {taggedUser, editingView, deleteFromList, setStart} = props; const state = useSelector((rs: RootState) => rs); const dispatch = useDispatch(); let uriX = require('../../assets/images/draggableX.png'); let uriTip = require('../../assets/images/Tagg-Triangle.png'); const draggableRef = useRef(null); useEffect(() => { draggableRef.current.measure((fx, fy, width, height, px, py) => { console.log('Drag Component width is: ' + width); console.log('Drag Component height is: ' + height); console.log('X offset to frame: ' + fx); console.log('Y offset to frame: ' + fy); console.log('X offset to page: ' + px); console.log('Y offset to page: ' + py); setStart([width, height]); }); }, []); const user: UserType = { userId: taggedUser.id, username: taggedUser.username, }; return ( navigateToProfile( state, dispatch, navigation, ScreenType.Profile, user, ) } disabled={editingView} style={[styles.button]} ref={draggableRef}> @{taggedUser.username} {editingView && ( deleteFromList()}> )} ); }; const styles = StyleSheet.create({ container: { borderWidth: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', }, buttonTitle: { borderWidth: 1, color: 'white', fontSize: normalize(11), fontWeight: '700', lineHeight: normalize(13.13), letterSpacing: normalize(0.6), paddingHorizontal: '1%', }, buttonTitleX: { color: 'white', fontSize: normalize(11), fontWeight: '700', lineHeight: normalize(13.13), letterSpacing: normalize(0.6), paddingHorizontal: '1%', marginRight: '-10%', }, avatar: { borderWidth: 1, borderRadius: 100 / 2, overflow: 'hidden', marginLeft: '4%', marginRight: '-1%', flex: 0.45, aspectRatio: 1, }, imageX: { borderWidth: 1, width: normalize(15), height: normalize(15), }, imageTip: { borderWidth: 1, bottom: -5, width: normalize(15), height: normalize(15), }, button: { borderWidth: 1, paddingTop: 3, paddingBottom: 3, justifyContent: 'space-evenly', alignItems: 'center', borderRadius: 20, flexDirection: 'row', backgroundColor: 'rgba(0, 0, 0, 0.8)', }, }); export default TaggDraggable;