import { Image, StyleSheet, Text, View } from 'react-native' import React, { useState } from 'react' import AntIcon from 'react-native-vector-icons/AntDesign' import ButtonWrapper from '../../atoms/ButtonWrapper' import LineIcon from 'react-native-vector-icons/SimpleLineIcons' import colors from '../../../theme/colors' import fonts from '../../../theme/fonts' import images from '../../../assets/images/images' import { Menu, Provider } from 'react-native-paper' import { getTimestamp } from '../../../utils/Constants/functions' const CommentCard = ({ navigation, timestamp, name, comment, likeCount, dislikeCount, }) => { // * Like Counter const [isDisliked, setDisliked] = useState(false) const [isLiked, setLiked] = useState(false) const [likeCounter, setLikeCounter] = useState(likeCount ?? 123) const [dislikeCounter, setDislikeCounter] = useState(dislikeCount ?? 452) // * Menu Visibility const [optionsMenuVisible, setOptionsMenuVisible] = React.useState(false); const openOptionsMenu = () => setOptionsMenuVisible(true); const closeOptionsMenu = () => setOptionsMenuVisible(false); const toggleOptionsMenu = () => setOptionsMenuVisible(!optionsMenuVisible) const [optionsMenuAnchor, setOptionsMenuAnchor] = React.useState({ y: 0, x: 0 }) const onOptionsMenuPress = (event) => { const { nativeEvent } = event; console.log(nativeEvent) const anchor = { x: nativeEvent.locationX, y: nativeEvent.locationY, // x:0, // y:0 }; setOptionsMenuAnchor(anchor); toggleOptionsMenu() } const handleToggleDislike = () => { setDisliked(!isDisliked) setDislikeCounter(isDisliked === true ? dislikeCounter - 1 : dislikeCounter + 1) } const handleToggleLike = () => { setLiked(!isLiked) setLikeCounter(isLiked === true ? likeCounter - 1 : likeCounter + 1) } return ( Semina Gurung {getTimestamp(timestamp)} } > { }} title="Item 1" /> { }} title="Item 2" /> { }} title="Item 3" /> Lorem Ip sum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply du View 14 replies { handleToggleLike() }} > {`${likeCounter}`} { handleToggleDislike() }} > {`${dislikeCounter}`} ) } export default CommentCard const styles = StyleSheet.create({ header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }, commentContainer: { width: '100%', height: 150, // height: 'auto', paddingVertical: fonts.getSize(4) }, profileIcon: { height: 42, width: 42, borderRadius: 42, marginRight: fonts.getSize(8), }, buttonStyle: { alignItems: 'center', justifyContent: 'center', height: 'auto', width: 'auto' }, icon: { color: colors.topColor, fontSize: fonts.getSize(16) }, name: { fontFamily: fonts.type.regular, color: colors.black, fontSize: fonts.getSize(12) }, timestamp: { fontFamily: fonts.type.regular, color: colors.gray, fontSize: fonts.getSize(9) }, replyIcon: { height: 22, width: 22, borderColor: colors.white, borderWidth: 1, borderRadius: 24, marginRight: -8 }, utilContainer: { flexDirection: 'row', gap: 12 }, utilButtons: { flexDirection: 'row', alignItems: 'baseline' }, utilText: { fontFamily: fonts.type.medium, color: colors.black, paddingRight: 4 }, })