import React from "react"; import { View, Text, TouchableOpacity, StyleSheet, Alert, ScrollView, Image, } from "react-native"; import { useNavigation, useRouter } from "expo-router"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { Ionicons } from "@expo/vector-icons"; import { useAuth } from "../../hooks/useAuth"; export default function AccountScreen() { const router = useRouter(); const insets = useSafeAreaInsets(); const { user, logout } = useAuth(); const handleLogout = async () => { Alert.alert("Đăng xuất", "Bạn có chắc muốn đăng xuất?", [ { text: "Hủy", style: "cancel", }, { text: "Đăng xuất", style: "destructive", onPress: async () => { const success = await logout(); if (success) { router.replace("/"); } }, }, ]); }; const menuItems = [ { id: "address", label: "Address", icon: "location" }, { id: "payment", label: "Payment method", icon: "card" }, { id: "voucher", label: "Voucher", icon: "ticket" }, { id: "wishlist", label: "My Wishlist", icon: "heart" , screen: "wishlist"}, { id: "rate", label: "Rate this app", icon: "star" }, ]; const navigation = useNavigation(); return ( {/* Header with Settings Icon */} My Profile {/* User Profile Section */} {/* Avatar */} {/* User Info */} {user?.email?.split("@")[0] || "User"} {user?.email || "email@example.com"} {/* Menu Items */} {menuItems.map((item) => ( { if (item.screen) { navigation.navigate(item.screen); } }} > {item.label} ))} {/* Logout Button */} Log out ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fff", }, header: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", paddingHorizontal: 16, paddingVertical: 12, borderBottomWidth: 1, borderBottomColor: "#f0f0f0", }, headerTitle: { fontSize: 18, fontWeight: "700", color: "#333", }, settingsBtn: { padding: 8, }, scrollView: { flex: 1, }, profileSection: { paddingHorizontal: 16, paddingVertical: 24, borderBottomWidth: 1, borderBottomColor: "#f5f5f5", }, profileContent: { flexDirection: "row", alignItems: "center", }, avatarContainer: { marginRight: 16, }, avatar: { width: 60, height: 60, borderRadius: 30, backgroundColor: "#D4A574", justifyContent: "center", alignItems: "center", }, userInfo: { flex: 1, }, userName: { fontSize: 16, fontWeight: "700", color: "#333", marginBottom: 4, textTransform: "capitalize", }, userEmail: { fontSize: 13, color: "#999", }, menuContainer: { paddingHorizontal: 16, paddingVertical: 16, }, menuItem: { paddingVertical: 14, borderBottomWidth: 1, borderBottomColor: "#f5f5f5", }, menuItemContent: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", }, menuItemLeft: { flexDirection: "row", alignItems: "center", }, menuItemText: { marginLeft: 16, fontSize: 14, fontWeight: "500", color: "#333", }, logoutMenuItem: { marginTop: 8, }, logoutText: { color: "#E74C3C", }, });