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.
 
 
 
 
 

111 lines
2.8 KiB

import React, { useState, useEffect } from "react";
import {
SafeAreaView,
ScrollView,
StatusBar,
LayoutAnimation,
Platform,
Dimensions,
View,
} from "react-native";
import { connect } from "react-redux";
import { userProduct } from "../../redux/actions";
//components
import Navbar from "../../components/Navbar";
import Drawer from "../../components/Drawer";
import Book from "./components/Book";
import Empty from "../../components/Empty";
//style
import tw from "tailwind-rn";
const { height } = Dimensions.get("window");
const ios = Platform.OS === "ios";
function AR({ getUserProducts, userProducts, mobile, theme }) {
const [position, setPosition] = useState("100%");
useEffect(() => {
getUserProducts();
StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`,
true
);
}, []);
useEffect(() => {
StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`,
true
);
}, [theme]);
const setBoxPosition = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setPosition(position === "100%" ? "0%" : "100%");
};
return (
<SafeAreaView
style={{
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative",
flex: 1,
}}
>
<Navbar
setBoxPosition={setBoxPosition}
headerOptions={{
logo: false,
menu: false,
hamburgerMenu: false,
title: "واقعیت افزوده",
bookmark: false,
qr: false,
back: true,
}}
/>
<Drawer setBoxPosition={setBoxPosition} position={position} />
{userProducts?.length ? (
<ScrollView
style={{
paddingHorizontal: 16,
height: height,
}}
contentContainerStyle={{ paddingBottom: 100 }}
>
<View style={tw(`flex flex-wrap flex-row-reverse`)}>
{userProducts
?.filter(
(product) =>
(product?.productType === 2 || product?.productType === 3) &&
product?.condition >= 2
)
?.map((book, index) => (
<Book book={book} key={index} />
))}
</View>
</ScrollView>
) : (
<Empty
text="هیچ موردی برای شما وجود ندارد."
buttonText={"رفتن به فروشگاه"}
buttonAction={() => navigation.push("Products")}
/>
)}
</SafeAreaView>
);
}
const mapStateToProps = (state) => ({
userProducts: state.userProduct.list,
mobile: state.publicApi.mobile,
theme: state.publicApi.theme,
});
const mapDispatchToProps = {
getUserProducts: userProduct.list,
};
export default connect(mapStateToProps, mapDispatchToProps)(AR);