shahilsaha

Untitled

Dec 15th, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // ======================== _layout.jsx ==================
  3.  
  4. import { Stack } from "expo-router";
  5.  
  6. export default function RootLayout() {
  7.     return (
  8.         <Stack>
  9.             <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
  10.         </Stack>
  11.     );
  12. }
  13.  
  14.  
  15.  
  16. // ======================= _layout.web.jsx ===================================
  17. import { Button, Image } from "react-native";
  18. import { Stack } from "expo-router";
  19. import { NavBarRight, NavBarCenter } from "../components/NavBar";
  20.  
  21. const headerOptions = {
  22.     headerStyle: {
  23.         backgroundColor: "#000",
  24.     },
  25.     headerTintColor: "#fff", // Ensures the text/buttons are visible against the black background
  26.     headerTitleStyle: {
  27.         fontWeight: "bold",
  28.     },
  29.     headerShown: true,
  30.     headerTitleAlign: "center",
  31.  
  32.     // Custom Button in the headerTitle
  33.     headerTitle: () => <NavBarRight />,
  34.  
  35.     // Custom logo in the headerLeft
  36.     headerLeft: () => <NavBarCenter />,
  37. };
  38.  
  39. export default function RootLayout() {
  40.     const routes = [
  41.         { name: "home", title: "Home" },
  42.         { name: "about", title: "About" },
  43.     ];
  44.  
  45.     return (
  46.         <Stack screenOptions={headerOptions}>
  47.             {routes.map((route) => (
  48.                 <Stack.Screen
  49.                     key={route.name}
  50.                     name={route.name}
  51.                     options={{ title: route.title }}
  52.                 />
  53.             ))}
  54.         </Stack>
  55.     );
  56. }
  57.  
  58. // (tabs) directory _layout.jsx
  59. // =====================
  60. import FontAwesome from "@expo/vector-icons/FontAwesome";
  61. import { Tabs } from "expo-router";
  62.  
  63. export default function TabLayout() {
  64.     return (
  65.         <Tabs screenOptions={{ tabBarActiveTintColor: "blue" }}>
  66.             <Tabs.Screen
  67.                 name="(tabs)/index"
  68.                 options={{
  69.                     title: "Home",
  70.                     tabBarIcon: ({ color }) => (
  71.                         <FontAwesome size={28} name="home" color={color} />
  72.                     ),
  73.                 }}
  74.             />
  75.             <Tabs.Screen
  76.                 name="settings"
  77.                 options={{
  78.                     title: "Settings",
  79.                     tabBarIcon: ({ color }) => (
  80.                         <FontAwesome size={28} name="cog" color={color} />
  81.                     ),
  82.                 }}
  83.             />
  84.         </Tabs>
  85.     );
  86. }
  87.  
  88.  
Advertisement
Add Comment
Please, Sign In to add comment