react-native-vision-camera/example/index.tsx

58 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-02-19 10:12:07 -07:00
import 'react-native-gesture-handler';
2021-02-19 10:02:24 -07:00
import { Navigation } from "react-native-navigation";
2021-02-19 10:12:07 -07:00
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';
2021-02-19 10:43:41 -07:00
import { App } from './src/App';
import { Settings } from './src/Settings';
import { Splash } from './src/Splash';
2021-02-19 10:44:05 -07:00
import { Media } from './src/Media';
2021-02-19 11:51:59 -07:00
import { Camera } from 'react-native-vision-camera';
2021-02-19 08:07:53 -07:00
2021-02-19 10:24:32 -07:00
Navigation.setDefaultOptions({
topBar: {
visible: false,
},
2021-02-19 11:51:59 -07:00
window: {
backgroundColor: 'black',
},
layout: {
backgroundColor: 'black',
componentBackgroundColor: 'black'
},
2021-02-19 10:24:32 -07:00
});
2021-02-19 10:12:07 -07:00
Navigation.registerComponent('Splash', () => gestureHandlerRootHOC(Splash), () => Splash);
Navigation.registerComponent('Home', () => gestureHandlerRootHOC(App), () => App);
2021-02-19 10:44:05 -07:00
Navigation.registerComponent('Media', () => gestureHandlerRootHOC(Media), () => Media);
2021-02-19 10:12:07 -07:00
Navigation.registerComponent('Settings', () => gestureHandlerRootHOC(Settings), () => Settings);
2021-02-19 10:02:24 -07:00
2021-02-19 12:05:02 -07:00
Navigation.events().registerNavigationButtonPressedListener((event) => {
if (event.buttonId === "back") {
Navigation.pop(event.componentId);
}
});
2021-02-19 11:51:59 -07:00
Navigation.events().registerAppLaunchedListener(async () => {
const [cameraPermission, microphonePermission] = await Promise.all([
Camera.getCameraPermissionStatus(),
Camera.getMicrophonePermissionStatus(),
]);
let rootName = "Splash";
if (cameraPermission === "authorized" && microphonePermission === "authorized") {
rootName = "Home";
}
Navigation.setRoot({
root: {
stack: {
children: [
{
component: {
name: rootName
}
}
]
}
}
2021-02-19 10:02:24 -07:00
});
});