reza added qr activation

master
Reza_ashrafi 3 years ago
parent 0c0bd6e35f
commit df7e093737
  1. 6
      src/components/Navbar.js
  2. 1
      src/redux/reducers/user.js
  3. 1
      src/redux/reducers/userProduct.js
  4. 9
      src/screens/Activation/index.js
  5. 2
      src/screens/Otp/index.js
  6. 32
      src/screens/QR/layouts/Scan/index.js

@ -49,7 +49,7 @@ const Navbar = ({
).length; ).length;
}, [headerOptions, userFavoriteList]); }, [headerOptions, userFavoriteList]);
const Button = useCallback(({ icon, route }) => { const Button = useCallback(({ icon, route, state }) => {
return ( return (
<TouchableOpacity <TouchableOpacity
style={[ style={[
@ -61,7 +61,7 @@ const Navbar = ({
marginLeft: route === "AR" ? 10 : 0, marginLeft: route === "AR" ? 10 : 0,
}, },
]} ]}
onPress={() => navigation.navigate(route)} onPress={() => navigation.navigate(route, { page: state })}
> >
{icon} {icon}
</TouchableOpacity> </TouchableOpacity>
@ -351,6 +351,7 @@ const Navbar = ({
</Svg> </Svg>
} }
route={"QR"} route={"QR"}
state={"book"}
/> />
<Button <Button
icon={ icon={
@ -389,6 +390,7 @@ const Navbar = ({
</Svg> </Svg>
} }
route={"AR"} route={"AR"}
state={"AR"}
/> />
</> </>
)} )}

@ -27,7 +27,6 @@ const user = (state = initialState, action) => {
case "public/sendOTP": case "public/sendOTP":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "user/getStatus": case "user/getStatus":
console.log(data.status);
return { ...state, status: JSON.parse(data.status), error: null }; return { ...state, status: JSON.parse(data.status), error: null };
case "user/login": case "user/login":
case "user/otp/login": case "user/otp/login":

@ -36,7 +36,6 @@ export default function userFactor(state = initialState, action) {
case "userProduct/update": case "userProduct/update":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userProduct/add": case "userProduct/add":
console.log(data);
return { return {
...state, ...state,
loading: false, loading: false,

@ -11,9 +11,11 @@ import {
Dimensions, Dimensions,
} from "react-native"; } from "react-native";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native";
import Svg, { Image as Imagee } from "react-native-svg"; import Svg, { Image as Imagee } from "react-native-svg";
import { activation } from "../../redux/actions"; import { activation } from "../../redux/actions";
//components
import TopHeader from "../../components/Header"; import TopHeader from "../../components/Header";
import Navbar from "../../components/Navbar"; import Navbar from "../../components/Navbar";
import CustomPressable from "../../components/Pressable"; import CustomPressable from "../../components/Pressable";
@ -31,8 +33,10 @@ import bgQr from "./assets/QR.png";
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
const { height } = Dimensions.get("window"); const { height } = Dimensions.get("window");
function Activation({ add, mobile, theme }) { function Activation({ add, mobile, theme, route }) {
const {data} = route.params;
const [value, setValue] = useState(null); const [value, setValue] = useState(null);
const navigation = useNavigation();
return ( return (
<SafeAreaView <SafeAreaView
@ -99,6 +103,7 @@ function Activation({ add, mobile, theme }) {
fontFamily: "light", fontFamily: "light",
}, },
]} ]}
value={value || data}
onChange={(name, value) => setValue(value)} onChange={(name, value) => setValue(value)}
/> />
<CustomPressable <CustomPressable
@ -116,7 +121,7 @@ function Activation({ add, mobile, theme }) {
color={"white"} color={"white"}
border={{ color: "#196EC0", width: 0 }} border={{ color: "#196EC0", width: 0 }}
width={"100%"} width={"100%"}
onPress={() => {}} onPress={() => navigation.push("QR", { page: "activation" })}
/> />
</View> </View>
</View> </View>

@ -158,7 +158,7 @@ function Otp(props) {
useEffect(() => { useEffect(() => {
if (props.isLogin) { if (props.isLogin) {
// props.navigation.navigate("Root"); props.navigation.navigate("Root");
} }
}, [props.isLogin]); }, [props.isLogin]);

@ -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);
Loading…
Cancel
Save