import React, { useState, useEffect } from "react";
import {
View,
Text,
TouchableOpacity,
Dimensions,
ImageBackground,
StatusBar
} from "react-native";
import { useNavigation } from "@react-navigation/native";
import tw from "tailwind-rn";
import { BarCodeScanner } from "expo-barcode-scanner";
import Colors from "../../../constants/Colors";
const { width, height } = Dimensions.get("window");
//assets
import laptopImage from "../assets/laptop.png";
export default function Scan({}) {
const navigation = useNavigation();
const [hasPermission, setHasPermission] = useState(null);
const [scanned, setScanned] = useState(false);
useEffect(() => {
(async () => {
const { status } = await BarCodeScanner.requestPermissionsAsync();
setHasPermission(status === "granted");
})();
}, []);
const handleBarCodeScanned = ({ type, data }) => {
setScanned(true);
navigation.navigate("QRContent", {data});
};
if (hasPermission === null) {
return Requesting for camera permission;
}
if (hasPermission === false) {
return No access to camera;
}
return (
{/* {scanned && ( */}
navigation.goBack()}
style={[
tw("py-2.5 rounded-full flex justify-center flex-row"),
{
width: height / 3.5,
borderWidth: 1,
borderColor: Colors.theme1.light.blue8,
},
]}
>
بازگشت
{/* )} */}
);
}