/** * The app navigator (formerly "AppNavigator" and "MainNavigator") is used for the primary * navigation flows of your app. * Generally speaking, it will contain an auth flow (registration, login, forgot password) * and a "main" flow which the user will use once logged in. */ import { NavigationContainer } from "@react-navigation/native" import { createNativeStackNavigator } from "@react-navigation/native-stack" import Config from "@/config" import { useAuth } from "@/context/AuthContext" // @demo remove-current-line import { ErrorBoundary } from "@/screens/ErrorScreen/ErrorBoundary" import { LoginScreen } from "@/screens/LoginScreen" // @demo remove-current-line import { WelcomeScreen } from "@/screens/WelcomeScreen" import { useAppTheme } from "@/theme/context" import { DemoNavigator } from "./DemoNavigator" // @demo remove-current-line import { navigationRef, useBackButtonHandler } from "./navigationUtilities" import type { AppStackParamList, NavigationProps } from "./navigationTypes" /** * This is a list of all the route names that will exit the app if the back button * is pressed while in that screen. Only affects Android. */ const exitRoutes = Config.exitRoutes // Documentation: https://reactnavigation.org/docs/stack-navigator/ const Stack = createNativeStackNavigator() const AppStack = () => { // @demo remove-block-start const { isAuthenticated } = useAuth() // @demo remove-block-end const { theme: { colors }, } = useAppTheme() return ( {/* @demo remove-block-start */} {isAuthenticated ? ( <> {/* @demo remove-block-end */} {/* @demo remove-block-start */} ) : ( <> )} {/* @demo remove-block-end */} {/** 🔥 Your screens go here */} {/* IGNITE_GENERATOR_ANCHOR_APP_STACK_SCREENS */} ) } export const AppNavigator = (props: NavigationProps) => { const { navigationTheme } = useAppTheme() useBackButtonHandler((routeName) => exitRoutes.includes(routeName)) return ( ) }