BrixCafe/app/screens/user/ProfileScreen.tsx
2025-04-23 03:41:33 +01:00

93 lines
2.4 KiB
TypeScript

import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Alert } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { ArrowLeft } from 'lucide-react-native';
import { router } from "expo-router";
import { getAuth, signOut } from "firebase/auth";
export default function ProfileScreen() {
const handleSignOut = () => {
Alert.alert(
"Déconnexion",
"Êtes-vous sûr de vouloir vous déconnecter ?",
[
{ text: "Annuler", style: "cancel" },
{
text: "Se déconnecter",
style: "destructive",
onPress: async () => {
try {
const auth = getAuth();
await signOut(auth);
router.replace('/'); // Replace with your actual sign-in screen route
} catch (error) {
Alert.alert("Erreur", "Impossible de se déconnecter.");
console.error("Sign out error:", error);
}
}
}
]
);
};
return (
<SafeAreaView style={styles.container}>
<View style={styles.header}>
<TouchableOpacity style={styles.backButton} onPress={() => router.back()}>
<ArrowLeft size={24} color="#666" />
</TouchableOpacity>
<Text style={styles.headerTitle}>Espace Personnel</Text>
</View>
<View style={styles.body}>
<TouchableOpacity style={styles.signOutButton} onPress={handleSignOut}>
<Text style={styles.signOutButtonText}>Se déconnecter</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
},
header: {
height: 60,
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
backgroundColor: '#fff',
borderBottomWidth: 1,
borderBottomColor: '#eee',
marginTop: 5,
},
backButton: {
position: 'absolute',
left: 20,
top: '50%',
transform: [{ translateY: -12 }],
},
headerTitle: {
fontSize: 20,
fontWeight: '600',
color: '#333',
},
body: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
signOutButton: {
backgroundColor: '#B07B4F',
paddingVertical: 12,
paddingHorizontal: 24,
borderRadius: 10,
},
signOutButtonText: {
color: '#fff',
fontSize: 16,
fontWeight: '600',
},
});