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.
 
 
 
 
 

155 lines
4.3 KiB

import React, { useState, useEffect } from "react";
import {
View,
Text,
ScrollView,
Dimensions,
StyleSheet,
Pressable,
SafeAreaView,
StatusBar,
LayoutAnimation,
ActivityIndicator,
} from "react-native";
import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native";
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
import { user } from "../../redux/actions";
import Svg, { G, Path } from "react-native-svg";
//components
import Navbar from "../../components/Navbar";
import Drawer from "../../components/Drawer";
import User from "./components/User";
import Trophy from "./components/Trophy";
import List from "./components/List";
//style
import fontSize from "../../constants/fontSize";
import Colors from "../../constants/Colors";
import tw from "tailwind-rn";
function Profile({ mobile, theme, logout, loading }) {
const navigation = useNavigation();
const [position, setPosition] = useState("100%");
useEffect(() => {}, []);
const setBoxPosition = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setPosition(position === "100%" ? "0%" : "100%");
};
return (
<SafeAreaView
style={{
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative",
}}
>
<Navbar
setBoxPosition={setBoxPosition}
headerOptions={{
logo: false,
menu: false,
hamburgerMenu: false,
title: "حساب کاربری",
bookmark: false,
qr: false,
back: false,
}}
/>
<Drawer setBoxPosition={setBoxPosition} position={position} />
<ScrollView
contentContainerStyle={styles.contentContainerStyle}
style={styles.container}
>
<User />
{/* <Trophy /> */}
<List />
<Pressable
style={tw(`flex w-full ${mobile ? "mt-0" : "mt-4"}`)}
onPress={() =>
asyncAwesomeAlert("", "آیا قصد خروج از حساب کاربری فعلی رو داری؟", {
showCancelButton: true,
confirmText : 'آره',
cancelText: "خیر",
onConfirm: () => {
navigation.navigate("HomeTab", { screen: "Home" });
logout();
},
})
}
>
<View
style={[tw(`flex items-center w-full pb-3 mb-3 flex-row-reverse`)]}
>
{loading ? (
<ActivityIndicator
color={Colors.theme1.redC0}
size={fontSize.xl}
/>
) : (
<Svg
data-name="vuesax/linear/logout"
xmlns="http://www.w3.org/2000/svg"
width={34.034}
height={34.034}
style={{ transform: [{ scale: 0.8 }] }}
>
<G
fill="none"
stroke="#ff2020"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
>
<Path d="M12.621 10.721c.44-5.105 3.063-7.19 8.806-7.19h.184c6.339 0 8.877 2.538 8.877 8.877v9.246c.001 6.339-2.537 8.877-8.876 8.877h-.185c-5.7 0-8.324-2.056-8.792-7.076" />
<Path
data-name="Vector"
d="M21.272 17.017H5.134M8.296 12.267l-4.751 4.751 4.751 4.749"
/>
</G>
</Svg>
)}
<Text
style={{
fontSize: fontSize.tiny,
fontFamily: "bold",
color: Colors.theme1.redFF1,
marginRight: 4,
}}
>
خروج از حساب کاربری
</Text>
</View>
</Pressable>
</ScrollView>
</SafeAreaView>
);
}
const mapStateToProps = (state) => ({
mobile: state.publicApi.mobile,
theme: state.publicApi.theme,
loading: state.user.loading,
});
const mapDispatchToProps = {
logout: user.logout,
};
export default connect(mapStateToProps, mapDispatchToProps)(Profile);
const styles = StyleSheet.create({
contentContainerStyle: {
paddingBottom: 100,
position: "relative",
},
container: {
flexDirection: "column",
paddingVertical: 5,
paddingHorizontal: 16,
},
});