Toggle navigation
Toggle navigation
This project
Loading...
Sign in
skywrace
/
drowsiness_detector
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
skywrace
2022-05-12 01:25:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
62ba11c8f394ee93853c44d85552ed66aa3bc22f
62ba11c8
1 parent
7bedfc8e
feat: Install react-native-vision-camera module and handle media permissions
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
97 deletions
DetectApp/App.tsx
DetectApp/android/app/src/main/AndroidManifest.xml
DetectApp/ios/DetectApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
DetectApp/ios/DetectApp/Info.plist
DetectApp/ios/Podfile.lock
DetectApp/package.json
DetectApp/yarn.lock
DetectApp/App.tsx
View file @
62ba11c
...
...
@@ -9,110 +9,39 @@
*/
import {NativeBaseProvider} from 'native-base';
import React from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
const Section: React.FC<{
title: string;
}> = ({children, title}) => {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
};
import React, {useLayoutEffect} from 'react';
import {SafeAreaView} from 'react-native';
import {Camera, useCameraDevices} from 'react-native-vision-camera';
const App = () => {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
const devices = useCameraDevices();
const device = devices.front;
useLayoutEffect(() => {
(async () => {
const [cameraPermission, micPermission] = await Promise.all([
Camera.getCameraPermissionStatus(),
Camera.getMicrophonePermissionStatus(),
]);
const requests: (() => Promise<unknown>)[] = [];
if (cameraPermission !== 'authorized') {
requests.push(Camera.requestCameraPermission);
}
if (micPermission !== 'authorized') {
requests.push(Camera.requestMicrophonePermission);
}
await Promise.all(requests.map(request => request()));
})();
}, []);
return (
<NativeBaseProvider>
<SafeAreaView style={backgroundStyle}>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
<SafeAreaView>
{device && <Camera isActive device={device} />}
</SafeAreaView>
</NativeBaseProvider>
);
};
const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});
export default App;
...
...
DetectApp/android/app/src/main/AndroidManifest.xml
View file @
62ba11c
...
...
@@ -2,6 +2,8 @@
package=
"com.detectapp"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<uses-permission
android:name=
"android.permission.RECORD_AUDIO"
/>
<application
android:name=
".MainApplication"
...
...
DetectApp/ios/DetectApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
0 → 100644
View file @
62ba11c
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
<key>
IDEDidComputeMac32BitWarning
</key>
<true/>
</dict>
</plist>
DetectApp/ios/DetectApp/Info.plist
View file @
62ba11c
...
...
@@ -37,6 +37,10 @@
</dict>
<key>
NSLocationWhenInUseUsageDescription
</key>
<string></string>
<key>
NSCameraUsageDescription
</key>
<string>
$(PRODUCT_NAME) needs access to your Camera.
</string>
<key>
NSMicrophoneUsageDescription
</key>
<string>
$(PRODUCT_NAME) needs access to your Microphone.
</string>
<key>
UILaunchStoryboardName
</key>
<string>
LaunchScreen
</string>
<key>
UIRequiredDeviceCapabilities
</key>
...
...
DetectApp/ios/Podfile.lock
View file @
62ba11c
...
...
@@ -356,6 +356,10 @@ PODS:
- RNSVG (12.3.0):
- React-Core
- SocketRocket (0.6.0)
- VisionCamera (2.13.3):
- React
- React-callinvoker
- React-Core
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)
...
...
@@ -417,6 +421,7 @@ DEPENDENCIES:
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNSVG (from `../node_modules/react-native-svg`)
- VisionCamera (from `../node_modules/react-native-vision-camera`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
SPEC REPOS:
...
...
@@ -502,6 +507,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
RNSVG:
:path: "../node_modules/react-native-svg"
VisionCamera:
:path: "../node_modules/react-native-vision-camera"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"
...
...
@@ -552,6 +559,7 @@ SPEC CHECKSUMS:
ReactCommon: bf2888a826ceedf54b99ad1b6182d1bc4a8a3984
RNSVG: 302bfc9905bd8122f08966dc2ce2d07b7b52b9f8
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
VisionCamera: c1c171fcdbf18c438987847f785829c5638f3a4c
Yoga: 17cd9a50243093b547c1e539c749928dd68152da
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
...
...
DetectApp/package.json
View file @
62ba11c
...
...
@@ -14,7 +14,8 @@
"react"
:
"17.0.2"
,
"react-native"
:
"0.68.1"
,
"react-native-safe-area-context"
:
"^4.2.5"
,
"react-native-svg"
:
"^12.3.0"
"react-native-svg"
:
"^12.3.0"
,
"react-native-vision-camera"
:
"^2.13.3"
},
"devDependencies"
:
{
"@babel/core"
:
"^7.12.9"
,
...
...
DetectApp/yarn.lock
View file @
62ba11c
...
...
@@ -6706,6 +6706,11 @@ react-native-svg@^12.3.0:
css-select "^4.2.1"
css-tree "^1.0.0-alpha.39"
react-native-vision-camera@^2.13.3:
version "2.13.3"
resolved "https://registry.yarnpkg.com/react-native-vision-camera/-/react-native-vision-camera-2.13.3.tgz#cacd20b7f3fd777691496f007a47a34c02be93be"
integrity sha512-aikp6kNmb9b8lsVFKEKCBgch5h93Cs8Qqw/bSZsn/dO+Qa4uktpe89WIO1VTs88d40vJiLeYFlbyWe589E/UuA==
react-native@0.68.1:
version "0.68.1"
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.68.1.tgz#c3d92f89028cdc2453fe7cd2d532b3f68d1c27c8"
...
...
Please
register
or
login
to post a comment