2023-09-26 03:39:17 -06:00
|
|
|
import { NavigationContainer } from '@react-navigation/native'
|
2023-12-19 06:22:04 -07:00
|
|
|
import React from 'react'
|
2023-09-26 03:39:17 -06:00
|
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
|
|
|
import { PermissionsPage } from './PermissionsPage'
|
|
|
|
import { MediaPage } from './MediaPage'
|
|
|
|
import { CameraPage } from './CameraPage'
|
2023-11-09 03:57:05 -07:00
|
|
|
import { CodeScannerPage } from './CodeScannerPage'
|
2023-09-26 03:39:17 -06:00
|
|
|
import type { Routes } from './Routes'
|
2023-12-19 06:22:04 -07:00
|
|
|
import { Camera } from 'react-native-vision-camera'
|
2023-09-26 03:39:17 -06:00
|
|
|
import { GestureHandlerRootView } from 'react-native-gesture-handler'
|
2023-09-29 07:27:09 -06:00
|
|
|
import { StyleSheet } from 'react-native'
|
2023-10-05 06:52:03 -06:00
|
|
|
import { DevicesPage } from './DevicesPage'
|
2021-10-05 04:22:14 -06:00
|
|
|
|
2023-09-26 03:39:17 -06:00
|
|
|
const Stack = createNativeStackNavigator<Routes>()
|
2021-10-05 04:22:14 -06:00
|
|
|
|
|
|
|
export function App(): React.ReactElement | null {
|
2023-12-19 06:22:04 -07:00
|
|
|
const cameraPermission = Camera.getCameraPermissionStatus()
|
|
|
|
const microphonePermission = Camera.getMicrophonePermissionStatus()
|
2021-10-05 04:22:14 -06:00
|
|
|
|
2023-09-26 03:39:17 -06:00
|
|
|
console.log(`Re-rendering Navigator. Camera: ${cameraPermission} | Microphone: ${microphonePermission}`)
|
2021-10-05 04:22:14 -06:00
|
|
|
|
2023-09-26 03:39:17 -06:00
|
|
|
const showPermissionsPage = cameraPermission !== 'granted' || microphonePermission === 'not-determined'
|
2021-10-05 04:22:14 -06:00
|
|
|
return (
|
|
|
|
<NavigationContainer>
|
2023-09-29 07:27:09 -06:00
|
|
|
<GestureHandlerRootView style={styles.root}>
|
2023-02-13 07:22:45 -07:00
|
|
|
<Stack.Navigator
|
|
|
|
screenOptions={{
|
|
|
|
headerShown: false,
|
|
|
|
statusBarStyle: 'dark',
|
|
|
|
animationTypeForReplace: 'push',
|
2021-10-05 04:22:14 -06:00
|
|
|
}}
|
2023-02-13 07:22:45 -07:00
|
|
|
initialRouteName={showPermissionsPage ? 'PermissionsPage' : 'CameraPage'}>
|
|
|
|
<Stack.Screen name="PermissionsPage" component={PermissionsPage} />
|
|
|
|
<Stack.Screen name="CameraPage" component={CameraPage} />
|
2023-11-09 03:57:05 -07:00
|
|
|
<Stack.Screen name="CodeScannerPage" component={CodeScannerPage} />
|
2023-02-13 07:22:45 -07:00
|
|
|
<Stack.Screen
|
|
|
|
name="MediaPage"
|
|
|
|
component={MediaPage}
|
|
|
|
options={{
|
|
|
|
animation: 'none',
|
|
|
|
presentation: 'transparentModal',
|
|
|
|
}}
|
|
|
|
/>
|
2023-10-05 06:52:03 -06:00
|
|
|
<Stack.Screen name="Devices" component={DevicesPage} />
|
2023-02-13 07:22:45 -07:00
|
|
|
</Stack.Navigator>
|
|
|
|
</GestureHandlerRootView>
|
2021-10-05 04:22:14 -06:00
|
|
|
</NavigationContainer>
|
2023-09-26 03:39:17 -06:00
|
|
|
)
|
2021-10-05 04:22:14 -06:00
|
|
|
}
|
2023-09-29 07:27:09 -06:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
root: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
})
|