import { useTheme } from '@/components/ThemeContext'; import { BottomSheetBackdrop, BottomSheetBackdropProps, BottomSheetModal, BottomSheetScrollView, } from '@gorhom/bottom-sheet'; import { Image } from 'expo-image'; import React, { useCallback, useEffect, useMemo, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'; export type Option = { label: string; value: string; flag?: string; }; type CategorySelectorProps = { isOpen: boolean; onClose: () => void; selectedValue: string; onSelect: (value: string) => void; data: Option[]; }; export default function CategorySelectorBottomSheet({ isOpen, onClose, selectedValue, onSelect, data = [], }: CategorySelectorProps) { const { isDark } = useTheme(); const { t } = useTranslation(); const theme = { background: isDark ? '#1e293b' : '#ffffff', text: isDark ? '#f8fafc' : '#0f172a', border: isDark ? '#334155' : '#e2e8f0', selectedBg: '#2563eb', selectedText: '#ffffff', indicator: isDark ? '#cbd5e1' : '#94a3b8', }; const bottomSheetRef = useRef(null); const snapPoints = useMemo(() => ['60%', '85%'], []); const renderBackdrop = useCallback( (props: BottomSheetBackdropProps) => ( ), [] ); useEffect(() => { if (isOpen) { bottomSheetRef.current?.present(); } else { bottomSheetRef.current?.dismiss(); } }, [isOpen]); return ( {t('Tanlang')} {data.map((item) => ( { onSelect(item.value); onClose(); }} > {item.flag ? ( ) : null} {item.label} ))} ); } const styles = StyleSheet.create({ header: { paddingVertical: 16, paddingHorizontal: 20, borderBottomWidth: 1, alignItems: 'center', }, title: { fontSize: 18, fontWeight: '700', }, content: { flex: 1, }, contentContainer: { paddingHorizontal: 8, paddingBottom: 40, }, optionRow: { paddingVertical: 16, paddingHorizontal: 20, borderBottomWidth: 1, flexDirection: 'row', alignContent: 'center', alignItems: 'center', gap: 10, }, optionText: { fontSize: 16, }, optionTextSelected: { fontWeight: '600', }, });