-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
74 lines (62 loc) · 2.39 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import React, { useState } from 'react';
import { View, Switch, StyleSheet, useColorScheme } from 'react-native';
import { NavigationContainer, DefaultTheme, DarkTheme } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import Dashboard from './screens/Dashboard';
import Registration from './screens/Registration';
import Feedback from './screens/Feedback';
import { NavigationIndependentTree } from '@react-navigation/native';
import Icon from 'react-native-vector-icons/Ionicons';
import theme from './components/theme';
const Tab = createBottomTabNavigator();
export default function App() {
const [isDarkMode, setIsDarkMode] = useState(false);
const scheme = useColorScheme();
const toggleTheme = () => {
setIsDarkMode(!isDarkMode);
};
const currentTheme = isDarkMode ? theme.dark : theme.light;
return (
<NavigationIndependentTree>
<NavigationContainer theme={isDarkMode ? DarkTheme : DefaultTheme}>
{/* Theme Toggle */}
<View style={[styles.switchContainer, { backgroundColor: currentTheme.background }]}>
<Switch value={isDarkMode} onValueChange={toggleTheme} />
</View>
{/* Bottom Tabs */}
<Tab.Navigator
screenOptions={({ route }) => ({
headerShown: false, // Hides default headers for screens
tabBarStyle: {
backgroundColor: currentTheme.background,
},
tabBarActiveTintColor: currentTheme.text,
tabBarInactiveTintColor: isDarkMode ? '#888' : '#aaa',
tabBarIcon: ({ color, size }) => {
let iconName;
if (route.name === 'Dashboard') {
iconName = 'home-outline';
} else if (route.name === 'Feedback') {
iconName = 'chatbubble-ellipses-outline';
}
return <Icon name={iconName} size={size} color={color} />;
},
})}
>
<Tab.Screen name="Dashboard" children={() => <Dashboard theme={currentTheme} />} />
<Tab.Screen name="Feedback" children={() => <Feedback theme={currentTheme} />} />
</Tab.Navigator>
</NavigationContainer>
</NavigationIndependentTree>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'flex-end',
},
switchContainer: {
alignItems: 'flex-end',
padding: 10,
}
});