|
|
@ -1,35 +1,12 @@ |
|
|
|
import { |
|
|
|
|
|
|
|
View, |
|
|
|
|
|
|
|
Text, |
|
|
|
|
|
|
|
Pressable, |
|
|
|
|
|
|
|
TouchableOpacity, |
|
|
|
|
|
|
|
Appearance, |
|
|
|
|
|
|
|
ActivityIndicator, |
|
|
|
|
|
|
|
SafeAreaView, |
|
|
|
|
|
|
|
ScrollView, |
|
|
|
|
|
|
|
StyleSheet, |
|
|
|
|
|
|
|
Platform, |
|
|
|
|
|
|
|
Dimensions, |
|
|
|
|
|
|
|
StatusBar, |
|
|
|
|
|
|
|
} from "react-native"; |
|
|
|
|
|
|
|
import React from "react"; |
|
|
|
import React from "react"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
import { userAddress, userFactor } from "../../../../../redux/actions"; |
|
|
|
import { userAddress, userFactor } from "../../../../redux/actions"; |
|
|
|
import { Link, useNavigate } from "react-router-dom"; |
|
|
|
import Svg, { G, Path } from "react-native-svg"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//components
|
|
|
|
//components
|
|
|
|
import Navbar from "../../../../components/Navbar"; |
|
|
|
import Empty from "../../../../../components/Empty"; |
|
|
|
import CustomPressable from "../../../../components/Pressable"; |
|
|
|
import Button from "../../../../../components/Button"; |
|
|
|
import Empty from "../../../../components/Empty"; |
|
|
|
import FloatingButton from "../../../../../components/FloatingButton"; |
|
|
|
|
|
|
|
|
|
|
|
//style
|
|
|
|
|
|
|
|
import tw from "tailwind-rn"; |
|
|
|
|
|
|
|
import Colors from "../../../../constants/Colors"; |
|
|
|
|
|
|
|
import fontSize from "../../../../constants/fontSize"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { height, width } = Dimensions.get("window"); |
|
|
|
|
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ProfileAddress = ({ |
|
|
|
const ProfileAddress = ({ |
|
|
|
addresses, |
|
|
|
addresses, |
|
|
@ -41,156 +18,81 @@ const ProfileAddress = ({ |
|
|
|
loading, |
|
|
|
loading, |
|
|
|
closeBottomSheet, |
|
|
|
closeBottomSheet, |
|
|
|
mobile, |
|
|
|
mobile, |
|
|
|
|
|
|
|
isDark, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
const colorScheme = Appearance.getColorScheme(); |
|
|
|
const navigation = useNavigate(); |
|
|
|
const navigation = useNavigation(); |
|
|
|
|
|
|
|
const [height, setHeight] = React.useState(Dimensions.get("window").height); |
|
|
|
|
|
|
|
const Location = ({ address, active }) => { |
|
|
|
const Location = ({ address, active }) => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Pressable |
|
|
|
<div |
|
|
|
style={[ |
|
|
|
className={`bg-opacity-5 border border-solid flex flex-row items-center w-full px-3 py-2 rounded-md mt-2 ${ |
|
|
|
{ |
|
|
|
active ? "bg-blueC0 border-blueC0" : "bg-gray-300 border-gray-300" |
|
|
|
backgroundColor: |
|
|
|
}`}
|
|
|
|
userAddressId === address?.id |
|
|
|
onClick={() => |
|
|
|
? Colors.theme1[colorScheme].greenCF + "0a" |
|
|
|
|
|
|
|
: Colors.theme1[colorScheme].grayE3 + "44", |
|
|
|
|
|
|
|
borderWidth: 2, |
|
|
|
|
|
|
|
borderColor: |
|
|
|
|
|
|
|
userAddressId === address?.id |
|
|
|
|
|
|
|
? Colors.theme1[colorScheme].greenCF + "aa" |
|
|
|
|
|
|
|
: Colors.theme1[colorScheme].grayE3, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tw( |
|
|
|
|
|
|
|
`flex flex-row-reverse items-center w-full px-3 py-2 rounded-md mt-2` |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => |
|
|
|
|
|
|
|
userAddressId === address?.id |
|
|
|
userAddressId === address?.id |
|
|
|
? {} |
|
|
|
? {} |
|
|
|
: update({ userAddressId: address.id, userId }) |
|
|
|
: update({ userAddressId: address.id, userId }) |
|
|
|
} |
|
|
|
} |
|
|
|
> |
|
|
|
> |
|
|
|
<View style={tw("flex flex-1 mr-2")}> |
|
|
|
<div className={"flex flex-col flex-1 mr-2"}> |
|
|
|
{active && ( |
|
|
|
{active && ( |
|
|
|
<View |
|
|
|
<div className={"w-full flex flex-row justify-between mb-3"}> |
|
|
|
style={tw("w-full flex flex-row-reverse justify-between mb-3")} |
|
|
|
<div className={"flex flex-row items-center"}> |
|
|
|
> |
|
|
|
<strong className={"text-base font-bold text-gray1"}> |
|
|
|
<View style={tw("flex flex-row-reverse items-center")}> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontSize: fontSize.base, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].gray20, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
آدرس انتخابی شما |
|
|
|
آدرس انتخابی شما |
|
|
|
</Text> |
|
|
|
</strong> |
|
|
|
<Text |
|
|
|
<span className={"text-xs text-gray1 mr-2.5"}>فعال</span> |
|
|
|
style={{ |
|
|
|
</div> |
|
|
|
fontSize: fontSize.xs, |
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={24} height={24}> |
|
|
|
fontFamily: "regular", |
|
|
|
<g fill="#07612c" data-name="vuesax/linear/more"> |
|
|
|
color: Colors.theme1[colorScheme].gray20, |
|
|
|
<path d="M10 19a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" /> |
|
|
|
marginRight: 10, |
|
|
|
<path |
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
فعال |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
<Svg xmlns="http://www.w3.org/2000/svg" width={24} height={24}> |
|
|
|
|
|
|
|
<G fill="#07612c" data-name="vuesax/linear/more"> |
|
|
|
|
|
|
|
<Path d="M10 19a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" /> |
|
|
|
|
|
|
|
<Path |
|
|
|
|
|
|
|
data-name="Vector" |
|
|
|
data-name="Vector" |
|
|
|
d="M10 5a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2ZM10 12a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" |
|
|
|
d="M10 5a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2ZM10 12a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</G> |
|
|
|
</g> |
|
|
|
</Svg> |
|
|
|
</svg> |
|
|
|
</View> |
|
|
|
</div> |
|
|
|
)} |
|
|
|
)} |
|
|
|
<View style={tw(`flex w-full ${active ? "" : "flex-row-reverse"}`)}> |
|
|
|
<div className={`flex w-full ${active ? "" : "flex-row"}`}> |
|
|
|
<View style={tw("flex flex-1 mb-4")}> |
|
|
|
<div className={"flex flex-col flex-1 mb-4"}> |
|
|
|
<Text |
|
|
|
<span className={"text-sm leading-6"}> |
|
|
|
style={[ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fontFamily: "regular", |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.sm : fontSize.lg, |
|
|
|
|
|
|
|
lineHeight: 22, |
|
|
|
|
|
|
|
textAlign: ios ? "right" : "auto", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{"آدرس:" + " " + address.address} |
|
|
|
{"آدرس:" + " " + address.address} |
|
|
|
</Text> |
|
|
|
</span> |
|
|
|
<Text |
|
|
|
<span className={"text-sm leading-6 mt-1.5"}> |
|
|
|
style={[ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
marginTop: mobile ? 4 : 8, |
|
|
|
|
|
|
|
fontFamily: "regular", |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.sm : fontSize.lg, |
|
|
|
|
|
|
|
lineHeight: 22, |
|
|
|
|
|
|
|
textAlign: ios ? "right" : "auto", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{"نام:" + " " + address.firstName + " " + address.lastName} |
|
|
|
{"نام:" + " " + address.firstName + " " + address.lastName} |
|
|
|
</Text> |
|
|
|
</span> |
|
|
|
<Text |
|
|
|
<span className={"text-sm leading-6 mt-1.5"}> |
|
|
|
style={[ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
marginTop: mobile ? 4 : 8, |
|
|
|
|
|
|
|
fontFamily: "regular", |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.sm : fontSize.lg, |
|
|
|
|
|
|
|
lineHeight: 22, |
|
|
|
|
|
|
|
textAlign: ios ? "right" : "auto", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{"کد پستی:" + " " + address.postalCode} |
|
|
|
{"کد پستی:" + " " + address.postalCode} |
|
|
|
</Text> |
|
|
|
</span> |
|
|
|
<Text |
|
|
|
<span className={"text-sm leading-6 mt-1.5"}> |
|
|
|
style={[ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
marginTop: mobile ? 4 : 8, |
|
|
|
|
|
|
|
fontFamily: "regular", |
|
|
|
|
|
|
|
fontSize: mobile ? fontSize.sm : fontSize.lg, |
|
|
|
|
|
|
|
lineHeight: 22, |
|
|
|
|
|
|
|
textAlign: ios ? "right" : "auto", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{"شماره تماس:" + " " + address.cellphone} |
|
|
|
{"شماره تماس:" + " " + address.cellphone} |
|
|
|
</Text> |
|
|
|
</span> |
|
|
|
</View> |
|
|
|
</div> |
|
|
|
{!active && ( |
|
|
|
{!active && ( |
|
|
|
<Svg xmlns="http://www.w3.org/2000/svg" width={24} height={24}> |
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" width={24} height={24}> |
|
|
|
<G |
|
|
|
<g fill={"#aaa"} data-name="vuesax/linear/more"> |
|
|
|
fill={Colors.theme1[colorScheme].gray20} |
|
|
|
<path d="M10 19a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" /> |
|
|
|
data-name="vuesax/linear/more" |
|
|
|
<path |
|
|
|
> |
|
|
|
|
|
|
|
<Path d="M10 19a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" /> |
|
|
|
|
|
|
|
<Path |
|
|
|
|
|
|
|
data-name="Vector" |
|
|
|
data-name="Vector" |
|
|
|
d="M10 5a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2ZM10 12a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" |
|
|
|
d="M10 5a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2ZM10 12a2 2 0 1 0 2-2 2.006 2.006 0 0 0-2 2Z" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</G> |
|
|
|
</g> |
|
|
|
</Svg> |
|
|
|
</svg> |
|
|
|
)} |
|
|
|
)} |
|
|
|
</View> |
|
|
|
</div> |
|
|
|
|
|
|
|
<Button |
|
|
|
<CustomPressable |
|
|
|
title="نمایش روی نقشه" |
|
|
|
title={"مشاهده روی نقشه"} |
|
|
|
backgroundColor={isDark ? "bg-transparent" : "bg-blueC0"} |
|
|
|
backgroundColor={ |
|
|
|
border={{ |
|
|
|
active |
|
|
|
color: isDark ? "#ffffff55" : "#196EC055", |
|
|
|
? Colors.theme1[colorScheme].greenCF |
|
|
|
width: "0px", |
|
|
|
: Colors.theme1[colorScheme].gray20 + "66" |
|
|
|
}} |
|
|
|
} |
|
|
|
width="100%" |
|
|
|
color={"white"} |
|
|
|
color={isDark ? "text-blueC0" : "text-white"} |
|
|
|
border={{ color: "#196EC0", width: 0 }} |
|
|
|
onClick={() => {}} |
|
|
|
width={"100%"} |
|
|
|
|
|
|
|
onPress={() => {}} |
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
</View> |
|
|
|
</div> |
|
|
|
</Pressable> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -200,34 +102,10 @@ const ProfileAddress = ({ |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<SafeAreaView |
|
|
|
<div className="flex-1 flex flex-col relative"> |
|
|
|
style={{ |
|
|
|
|
|
|
|
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, |
|
|
|
|
|
|
|
position: "relative", |
|
|
|
|
|
|
|
backgroundColor: "white", |
|
|
|
|
|
|
|
flex: 1, |
|
|
|
|
|
|
|
paddingBottom: 20, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Navbar |
|
|
|
|
|
|
|
headerOptions={{ |
|
|
|
|
|
|
|
logo: false, |
|
|
|
|
|
|
|
menu: false, |
|
|
|
|
|
|
|
hamburgerMenu: false, |
|
|
|
|
|
|
|
title: "آدرسها", |
|
|
|
|
|
|
|
bookmark: false, |
|
|
|
|
|
|
|
qr: false, |
|
|
|
|
|
|
|
back: true, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
{addresses.length > 0 ? ( |
|
|
|
{addresses.length > 0 ? ( |
|
|
|
<ScrollView |
|
|
|
<div className="w-full mt-2 px-4"> |
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
<div className="p-0 m-0 flex "> |
|
|
|
style={[styles.container]} |
|
|
|
|
|
|
|
onLayout={() => setHeight(Dimensions.get("window").height)} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<View style={tw("w-full mt-2 px-4")}> |
|
|
|
|
|
|
|
<View style={tw("p-0 m-0 flex ")}> |
|
|
|
|
|
|
|
{addresses.map((address, index) => ( |
|
|
|
{addresses.map((address, index) => ( |
|
|
|
<Location |
|
|
|
<Location |
|
|
|
address={address} |
|
|
|
address={address} |
|
|
@ -235,49 +113,17 @@ const ProfileAddress = ({ |
|
|
|
active={userAddressId === address?.id} |
|
|
|
active={userAddressId === address?.id} |
|
|
|
/> |
|
|
|
/> |
|
|
|
))} |
|
|
|
))} |
|
|
|
</View> |
|
|
|
</div> |
|
|
|
</View> |
|
|
|
</div> |
|
|
|
</ScrollView> |
|
|
|
|
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<Empty text="هیچ آدرسی ثبت نشده :(" /> |
|
|
|
<Empty text="هیچ آدرسی ثبت نشده :(" /> |
|
|
|
)} |
|
|
|
)} |
|
|
|
<View style={tw("w-full px-4")}> |
|
|
|
<FloatingButton |
|
|
|
<TouchableOpacity |
|
|
|
action={() => navigation("/createAddress")} |
|
|
|
style={[ |
|
|
|
position={{ bottom: 100, right: 16 }} |
|
|
|
{ |
|
|
|
size={16} |
|
|
|
backgroundColor: Colors.theme1[colorScheme].greenCF + "05", |
|
|
|
/> |
|
|
|
borderColor: Colors.theme1[colorScheme].greenCF, |
|
|
|
</div> |
|
|
|
borderWidth: 1.5, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
tw( |
|
|
|
|
|
|
|
`flex flex-row-reverse self-end justify-center py-2 rounded-md items-center mt-4 w-full` |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
onPress={() => navigation.push("CreateAddress")} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
fontSize: fontSize.tiny, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].greenCF, |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
یک آدرس جدید اضافه کنید |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
marginTop: 3, |
|
|
|
|
|
|
|
marginRight: 5, |
|
|
|
|
|
|
|
fontSize: fontSize.xl3, |
|
|
|
|
|
|
|
color: Colors.theme1[colorScheme].greenCF, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
+ |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</TouchableOpacity> |
|
|
|
|
|
|
|
</View> |
|
|
|
|
|
|
|
</SafeAreaView> |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -287,6 +133,7 @@ const mapStateToProps = (state) => ({ |
|
|
|
loading: state.userFactor.loading, |
|
|
|
loading: state.userFactor.loading, |
|
|
|
addresses: state.userAddress.list, |
|
|
|
addresses: state.userAddress.list, |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
mobile: state.publicApi.mobile, |
|
|
|
|
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
@ -296,16 +143,3 @@ const mapDispatchToProps = { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ProfileAddress); |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ProfileAddress); |
|
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
|
|
|
|
contentContainerStyle: { |
|
|
|
|
|
|
|
paddingBottom: 100, |
|
|
|
|
|
|
|
position: "relative", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
container: { |
|
|
|
|
|
|
|
backgroundColor: "white", |
|
|
|
|
|
|
|
flexDirection: "column", |
|
|
|
|
|
|
|
paddingVertical: 0, |
|
|
|
|
|
|
|
paddingHorizontal: 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|