You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
4.4 KiB
145 lines
4.4 KiB
import { View, Text, Image, Platform, Pressable, BackHandler } from "react-native"; |
|
import React from "react"; |
|
import { connect } from "react-redux"; |
|
import {user} from "../../../redux/actions"; |
|
import Svg, { Path } from "react-native-svg"; |
|
import { asyncAwesomeAlert } from "../../../utils/AsyncWrappers"; |
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
//style |
|
import tw from "tailwind-rn"; |
|
import fontSize from "../../../constants/fontSize"; |
|
import Colors from "../../../constants/Colors"; |
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
const User = ({ user, mobile, theme, logout }) => { |
|
const [dropdown, setDropdown] = React.useState(true); |
|
const navigation = useNavigation(); |
|
|
|
React.useEffect(() => { |
|
if(!user){ |
|
navigation.navigate('Login'); |
|
} |
|
},[user]); |
|
|
|
return ( |
|
<View style={tw(`w-full ${ios ? "items-end" : ""}`)}> |
|
<Pressable |
|
style={tw( |
|
`w-full mt-2 mb-2 flex flex-row-reverse justify-between items-center` |
|
)} |
|
onPress={() => setDropdown(!dropdown)} |
|
> |
|
<View style={tw(`flex items-center flex-row-reverse`)}> |
|
{user?.picFileIds ? ( |
|
<Image |
|
source={{ uri: "https://dnvn.ir/api/v1/" + user.picFileIds }} |
|
style={[ |
|
tw("rounded-full"), |
|
{ width: mobile ? 70 : 140, height: mobile ? 70 : 140 }, |
|
]} |
|
/> |
|
) : ( |
|
<View |
|
style={[ |
|
tw("rounded-full"), |
|
{ |
|
width: mobile ? 70 : 140, |
|
height: mobile ? 70 : 140, |
|
zIndex: 1, |
|
backgroundColor: "#ddd", |
|
}, |
|
]} |
|
></View> |
|
)} |
|
<View style={tw(`flex mr-1 ${ios ? "items-end" : ""}`)}> |
|
<Text |
|
style={{ |
|
fontSize: mobile ? fontSize.lg : fontSize.xl5, |
|
color: Colors.theme1[theme].gray20, |
|
fontFamily: "bold", |
|
}} |
|
> |
|
{(user?.firstName || " ") + " " + (user?.lastName || " ")} |
|
</Text> |
|
<Text |
|
style={{ |
|
fontSize: mobile ? fontSize.tiny : fontSize.xl2, |
|
color: Colors.theme1[theme].gray20, |
|
fontFamily: "light", |
|
marginTop: mobile ? 3 : 6, |
|
}} |
|
> |
|
{user?.cellphone} |
|
</Text> |
|
</View> |
|
</View> |
|
<Svg |
|
xmlns="http://www.w3.org/2000/svg" |
|
width={24} |
|
height={24} |
|
style={{ transform: [{ rotate: dropdown ? "0deg" : "180deg" }] }} |
|
> |
|
<Path |
|
d="M6.08 15.82h11.84a1.077 1.077 0 0 0 .76-1.84L13.499 8.8a2.131 2.131 0 0 0-3.01 0l-1.97 1.97-3.21 3.21a1.082 1.082 0 0 0 .771 1.84Z" |
|
fill="#c6c6c6" |
|
data-name="vuesax/bold/arrow-down" |
|
/> |
|
</Svg> |
|
</Pressable> |
|
{dropdown && ( |
|
<View style={tw(`flex flex-col pr-16 ${ios ? "items-end" : " "}`)}> |
|
<Pressable |
|
style={tw(`flex w-full ${mobile ? "mt-0" : "mt-4"}`)} |
|
onPress={() => |
|
asyncAwesomeAlert("نتیجه", "این قابلیت در حال توسعه است.", { |
|
showCancelButton: false, |
|
}) |
|
} |
|
> |
|
<View |
|
style={[ |
|
tw(`flex items-center w-full pb-3 mb-3 flex-row-reverse pt-2`), |
|
{ |
|
borderTopWidth: 1, |
|
borderColor: Colors.theme1[theme].grayE3, |
|
}, |
|
]} |
|
> |
|
<Text |
|
style={{ |
|
fontSize: mobile ? fontSize.base : fontSize.xl, |
|
fontFamily: "bold", |
|
color: Colors.theme1[theme].gray20, |
|
}} |
|
> |
|
افزودن حساب کاربری جدید |
|
</Text> |
|
<Text |
|
style={{ |
|
marginRight: 5, |
|
marginTop: 3, |
|
fontSize: fontSize.xl2, |
|
fontFamily: "bold", |
|
color: Colors.theme1[theme].gray20, |
|
}} |
|
> |
|
+ |
|
</Text> |
|
</View> |
|
</Pressable> |
|
</View> |
|
)} |
|
</View> |
|
); |
|
}; |
|
|
|
const mapStateToProps = (state) => ({ |
|
user: state.user.status, |
|
mobile: state.publicApi.mobile, |
|
theme: state.publicApi.theme, |
|
}); |
|
|
|
|
|
export default connect(mapStateToProps)(User);
|
|
|