import React, { useState, useRef } from 'react'; import { View, Text, StyleSheet, TouchableOpacity, Animated, Dimensions, } from 'react-native'; import { InsideHeader } from '../../Component/Index'; import { useFetchLiveTender, useFetchPurchaseTender, } from '../../Services/BBPS/Hooks'; import colors from '../../Constant/Color'; import { ShoppingCart } from 'lucide-react-native'; import { useNavigation } from '@react-navigation/native'; import NavigationString from '../../Constant/NavigationString'; import FontsFamily from '../../Constant/FontsFamily'; import { useSelector } from 'react-redux'; import LiveTender from './LiveTender'; import PurchaseTenderAllList from './PurchaseTenderAllList'; const { width } = Dimensions.get('screen') const TAB_WIDTH = 140; const TAB_HEIGHT = 44; const Tender = () => { const Navigation = useNavigation() as any const { data: liveTenderData = {} }: any = useFetchLiveTender(); const { data: purchaseTenderData = {} } : any = useFetchPurchaseTender(); const SelectedPurchaseList = useSelector((state: any) => state?.selectPurchaseTender); const liveCount = liveTenderData?.totalCount || 0; const purchaseCount = purchaseTenderData?.pages?.[0]?.totalCount || 0; const [selectedTab, setSelectedTab] = useState<'live' | 'purchase'>('live'); const translateX = useRef(new Animated.Value(0)).current; const onTabPress = (tab: 'live' | 'purchase', index: number) => { setSelectedTab(tab); Animated.spring(translateX, { toValue: index * TAB_WIDTH, useNativeDriver: true, friction: 8, }).start(); }; return ( {/* Switch Tabs */} onTabPress('live', 0)} > Live ({liveCount}) onTabPress('purchase', 1)} > Purchased ({purchaseCount}) {/* Cart */} {SelectedPurchaseList.length && {SelectedPurchaseList.length} } { Navigation.navigate(NavigationString.PurchaseTenderList) }}> {selectedTab === 'live' ? : } ); }; export default Tender; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: colors.white, }, /* ---------- Switch UI ---------- */ switchWrapper: { flexDirection: 'row', marginVertical: 14, backgroundColor: '#f1f5f9', borderRadius: 18, padding: 2, height: TAB_HEIGHT, }, tab: { width: TAB_WIDTH, height: TAB_HEIGHT - 4, alignItems: 'center', justifyContent: 'center', zIndex: 2, }, tabText: { fontSize: 14, color: '#64748b', lineHeight: 18, fontFamily: FontsFamily.poppinsSemiBold }, activeText: { color: colors.primary, }, activeTab: { position: 'absolute', top: 2, left: 2, width: TAB_WIDTH, height: TAB_HEIGHT - 4, backgroundColor: '#fff', borderRadius: 16, shadowColor: '#000', shadowOpacity: 0.1, shadowRadius: 6, elevation: 3, }, });