1+ // app/_layout.tsx
2+ import React from "react" ;
3+ import { View , Text , TouchableOpacity , StyleSheet , useColorScheme } from "react-native" ;
4+ import { Stack , useRouter , usePathname } from "expo-router" ;
5+ import { Ionicons } from "@expo/vector-icons" ;
6+ import { SafeAreaProvider } from "react-native-safe-area-context" ;
7+
8+ export default function RootLayout ( ) {
9+ const router = useRouter ( ) ;
10+ const pathname = usePathname ( ) ;
11+ const scheme = useColorScheme ( ) ;
12+ const isDark = scheme === "dark" ;
13+
14+ // Define colors based on theme
15+ const colors = {
16+ background : isDark ? "#121212" : "#f2f2f2" ,
17+ card : isDark ? "#1e1e1e" : "#fff" ,
18+ text : isDark ? "#fff" : "#333" ,
19+ subtext : isDark ? "#ccc" : "#666" ,
20+ border : isDark ? "#333" : "#ccc" ,
21+ accent : "#4caf50" ,
22+ } ;
23+
24+ const tabs : { name : string ; icon : React . ComponentProps < typeof Ionicons > [ "name" ] ; path : "/" | "/focus" | "/notes" | "/game" } [ ] = [
25+ { name : "Tasks" , icon : "checkbox-outline" , path : "/" } ,
26+ { name : "Focus" , icon : "timer-outline" , path : "/focus" } ,
27+ { name : "Notes" , icon : "document-text-outline" , path : "/notes" } ,
28+ { name : "Game" , icon : "grid-outline" , path : "/game" } ,
29+ ] ;
30+
31+ return (
32+ < SafeAreaProvider >
33+ < Stack screenOptions = { { headerShown : false } } />
34+
35+ { /* Bottom Navigation */ }
36+ < View style = { [ styles . tabBar , { backgroundColor : colors . card , borderTopColor : colors . border } ] } >
37+ { tabs . map ( ( tab ) => (
38+ < TouchableOpacity
39+ key = { tab . path }
40+ style = { styles . tabItem }
41+ onPress = { ( ) => router . push ( tab . path ) }
42+ >
43+ < Ionicons
44+ name = { tab . icon }
45+ size = { 24 }
46+ color = { pathname === tab . path ? colors . accent : colors . subtext }
47+ />
48+ < Text
49+ style = { [
50+ styles . tabText ,
51+ { color : pathname === tab . path ? colors . accent : colors . subtext } ,
52+ ] }
53+ >
54+ { tab . name }
55+ </ Text >
56+ </ TouchableOpacity >
57+ ) ) }
58+ </ View >
59+ </ SafeAreaProvider >
60+ ) ;
61+ }
62+
63+ const styles = StyleSheet . create ( {
64+ tabBar : {
65+ flexDirection : "row" ,
66+ position : "absolute" ,
67+ bottom : 0 ,
68+ left : 0 ,
69+ right : 0 ,
70+ height : 70 ,
71+ borderTopWidth : 1 ,
72+ paddingBottom : 10 ,
73+ } ,
74+ tabItem : {
75+ flex : 1 ,
76+ alignItems : "center" ,
77+ justifyContent : "center" ,
78+ } ,
79+ tabText : {
80+ fontSize : 12 ,
81+ marginTop : 4 ,
82+ } ,
83+ } ) ;
0 commit comments