|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
|
import React from "react"; |
|
|
|
|
import { |
|
|
|
|
View, |
|
|
|
|
Text, |
|
|
|
@ -10,32 +10,40 @@ import { |
|
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
|
import { BarCodeScanner } from "expo-barcode-scanner"; |
|
|
|
|
import { Entypo } from "@expo/vector-icons"; |
|
|
|
|
import {connect} from "react-redux"; |
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
|
|
import tw from "tailwind-rn"; |
|
|
|
|
import Colors from "../../../constants/Colors"; |
|
|
|
|
import Colors from "../../../../constants/Colors"; |
|
|
|
|
|
|
|
|
|
const { width, height } = Dimensions.get("screen"); |
|
|
|
|
|
|
|
|
|
//assets
|
|
|
|
|
import laptopImage from "../assets/laptop.png"; |
|
|
|
|
|
|
|
|
|
function Scan({theme}) { |
|
|
|
|
function Scan({ theme, route }) { |
|
|
|
|
const { page } = route.params; |
|
|
|
|
const navigation = useNavigation(); |
|
|
|
|
const [hasPermission, setHasPermission] = useState(null); |
|
|
|
|
const [scanned, setScanned] = useState(false); |
|
|
|
|
const [hasPermission, setHasPermission] = React.useState(null); |
|
|
|
|
const [scanned, setScanned] = React.useState(false); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
React.useEffect(() => { |
|
|
|
|
(async () => { |
|
|
|
|
const { status } = await BarCodeScanner.requestPermissionsAsync(); |
|
|
|
|
setHasPermission(status === "granted"); |
|
|
|
|
})(); |
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
const handleBarCodeScanned = ({ type, data }) => { |
|
|
|
|
setScanned(true); |
|
|
|
|
navigation.navigate("QRContent", { data }); |
|
|
|
|
}; |
|
|
|
|
const handleBarCodeScanned = React.useCallback( |
|
|
|
|
({ type, data }) => { |
|
|
|
|
setScanned(true); |
|
|
|
|
if (page === "activation") { |
|
|
|
|
navigation.push("QRContent", { data }); |
|
|
|
|
}else{ |
|
|
|
|
navigation.push("Activation", { data }); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
[route, scanned] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (hasPermission === null) { |
|
|
|
|
return <Text>Requesting for camera permission</Text>; |
|
|
|
@ -98,7 +106,7 @@ function Scan({theme}) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
|
theme: state.publicApi.theme |
|
|
|
|
}) |
|
|
|
|
theme: state.publicApi.theme, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(Scan); |