reza added some change

master
Reza_ashrafi 3 years ago
parent 7b16deabe0
commit 9400f85860
  1. 2
      navigation/index.js
  2. 117
      src/components/BottomSheetComponents/ProductQuestion.js
  3. 44
      src/components/Empty.js
  4. 2
      src/components/Navbar.js
  5. 7
      src/redux/reducers/userFavorite.js
  6. 7
      src/screens/Home/components/Blogs.js
  7. 110
      src/screens/Home/components/MyBooks.js
  8. 6
      src/screens/Home/components/Scroll.js
  9. 14
      src/screens/Home/components/Videos.js
  10. 6
      src/screens/Product/components/Book.js
  11. 47
      src/screens/Profile/components/ProfileAddress/index.js
  12. 57
      src/screens/Profile/components/ProfileBookmark/index.js
  13. 3
      src/screens/Profile/components/User.js
  14. 227
      src/screens/ShoppingCart/index.js
  15. 2
      src/screens/VideoDisplay/index.js

@ -67,7 +67,7 @@ const BottomTabNavigator = ({}) => {
tabBarActiveTintColor: Colors.theme1[colorScheme].green79, tabBarActiveTintColor: Colors.theme1[colorScheme].green79,
tabBarInactiveTintColor: "grey", tabBarInactiveTintColor: "grey",
tabBarStyle: { tabBarStyle: {
backgroundColor: Colors.theme1[colorScheme].greenFF1, backgroundColor: Colors.theme1[colorScheme].white,
}, },
tabBarLabelStyle: { tabBarLabelStyle: {
// fontSize: fontSize.sm, // fontSize: fontSize.sm,

@ -15,65 +15,10 @@ import fontSize from "../../constants/fontSize";
import tw from "tailwind-rn"; import tw from "tailwind-rn";
import Colors from "../../constants/Colors"; import Colors from "../../constants/Colors";
const { width } = Dimensions.get("window");
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
const ProductQuestion = ({ list, mobile }) => { const ProductQuestion = ({ list, mobile }) => {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
const Question = ({ question }) => {
return (
<View style={[tw("flex mb-3")]}>
<Text
style={{
fontFamily: "bold",
color: Colors.theme1[colorScheme].green79,
fontSize: mobile ? fontSize.tiny : fontSize.xl3,
textAlign: ios ? "right" : "auto",
}}
>
سوال
</Text>
<Text
style={{
fontFamily: "bold",
color: "#323232",
fontSize: mobile ? fontSize.sm : fontSize.base,
textAlign: ios ? "right" : "auto",
}}
>
{question.question}
</Text>
{question.answer && (
<>
<Text
style={{
fontFamily: "bold",
color: Colors.theme1[colorScheme].green79,
fontSize: fontSize.tiny,
marginTop: 10,
textAlign: ios ? "right" : "auto",
}}
>
پاسخ
</Text>
<Text
style={{
fontFamily: "bold",
color: Colors.theme1[colorScheme].gray2077,
fontSize: mobile ? fontSize.sm : fontSize.base,
textAlign: ios ? "right" : "auto",
marginTop: mobile ? "" : 10,
}}
>
{question.question}
</Text>
</>
)}
{/* <View></View> */}
<Divider type="vertical" />
</View>
);
};
return ( return (
<View style={{ flex: 1, paddingHorizontal: 16 }}> <View style={{ flex: 1, paddingHorizontal: 16 }}>
<View <View
@ -102,14 +47,70 @@ const ProductQuestion = ({ list, mobile }) => {
</Text> </Text>
</View> </View>
<ScrollView style={tw("flex-1")}> <ScrollView style={tw("flex-1")}>
{list.map((question, index) => ( {/* {list?.map((question, index) => (
<Question question={question} key={index} /> <Question question={question} key={index} mobile={mobile} />
))} ))} */}
</ScrollView> </ScrollView>
</View> </View>
); );
}; };
const Question = ({ question, mobile }) => {
const colorScheme = Appearance.getColorScheme();
return (
<View style={[tw("flex mb-3")]}>
<Text
style={{
fontFamily: "bold",
color: Colors.theme1[colorScheme].green79,
fontSize: mobile ? fontSize.tiny : fontSize.xl3,
textAlign: ios ? "right" : "auto",
}}
>
سوال
</Text>
<Text
style={{
fontFamily: "bold",
color: "#323232",
fontSize: mobile ? fontSize.sm : fontSize.base,
textAlign: ios ? "right" : "auto",
}}
>
{question?.question}
</Text>
{question?.answer && (
<>
<Text
style={{
fontFamily: "bold",
color: Colors.theme1[colorScheme].green79,
fontSize: fontSize.tiny,
marginTop: 10,
textAlign: ios ? "right" : "auto",
}}
>
پاسخ
</Text>
<Text
style={{
fontFamily: "bold",
color: Colors.theme1[colorScheme].gray2077,
fontSize: mobile ? fontSize.sm : fontSize.base,
textAlign: ios ? "right" : "auto",
marginTop: mobile ? "" : 10,
}}
>
{question?.answer}
</Text>
</>
)}
{/* <View></View> */}
<Divider type="vertical" />
</View>
);
};
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
mobile: state.publicApi.mobile, mobile: state.publicApi.mobile,
}); });

@ -0,0 +1,44 @@
import { View, Text, Pressable, Appearance } from "react-native";
import React from "react";
//style
import Colors from "../constants/Colors";
import tw from "tailwind-rn";
import fontSize from "../constants/fontSize";
const Empty = ({ text, buttonText, buttonAction }) => {
const colorScheme = Appearance.getColorScheme();
return (
<View style={tw("flex-1 flex justify-center items-center")}>
<Text
style={[
tw("text-gray-500"),
{
fontFamily: "regular",
fontSize: fontSize.tiny,
transform: [{ translateY: -50 }],
},
]}
>
{text + " " + ":("}
</Text>
{buttonText && (
<Pressable style={[tw('py-2 px-5 rounded-sm'),{ backgroundColor: Colors.theme1[colorScheme].greenCF }]} onPress={() => buttonAction()}>
<Text
style={[
tw("text-white"),
{
fontFamily: "regular",
fontSize: fontSize.tiny,
},
]}
>
{buttonText}
</Text>
</Pressable>
)}
</View>
);
};
export default Empty;

@ -80,7 +80,7 @@ const Navbar = ({
<Text <Text
style={{ style={{
fontFamily: "bold", fontFamily: "bold",
fontSize: fontSize.xl, fontSize: fontSize.lg,
color: Color.theme1[colorScheme].green79, color: Color.theme1[colorScheme].green79,
paddingRight: 16, paddingRight: 16,
}} }}

@ -1,3 +1,6 @@
import { toastMessage} from '../../utils/message';
import { asyncAwesomeAlert } from '../../utils/AsyncWrappers';
const initialState = { const initialState = {
loading: false, loading: false,
error: null, error: null,
@ -16,12 +19,16 @@ export default function userAddress(state = initialState, action) {
case "userAddress/update": case "userAddress/update":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userAddress/add": case "userAddress/add":
toastMessage('به لیست علاقهمندیها اضافه شد.');
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userAddress/delete": case "userAddress/delete":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userAddress/loading": case "userAddress/loading":
return { ...state, loading: true }; return { ...state, loading: true };
case "userAddress/error": case "userAddress/error":
asyncAwesomeAlert("خطا", data.message, {
showCancelButton: false,
});
return { ...state, loading: false, error: data.message }; return { ...state, loading: false, error: data.message };
default: default:
return state; return state;

@ -29,8 +29,8 @@ const ios = Platform.OS === "ios";
function Blogs({ blogs, mobile }) { function Blogs({ blogs, mobile }) {
return ( return (
<View style={[tw("flex pr-3 mb-5")]}> <View style={[tw("flex mb-5")]}>
<View style={tw("w-full pl-3")}> <View style={tw("w-full px-4")}>
<Header title={"خواندنیها"} route={"Blogs"} /> <Header title={"خواندنیها"} route={"Blogs"} />
</View> </View>
<FlatList <FlatList
@ -54,7 +54,7 @@ const Blog = ({ blog, mobile }) => {
return ( return (
<Pressable <Pressable
style={[ style={[
tw("rounded-md ml-3 rounded-md relative"), tw("rounded-md mr-4 rounded-md relative"),
{ width: mobile ? 250 : width / 2.2 }, { width: mobile ? 250 : width / 2.2 },
]} ]}
onPress={() => navigation.push("Blog", { id: blog?.id })} onPress={() => navigation.push("Blog", { id: blog?.id })}
@ -106,7 +106,6 @@ const Blog = ({ blog, mobile }) => {
style={[tw("rounded-full ml-1"), { width: 20, flex: 1 }]} style={[tw("rounded-full ml-1"), { width: 20, flex: 1 }]}
/> />
</View> </View>
<Text <Text
style={[ style={[
{ {

@ -22,62 +22,11 @@ const ios = Platform.OS === "ios";
function MyBooks({ books, grades }) { function MyBooks({ books, grades }) {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
const Book = ({ book }) => {
const navigation = useNavigation();
return (
<Pressable
style={tw(`flex ml-3 ${ios ? "items-end" : ""}`)}
onPress={() => {}}
>
<View style={{ height: 165 }}>
<Image
source={{
uri: `https://dnvn.ir/api/v1/file/${book.product.book.fileIds}`,
}}
resizeMode="contain"
style={[
{
width: 110,
flex: 1,
},
]}
/>
</View>
<Text
style={[
tw("mt-2 pr-1"),
{
color: Colors.theme1[colorScheme].gray20,
fontFamily: "bold",
fontSize: fontSize.sm,
},
]}
>
{book.product.book.name}
</Text>
<Text
style={[
tw("pr-1"),
{
color: Colors.theme1[colorScheme].gray20,
fontFamily: "light",
fontSize: fontSize.sm,
},
]}
>
{"پایه" + " " + grades[book.product.book.gradeId]}
</Text>
<Progress percent={60} alignItems={"items-end"} />
</Pressable>
);
};
return ( return (
<View style={[tw("flex w-full px-4 mb-5")]}> <View style={[tw("flex w-full mb-5")]}>
<View <View
style={[ style={[
tw(`w-full flex rounded-md pt-3 px-2 overflow-hidden`), tw(`w-full flex rounded-md pt-3 overflow-hidden`),
{ {
backgroundColor: Colors.theme1[colorScheme].greenCF + "0F", backgroundColor: Colors.theme1[colorScheme].greenCF + "0F",
borderColor: Colors.theme1[colorScheme].greenD9 + "", borderColor: Colors.theme1[colorScheme].greenD9 + "",
@ -87,7 +36,7 @@ function MyBooks({ books, grades }) {
> >
<Text <Text
style={[ style={[
tw(`${ios ? "text-right" : ""} w-full`), tw(`pr-4 ${ios ? "text-right" : ""} w-full`),
{ {
color: Colors.theme1[colorScheme].green79, color: Colors.theme1[colorScheme].green79,
fontFamily: "demi", fontFamily: "demi",
@ -103,7 +52,7 @@ function MyBooks({ books, grades }) {
horizontal={true} horizontal={true}
inverted={true} inverted={true}
data={books} data={books}
renderItem={({ item }) => <Book book={item} />} renderItem={({ item }) => <Book book={item} grades={grades} />}
keyExtractor={(book) => book?.id} keyExtractor={(book) => book?.id}
/> />
</View> </View>
@ -111,6 +60,57 @@ function MyBooks({ books, grades }) {
); );
} }
const Book = ({ book, grades }) => {
const colorScheme = Appearance.getColorScheme();
const navigation = useNavigation();
return (
<Pressable
style={tw(`flex mr-4 ${ios ? "items-end" : ""}`)}
onPress={() => {}}
>
<View style={{ height: 165 }}>
<Image
source={{
uri: `https://dnvn.ir/api/v1/file/${book.product.book.fileIds}`,
}}
resizeMode="contain"
style={[
{
width: 110,
flex: 1,
},
]}
/>
</View>
<Text
style={[
tw("mt-2 pr-1"),
{
color: Colors.theme1[colorScheme].gray20,
fontFamily: "bold",
fontSize: fontSize.sm,
},
]}
>
{book.product.book.name}
</Text>
<Text
style={[
tw("pr-1"),
{
color: Colors.theme1[colorScheme].gray20,
fontFamily: "light",
fontSize: fontSize.sm,
},
]}
>
{"پایه" + " " + grades[book.product.book.gradeId]}
</Text>
<Progress percent={60} alignItems={"items-end"} />
</Pressable>
);
};
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
grades: state.publicApi.grades, grades: state.publicApi.grades,
}); });

@ -25,10 +25,11 @@ function Scroll({ books, mobile }) {
navigation.navigate("Product", { id: book?.id, type: "book" }) navigation.navigate("Product", { id: book?.id, type: "book" })
} }
style={[ style={[
tw("mx-1 overflow-hidden"), tw("mr-1 overflow-hidden"),
{ {
width: position === 0 ? mobile ? 163 : 240 : mobile ? 84 : 125, width: position === 0 ? mobile ? 163 : 240 : mobile ? 84 : 125,
height: position === 0 ? mobile ? 245 : 350 : mobile ? 118 : 170, height: position === 0 ? mobile ? 245 : 350 : mobile ? 118 : 170,
marginLeft : position === 0 ? 16 : 4,
}, },
]} ]}
> >
@ -58,7 +59,7 @@ function Scroll({ books, mobile }) {
); );
}; };
return ( return (
<View style={[tw(`flex pr-3 mb-5`)]}> <View style={[tw(`flex mb-5`)]}>
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
horizontal={true} horizontal={true}
@ -67,7 +68,6 @@ function Scroll({ books, mobile }) {
data={[{ id: 0 }]} data={[{ id: 0 }]}
renderItem={({}) => <Box books={books} />} renderItem={({}) => <Box books={books} />}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
/> />
</View> </View>
); );

@ -23,13 +23,11 @@ const ios = Platform.OS === "ios";
function Videos({ videos, grades, mobile }) { function Videos({ videos, grades, mobile }) {
return ( return (
<View style={[tw("w-full px-2 mb-5")]}> <View style={[tw("w-full mb-5")]}>
<View <View style={[tw("w-full flex rounded-md pt-2 overflow-hidden")]}>
style={[ <View style={tw('flex px-4')}>
tw("w-full flex rounded-md pt-2 px-2 overflow-hidden"), <Header title="دورههای ویدئویی شما" route={"VOD"} />
]} </View>
>
<Header title="دورههای ویدئویی شما" route={"VOD"} />
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
style={[tw("py-3")]} style={[tw("py-3")]}
@ -52,7 +50,7 @@ const Video = ({ video, mobile, grades }) => {
return ( return (
<Pressable <Pressable
style={[ style={[
tw(`flex relative ${mobile ? "ml-3" : "ml-5"}`), tw(`flex relative ${mobile ? "mr-4" : "ml-5"}`),
{ width: mobile ? 130 : 200, height: mobile ? 280 : 280 }, { width: mobile ? 130 : 200, height: mobile ? 280 : 280 },
]} ]}
onPress={() => navigation.navigate("Video", { id: video.id })} onPress={() => navigation.navigate("Video", { id: video.id })}

@ -594,19 +594,19 @@ function Book({
component={ component={
<ProductSpecifications list={book?.product[type]?.properties} /> <ProductSpecifications list={book?.product[type]?.properties} />
} }
height={height - height / 4} height={height / 2}
/> />
<LinkBox <LinkBox
title="نقد بررسی و توضیحات تکمیلی محصول" title="نقد بررسی و توضیحات تکمیلی محصول"
key={"1"} key={"1"}
component={<ProductReview />} component={<ProductReview />}
height={height - height / 4} height={height / 2}
/> />
<LinkBox <LinkBox
title="پرسش و پاسخ" title="پرسش و پاسخ"
key={"2"} key={"2"}
component={<ProductQuestion />} component={<ProductQuestion />}
height={height - height / 4} height={height / 2}
/> />
{product.rates && ( {product.rates && (
<View <View

@ -21,6 +21,7 @@ import Svg, { G, Path } from "react-native-svg";
//components //components
import Navbar from "../../../../components/Navbar"; import Navbar from "../../../../components/Navbar";
import CustomPressable from "../../../../components/Pressable"; import CustomPressable from "../../../../components/Pressable";
import Empty from "../../../../components/Empty";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -106,11 +107,7 @@ const ProfileAddress = ({
</Svg> </Svg>
</View> </View>
)} )}
<View <View style={tw(`flex w-full ${active ? "" : "flex-row-reverse"}`)}>
style={tw(
`flex w-full ${active ? "" : "flex-row-reverse"}`
)}
>
<View style={tw("flex flex-1 mb-4")}> <View style={tw("flex flex-1 mb-4")}>
<Text <Text
style={[ style={[
@ -208,8 +205,8 @@ const ProfileAddress = ({
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative", position: "relative",
backgroundColor: "white", backgroundColor: "white",
flex : 1, flex: 1,
paddingBottom : 20 paddingBottom: 20,
}} }}
> >
<Navbar <Navbar
@ -223,23 +220,27 @@ const ProfileAddress = ({
back: true, back: true,
}} }}
/> />
<ScrollView {addresses.length > 0 ? (
contentContainerStyle={styles.contentContainerStyle} <ScrollView
style={[styles.container]} contentContainerStyle={styles.contentContainerStyle}
onLayout={() => setHeight(Dimensions.get("window").height)} 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 ")}> <View style={tw("w-full mt-2 px-4")}>
{addresses.map((address, index) => ( <View style={tw("p-0 m-0 flex ")}>
<Location {addresses.map((address, index) => (
address={address} <Location
key={index} address={address}
active={userAddressId === address?.id} key={index}
/> active={userAddressId === address?.id}
))} />
))}
</View>
</View> </View>
</View> </ScrollView>
</ScrollView> ) : (
<Empty text="هیچ آدرسی ثبت نشده :(" />
)}
<View style={tw("w-full px-4")}> <View style={tw("w-full px-4")}>
<TouchableOpacity <TouchableOpacity
style={[ style={[

@ -16,10 +16,11 @@ import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import Svg, { Path } from "react-native-svg"; import Svg, { Path } from "react-native-svg";
import {userFavorite} from '../../../../redux/actions'; import { userFavorite } from "../../../../redux/actions";
//components //components
import Navbar from "../../../../components/Navbar"; import Navbar from "../../../../components/Navbar";
import Empty from "../../../../components/Empty";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -33,10 +34,9 @@ const { height, width } = Dimensions.get("window");
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
const ProfileBookmark = ({ bookmarkList, getList }) => { const ProfileBookmark = ({ bookmarkList, getList }) => {
React.useEffect(() => { React.useEffect(() => {
getList(); getList();
},[]); }, []);
return ( return (
<SafeAreaView <SafeAreaView
@ -57,28 +57,33 @@ const ProfileBookmark = ({ bookmarkList, getList }) => {
back: true, back: true,
}} }}
/> />
<ScrollView {bookmarkList?.length > 0 ? (
contentContainerStyle={styles.contentContainerStyle} <ScrollView
style={styles.container} contentContainerStyle={styles.contentContainerStyle}
> style={styles.container}
<View style={tw("w-full mt-2 px-4")}> >
<View style={tw("p-0 m-0 flex ")}> <View style={tw("w-full mt-2 px-4")}>
{bookmarkList.map((bookmark, index) => ( <View style={tw("p-0 m-0 flex")}>
<Bookmark key={index} bookmark={bookmark} /> {bookmarkList?.map((bookmark, index) => (
))} <Bookmark key={index} bookmark={bookmark} />
))}
</View>
</View> </View>
</View> </ScrollView>
</ScrollView> ) : (
<Empty text="لیست علاقهمندیها خالی است." />
)}
</SafeAreaView> </SafeAreaView>
); );
}; };
const Bookmark = ({ bookmark }) => { const Bookmark = ({ bookmark }) => {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
return ( return (
<Pressable <Pressable
style={[ style={[
tw("flex flex-row-reverse rounded-md justify-between px-3.5 py-2"), tw("flex flex-row-reverse rounded-md justify-between px-3.5 py-2 bg-red-100"),
{ {
borderWidth: 1.5, borderWidth: 1.5,
borderColor: Colors.theme1[colorScheme].greenCF, borderColor: Colors.theme1[colorScheme].greenCF,
@ -144,11 +149,11 @@ const Bookmark = ({ bookmark }) => {
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
loading: state.userFactor.loading, loading: state.userFactor.loading,
mobile: state.publicApi.mobile, mobile: state.publicApi.mobile,
bookmarkList : state.userFavorite.list bookmarkList: state.userFavorite.list,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getList : userFavorite.list, getList: userFavorite.list,
}; };
export default connect(mapStateToProps, mapDispatchToProps)(ProfileBookmark); export default connect(mapStateToProps, mapDispatchToProps)(ProfileBookmark);
@ -166,12 +171,12 @@ const styles = StyleSheet.create({
}, },
}); });
ProfileBookmark.defaultProps = { // ProfileBookmark.defaultProps = {
bookmarkList: [ // bookmarkList: [
{ // {
name: "کتاب آموزشی علوم تجربی", // name: "کتاب آموزشی علوم تجربی",
grade: "پایه ششم ابتدایی", // grade: "پایه ششم ابتدایی",
image: bookImage, // image: bookImage,
}, // },
], // ],
}; // };

@ -58,7 +58,7 @@ const User = ({ user, mobile }) => {
fontFamily: "bold", fontFamily: "bold",
}} }}
> >
{user?.firstName + " " + user?.lastName} {(user?.firstName || " ") + " " + (user?.lastName || " ")}
</Text> </Text>
<Text <Text
style={{ style={{
@ -93,7 +93,6 @@ const User = ({ user, mobile }) => {
}` }`
)} )}
> >
<View <View
style={[ style={[
tw(`flex items-center w-full pb-3 mb-3 flex-row-reverse`), tw(`flex items-center w-full pb-3 mb-3 flex-row-reverse`),

@ -17,7 +17,7 @@ import { Ionicons } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
import separate from "../../utils/separate"; import separate from "../../utils/separate";
import * as Linking from 'expo-linking'; import * as Linking from "expo-linking";
//components //components
import Product from "./components/Product"; import Product from "./components/Product";
@ -25,6 +25,7 @@ import Code from "./components/Code";
import CustomPressable from "../../components/Pressable"; import CustomPressable from "../../components/Pressable";
import Navbar from "../../components/Navbar"; import Navbar from "../../components/Navbar";
import Drawer from "../../components/Drawer"; import Drawer from "../../components/Drawer";
import Empty from "../../components/Empty";
//style //style
import fontSize from "../../constants/fontSize"; import fontSize from "../../constants/fontSize";
@ -103,7 +104,7 @@ function ShoppingCart({
.length !== 0; .length !== 0;
useEffect(() => { useEffect(() => {
if(list.length === 0){ if (list.length === 0) {
getList(); getList();
} }
getFactorInfo({ userId }); getFactorInfo({ userId });
@ -135,128 +136,138 @@ function ShoppingCart({
}} }}
/> />
<Drawer setBoxPosition={setBoxPosition} position={position} /> <Drawer setBoxPosition={setBoxPosition} position={position} />
<ScrollView {list?.filter((product) => product.condition < 2)?.length > 0 ? (
contentContainerStyle={styles.contentContainerStyle} <ScrollView
style={styles.container} contentContainerStyle={styles.contentContainerStyle}
> style={styles.container}
{list
?.sort((a, b) => a?.id - b?.id)
?.map(
(product, index) =>
product.condition < 2 && (
<Product key={index} product={product} loading={loading} />
)
)}
<Code />
<View
style={tw(
"flex w-full border-t py-2 border-gray-300 border-b mt-6"
)}
>
<PriceStatus
name="مبلغ سبد خرید"
value={isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice))}
type="normal"
/>
<PriceStatus
name="میزان تخفیف"
value={isEmpty ? 0 : separate(Math.round(factorInfo?.offPrice))}
type="error"
/>
<PriceStatus
name="مالیات بر ارزش افزوده"
value={
isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice * 0.009))
}
type="error"
/>
</View>
<View
style={tw(
"flex flex-row-reverse justify-between items-center w-full py-3"
)}
> >
<Text {list
style={[ ?.sort((a, b) => a?.id - b?.id)
{ ?.map(
color: Colors.theme1[colorScheme].green79, (product, index) =>
fontSize: fontSize.base, product.condition < 2 && (
fontFamily: "bold", <Product key={index} product={product} loading={loading} />
}, )
]} )}
<Code />
<View
style={tw(
"flex w-full border-t py-2 border-gray-300 border-b mt-6"
)}
>
<PriceStatus
name="مبلغ سبد خرید"
value={isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice))}
type="normal"
/>
<PriceStatus
name="میزان تخفیف"
value={isEmpty ? 0 : separate(Math.round(factorInfo?.offPrice))}
type="error"
/>
<PriceStatus
name="مالیات بر ارزش افزوده"
value={
isEmpty ? 0 : separate(Math.round(factorInfo?.sumPrice * 0.009))
}
type="error"
/>
</View>
<View
style={tw(
"flex flex-row-reverse justify-between items-center w-full py-3"
)}
> >
جمع کل سبد خرید
</Text>
<View style={tw("flex flex-row-reverse items-center")}>
<Text <Text
style={[ style={[
{ {
color: Colors.theme1[colorScheme].green79, color: Colors.theme1[colorScheme].green79,
fontSize: fontSize.xl, fontSize: fontSize.base,
fontFamily: "bold", fontFamily: "bold",
}, },
]} ]}
> >
{isEmpty ? 0 : separate(factorInfo?.payPrice)} جمع کل سبد خرید
</Text>
<Text
style={[
{
color: Colors.theme1[colorScheme].green79,
fontSize: fontSize.sm,
fontFamily: "regular",
marginRight: 4,
},
]}
>
تومان
</Text> </Text>
<View style={tw("flex flex-row-reverse items-center")}>
<Text
style={[
{
color: Colors.theme1[colorScheme].green79,
fontSize: fontSize.xl,
fontFamily: "bold",
},
]}
>
{isEmpty ? 0 : separate(factorInfo?.payPrice)}
</Text>
<Text
style={[
{
color: Colors.theme1[colorScheme].green79,
fontSize: fontSize.sm,
fontFamily: "regular",
marginRight: 4,
},
]}
>
تومان
</Text>
</View>
</View> </View>
</View> <View style={tw("w-full")}>
<View style={tw("w-full")}> <Pressable
<Pressable
style={[
tw(
"w-full rounded-md flex flex-row justify-center items-center py-3 px-3 my-5"
),
{ backgroundColor: Colors.theme1[colorScheme].greenC8 + "1a" },
]}
>
<Text
style={[ style={[
tw("mr-1"), tw(
{ "w-full rounded-md flex flex-row justify-center items-center py-3 px-3 my-5"
color: Colors.theme1[colorScheme].green79, ),
fontSize: fontSize.sm, { backgroundColor: Colors.theme1[colorScheme].greenC8 + "1a" },
fontFamily: "regular",
},
]} ]}
> >
هزینه ارسال کالا پس از تعیین محل آدرس مشخص میشود <Text
</Text> style={[
<Ionicons tw("mr-1"),
name="alert-circle-outline" {
size={20} color: Colors.theme1[colorScheme].green79,
color={Colors.theme1[colorScheme].greenC8} fontSize: fontSize.sm,
/> fontFamily: "regular",
</Pressable> },
]}
>
هزینه ارسال کالا پس از تعیین محل آدرس مشخص میشود
</Text>
<Ionicons
name="alert-circle-outline"
size={20}
color={Colors.theme1[colorScheme].greenC8}
/>
</Pressable>
<CustomPressable <CustomPressable
title={hasPhysical ? "ادامه فرایند خرید" : "پرداخت"} title={hasPhysical ? "ادامه فرایند خرید" : "پرداخت"}
backgroundColor={Colors.theme1[colorScheme].greenCF} backgroundColor={Colors.theme1[colorScheme].greenCF}
color={"white"} color={"white"}
border={{ color: "#196EC0", width: 0 }} border={{ color: "#196EC0", width: 0 }}
width={"100%"} width={"100%"}
onPress={() => onPress={() =>
isEmpty isEmpty
? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", { ? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", {
showCancelButton: false, showCancelButton: false,
}) })
: hasPhysical ? navigation.push("DeliveryForm") : payFactor({userId}) : hasPhysical
} ? navigation.push("DeliveryForm")
/> : payFactor({ userId })
</View> }
</ScrollView> />
</View>
</ScrollView>
) : (
<Empty
text={"سبد خرید شما خالی است"}
buttonText={"فروشگاه"}
buttonAction={() => navigation.navigate("Products")}
/>
)}
</SafeAreaView> </SafeAreaView>
); );
} }

@ -35,8 +35,6 @@ function VideoDisplay({ route, mobile }) {
const [status, setStatus] = React.useState({}); const [status, setStatus] = React.useState({});
const [position, setPosition] = useState("100%"); const [position, setPosition] = useState("100%");
useEffect(() => {}, []);
const setBoxPosition = () => { const setBoxPosition = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setPosition(position === "100%" ? "0%" : "100%"); setPosition(position === "100%" ? "0%" : "100%");

Loading…
Cancel
Save