import { ThemedText } from '@/components/themed-text'; import Feather from '@expo/vector-icons/Feather'; import MaterialIcons from '@expo/vector-icons/MaterialIcons'; import React, { useEffect, useRef, useState } from 'react'; import { Animated, Modal, TouchableOpacity, View } from 'react-native'; import { styles } from '../styles/welcomeStyle'; export default function LanguageSelect() { const [visible, setVisible] = useState(false); const [current, setCurrent] = useState('uz'); const [menuPos, setMenuPos] = useState({ x: 0, y: 0, width: 0, height: 0 }); const triggerRef = useRef(null); useEffect(() => { const fetchLang = async () => { const lang = await getLang(); if (lang) setCurrent(lang); }; fetchLang(); }, []); const backdropAnim = useRef(new Animated.Value(0)).current; const fadeAnim = useRef(new Animated.Value(0)).current; const slideAnim = useRef(new Animated.Value(-20)).current; const scaleAnim = useRef(new Animated.Value(0.9)).current; const languages = [ { key: 'uz', label: "๐Ÿ‡บ๐Ÿ‡ฟ O'zbek" }, { key: 'ru', label: '๐Ÿ‡ท๐Ÿ‡บ ะ ัƒััะบะธะน' }, { key: 'en', label: '๐Ÿ‡บ๐Ÿ‡ธ English' }, ]; const openMenu = () => { triggerRef.current?.measureInWindow((x, y, width, height) => { setMenuPos({ x, y: y + height + 60, width, height, }); setVisible(true); }); }; const closeMenu = () => { Animated.parallel([ Animated.timing(backdropAnim, { toValue: 0, duration: 200, useNativeDriver: true, }), Animated.timing(fadeAnim, { toValue: 0, duration: 150, useNativeDriver: true, }), Animated.timing(slideAnim, { toValue: -20, duration: 150, useNativeDriver: true, }), Animated.timing(scaleAnim, { toValue: 0.9, duration: 150, useNativeDriver: true, }), ]).start(() => { setVisible(false); }); }; useEffect(() => { if (visible) { backdropAnim.setValue(0); fadeAnim.setValue(0); slideAnim.setValue(-20); scaleAnim.setValue(0.9); Animated.parallel([ Animated.timing(backdropAnim, { toValue: 1, duration: 250, useNativeDriver: true, }), Animated.timing(fadeAnim, { toValue: 1, duration: 250, useNativeDriver: true, }), Animated.spring(slideAnim, { toValue: 0, tension: 100, friction: 8, useNativeDriver: true, }), Animated.spring(scaleAnim, { toValue: 1, tension: 100, friction: 8, useNativeDriver: true, }), ]).start(); } }, [visible]); const selectLanguage = async (lang: string) => { closeMenu(); setCurrent(lang); await i18n.changeLanguage(lang); await saveLang(lang); }; return ( {current.toUpperCase()} {languages.map((l, index) => ( selectLanguage(l.key)} activeOpacity={0.7} style={{ paddingVertical: 14, paddingHorizontal: 16, flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', backgroundColor: current === l.key ? '#EEF2FF' : 'transparent', borderBottomWidth: index < languages.length - 1 ? 1 : 0, borderBottomColor: '#F3F4F6', }} > {l.label} {current === l.key && } ))} ); } // StyleSheet.absoluteFillObject uchun import qo'shing: import { getLang, saveLang } from '@/hooks/storage.native'; import i18n from '@/i18n/i18n'; import { StyleSheet } from 'react-native';