import React from 'react';
import {
View,
ScrollView,
Text,
StyleSheet,
SafeAreaView,
TouchableOpacity,
Alert,
ActivityIndicator,
} from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { useRouter } from 'expo-router';
import { useAuthStore } from '../lib/auth-store';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#f5f5f5',
},
profileHeader: {
backgroundColor: '#fff',
paddingVertical: 24,
paddingHorizontal: 16,
alignItems: 'center',
borderBottomWidth: 1,
borderBottomColor: '#e0e0e0',
},
avatar: {
width: 80,
height: 80,
borderRadius: 40,
backgroundColor: '#0066cc',
justifyContent: 'center',
alignItems: 'center',
marginBottom: 12,
},
avatarText: {
color: '#fff',
fontSize: 32,
fontWeight: '700',
},
profileName: {
fontSize: 20,
fontWeight: '700',
color: '#000',
marginBottom: 4,
},
profileStatus: {
fontSize: 14,
color: '#666',
},
section: {
paddingHorizontal: 16,
marginTop: 16,
},
sectionTitle: {
fontSize: 14,
fontWeight: '600',
color: '#999',
textTransform: 'uppercase',
marginBottom: 8,
},
menuItem: {
backgroundColor: '#fff',
paddingVertical: 14,
paddingHorizontal: 16,
borderBottomWidth: 1,
borderBottomColor: '#f0f0f0',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
menuItemFirst: {
borderTopLeftRadius: 12,
borderTopRightRadius: 12,
},
menuItemLast: {
borderBottomLeftRadius: 12,
borderBottomRightRadius: 12,
borderBottomWidth: 0,
},
menuIcon: {
width: 24,
height: 24,
justifyContent: 'center',
alignItems: 'center',
marginRight: 12,
},
menuLabel: {
fontSize: 15,
color: '#000',
flex: 1,
fontWeight: '500',
},
menuArrow: {
color: '#999',
},
signOutButton: {
backgroundColor: '#fff',
paddingVertical: 12,
paddingHorizontal: 16,
marginTop: 8,
borderRadius: 12,
alignItems: 'center',
borderWidth: 1,
borderColor: '#ff4444',
},
signOutText: {
color: '#ff4444',
fontSize: 15,
fontWeight: '600',
},
});
export default function ProfileScreen() {
const router = useRouter();
const { user, isAuthenticated, isLoading, logout } = useAuthStore();
const handleSignOut = () => {
Alert.alert('Sign Out', 'Are you sure you want to sign out?', [
{ text: 'Cancel', style: 'cancel' },
{
text: 'Sign Out',
style: 'destructive',
onPress: async () => {
await logout();
router.replace('/(auth)/login');
},
},
]);
};
const handleSignIn = () => {
router.push('/(auth)/login');
};
// Get user initials for avatar
const getInitials = () => {
if (!user?.name) return '?';
const names = user.name.split(' ');
if (names.length >= 2) {
return `${names[0][0]}${names[1][0]}`.toUpperCase();
}
return names[0][0].toUpperCase();
};
if (!isAuthenticated) {
return (
Welcome
Sign in to access your profile
Sign In
About
About Us
Privacy Policy
Terms of Service
);
}
return (
{getInitials()}
{user?.name || 'User'}
{user?.email || 'Active Member'}
Account
Edit Profile
Notifications
Change Password
Preferences
Dark Mode
Language
Help
Help & Support
Contact Us
Sign Out
);
}