diff --git a/components/CameraView.tsx b/components/CameraView.tsx deleted file mode 100644 index 564a923..0000000 --- a/components/CameraView.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { Camera } from 'expo-camera'; -import { View, StyleSheet } from 'react-native'; - -interface CameraViewProps { - onBarcodeScanned?: (data: any) => void; - barcodeScannerSettings?: any; - style?: any; -} - -const CameraView: React.FC = ({ onBarcodeScanned, barcodeScannerSettings, style }) => { - return ( - - - - ); -}; - -export default CameraView; diff --git a/screens/QRScannerScreen.tsx b/screens/QRScannerScreen.tsx index a427ab6..f915718 100644 --- a/screens/QRScannerScreen.tsx +++ b/screens/QRScannerScreen.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useContext } from 'react'; import { View, Text, StyleSheet, ActivityIndicator, TouchableOpacity } from 'react-native'; -import { CameraView, Camera } from 'expo-camera'; +import { Camera, CameraView } from 'expo-camera'; import { QRCodeContext } from '../types'; import axios from 'axios'; import { Ionicons } from '@expo/vector-icons'; @@ -21,6 +21,7 @@ const QRScannerScreen: React.FC = ({ clearScanData }) => { const [scannedData, setScannedData] = useState(''); const [scanResult, setScanResult] = useState(null); // State for VirusTotal scan result const [dataType, setDataType] = useState(''); // State for data type + const [enableTorch, setEnableTorch] = useState(false); // State for torch useEffect(() => { const initializeApp = async () => { @@ -115,7 +116,11 @@ const QRScannerScreen: React.FC = ({ clearScanData }) => { }); return unsubscribe; }, [navigation]); - + + const toggleTorch = () => { + setEnableTorch((prev) => !prev); + }; + if (showSplash) { return ( @@ -145,7 +150,14 @@ const QRScannerScreen: React.FC = ({ clearScanData }) => { onBarcodeScanned={scanned ? undefined : handleQRCodeScanned} barcodeScannerSettings={{ barcodeTypes: ['qr', 'pdf417'] }} style={styles.camera} + enableTorch={enableTorch} /> + + + + {enableTorch ? 'Turn Off' : 'Turn On'} Torch + + {scannedData !== '' && ( @@ -207,6 +219,19 @@ const styles = StyleSheet.create({ width: '100%', height: '100%', }, + flashButton: { + position: 'absolute', + bottom: 20, + alignSelf: 'center', + alignItems: 'center', + backgroundColor: '#000', + padding: 10, + borderRadius: 5, + }, + flashText: { + color: '#fff', + marginTop: 5, + }, dataBox: { position: 'absolute', top: '10%',