Modify HomeScreen.js:
// screens/HomeScreen.js
import React, { useContext } from 'react';
import {
View,
Text,
TouchableOpacity,
StyleSheet,
SafeAreaView,
ScrollView,
} from 'react-native';
import { AuthContext } from '../context/AuthContext';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; // You can choose any icon set you prefer
const HomeScreen = ({ navigation }) => {
const { signOut } = useContext(AuthContext);
const menuItems = [
{
title: 'Exercises',
icon: 'run',
onPress: () => navigation.navigate('Exercises'),
},
{
title: 'Progress',
icon: 'graph',
onPress: () => navigation.navigate('Progress'),
},
{
title: 'Body Analysis',
icon: 'human-male-height',
onPress: () => navigation.navigate('BodyAnalysis'),
},
{
title: 'Nutrition',
icon: 'food',
onPress: () => navigation.navigate('Nutrition'),
},
{
title: 'Settings',
icon: 'cog',
onPress: () => navigation.navigate('Settings'),
},
{
title: 'Logout',
icon: 'logout',
onPress: signOut,
color: '#ff4d4d', // Red color for logout
},
];
return (
<SafeAreaView style={styles.safeArea}>
<ScrollView contentContainerStyle={styles.container}>
<Text style={styles.title}>Welcome, [User]!</Text>
<View style={styles.menuContainer}>
{menuItems.map((item, index) => (
<TouchableOpacity
key={index}
style={[
styles.menuItem,
item.color ? { backgroundColor: item.color } : {},
]}
onPress={item.onPress}
>
<Icon
name={item.icon}
size={30}
color={item.color ? '#fff' : '#4F8EF7'}
/>
<Text style={styles.menuText}>{item.title}</Text>
</TouchableOpacity>
))}
</View>
</ScrollView>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: '#f0f0f0',
},
container: {
flexGrow: 1,
alignItems: 'center',
justifyContent: 'center',
padding: 20,
backgroundColor: '#f0f0f0',
},
title: {
fontSize: 28,
fontWeight: 'bold',
marginBottom: 30,
color: '#333',
},
menuContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
width: '100%',
},
menuItem: {
width: '45%',
backgroundColor: '#fff',
borderRadius: 10,
padding: 20,
marginBottom: 20,
alignItems: 'center',
justifyContent: 'center',
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 5,
elevation: 3,
},
menuText: {
marginTop: 10,
fontSize: 16,
color: '#333',
},
});
export default HomeScreen;