-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathAppNavigator.tsx
More file actions
88 lines (80 loc) · 3.45 KB
/
AppNavigator.tsx
File metadata and controls
88 lines (80 loc) · 3.45 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
/**
* 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 { DarkTheme, DefaultTheme, NavigationContainer } from "@react-navigation/native"
import { createNativeStackNavigator, NativeStackScreenProps } from "@react-navigation/native-stack"
import { observer } from "mobx-react-lite"
import React from "react"
import { useColorScheme } from "react-native"
import * as Screens from "~/screens"
import { navigationRef } from "./navigationUtilities"
import { colors } from "~/theme"
/**
* This type allows TypeScript to know what routes are defined in this navigator
* as well as what properties (if any) they might take when navigating to them.
*
* If no params are allowed, pass through `undefined`. Generally speaking, we
* recommend using your MobX-State-Tree store(s) to keep application state
* rather than passing state through navigation params.
*
* For more information, see this documentation:
* https://reactnavigation.org/docs/params/
* https://reactnavigation.org/docs/typescript#type-checking-the-navigator
* https://reactnavigation.org/docs/typescript/#organizing-types
*/
export type AppStackParamList = {
Welcome: undefined
// 🔥 Your screens go here
Home: Record<string, never>
FaceDetection: Record<string, never>
ImageLabeling: Record<string, never>
ObjectDetection: Record<string, never>
DocumentScanner: Record<string, never>
TextRecognition: Record<string, never>
BarcodeScanning: Record<string, never>
// IGNITE_GENERATOR_ANCHOR_APP_STACK_PARAM_LIST
}
export type AppStackScreenProps<T extends keyof AppStackParamList> = NativeStackScreenProps<
AppStackParamList,
T
>
export type AppStackNavigationProp<T extends keyof AppStackParamList> =
AppStackScreenProps<T>["navigation"]
// Documentation: https://reactnavigation.org/docs/stack-navigator/
const Stack = createNativeStackNavigator<AppStackParamList>()
const AppStack = observer(function AppStack() {
return (
<Stack.Navigator
screenOptions={{ headerShown: false, navigationBarColor: colors.background }}
initialRouteName={"Home"}
>
<Stack.Screen name="Welcome" component={Screens.WelcomeScreen} />
{/** 🔥 Your screens go here */}
<Stack.Screen name="Home" component={Screens.HomeScreen} />
<Stack.Screen name="FaceDetection" component={Screens.FaceDetectionScreen} />
<Stack.Screen name="ImageLabeling" component={Screens.ImageLabelingScreen} />
<Stack.Screen name="ObjectDetection" component={Screens.ObjectDetectionScreen} />
<Stack.Screen name="DocumentScanner" component={Screens.DocumentScannerScreen} />
<Stack.Screen name="TextRecognition" component={Screens.TextRecognitionScreen} />
<Stack.Screen name="BarcodeScanning" component={Screens.BarcodeScanningScreen} />
{/* IGNITE_GENERATOR_ANCHOR_APP_STACK_SCREENS */}
</Stack.Navigator>
)
})
export interface NavigationProps
extends Partial<React.ComponentProps<typeof NavigationContainer>> {}
export const AppNavigator = observer(function AppNavigator(props: NavigationProps) {
const colorScheme = useColorScheme()
return (
<NavigationContainer
ref={navigationRef}
theme={colorScheme === "dark" ? DarkTheme : DefaultTheme}
{...props}
>
<AppStack />
</NavigationContainer>
)
})