Diff of /mobile/ElderCare/App.js [000000] .. [3739ec]

Switch to unified view

a b/mobile/ElderCare/App.js
1
import * as React from 'react';
2
import { NavigationContainer } from '@react-navigation/native';
3
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
4
import { Image, StyleSheet, Text, View } from 'react-native';
5
6
import HomeScreen from './HomeScreen';
7
import AddElderScreen from './AddElderScreen';
8
import ConnectDeviceScreen from './ConnectDeviceScreen';
9
10
const Tab = createBottomTabNavigator();
11
12
const tabBarIcon = (route, focused, color, size) => {
13
    let iconName;
14
15
    if (route.name === 'Home') {
16
        iconName = require('./assets/home.png');
17
    } else if (route.name === 'Add Elder') {
18
        iconName = require('./assets/add.png');
19
    } else if (route.name === 'Connect Device') {
20
        iconName = require('./assets/device.png');
21
    }
22
23
    return <Image source={iconName} style={{ width: size, height: size }} />;
24
};
25
26
const screenOptions = ({ route }) => ({
27
    tabBarIcon: ({ focused, color, size }) =>
28
        tabBarIcon(route, focused, color, size),
29
    tabBarActiveTintColor: '#2D328C',
30
    tabBarInactiveTintColor: 'gray',
31
    tabBarStyle: {
32
        height: 60, // Increase height
33
        paddingBottom: 10, // Adjust padding to give some margin
34
    },
35
    tabBarIconStyle: {
36
        marginBottom: 0, // Adjust icon margin bottom
37
    },
38
    tabBarLabelStyle: {
39
        fontSize: 16, // Default font size
40
        fontWeight: 'normal', // Default font weight
41
    },
42
    tabBarLabel: ({ focused, color }) => (
43
        <Text
44
            style={{
45
                fontSize: focused ? 14 : 12, // Larger font size for selected
46
                fontWeight: focused ? 'bold' : 'normal', // Bold for selected
47
                color: color, // Use the color provided by tabBarActiveTintColor or tabBarInactiveTintColor
48
            }}>
49
            {route.name}
50
        </Text>
51
    ),
52
    headerTitleAlign: 'left',
53
    headerTitle: ({ focused }) => (
54
        <View style={{ flexDirection: 'row', alignItems: 'center' }}>
55
            {tabBarIcon(route, focused, '#2D328C', 25)}
56
            <Text
57
                style={{
58
                    marginLeft: 10,
59
                    fontSize: 18,
60
                    color: '#2D328C',
61
                    fontWeight: 'bold',
62
                }}>
63
                {route.name}
64
            </Text>
65
        </View>
66
    ),
67
});
68
69
export default function App() {
70
    return (
71
        <NavigationContainer>
72
            <Tab.Navigator
73
                initialRouteName="Home"
74
                screenOptions={screenOptions}>
75
                <Tab.Screen name="Home" component={HomeScreen} />
76
                <Tab.Screen name="Add Elder" component={AddElderScreen} />
77
                <Tab.Screen
78
                    name="Connect Device"
79
                    component={ConnectDeviceScreen}
80
                />
81
            </Tab.Navigator>
82
        </NavigationContainer>
83
    );
84
}
85
86
const styles = StyleSheet.create({
87
    container: {
88
        flex: 1,
89
        backgroundColor: '#fff',
90
        alignItems: 'center',
91
        justifyContent: 'center',
92
    },
93
});