/* eslint-disable max-lines-per-function */ import { BottomSheetFlatList, type BottomSheetModal, } from '@gorhom/bottom-sheet'; import { FlashList } from '@shopify/flash-list'; import { useColorScheme } from 'nativewind'; import * as React from 'react'; import type { FieldValues } from 'react-hook-form'; import { useController } from 'react-hook-form'; import { Platform, View } from 'react-native'; import { Pressable, type PressableProps } from 'react-native'; import type { SvgProps } from 'react-native-svg'; import Svg, { Path } from 'react-native-svg'; import { tv } from 'tailwind-variants'; import colors from '../../components/ui/colors'; import { CaretDown } from '../../components/ui/icons'; import type { InputControllerType } from './input'; import { useModal } from './modal'; import { Modal } from './modal'; import { Text } from './text'; const selectTv = tv({ slots: { container: 'mb-4', label: 'text-grey-100 mb-1 text-lg dark:text-neutral-100', input: 'border-grey-50 mt-0 flex-row items-center justify-center rounded-xl border-[0.5px] p-3 dark:border-neutral-500 dark:bg-neutral-800', inputValue: 'dark:text-neutral-100', }, variants: { focused: { true: { input: 'border-neutral-600', }, }, error: { true: { input: 'border-danger-600', label: 'text-danger-600 dark:text-danger-600', inputValue: 'text-danger-600', }, }, disabled: { true: { input: 'bg-neutral-200', }, }, }, defaultVariants: { error: false, disabled: false, }, }); const List = Platform.OS === 'web' ? FlashList : BottomSheetFlatList; export type OptionType = { label: string; value: string | number }; type OptionsProps = { options: OptionType[]; onSelect: (option: OptionType) => void; value?: string | number; testID?: string; }; function keyExtractor(item: OptionType) { return `select-item-${item.value}`; } export const Options = React.forwardRef( ({ options, onSelect, value, testID }, ref) => { const height = options.length * 70 + 100; const snapPoints = React.useMemo(() => [height], [height]); const { colorScheme } = useColorScheme(); const isDark = colorScheme === 'dark'; const renderSelectItem = React.useCallback( ({ item }: { item: OptionType }) => (