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