reza fixed qr code

master
Reza_ashrafi 3 years ago
parent 8aae174d19
commit 406d4ce8a2
  1. 77
      src/screens/DeliveryForm/Address/index.js
  2. 2
      src/screens/DeliveryForm/index.js
  3. 27
      src/screens/QR/layouts/Scan/index.js

@ -8,9 +8,10 @@ import {
} from "react-native";
import React from "react";
import { connect } from "react-redux";
import {asyncAwesomeAlert} from "../../../utils/AsyncWrappers";
import { Ionicons, Entypo } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native";
import { userFactor } from "../../../redux/actions";
import { userFactor, userAddress } from "../../../redux/actions";
//style
import tw from "tailwind-rn";
@ -26,6 +27,7 @@ const Address = ({
userAddressId,
loading,
mobile,
deleteItem,
theme,
}) => {
const navigation = useNavigation();
@ -70,16 +72,14 @@ const Address = ({
{selectedItem === address?.id && loading ? (
<ActivityIndicator size="small" color={Colors.theme1.greenC8} />
) : active ? (
<Entypo
name="check"
size={20}
color={Colors.theme1.greenCF}
/>
<Entypo name="check" size={20} color={Colors.theme1.greenCF} />
) : (
<Entypo
name="circle"
size={20}
color={theme === "light" ? Colors.theme1.grayE3 : Colors.theme1.white}
color={
theme === "light" ? Colors.theme1.grayE3 : Colors.theme1.white
}
/>
)}
<View style={tw(`flex flex-1 ${mobile ? "mr-2" : "mr-5"}`)}>
@ -103,13 +103,71 @@ const Address = ({
{address?.address}
</Text>
</View>
<View style={tw("flex flex-row-reverse h-full")}>
<Pressable
style={tw("ml-3 h-full")}
onPress={() =>
navigation.navigate("CreateAddress", {
type: "editAddress",
form: address,
})
}
>
<Ionicons
name="ios-pencil-sharp"
size={16}
color={
theme === "light"
? "#52796F"
: active
? Colors.theme1.greenCF
: Colors.theme1.white
}
/>
</Pressable>
<Pressable
onPress={() =>
asyncAwesomeAlert("", "آدرس مورد نظر حذف شود؟", {
showCancelButton: true,
confirmText: "بله",
cancelText: "لغو",
onConfirm: () => deleteItem({ id: address?.id }),
})
}
style={tw('h-full')}
>
<Ionicons
name="trash-bin"
size={16}
color={
theme === "light"
? "#52796F"
: active
? Colors.theme1.greenCF
: Colors.theme1.white
}
/>
</Pressable>
</View>
</Pressable>
);
};
return (
<View style={tw("w-full mt-2")}>
<View style={tw("p-0 m-0 flex ")}>
{addresses?.length ? (
<Text
style={{
fontSize: mobile ? fontSize.base : fontSize.xl,
fontFamily: "bold",
color: light ? Colors.theme1.green79 : Colors.theme1.white,
textAlign: ios ? "right" : "auto",
}}
>
لطفا آدرس مورد نظر را انتخاب کنید.
</Text>
) : null}
<View style={tw("p-0 mt-2 flex")}>
{addresses?.map((address, index) => (
<Location
address={address}
@ -136,7 +194,7 @@ const Address = ({
<Text
style={{
fontFamily: "regular",
fontSize: mobile ? fontSize.sm : fontSize.lg,
fontSize: mobile ? fontSize.tiny : fontSize.lg,
color: light ? Colors.theme1.gray2077 : Colors.theme1.grayE3,
}}
>
@ -166,6 +224,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = {
update: userFactor.update,
deleteItem: userAddress.update
};
export default connect(mapStateToProps, mapDispatchToProps)(Address);

@ -96,7 +96,7 @@ const DeliveryForm = ({
width={"100%"}
onPress={() =>
factorInfo?.transportId && factorInfo?.userAddressId
? payFactor({ userId })
? payFactor({ userId, clientUrl: "dnvn://" })
: asyncAwesomeAlert("خطا", "آدرس یا نحوه ارسال را وارد کنید", {
showCancelButton: false,
confirmText: "باشه",

@ -21,7 +21,7 @@ const { width, height } = Dimensions.get("screen");
//assets
import laptopImage from "../../assets/laptop.png";
function Scan({ theme, page }) {
function Scan({ route, theme, page }) {
const navigation = useNavigation();
const [hasPermission, setHasPermission] = React.useState(null);
const [scanned, setScanned] = React.useState(false);
@ -33,17 +33,24 @@ function Scan({ theme, page }) {
})();
}, []);
const handleBarCodeScanned = React.useCallback(
({ type, data }) => {
const handleBarCodeScanned = ({ type, data }) => {
setScanned(true);
if (page === "activation") {
navigation.push("Activation", { data });
setTimeout(() => {
setScanned(false);
}, 300);
navigation.replace("Activation", {
data: data.slice(data.lastIndexOf("/") + 1, data.length),
});
} else {
navigation.push("QRContent", { data });
setTimeout(() => {
setScanned(false);
}, 300);
navigation.replace("QRContent", {
data: data.slice(data.lastIndexOf("/") + 1, data.length),
});
}
},
[page, scanned]
);
};
return (
<ImageBackground
@ -57,9 +64,9 @@ function Scan({ theme, page }) {
)}
>
<View style={{ width: height / 2.5, height: height / 2.5 }}>
{hasPermission ? (
{hasPermission && !scanned ? (
<BarCodeScanner
onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
onBarCodeScanned={handleBarCodeScanned}
style={{ width: "100%", height: "100%" }}
/>
) : null}

Loading…
Cancel
Save