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.
141 lines
4.4 KiB
141 lines
4.4 KiB
import { View, Text, Platform, Pressable, Dimensions } from "react-native"; |
|
import React from "react"; |
|
import { connect } from "react-redux"; |
|
import { useNavigation } from "@react-navigation/native"; |
|
|
|
//components |
|
import Avatar from "../../../components/Avatar"; |
|
|
|
//style |
|
import tw from "tailwind-rn"; |
|
import fontSize from "../../../constants/fontSize"; |
|
import Colors from "../../../constants/Colors"; |
|
|
|
//variables |
|
const ios = Platform.OS === "ios"; |
|
const { width } = Dimensions.get("window"); |
|
|
|
const User = ({ user, mobile, theme }) => { |
|
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`)}> |
|
<Avatar source={user?.picFileIds} size={mobile ? width / 5.5 : width / 7} /> |
|
<View style={tw(`flex mr-2 ${ios ? "items-end" : ""}`)}> |
|
<Text |
|
style={{ |
|
fontSize: mobile ? fontSize.lg : fontSize.xl, |
|
color: |
|
theme === "light" |
|
? Colors.theme1.gray20 |
|
: Colors.theme1.white, |
|
fontFamily: "bold", |
|
}} |
|
> |
|
{(user?.firstName || " ") + " " + (user?.lastName || " ")} |
|
</Text> |
|
<Text |
|
style={{ |
|
fontSize: mobile ? fontSize.tiny : fontSize.base, |
|
color: |
|
theme === "light" |
|
? Colors.theme1.gray20 |
|
: Colors.theme1.white, |
|
fontFamily: "light", |
|
marginTop: mobile ? 3 : 6, |
|
textAlign: "right", |
|
}} |
|
> |
|
{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("", "این قابلیت در حال توسعه است.", { |
|
confirmText : 'باشه', |
|
showCancelButton: false, |
|
}) |
|
} |
|
> |
|
<View |
|
style={[ |
|
tw(`flex items-center w-full pb-3 mb-3 flex-row-reverse pt-2`), |
|
{ |
|
borderTopWidth: 1, |
|
borderColor: |
|
Colors.theme1.grayE3 + (theme === "light" ? "" : "55"), |
|
}, |
|
]} |
|
> |
|
<Text |
|
style={{ |
|
fontSize: mobile ? fontSize.base : fontSize.xl, |
|
fontFamily: "bold", |
|
color: |
|
theme === "light" |
|
? Colors.theme1.gray20 |
|
: Colors.theme1.white, |
|
}} |
|
> |
|
افزودن حساب کاربری جدید |
|
</Text> |
|
<Text |
|
style={{ |
|
marginRight: 5, |
|
marginTop: 3, |
|
fontSize: fontSize.xl2, |
|
fontFamily: "bold", |
|
color: |
|
theme === "light" |
|
? Colors.theme1.gray20 |
|
: Colors.theme1.white, |
|
}} |
|
> |
|
+ |
|
</Text> |
|
</View> |
|
</Pressable> |
|
</View> |
|
) : null} */} |
|
</View> |
|
); |
|
}; |
|
|
|
const mapStateToProps = (state) => ({ |
|
user: state.user.status, |
|
mobile: state.publicApi.mobile, |
|
theme: state.publicApi.theme, |
|
}); |
|
|
|
export default connect(mapStateToProps)(User);
|
|
|