-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
92 lines (86 loc) · 3.17 KB
/
App.js
File metadata and controls
92 lines (86 loc) · 3.17 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { Provider as PaperProvider } from 'react-native-paper';
import { MaterialCommunityIcons } from '@expo/vector-icons';
import { SettingsProvider } from './context';
import { theme } from './utils/theme';
// Import screens
import OnboardingScreen from './screens/OnboardingScreen.js';
import HomeScreen from './screens/HomeScreen.js';
import SolverScreen from './screens/SolverScreen.js';
import LearnScreen from './screens/LearnScreen.js';
import TimerScreen from './screens/TimerScreen.js';
import SettingsScreen from './screens/SettingsScreen.js';
import AlgorithmLibraryScreen from './screens/AlgorithmLibraryScreen.js';
import FlashcardsScreen from './screens/FlashcardsScreen.js';
const Tab = createBottomTabNavigator();
const Stack = createNativeStackNavigator();
// Adapt custom theme to Paper's format
const paperTheme = {
...theme,
colors: {
...theme.colors,
onBackground: theme.colors.text,
placeholder: theme.colors.textSecondary,
disabled: theme.colors.textSecondary,
},
};
const getTabIcon = (routeName, focused) => {
const icons = {
Home: focused ? 'home' : 'home-outline',
Solver: focused ? 'cube' : 'cube-outline',
Learn: focused ? 'school' : 'school-outline',
Timer: focused ? 'timer' : 'timer-outline',
};
return icons[routeName] || 'help';
};
function MainTabs() {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => (
<MaterialCommunityIcons
name={getTabIcon(route.name, focused)}
size={size}
color={color}
/>
),
tabBarActiveTintColor: theme.colors.primary,
tabBarInactiveTintColor: theme.colors.textSecondary,
tabBarStyle: {
backgroundColor: theme.colors.surface,
borderTopColor: theme.colors.border,
height: 60,
paddingBottom: 8,
paddingTop: 8,
},
headerShown: false,
})}
>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Solver" component={SolverScreen} />
<Tab.Screen name="Learn" component={LearnScreen} />
<Tab.Screen name="Timer" component={TimerScreen} />
</Tab.Navigator>
);
}
export default function App() {
return (
<SettingsProvider>
<PaperProvider theme={paperTheme}>
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }}>
<Stack.Screen name="Onboarding" component={OnboardingScreen} />
<Stack.Screen name="MainTabs" component={MainTabs} />
{/* Nested screens accessible from Home/Learn */}
<Stack.Screen name="Algorithms" component={AlgorithmLibraryScreen} />
<Stack.Screen name="Flashcards" component={FlashcardsScreen} />
<Stack.Screen name="Settings" component={SettingsScreen} />
</Stack.Navigator>
</NavigationContainer>
</PaperProvider>
</SettingsProvider>
);
}