import { ProductDetailsShimmer } from "@/components/ProductDetailsShimmer"; import { fetchProduct } from "@/utils/api"; import { COLORS } from "@/utils/colors"; import { useQuery } from "@tanstack/react-query"; import { Image } from "expo-image"; import { Stack, useLocalSearchParams } from "expo-router"; import React from "react"; import useCartStore from "@/store/cartStore"; import { Ionicons } from "@expo/vector-icons"; import { Platform, ScrollView, Share, StyleSheet, Text, TouchableOpacity, View, } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; const Page = () => { const { id } = useLocalSearchParams(); const { bottom } = useSafeAreaInsets(); const { addProduct } = useCartStore(); const { data: product, isLoading } = useQuery({ queryKey: ["product", id], queryFn: () => fetchProduct(Number(id)), }); const onShare = async () => { const url = `mnkyshop://product/${product?.id}`; if (Platform.OS === "ios") { await Share.share({ url, message: `Check out this product on Galaxies Shop: ${url}`, }); } else { await Share.share({ message: `Check out this product on Galaxies Shop: ${url}`, }); } }; if (isLoading) { return ; } if (!product) { return Product not found; } const handleAddToCart = () => { addProduct(product); }; return ( ( ), }} /> {product.title} ${product.price} {product.category} {product.description} ★ {product.rating.rate} ({product.rating.count} reviews) Add to Cart ); }; export default Page; const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fff", }, image: { width: "100%", height: 300, backgroundColor: "#f9f9f9", }, content: { padding: 16, gap: 12, }, title: { fontSize: 24, fontWeight: "600", }, price: { fontSize: 20, fontWeight: "700", color: COLORS.primary, }, category: { fontSize: 16, color: "#666", textTransform: "capitalize", }, description: { fontSize: 16, lineHeight: 24, color: "#333", }, ratingContainer: { flexDirection: "row", alignItems: "center", gap: 8, }, rating: { fontSize: 16, fontWeight: "600", color: "#FFB800", }, ratingCount: { fontSize: 14, color: "#666", }, addToCartButton: { backgroundColor: COLORS.primary, flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 8, padding: 16, }, addToCartText: { color: "white", fontWeight: "600", fontSize: 16, }, });