From 9400f858601b242a912e221b84fa08f1010ef921 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Tue, 22 Mar 2022 14:24:36 +0430 Subject: [PATCH] reza added some change --- navigation/index.js | 2 +- .../BottomSheetComponents/ProductQuestion.js | 117 ++++----- src/components/Empty.js | 44 ++++ src/components/Navbar.js | 2 +- src/redux/reducers/userFavorite.js | 7 + src/screens/Home/components/Blogs.js | 7 +- src/screens/Home/components/MyBooks.js | 110 ++++----- src/screens/Home/components/Scroll.js | 6 +- src/screens/Home/components/Videos.js | 14 +- src/screens/Product/components/Book.js | 6 +- .../components/ProfileAddress/index.js | 47 ++-- .../components/ProfileBookmark/index.js | 57 +++-- src/screens/Profile/components/User.js | 3 +- src/screens/ShoppingCart/index.js | 227 +++++++++--------- src/screens/VideoDisplay/index.js | 2 - 15 files changed, 357 insertions(+), 294 deletions(-) create mode 100644 src/components/Empty.js diff --git a/navigation/index.js b/navigation/index.js index 1b7b06d..c900402 100644 --- a/navigation/index.js +++ b/navigation/index.js @@ -67,7 +67,7 @@ const BottomTabNavigator = ({}) => { tabBarActiveTintColor: Colors.theme1[colorScheme].green79, tabBarInactiveTintColor: "grey", tabBarStyle: { - backgroundColor: Colors.theme1[colorScheme].greenFF1, + backgroundColor: Colors.theme1[colorScheme].white, }, tabBarLabelStyle: { // fontSize: fontSize.sm, diff --git a/src/components/BottomSheetComponents/ProductQuestion.js b/src/components/BottomSheetComponents/ProductQuestion.js index 95b6f70..51586a8 100644 --- a/src/components/BottomSheetComponents/ProductQuestion.js +++ b/src/components/BottomSheetComponents/ProductQuestion.js @@ -15,65 +15,10 @@ import fontSize from "../../constants/fontSize"; import tw from "tailwind-rn"; import Colors from "../../constants/Colors"; -const { width } = Dimensions.get("window"); const ios = Platform.OS === "ios"; const ProductQuestion = ({ list, mobile }) => { const colorScheme = Appearance.getColorScheme(); - const Question = ({ question }) => { - return ( - - - سوال - - - {question.question} - - {question.answer && ( - <> - - پاسخ - - - {question.question} - - - )} - {/* */} - - - ); - }; return ( { - {list.map((question, index) => ( - - ))} + {/* {list?.map((question, index) => ( + + ))} */} ); }; +const Question = ({ question, mobile }) => { + const colorScheme = Appearance.getColorScheme(); + return ( + + + سوال + + + {question?.question} + + {question?.answer && ( + <> + + پاسخ + + + {question?.answer} + + + )} + {/* */} + + + ); +}; + const mapStateToProps = (state) => ({ mobile: state.publicApi.mobile, }); diff --git a/src/components/Empty.js b/src/components/Empty.js new file mode 100644 index 0000000..18b0534 --- /dev/null +++ b/src/components/Empty.js @@ -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 ( + + + {text + " " + ":("} + + {buttonText && ( + buttonAction()}> + + {buttonText} + + + )} + + ); +}; + +export default Empty; diff --git a/src/components/Navbar.js b/src/components/Navbar.js index ac4d05f..3dbec17 100644 --- a/src/components/Navbar.js +++ b/src/components/Navbar.js @@ -80,7 +80,7 @@ const Navbar = ({ - + +
{ return ( navigation.push("Blog", { id: blog?.id })} @@ -106,7 +106,6 @@ const Blog = ({ blog, mobile }) => { style={[tw("rounded-full ml-1"), { width: 20, flex: 1 }]} /> - { - const navigation = useNavigation(); - return ( - {}} - > - - - - - {book.product.book.name} - - - {"پایه" + " " + grades[book.product.book.gradeId]} - - - - ); - }; - return ( - + } + renderItem={({ item }) => } keyExtractor={(book) => book?.id} /> @@ -111,6 +60,57 @@ function MyBooks({ books, grades }) { ); } +const Book = ({ book, grades }) => { + const colorScheme = Appearance.getColorScheme(); + const navigation = useNavigation(); + return ( + {}} + > + + + + + {book.product.book.name} + + + {"پایه" + " " + grades[book.product.book.gradeId]} + + + + ); +}; + const mapStateToProps = (state) => ({ grades: state.publicApi.grades, }); diff --git a/src/screens/Home/components/Scroll.js b/src/screens/Home/components/Scroll.js index 91031ca..722be54 100644 --- a/src/screens/Home/components/Scroll.js +++ b/src/screens/Home/components/Scroll.js @@ -25,10 +25,11 @@ function Scroll({ books, mobile }) { navigation.navigate("Product", { id: book?.id, type: "book" }) } style={[ - tw("mx-1 overflow-hidden"), + tw("mr-1 overflow-hidden"), { width: position === 0 ? mobile ? 163 : 240 : mobile ? 84 : 125, height: position === 0 ? mobile ? 245 : 350 : mobile ? 118 : 170, + marginLeft : position === 0 ? 16 : 4, }, ]} > @@ -58,7 +59,7 @@ function Scroll({ books, mobile }) { ); }; return ( - + } keyExtractor={(item) => item.id} - /> ); diff --git a/src/screens/Home/components/Videos.js b/src/screens/Home/components/Videos.js index 51cf663..4853b48 100644 --- a/src/screens/Home/components/Videos.js +++ b/src/screens/Home/components/Videos.js @@ -23,13 +23,11 @@ const ios = Platform.OS === "ios"; function Videos({ videos, grades, mobile }) { return ( - - -
+ + + +
+ { return ( navigation.navigate("Video", { id: video.id })} diff --git a/src/screens/Product/components/Book.js b/src/screens/Product/components/Book.js index b02b54e..7c84df1 100644 --- a/src/screens/Product/components/Book.js +++ b/src/screens/Product/components/Book.js @@ -594,19 +594,19 @@ function Book({ component={ } - height={height - height / 4} + height={height / 2} /> } - height={height - height / 4} + height={height / 2} /> } - height={height - height / 4} + height={height / 2} /> {product.rates && ( )} - + - setHeight(Dimensions.get("window").height)} - > - - - {addresses.map((address, index) => ( - - ))} + {addresses.length > 0 ? ( + setHeight(Dimensions.get("window").height)} + > + + + {addresses.map((address, index) => ( + + ))} + - - + + ) : ( + + )} { - React.useEffect(() => { getList(); - },[]); + }, []); return ( { back: true, }} /> - - - - {bookmarkList.map((bookmark, index) => ( - - ))} + {bookmarkList?.length > 0 ? ( + + + + {bookmarkList?.map((bookmark, index) => ( + + ))} + - - + + ) : ( + + )} ); }; const Bookmark = ({ bookmark }) => { const colorScheme = Appearance.getColorScheme(); + return ( { const mapStateToProps = (state) => ({ loading: state.userFactor.loading, mobile: state.publicApi.mobile, - bookmarkList : state.userFavorite.list + bookmarkList: state.userFavorite.list, }); const mapDispatchToProps = { - getList : userFavorite.list, + getList: userFavorite.list, }; export default connect(mapStateToProps, mapDispatchToProps)(ProfileBookmark); @@ -166,12 +171,12 @@ const styles = StyleSheet.create({ }, }); -ProfileBookmark.defaultProps = { - bookmarkList: [ - { - name: "کتاب آموزشی علوم تجربی", - grade: "پایه ششم ابتدایی", - image: bookImage, - }, - ], -}; +// ProfileBookmark.defaultProps = { +// bookmarkList: [ +// { +// name: "کتاب آموزشی علوم تجربی", +// grade: "پایه ششم ابتدایی", +// image: bookImage, +// }, +// ], +// }; diff --git a/src/screens/Profile/components/User.js b/src/screens/Profile/components/User.js index 5161651..869c881 100644 --- a/src/screens/Profile/components/User.js +++ b/src/screens/Profile/components/User.js @@ -58,7 +58,7 @@ const User = ({ user, mobile }) => { fontFamily: "bold", }} > - {user?.firstName + " " + user?.lastName} + {(user?.firstName || " ") + " " + (user?.lastName || " ")} { }` )} > - { - if(list.length === 0){ + if (list.length === 0) { getList(); } getFactorInfo({ userId }); @@ -135,128 +136,138 @@ function ShoppingCart({ }} /> - - {list - ?.sort((a, b) => a?.id - b?.id) - ?.map( - (product, index) => - product.condition < 2 && ( - - ) - )} - - - - - - - product.condition < 2)?.length > 0 ? ( + - a?.id - b?.id) + ?.map( + (product, index) => + product.condition < 2 && ( + + ) + )} + + + + + + + - جمع کل سبد خرید - - - {isEmpty ? 0 : separate(factorInfo?.payPrice)} - - - تومان + جمع کل سبد خرید + + + {isEmpty ? 0 : separate(factorInfo?.payPrice)} + + + تومان + + - - - - + - هزینه ارسال کالا پس از تعیین محل آدرس مشخص می‌شود - - - + + هزینه ارسال کالا پس از تعیین محل آدرس مشخص می‌شود + + + - - isEmpty - ? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", { - showCancelButton: false, - }) - : hasPhysical ? navigation.push("DeliveryForm") : payFactor({userId}) - } - /> - - + + isEmpty + ? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", { + showCancelButton: false, + }) + : hasPhysical + ? navigation.push("DeliveryForm") + : payFactor({ userId }) + } + /> + + + ) : ( + navigation.navigate("Products")} + /> + )} ); } diff --git a/src/screens/VideoDisplay/index.js b/src/screens/VideoDisplay/index.js index 90331bd..dc98c2c 100644 --- a/src/screens/VideoDisplay/index.js +++ b/src/screens/VideoDisplay/index.js @@ -35,8 +35,6 @@ function VideoDisplay({ route, mobile }) { const [status, setStatus] = React.useState({}); const [position, setPosition] = useState("100%"); - useEffect(() => {}, []); - const setBoxPosition = () => { LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); setPosition(position === "100%" ? "0%" : "100%");