Obanana_test/app/pages/profile/MyPurchases.jsx

182 lines
5.1 KiB
React
Raw Normal View History

2023-09-26 14:33:01 +08:00
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
import { useNavigation } from "@react-navigation/native";
import React from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import { createMaterialTopTabNavigator } from "@react-navigation/material-top-tabs";
import CompletedCard from "../../components/profile/my_purchases/CompletedCard";
import MasonryList from "@react-native-seoul/masonry-list";
import { checkOut } from "../../constants/checkout";
import ToPayCard from "../../components/profile/my_purchases/ToPay";
import ToShipCard from "../../components/profile/my_purchases/ToShip";
import ToReceiveCard from "../../components/profile/my_purchases/ToReceive";
const Tab = createMaterialTopTabNavigator();
function ToPay() {
return (
<View style={styles.tabCon}>
<MasonryList
data={checkOut.filter((item) => item.status === "to pay")}
keyExtractor={(item) => item.id}
style={styles.list}
numColumns={1}
showsVerticalScrollIndicator={false}
renderItem={({ item }) => <ToPayCard cart={item} />}
containerStyle={styles.container1}
contentContainerStyle={styles.content}
onEndReachedThreshold={0.1}
/>
</View>
);
}
function ToShip() {
return (
<View style={styles.tabCon}>
<MasonryList
data={checkOut.filter((item) => item.status === "to ship")}
keyExtractor={(item) => item.id}
style={styles.list}
numColumns={1}
showsVerticalScrollIndicator={false}
renderItem={({ item }) => <ToShipCard cart={item} />}
containerStyle={styles.container1}
contentContainerStyle={styles.content}
onEndReachedThreshold={0.1}
/>
</View>
);
}
function ToReceive() {
return (
<View style={styles.tabCon}>
<MasonryList
data={checkOut.filter((item) => item.status === "to receive")}
keyExtractor={(item) => item.id}
style={styles.list}
numColumns={1}
showsVerticalScrollIndicator={false}
renderItem={({ item }) => <ToReceiveCard cart={item} />}
containerStyle={styles.container1}
contentContainerStyle={styles.content}
onEndReachedThreshold={0.1}
/>
</View>
);
}
function Completed() {
return (
<View style={styles.tabCon}>
<MasonryList
data={checkOut.filter((item) => item.status === "completed")}
keyExtractor={(item) => item.id}
style={styles.list}
numColumns={1}
showsVerticalScrollIndicator={false}
renderItem={({ item }) => <CompletedCard cart={item} />}
containerStyle={styles.container1}
contentContainerStyle={styles.content}
onEndReachedThreshold={0.1}
/>
</View>
);
}
const MyPurchases = () => {
const navigation = useNavigation();
return (
<View style={styles.container}>
<View style={styles.header}>
<TouchableOpacity
onPress={() => navigation.navigate("Home")}
style={styles.backIcon}
>
<FontAwesomeIcon icon={faArrowLeft} color={"#d4c600"} size={25} />
</TouchableOpacity>
<Text style={styles.headerText}>My Purchases</Text>
</View>
<View style={styles.wrapper}>
<Tab.Navigator
scrollEnabled={true} // Set scrollEnabled to true to enable horizontal scrolling
screenOptions={{
tabBarScrollEnabled: true, // Make sure to set this to true as well
// Adjust the width of each tab as needed
tabBarIndicatorStyle: { backgroundColor: "#ffaa00" }, // Customize the indicator style
}}
>
<Tab.Screen
name="ToPay"
component={ToPay}
options={{ tabBarLabel: "To Pay" }}
initialParams={{}}
/>
<Tab.Screen
name="ToShip"
component={ToShip}
options={{ tabBarLabel: "To Ship" }}
initialParams={{}}
/>
<Tab.Screen
name="ToReceive"
component={ToReceive}
options={{ tabBarLabel: "To Receive" }}
initialParams={{}}
/>
<Tab.Screen
name="Completed"
component={Completed}
options={{ tabBarLabel: "Completed" }}
initialParams={{}}
/>
</Tab.Navigator>
</View>
</View>
);
};
const styles = StyleSheet.create({
container: {
backgroundColor: "#ffff",
width: "100%",
height: "100%",
},
wrapper: {
height: "95%",
width: "100%",
justifyContent: "center",
// alignItems:'center'
marginBottom: 20,
},
header: {
alignItems: "center",
width: "100%",
top: 0,
paddingLeft: 15,
flexDirection: "row",
borderColor: "#ddd",
paddingBottom: 15,
borderBottomWidth: 1,
},
headerText: {
fontSize: 16,
fontWeight: "600",
marginLeft: 25,
},
tabCon: {
width: "100%",
height: "100%",
},
list: {
width: "100%",
justifyContent: "center",
alignItems: "center",
padding: 5,
},
});
export default MyPurchases;