import { useState } from 'react'; import { StyleSheet } from 'react-native'; import Animated from 'react-native-reanimated'; import { AppPressable, usePressableOverlay } from '../buttons/AppPressable'; import { AppBox } from '../layout/AppBox'; import { AppText } from '../text/AppText'; import { useAppTheme } from '~/view/theme'; type Props = { index?: number; labels: string[]; onPress?: (index: number) => void; }; export const SegmentedButton = ({ onPress, labels, index }: Props) => { const [currentIndex, setCurrentIndex] = useState(index ?? 0); const { buttonSizes, colors } = useAppTheme(); return ( {labels.map((l, i, arr) => { const handleOnPress = (index: number) => () => { onPress?.(index); setCurrentIndex(index); }; return ( {i < arr.length - 1 && ( )} ); })} ); }; type SegmentProps = { selected: boolean; label: string; onPress?: () => void; }; const Segment = ({ selected, label, onPress }: SegmentProps) => { const { colors, borderRadii, buttonSizes } = useAppTheme(); const { onPressIn, onPressOut, layerStyle } = usePressableOverlay(onPress); return ( {label} ); };