import React, { useRef, useState } from "react"; import { Animated, Dimensions, LayoutAnimation, Platform, ScrollView, StyleSheet, Text, TouchableOpacity, View, } from "react-native"; import BottomNav from "../../components/main/BottomNav"; import Header from "../../components/main/Header"; import Cart from "./Cart"; import Chat from "./Chat"; import Home from "./Home"; import Notification from "./Notification"; import Profile from "./Profile"; const height = Dimensions.get("window").height; const Main = ({ cartList }) => { const [tabActive, settabActive] = useState("home"); // const [switchTab, setswitch] = useState("prod"); const [switchTab, setSwitchTab] = useState("prod"); const animatedValue = useRef(new Animated.Value(0)).current; const handleTabPress = (tab) => { // Determine the target value based on the selected tab const targetValue = tab === 'prod' ? 0 : 1; // Create a spring animation Animated.spring(animatedValue, { toValue: targetValue, friction: 5, // Adjust the friction to control the bounce effect tension: 10, // Adjust the tension to control the bounce effect useNativeDriver: true, }).start(); // Update the selected tab setSwitchTab(tab); }; // Interpolate the animated value to determine background color const backgroundColor = animatedValue.interpolate({ inputRange: [0, 1], outputRange: ['#ffaa00', '#ffaa00'], // Adjust colors as needed }); return ( {tabActive === "home" ? ( ) : tabActive === "notif" ? ( ) : tabActive === "message" ? ( ) : tabActive === "cart" ? ( ) : tabActive === "profile" ? ( ) : ( )} {tabActive === "home" ? ( handleTabPress('prod')} activeOpacity={0.8} > Products handleTabPress('ven')} activeOpacity={0.8} > Vendor ) : null} ); }; const styles = StyleSheet.create({ container: { backgroundColor: "#fff", height: "100%", width: "100%", justifyContent: "center", alignItems: "center", }, header: { position: "fixed", width: "100%", top: 0, }, footer: { // position: "absolute", bottom: 0, width: "100%", }, wrapper: { height: "100%", }, tabsCon: { height: 80, width: "100%", position: "absolute", justifyContent: "center", alignItems: "center", bottom: 50, }, tabs: { // height: 30, margin: "auto", flexDirection: "row", backgroundColor: "#fff", borderRadius: 15, overflow: "hidden", borderWidth: 1, borderColor: "#ddd", // padding:10 }, tab: { paddingVertical: 15, paddingHorizontal: 25, }, tabActive: { backgroundColor: "#ffaa00", paddingVertical: 15, paddingHorizontal: 25, borderRadius: 15, }, tabText: { textTransform: "uppercase", color: "#383838", fontWeight: "600", }, tabTextActive: { textTransform: "uppercase", color: "#fff", fontWeight: "600", }, }); export default Main;