From c58796c3324a0aaf872ce7f992088f7d5cd98360 Mon Sep 17 00:00:00 2001 From: Iskubee Date: Fri, 7 Jun 2024 00:13:11 +0800 Subject: [PATCH] Initial commit --- App.tsx | 114 +++++++++++++++++++++++++++++++++++++++++++--- package-lock.json | 12 +++++ package.json | 3 +- 3 files changed, 121 insertions(+), 8 deletions(-) diff --git a/App.tsx b/App.tsx index 0329d0c..b7dee2c 100644 --- a/App.tsx +++ b/App.tsx @@ -1,11 +1,75 @@ -import { StatusBar } from 'expo-status-bar'; -import { StyleSheet, Text, View } from 'react-native'; +import React, { useState, useEffect } from "react"; +import { Text, View, StyleSheet, Button, ActivityIndicator } from "react-native"; +import { CameraView, Camera } from "expo-camera"; export default function App() { + const [hasPermission, setHasPermission] = useState(null); + const [scanned, setScanned] = useState(false); + const [showSplash, setShowSplash] = useState(true); + + useEffect(() => { + const initializeApp = async () => { + const { status } = await Camera.requestCameraPermissionsAsync(); + setHasPermission(status === "granted"); + setShowSplash(false); + }; + + initializeApp(); + }, []); + + const handleBarCodeScanned = ({ type, data }) => { + setScanned(true); + 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 ( - Open up App.tsx to start working on your app! - + {/* Top Banner */} + + SafeQR + + + {/* Welcome Text */} + Welcome to SafeQR code Scanner + + {/* Camera Container */} + + + + + {/* Scan Again Button */} + {scanned && ( +