036856aed5
* Move everything into package * Remove .DS_Store * Move scripts and eslintrc to package * Create CODE_OF_CONDUCT.md * fix some links * Update all links (I think) * Update generated docs * Update notice-yarn-changes.yml * Update validate-android.yml * Update validate-cpp.yml * Delete notice-yarn-changes.yml * Update validate-cpp.yml * Update validate-cpp.yml * Update validate-js.yml * Update validate-cpp.yml * Update validate-cpp.yml * wrong c++ style * Revert "wrong c++ style" This reverts commit 55a3575589c6f13f8b05134d83384f55e0601ab2.
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
import { NavigationContainer } from '@react-navigation/native';
|
|
import React, { useEffect, useState } from 'react';
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
import { PermissionsPage } from './PermissionsPage';
|
|
import { MediaPage } from './MediaPage';
|
|
import { CameraPage } from './CameraPage';
|
|
import type { Routes } from './Routes';
|
|
import { Camera, CameraPermissionStatus } from 'react-native-vision-camera';
|
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
|
|
const Stack = createNativeStackNavigator<Routes>();
|
|
|
|
export function App(): React.ReactElement | null {
|
|
const [cameraPermission, setCameraPermission] = useState<CameraPermissionStatus>();
|
|
const [microphonePermission, setMicrophonePermission] = useState<CameraPermissionStatus>();
|
|
|
|
useEffect(() => {
|
|
Camera.getCameraPermissionStatus().then(setCameraPermission);
|
|
Camera.getMicrophonePermissionStatus().then(setMicrophonePermission);
|
|
}, []);
|
|
|
|
console.log(`Re-rendering Navigator. Camera: ${cameraPermission} | Microphone: ${microphonePermission}`);
|
|
|
|
if (cameraPermission == null || microphonePermission == null) {
|
|
// still loading
|
|
return null;
|
|
}
|
|
|
|
const showPermissionsPage = cameraPermission !== 'granted' || microphonePermission === 'not-determined';
|
|
return (
|
|
<NavigationContainer>
|
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
<Stack.Navigator
|
|
screenOptions={{
|
|
headerShown: false,
|
|
statusBarStyle: 'dark',
|
|
animationTypeForReplace: 'push',
|
|
}}
|
|
initialRouteName={showPermissionsPage ? 'PermissionsPage' : 'CameraPage'}>
|
|
<Stack.Screen name="PermissionsPage" component={PermissionsPage} />
|
|
<Stack.Screen name="CameraPage" component={CameraPage} />
|
|
<Stack.Screen
|
|
name="MediaPage"
|
|
component={MediaPage}
|
|
options={{
|
|
animation: 'none',
|
|
presentation: 'transparentModal',
|
|
}}
|
|
/>
|
|
</Stack.Navigator>
|
|
</GestureHandlerRootView>
|
|
</NavigationContainer>
|
|
);
|
|
}
|