← back to Costa Rica App

app/_layout.tsx

20 lines

import { Stack } from 'expo-router';
import { useEffect, useState } from 'react';
import { loadToken } from '../src/api';

export default function RootLayout() {
  const [ready, setReady] = useState(false);
  useEffect(() => { loadToken().finally(() => setReady(true)); }, []);
  if (!ready) return null;
  return (
    <Stack screenOptions={{ headerStyle: { backgroundColor: '#0a7d55' }, headerTintColor: '#fff' }}>
      <Stack.Screen name="index" options={{ title: 'Costa Rica' }} />
      <Stack.Screen name="listing/[slug]" options={{ title: 'Listing' }} />
      <Stack.Screen name="book/[slug]" options={{ title: 'Book' }} />
      <Stack.Screen name="bookings" options={{ title: 'My Bookings' }} />
      <Stack.Screen name="login" options={{ title: 'Sign in', presentation: 'modal' }} />
      <Stack.Screen name="host" options={{ title: 'Become a Host' }} />
    </Stack>
  );
}