From 83643a78b73dee5610be6ad9837fb72e9b944cb7 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Wed, 28 Aug 2024 15:53:21 +0200 Subject: Initial commit Generated by create-expo-app 3.0.0. --- components/Collapsible.tsx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 components/Collapsible.tsx (limited to 'components/Collapsible.tsx') diff --git a/components/Collapsible.tsx b/components/Collapsible.tsx new file mode 100644 index 0000000..c326473 --- /dev/null +++ b/components/Collapsible.tsx @@ -0,0 +1,41 @@ +import Ionicons from '@expo/vector-icons/Ionicons'; +import { PropsWithChildren, useState } from 'react'; +import { StyleSheet, TouchableOpacity, useColorScheme } from 'react-native'; + +import { ThemedText } from '@/components/ThemedText'; +import { ThemedView } from '@/components/ThemedView'; +import { Colors } from '@/constants/Colors'; + +export function Collapsible({ children, title }: PropsWithChildren & { title: string }) { + const [isOpen, setIsOpen] = useState(false); + const theme = useColorScheme() ?? 'light'; + + return ( + + setIsOpen((value) => !value)} + activeOpacity={0.8}> + + {title} + + {isOpen && {children}} + + ); +} + +const styles = StyleSheet.create({ + heading: { + flexDirection: 'row', + alignItems: 'center', + gap: 6, + }, + content: { + marginTop: 6, + marginLeft: 24, + }, +}); -- cgit v1.2.3-18-g5258