import React, { useState, useRef } from "react"; import { View, Text, TouchableOpacity, Animated, LayoutAnimation, Platform, UIManager, useColorScheme, } from "react-native"; import { Ionicons } from "@expo/vector-icons"; // Enable LayoutAnimation on Android idk honestly probably ok? if (Platform.OS === "android") { UIManager.setLayoutAnimationEnabledExperimental?.(true); } export interface FeedItem { id: string; title: string; author: string; timestamp: string; tag: string; paragraphs: string[]; } interface ExpandableItemProps { item: FeedItem; } export default function ExpandableItem({ item }: ExpandableItemProps) { const [expanded, setExpanded] = useState(false); const rotateAnim = useRef(new Animated.Value(0)).current; const scheme = useColorScheme(); const dark = scheme === "dark"; const toggle = () => { LayoutAnimation.configureNext({ duration: 280, create: { type: "easeInEaseOut", property: "opacity" }, update: { type: "spring", springDamping: 0.8 }, }); Animated.timing(rotateAnim, { toValue: expanded ? 0 : 1, duration: 250, useNativeDriver: true, }).start(); setExpanded((v) => !v); }; const chevronRotation = rotateAnim.interpolate({ inputRange: [0, 1], outputRange: ["0deg", "180deg"], }); return ( {/* Header */} {/* Tag + timestamp row */} {item.tag} {item.timestamp} {/* Title */} {item.title} {/* Author */} by {item.author} {/* Expanded body */} {expanded && ( {item.paragraphs.map((para, i) => ( {para} ))} )} ); }