import React from "react";
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Alert,
ScrollView,
} from "react-native";
import { useUser, useAuth } from "@clerk/clerk-expo";
import { useRouter } from "expo-router";
import { Ionicons } from "@expo/vector-icons";
export default function ProfileScreen() {
const { user } = useUser();
const { signOut } = useAuth();
const router = useRouter();
const handleLogout = async () => {
Alert.alert("Sign Out", "Are you sure you want to sign out?", [
{ text: "Cancel", style: "cancel" },
{
text: "Sign Out",
style: "destructive",
onPress: async () => {
try {
await signOut();
router.replace("/(auth)/sign-in");
} catch (error) {
Alert.alert("Error", "Failed to sign out");
}
},
},
]);
};
if (!user) {
return (
Loading...
);
}
return (
{/* Profile Header */}
{user.imageUrl ? (
{user.firstName?.charAt(0)}
{user.lastName?.charAt(0)}
) : (
)}
{user.firstName} {user.lastName}
{user.primaryEmailAddress?.emailAddress}
{user.primaryPhoneNumber && (
{user.primaryPhoneNumber.phoneNumber}
)}
{/* Account Information */}
Account Information
Email
{user.primaryEmailAddress?.emailAddress}
{user.primaryPhoneNumber && (
Phone
{user.primaryPhoneNumber.phoneNumber}
)}
Member Since
{new Date(user.createdAt!).toLocaleDateString()}
Email Verified
{user.primaryEmailAddress?.verification?.status === "verified"
? "Yes"
: "No"}
{/* Quick Actions */}
Quick Actions
Edit Profile
Notifications
Payment History
Settings
{/* Sign Out Button */}
Sign Out
{/* App Version */}
Version 1.0.0
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#f5f5f5",
},
content: {
padding: 20,
},
profileCard: {
backgroundColor: "white",
borderRadius: 16,
padding: 24,
alignItems: "center",
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 8,
elevation: 4,
marginBottom: 24,
},
avatarContainer: {
marginBottom: 16,
},
avatar: {
width: 80,
height: 80,
borderRadius: 40,
backgroundColor: "#2563eb",
justifyContent: "center",
alignItems: "center",
},
avatarText: {
fontSize: 32,
fontWeight: "bold",
color: "#fff",
},
name: {
fontSize: 24,
fontWeight: "bold",
color: "#1a1a1a",
marginBottom: 4,
},
email: {
fontSize: 16,
color: "#666",
marginBottom: 4,
},
phone: {
fontSize: 14,
color: "#999",
},
section: {
backgroundColor: "white",
borderRadius: 16,
padding: 20,
marginBottom: 16,
shadowColor: "#000",
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.05,
shadowRadius: 4,
elevation: 2,
},
sectionTitle: {
fontSize: 18,
fontWeight: "600",
color: "#1a1a1a",
marginBottom: 16,
},
infoRow: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingVertical: 12,
borderBottomWidth: 1,
borderBottomColor: "#f0f0f0",
},
infoLabel: {
flexDirection: "row",
alignItems: "center",
gap: 8,
},
infoLabelText: {
fontSize: 14,
color: "#666",
fontWeight: "500",
},
infoValue: {
fontSize: 14,
color: "#1a1a1a",
fontWeight: "500",
},
actionButton: {
flexDirection: "row",
alignItems: "center",
paddingVertical: 16,
borderBottomWidth: 1,
borderBottomColor: "#f0f0f0",
},
actionButtonText: {
flex: 1,
fontSize: 16,
color: "#1a1a1a",
marginLeft: 12,
fontWeight: "500",
},
logoutButton: {
backgroundColor: "#ef4444",
paddingVertical: 16,
borderRadius: 12,
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
gap: 8,
marginTop: 8,
marginBottom: 16,
shadowColor: "#ef4444",
shadowOffset: { width: 0, height: 4 },
shadowOpacity: 0.3,
shadowRadius: 8,
elevation: 4,
},
logoutText: {
color: "white",
fontSize: 16,
fontWeight: "600",
},
version: {
textAlign: "center",
fontSize: 12,
color: "#999",
marginTop: 8,
marginBottom: 20,
},
});