import { View, Text, Pressable, Alert } from "react-native"; import { useCallback, useMemo } from "react"; import { useUser, useCommentSection } from "replyke-core"; import BottomSheet, { BottomSheetBackdrop, BottomSheetBackdropProps, BottomSheetView, } from "@gorhom/bottom-sheet"; import useSheetManager from "../../../hooks/useSheetManager"; import { FlagIcon, TrashIcon } from "../../icons"; const CommentOptionsSheet = () => { const { deleteComment } = useCommentSection(); const { commentOptionsSheetRef, setOptionsComment, closeCommentOptionsSheet, openReportCommentSheet, setReportedComment, optionsComment, } = useSheetManager(); const { user } = useUser(); const isOwner = optionsComment && optionsComment.userId === user?.id; const snapPoints = useMemo(() => ["100%"], []); const handleDeleteComment = () => { Alert.alert( "Delete comment", // Title "Are you sure you want to proceed?", // Message [ { text: "Cancel", style: "cancel", onPress: () => { closeCommentOptionsSheet?.(); }, }, { text: "OK", onPress: () => { deleteComment?.({ commentId: optionsComment!.id }); closeCommentOptionsSheet?.(); }, }, ], { cancelable: false } // Prevents closing the alert by tapping outside ); }; const renderBackdrop = useCallback( (props: BottomSheetBackdropProps) => ( ), [] ); return ( { if (state === -1) { setOptionsComment?.(null); } }} backgroundStyle={{ backgroundColor: "#18181B" }} handleIndicatorStyle={{ backgroundColor: "#fff" }} handleComponent={() => ( comment options )} > {isOwner ? ( Delete ) : ( { closeCommentOptionsSheet?.(); openReportCommentSheet?.(); setReportedComment?.(optionsComment!); }} style={{ flexDirection: "row", alignItems: "center", gap: 16, // Use "rowGap" if supported; fallback otherwise padding: 12, }} > Report )} ); }; export default CommentOptionsSheet;