diff --git a/App.tsx b/App.tsx
index 5af7865..05a66d0 100644
--- a/App.tsx
+++ b/App.tsx
@@ -1,13 +1,17 @@
-import React, { useState, useEffect } from 'react';
-import { Text, View, StyleSheet, Button, ActivityIndicator } from 'react-native';
+import React, { useState, useEffect, createContext, useContext } from 'react';
+import { Text, View, StyleSheet, ActivityIndicator, TouchableOpacity, FlatList } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { CameraView, Camera } from 'expo-camera';
import { Ionicons } from '@expo/vector-icons';
+// Create a Context for QR code data
+const QRCodeContext = createContext();
+
const Tab = createBottomTabNavigator();
function QRScannerScreen() {
+ const { qrCodes, setQrCodes } = useContext(QRCodeContext); // Access context
const [hasPermission, setHasPermission] = useState(null);
const [scanned, setScanned] = useState(false);
const [showSplash, setShowSplash] = useState(true);
@@ -17,16 +21,18 @@ function QRScannerScreen() {
const initializeApp = async () => {
const { status } = await Camera.requestCameraPermissionsAsync();
setHasPermission(status === 'granted');
- setShowSplash(false);
+ setShowSplash(false); // Hide splash screen after initializing
};
initializeApp();
}, []);
const handleBarCodeScanned = ({ type, data }) => {
- setScanned(true);
- setScannedData(`Type: ${type}\nData: ${data}`);
- alert(`Bar code with type ${type} and data ${data} has been scanned!`);
+ setScanned(true); // Mark as scanned
+ const newScannedData = `Type: ${type}\nData: ${data}`;
+ setScannedData(newScannedData); // Save scanned data
+ setQrCodes([...qrCodes, newScannedData]); // Add scanned data to history
+ alert(`Bar code with type ${type} and data ${data} has been scanned!`); // Show an alert
};
if (showSplash) {
@@ -40,31 +46,43 @@ function QRScannerScreen() {
if (hasPermission === null) {
return Requesting for camera permission;
}
+
if (hasPermission === false) {
return No access to camera;
}
return (
+ {/* Header banner */}
SafeQR
+ {/* Welcome message */}
Welcome to SafeQR code Scanner
+ {/* Camera view container */}
+
+ {/* Display scanned data */}
{scannedData !== '' && (
{scannedData}
)}
+
+ {/* Button to scan again */}
{scanned && (
-