From 0e51214659c3a315b2f0b834e7c262b9c2d0c324 Mon Sep 17 00:00:00 2001
From: Josh <102478723+realjoshuau@users.noreply.github.com>
Date: Thu, 23 Nov 2023 17:39:02 -0600
Subject: [PATCH] Add camera permission handling and PIN functionality
---
apps/mobile/app/index.tsx | 54 +++++++++++++++++++++++++++++++++------
apps/mobile/package.json | 1 +
pnpm-lock.yaml | 7 +++++
3 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/apps/mobile/app/index.tsx b/apps/mobile/app/index.tsx
index fdde119..629facf 100644
--- a/apps/mobile/app/index.tsx
+++ b/apps/mobile/app/index.tsx
@@ -2,10 +2,11 @@
// import { HomeIcon, HomeScreen } from '@acme/feature-home';
import { BarCodeScanner } from 'expo-barcode-scanner';
import { useEffect, useState } from 'react';
-import { StyleSheet, View, Text, Image, Button } from 'react-native';
+import { StyleSheet, View, Text, Image, Button, Linking, Alert } from 'react-native';
export default function App() {
const [hasPermission, setHasPermission] = useState(null);
const [scanned, setScanned] = useState(false);
+ const [message, setMessage] = useState('No PIN entered.');
useEffect(() => {
const getBarCodeScannerPermissions = async () => {
@@ -16,18 +17,53 @@ export default function App() {
getBarCodeScannerPermissions();
}, []);
- const handleBarCodeScanned = ({ type, data }) => {
- setScanned(true);
- alert(`Bar code with type ${type} and data ${data} has been scanned!`);
- };
-
if (hasPermission === null) {
- return Requesting for camera permission;
+ return (
+ <>
+
+ Requesting for camera permission
+
+ >
+ );
}
if (hasPermission === false) {
- return No access to camera;
+ return (
+ <>
+
+ No access to camera
+
+ >
+ );
}
+ const handleBarCodeScanned = ({ type, data }) => {
+ setScanned(true);
+ alert(`Bar code with type ${type} and data ${data} has been scanned!`);
+ };
+
return (
Attendance!
@@ -46,6 +82,8 @@ export default function App() {
onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
style={StyleSheet.absoluteFillObject}
/>
+ Has permission: {hasPermission.toString()}
+
{scanned && setScanned(false)} />}
);
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index 0ded85a..d330daf 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -31,6 +31,7 @@
"react-dom": "18.2.0",
"react-native": "0.72.4",
"react-native-gesture-handler": "~2.12.0",
+ "react-native-prompt": "^1.0.0",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-svg": "^14.0.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ed04ec6..fde5326 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -61,6 +61,9 @@ importers:
react-native-gesture-handler:
specifier: ~2.12.0
version: 2.12.1(react-native@0.72.4)(react@18.2.0)
+ react-native-prompt:
+ specifier: ^1.0.0
+ version: 1.0.0
react-native-safe-area-context:
specifier: 4.6.3
version: 4.6.3(react-native@0.72.4)(react@18.2.0)
@@ -9374,6 +9377,10 @@ packages:
react-native: 0.72.4(@babel/core@7.23.3)(react@18.2.0)
dev: false
+ /react-native-prompt@1.0.0:
+ resolution: {integrity: sha512-LzZe8Jo3XRnnfPazUwLIhGhXefYoFrYaCTdWJoB/Skj0UpKByw5UfQ/o+qag9vJvAGwfFej1jAJff1Y6c2BP3w==}
+ dev: false
+
/react-native-safe-area-context@4.6.3(react-native@0.72.4)(react@18.2.0):
resolution: {integrity: sha512-3CeZM9HFXkuqiU9HqhOQp1yxhXw6q99axPWrT+VJkITd67gnPSU03+U27Xk2/cr9XrLUnakM07kj7H0hdPnFiQ==}
peerDependencies: