summaryrefslogtreecommitdiff
path: root/app/navigators
diff options
context:
space:
mode:
Diffstat (limited to 'app/navigators')
-rw-r--r--app/navigators/index.ts6
-rw-r--r--app/navigators/main-navigator.tsx17
-rw-r--r--app/navigators/navigation-utilities.tsx27
-rw-r--r--app/navigators/root-navigator.tsx15
4 files changed, 42 insertions, 23 deletions
diff --git a/app/navigators/index.ts b/app/navigators/index.ts
index b1b89a2..57dfc6f 100644
--- a/app/navigators/index.ts
+++ b/app/navigators/index.ts
@@ -1,4 +1,4 @@
-export * from "./main-navigator"
-export * from "./root-navigator"
-export * from "./navigation-utilities"
+export * from './main-navigator'
+export * from './root-navigator'
+export * from './navigation-utilities'
// export other navigators from here
diff --git a/app/navigators/main-navigator.tsx b/app/navigators/main-navigator.tsx
index d8dc634..a1c5bbf 100644
--- a/app/navigators/main-navigator.tsx
+++ b/app/navigators/main-navigator.tsx
@@ -4,9 +4,14 @@
*
* You'll likely spend most of your time in this file.
*/
-import React from "react"
-import { createStackNavigator } from "@react-navigation/stack"
-import { WelcomeScreen, DemoScreen, DemoListScreen, GraphScreen } from "../screens"
+import React from 'react'
+import { createStackNavigator } from '@react-navigation/stack'
+import {
+ WelcomeScreen,
+ DemoScreen,
+ DemoListScreen,
+ GraphScreen,
+} from '../screens'
/**
* This type allows TypeScript to know what routes are defined in this navigator
@@ -34,11 +39,11 @@ export function MainNavigator() {
return (
<Stack.Navigator
screenOptions={{
- cardStyle: { backgroundColor: "transparent" },
+ cardStyle: { backgroundColor: 'transparent' },
headerShown: false,
}}
>
- <Stack.Screen name="graph" component={GraphScreen}/>
+ <Stack.Screen name="graph" component={GraphScreen} />
</Stack.Navigator>
)
}
@@ -55,5 +60,5 @@ export function MainNavigator() {
*
* `canExit` is used in ./app/app.tsx in the `useBackButtonHandler` hook.
*/
-const exitRoutes = ["welcome"]
+const exitRoutes = ['welcome']
export const canExit = (routeName: string) => exitRoutes.includes(routeName)
diff --git a/app/navigators/navigation-utilities.tsx b/app/navigators/navigation-utilities.tsx
index de1ea05..3de1998 100644
--- a/app/navigators/navigation-utilities.tsx
+++ b/app/navigators/navigation-utilities.tsx
@@ -1,6 +1,10 @@
-import React, { useState, useEffect, useRef } from "react"
-import { BackHandler } from "react-native"
-import { PartialState, NavigationState, NavigationContainerRef } from "@react-navigation/native"
+import React, { useState, useEffect, useRef } from 'react'
+import { BackHandler } from 'react-native'
+import {
+ PartialState,
+ NavigationState,
+ NavigationContainerRef,
+} from '@react-navigation/native'
export const RootNavigation = {
navigate(name: string) {
@@ -13,7 +17,9 @@ export const RootNavigation = {
},
}
-export const setRootNavigation = (ref: React.RefObject<NavigationContainerRef>) => {
+export const setRootNavigation = (
+ ref: React.RefObject<NavigationContainerRef>,
+) => {
for (const method in RootNavigation) {
RootNavigation[method] = (...args: any) => {
if (ref.current) {
@@ -26,7 +32,9 @@ export const setRootNavigation = (ref: React.RefObject<NavigationContainerRef>)
/**
* Gets the current screen from any navigation state.
*/
-export function getActiveRouteName(state: NavigationState | PartialState<NavigationState>) {
+export function getActiveRouteName(
+ state: NavigationState | PartialState<NavigationState>,
+) {
const route = state.routes[state.index]
// Found the active route -- return the name
@@ -79,10 +87,11 @@ export function useBackButtonHandler(
}
// Subscribe when we come to life
- BackHandler.addEventListener("hardwareBackPress", onBackPress)
+ BackHandler.addEventListener('hardwareBackPress', onBackPress)
// Unsubscribe when we're done
- return () => BackHandler.removeEventListener("hardwareBackPress", onBackPress)
+ return () =>
+ BackHandler.removeEventListener('hardwareBackPress', onBackPress)
}, [ref])
}
@@ -91,7 +100,9 @@ export function useBackButtonHandler(
*/
export function useNavigationPersistence(storage: any, persistenceKey: string) {
const [initialNavigationState, setInitialNavigationState] = useState()
- const [isRestoringNavigationState, setIsRestoringNavigationState] = useState(true)
+ const [isRestoringNavigationState, setIsRestoringNavigationState] = useState(
+ true,
+ )
const routeNameRef = useRef()
const onNavigationStateChange = (state) => {
diff --git a/app/navigators/root-navigator.tsx b/app/navigators/root-navigator.tsx
index 2c04f29..aacf14d 100644
--- a/app/navigators/root-navigator.tsx
+++ b/app/navigators/root-navigator.tsx
@@ -4,11 +4,14 @@
* and a "main" flow (which is contained in your MainNavigator) which the user
* will use once logged in.
*/
-import React from "react"
-import { NavigationContainer, NavigationContainerRef } from "@react-navigation/native"
-import { createStackNavigator } from "@react-navigation/stack"
-import { MainNavigator } from "./main-navigator"
-import { color } from "../theme"
+import React from 'react'
+import {
+ NavigationContainer,
+ NavigationContainerRef,
+} from '@react-navigation/native'
+import { createStackNavigator } from '@react-navigation/stack'
+import { MainNavigator } from './main-navigator'
+import { color } from '../theme'
/**
* This type allows TypeScript to know what routes are defined in this navigator
@@ -56,4 +59,4 @@ export const RootNavigator = React.forwardRef<
)
})
-RootNavigator.displayName = "RootNavigator"
+RootNavigator.displayName = 'RootNavigator'