import { useState } from "react"; import { Pressable, type StyleProp, type TextStyle, TouchableOpacity, type ViewStyle, } from "react-native"; import { Flex, type FlexProps } from "../flex"; import { DEFAULT_STRINGS } from "../lang/default-strings"; import { Text } from "../text"; import { makeStyles } from "../theme"; type ToggleableContentProps = { header?: { open: string; closed: string }; style?: StyleProp; headerStyle?: StyleProp; gap?: number | "xs" | "sm" | "md" | "lg" | "xl"; openByDefault?: boolean; } & FlexProps; export function ToggleableContent({ children, header = { open: DEFAULT_STRINGS.seeLess, closed: DEFAULT_STRINGS.seeMore }, style, headerStyle, gap = "xs", openByDefault, }: ToggleableContentProps) { const styles = useStyles(); const [open, setOpen] = useState(openByDefault ?? false); return ( { setOpen(!open); }} > {open ? header.open : header.closed} {open && children} ); } const useStyles = makeStyles((theme) => ({ header: { color: theme.colors.get("gray", [6, 5]), }, }));