react-native-vision-camera/example/index.js
Marc Rousavy 35806ff660
Upgrade Example to RN 0.64 (#83)
* ReactLogger: Also log function

* Run SwiftFormat & SwiftLint in example project

* Upgrade to RN 0.64 1/2

* Update lockfiles

* Upgrade a few packages

* index.tsx -> index.js

* Upgrade docusaurus

* Fix line length violation

* Update CameraView.swift

* Update gradle plugin

* Fix example to prefer higher res cameras

* Remove unused log line

* Update App.tsx
2021-03-19 15:53:19 +01:00

83 lines
1.9 KiB
JavaScript

import 'react-native-gesture-handler';
import { Navigation } from 'react-native-navigation';
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';
import { App } from './src/App';
import { Settings } from './src/Settings';
import { Splash } from './src/Splash';
import { Media } from './src/Media';
import { Camera } from 'react-native-vision-camera';
Navigation.setDefaultOptions({
topBar: {
visible: false,
},
window: {
backgroundColor: 'black',
},
layout: {
backgroundColor: 'black',
componentBackgroundColor: 'black',
},
statusBar: {
animated: true,
drawBehind: true,
translucent: true,
visible: true,
style: 'dark',
},
animations: {
setRoot: {
alpha: {
duration: 500,
from: 0,
to: 1,
},
},
},
});
Navigation.registerComponent(
'Splash',
() => gestureHandlerRootHOC(Splash),
() => Splash,
);
Navigation.registerComponent(
'Home',
() => gestureHandlerRootHOC(App),
() => App,
);
Navigation.registerComponent(
'Media',
() => gestureHandlerRootHOC(Media),
() => Media,
);
Navigation.registerComponent(
'Settings',
() => gestureHandlerRootHOC(Settings),
() => Settings,
);
Navigation.events().registerNavigationButtonPressedListener((event) => {
if (event.buttonId === 'back') Navigation.pop(event.componentId);
});
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,
},
},
],
},
},
});
});