-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.tsx
61 lines (53 loc) · 1.97 KB
/
App.tsx
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
import './shim';
import {NavigationContainer} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {Camera, CameraPermissionStatus} from 'react-native-vision-camera';
import {StyleSheet, View} from 'react-native';
import {PermissionsPage} from './pages/PermisionPage';
import {CameraPage} from './pages/CameraPage';
import {HomePage} from './pages/HomePage';
import {ActionPage} from './pages/ActionPage';
import {WebViewWrapperProvider} from './WebViewProvider';
const Tab = createNativeStackNavigator();
export default function App(): React.ReactElement | null {
const [cameraPermission, setCameraPermission] =
useState<CameraPermissionStatus>();
useEffect(() => {
Camera.getCameraPermissionStatus().then(setCameraPermission);
}, []);
console.log(`Re-rendering Navigator. Camera: ${cameraPermission}`);
if (cameraPermission == null) {
// still loading
return null;
}
const showPermissionsPage = cameraPermission !== 'granted';
return (
<NavigationContainer>
<View style={styles.root}>
<WebViewWrapperProvider>
<Tab.Navigator
screenOptions={{
// headerShown: false,
statusBarStyle: 'dark',
animationTypeForReplace: 'push',
}}
initialRouteName={
showPermissionsPage ? 'PermissionsPage' : 'HomePage'
// showPermissionsPage ? 'PermissionsPage' : 'PermissionsPage'
}>
<Tab.Screen name="PermissionsPage" component={PermissionsPage} />
<Tab.Screen name="CameraPage" component={CameraPage} />
<Tab.Screen name="HomePage" component={HomePage} />
<Tab.Screen name="ActionPage" component={ActionPage} />
</Tab.Navigator>
</WebViewWrapperProvider>
</View>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
root: {
flex: 1,
},
});