import { faAngleDown, faCheck } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome"; import React, { useState } from "react"; import { View, Text, TouchableOpacity, Animated, Easing, StyleSheet, } from "react-native"; const Accordion = ({ sections, selected,sel }) => { const [activeSection, setActiveSection] = useState(-1); const [animatedHeights] = useState(sections.map(() => new Animated.Value(0))); const toggleSection = (sectionIndex) => { const animations = animatedHeights.map((height, index) => { if (index === sectionIndex) { const contentHeight = sections[sectionIndex].methods.length * 60; // Adjust the height as needed return Animated.timing(height, { toValue: activeSection === sectionIndex ? 0 : contentHeight, duration: 300, easing: Easing.ease, useNativeDriver: false, }); } else if (index === activeSection) { return Animated.timing(height, { toValue: 0, duration: 300, easing: Easing.ease, useNativeDriver: false, }); } return null; }); Animated.parallel(animations).start(); setActiveSection(activeSection === sectionIndex ? -1 : sectionIndex); }; return ( {sections.map((section, index) => ( {/* { toggleSection(index); }} > */} {/* {section.type} */} {/* {section?.methods.map((section, index) => ( */} { selected(section.methodName); }} > {section.methodName} {sel === section?.methodName ? ( ) : null} {/* ))} */} {/* */} ))} ); }; const styles = StyleSheet.create({ container: { backgroundColor: "#fff", height: "100%", width: "100%", // justifyContent:'center', alignItems: "center", }, section: { width: "100%", borderWidth: 1, borderColor: "#ececec", padding: 10, }, sectionTitle: { fontSize: 18, fontWeight: "bold", }, sectionContent: { overflow: "hidden", paddingHorizontal: 15, height: 200, }, acc: { justifyContent: "space-between", flexDirection: "row", alignItems: "center", padding: 10, }, btnMethod: { padding: 10, // borderWidth: 1, // borderColor: "#e9e7e7", borderRadius: 5, marginVertical: 1, flexDirection:'row', justifyContent : 'space-between', alignItems: 'center' }, btnMethodText: { fontSize: 20, }, }); export default Accordion;