Obanana_test/app/components/profile/Card.jsx

66 lines
1.8 KiB
React
Raw Normal View History

2023-09-26 14:33:01 +08:00
import { faAngleRight } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
2024-02-12 08:58:57 +08:00
import AsyncStorage from "@react-native-async-storage/async-storage";
2023-09-26 14:33:01 +08:00
import { useNavigation } from "@react-navigation/native";
import React from "react";
2024-02-12 08:58:57 +08:00
import { Linking } from "react-native";
2023-09-26 14:33:01 +08:00
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
const Card = ({ cart }) => {
const navigation = useNavigation();
2024-02-12 08:58:57 +08:00
const navigate = () => {
if (
cart.nav === "MyPurchases" ||
cart.nav === "MyWallet" ||
cart.nav === "MyFavorites" ||
cart.nav === "ViewHistory" ||
cart.nav === "AccountSettings"
) {
AsyncStorage.getItem("AccessToken")
.then((pass) => {
console.log(pass);
pass === null
? navigation.navigate("Login")
: navigation.navigate(cart.nav);
})
.catch((error) => {
console.log(error + "weeewwww");
});
} else if (cart.nav === "Privacy") {
Linking.openURL("https://www.obanana.com/privacy-policy.php");
} else {
navigation.navigate(cart.nav, { isrefresh: false });
}
};
2023-09-26 14:33:01 +08:00
return (
<View style={styles.container}>
2024-02-12 08:58:57 +08:00
<TouchableOpacity style={styles.subContent} onPress={() => navigate()}>
2023-09-26 14:33:01 +08:00
{cart.icon}
<Text style={styles.subContentText}>{cart.label}</Text>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
container: {
width: 120,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
},
subContent: {
2024-02-12 08:58:57 +08:00
borderRadius: 10,
2023-09-26 14:33:01 +08:00
width: "80%",
2024-02-12 08:58:57 +08:00
height: 140,
margin: "auto",
2023-09-26 14:33:01 +08:00
alignItems: "center",
2024-02-12 08:58:57 +08:00
paddingTop: 30,
},
subContentText: {
marginTop: 15,
color: "#777777",
textAlign: "center",
2023-09-26 14:33:01 +08:00
},
});
2024-02-12 08:58:57 +08:00
export default Card;