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";
import { LinearGradient } from "expo-linear-gradient";
import { theme } from "../../styles/theme";
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 with Gradient */}
{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: theme.colors.background,
},
content: {
padding: 20,
paddingTop: 60,
},
profileCard: {
borderRadius: theme.borderRadius.xl,
padding: 28,
alignItems: "center",
marginBottom: 24,
},
avatarContainer: {
marginBottom: 16,
},
avatar: {
width: 96,
height: 96,
borderRadius: 48,
justifyContent: "center",
alignItems: "center",
borderWidth: 3,
borderColor: "rgba(255, 255, 255, 0.3)",
},
avatarText: {
fontSize: theme.typography.fontSize['4xl'],
fontWeight: theme.typography.fontWeight.bold,
color: theme.colors.white,
},
name: {
fontSize: theme.typography.fontSize['2xl'],
fontWeight: theme.typography.fontWeight.bold,
color: theme.colors.white,
marginBottom: 6,
},
email: {
fontSize: theme.typography.fontSize.base,
color: "rgba(255, 255, 255, 0.9)",
marginBottom: 4,
},
phone: {
fontSize: theme.typography.fontSize.sm,
color: "rgba(255, 255, 255, 0.8)",
},
section: {
marginBottom: 24,
},
sectionTitle: {
fontSize: theme.typography.fontSize.xl,
fontWeight: theme.typography.fontWeight.semibold,
color: theme.colors.gray900,
marginBottom: 12,
},
infoCard: {
backgroundColor: theme.colors.white,
borderRadius: theme.borderRadius.xl,
padding: 16,
},
infoRow: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingVertical: 14,
borderBottomWidth: 1,
borderBottomColor: theme.colors.gray200,
},
infoLabel: {
flexDirection: "row",
alignItems: "center",
gap: 10,
},
infoIconContainer: {
width: 36,
height: 36,
borderRadius: 18,
justifyContent: "center",
alignItems: "center",
},
infoLabelText: {
fontSize: theme.typography.fontSize.sm,
color: theme.colors.gray700,
fontWeight: theme.typography.fontWeight.medium,
},
infoValue: {
fontSize: theme.typography.fontSize.sm,
color: theme.colors.gray900,
fontWeight: theme.typography.fontWeight.semibold,
},
actionButton: {
flexDirection: "row",
alignItems: "center",
backgroundColor: theme.colors.white,
borderRadius: theme.borderRadius.xl,
padding: 16,
marginBottom: 12,
},
actionIconContainer: {
width: 44,
height: 44,
borderRadius: 22,
justifyContent: "center",
alignItems: "center",
marginRight: 12,
},
actionButtonText: {
flex: 1,
fontSize: theme.typography.fontSize.base,
color: theme.colors.gray900,
fontWeight: theme.typography.fontWeight.medium,
},
logoutButton: {
paddingVertical: 16,
borderRadius: theme.borderRadius.lg,
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
gap: 8,
marginTop: 8,
marginBottom: 16,
},
logoutText: {
color: theme.colors.white,
fontSize: theme.typography.fontSize.base,
fontWeight: theme.typography.fontWeight.semibold,
},
version: {
textAlign: "center",
fontSize: theme.typography.fontSize.xs,
color: theme.colors.gray500,
marginTop: 8,
marginBottom: 20,
},
});