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. 35
      src/screens/QR/layouts/Scan/index.js

@ -8,9 +8,10 @@ import {
} from "react-native"; } from "react-native";
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import {asyncAwesomeAlert} from "../../../utils/AsyncWrappers";
import { Ionicons, Entypo } from "@expo/vector-icons"; import { Ionicons, Entypo } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import { userFactor } from "../../../redux/actions"; import { userFactor, userAddress } from "../../../redux/actions";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -26,6 +27,7 @@ const Address = ({
userAddressId, userAddressId,
loading, loading,
mobile, mobile,
deleteItem,
theme, theme,
}) => { }) => {
const navigation = useNavigation(); const navigation = useNavigation();
@ -70,16 +72,14 @@ const Address = ({
{selectedItem === address?.id && loading ? ( {selectedItem === address?.id && loading ? (
<ActivityIndicator size="small" color={Colors.theme1.greenC8} /> <ActivityIndicator size="small" color={Colors.theme1.greenC8} />
) : active ? ( ) : active ? (
<Entypo <Entypo name="check" size={20} color={Colors.theme1.greenCF} />
name="check"
size={20}
color={Colors.theme1.greenCF}
/>
) : ( ) : (
<Entypo <Entypo
name="circle" name="circle"
size={20} 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"}`)}> <View style={tw(`flex flex-1 ${mobile ? "mr-2" : "mr-5"}`)}>
@ -103,13 +103,71 @@ const Address = ({
{address?.address} {address?.address}
</Text> </Text>
</View> </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> </Pressable>
); );
}; };
return ( return (
<View style={tw("w-full mt-2")}> <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) => ( {addresses?.map((address, index) => (
<Location <Location
address={address} address={address}
@ -136,7 +194,7 @@ const Address = ({
<Text <Text
style={{ style={{
fontFamily: "regular", fontFamily: "regular",
fontSize: mobile ? fontSize.sm : fontSize.lg, fontSize: mobile ? fontSize.tiny : fontSize.lg,
color: light ? Colors.theme1.gray2077 : Colors.theme1.grayE3, color: light ? Colors.theme1.gray2077 : Colors.theme1.grayE3,
}} }}
> >
@ -166,6 +224,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = { const mapDispatchToProps = {
update: userFactor.update, update: userFactor.update,
deleteItem: userAddress.update
}; };
export default connect(mapStateToProps, mapDispatchToProps)(Address); export default connect(mapStateToProps, mapDispatchToProps)(Address);

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

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

Loading…
Cancel
Save