import React, { useState, type ReactNode } from 'react'; import { Pressable, Text, View, type StyleProp, type TextStyle } from 'react-native'; import { ChevronRight } from 'lucide-react-native'; import { themedColor } from '../../theme'; import { toolWidgetStyles } from './toolWidgetStyles'; /** * Uncontrolled disclosure. `collapsedTitle`/`expandedTitle` let the label * change with state like the web ("first code line…" → "Hide code"). */ export function ExpandableSection({ children, collapsedTitle, defaultExpanded = false, expandedTitle, monoTitle = false, titleStyle, }: { children: ReactNode; collapsedTitle: string; defaultExpanded?: boolean; expandedTitle?: string; monoTitle?: boolean; titleStyle?: StyleProp; }) { const [expanded, setExpanded] = useState(defaultExpanded); const title = expanded ? (expandedTitle ?? collapsedTitle) : collapsedTitle; return ( setExpanded((current) => !current)} style={toolWidgetStyles.sectionHeader} > {title} {expanded ? {children} : null} ); }