Navigation - GrasspIt/GrasspReactNativeDriverApp GitHub Wiki

This app uses react-navigation to navigate between screens.

Navigation Container

The NavigationContainer is located in App.jsx and wraps the app's navigation. The navigationRef is also initiated here, creating a ref to the navigators, so that navigation may be handled anywhere in the app. Including Redux action creators.

File Structure

Each navigator in the navigation folder contains different screens. Each screen in the screens folder acts as a parent component or container. Each screen connects to the Redux store, handles logic, and passes props to its child components in the components folder.

Auth Navigator

AuthNavigator handles user authentication and login. It handles auto-login if there is a valid token stored on the device. It then conditionally renders either the login screen or the drawer navigator if there is a logged in user. Learn more about authentication flows in React Navigation.

Drawer Navigator

DrawerNavigator contains the three main stack navigators in the app: Dashboard, Orders, and Routing. It also contains the Logout button for the user to log out. The drawer conditionally contains a DSPRScreen if the user is a driver for more than one DSPR. The drawer may be opened or closed by swiping from the left or by pressing the hamburger menu in the header.

Dashboard Navigator

DashboardNavigator is a stack navigator containing the DashboardScreen. This is the screen which handles background location tracking and push notifications.

OrderList Navigator

OrderListNavigator is a stack navigator containing the OrderListScreen, from which the user may navigate to the OrderDetailsScreen, and from there to the ManageNotesScreen.

OrderListScreen -> OrderDetailsScreen -> ManageNotesScreen

Routing Navigator

RoutingNavigator is a stack navigator containing the RoutingScreen, from which the user may navigate to the OrderDetailsScreen screen, and from there to the ManageNotesScreen.

RoutingScreen -> OrderDetailsScreen -> ManageNotesScreen