import React, { useState, useEffect } from 'react';
import { Text, View, StyleSheet, Button, ActivityIndicator } 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';
const Tab = createBottomTabNavigator();
function QRScannerScreen() {
const [hasPermission, setHasPermission] = useState(null);
const [scanned, setScanned] = useState(false);
const [showSplash, setShowSplash] = useState(true);
const [scannedData, setScannedData] = useState('');
useEffect(() => {
const initializeApp = async () => {
const { status } = await Camera.requestCameraPermissionsAsync();
setHasPermission(status === 'granted');
setShowSplash(false);
};
initializeApp();
}, []);
const handleBarCodeScanned = ({ type, data }) => {
setScanned(true);
setScannedData(`Type: ${type}\nData: ${data}`);
alert(`Bar code with type ${type} and data ${data} has been scanned!`);
};
if (showSplash) {
return (
);
}
if (hasPermission === null) {
return Requesting for camera permission;
}
if (hasPermission === false) {
return No access to camera;
}
return (
SafeQR
Welcome to SafeQR code Scanner
{scannedData !== '' && (
{scannedData}
)}
{scanned && (
);
}
function HistoryScreen() {
return (
History Screen
);
}
function SettingsScreen() {
return (
Settings Screen
);
}
function ProfileScreen() {
return (
Profile Screen
);
}
export default function App() {
return (
({
tabBarIcon: ({ color, size }) => {
let iconName;
if (route.name === 'QR Scanner') {
iconName = 'qr-code-outline';
} else if (route.name === 'History') {
iconName = 'time-outline';
} else if (route.name === 'Settings') {
iconName = 'settings-outline';
} else if (route.name === 'Profile') {
iconName = 'person-outline';
}
return ;
},
})}
tabBarOptions={{
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
}}
>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#f8f0fc", // light purple background
},
splashContainer: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#f8f0fc", // light purple background
},
banner: {
backgroundColor: "#ff69b4", // pink background
paddingVertical: 10,
alignItems: "center",
},
headerText: {
color: "white",
fontSize: 24,
},
welcomeText: {
textAlign: "center",
fontSize: 20,
marginVertical: 10, // Adjusted margin
color: "#ff69b4", // pink color
},
cameraContainer: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
camera: {
width: 300,
height: 300,
},
dataBox: {
marginVertical: 10,
padding: 10,
backgroundColor: "#fff",
borderRadius: 5,
alignItems: "center",
justifyContent: "center",
},
dataText: {
fontSize: 16,
color: "#000",
},
menu: {
flexDirection: "row",
justifyContent: "space-around",
alignItems: "center",
backgroundColor: "#ff69b4", // pink background
paddingVertical: 10,
},
});