From dd9eb2270eacb9d26299770499a94d684f304fc9 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Sun, 10 Apr 2022 13:44:06 +0430 Subject: [PATCH] reza completed rating without api --- package.json | 1 + src/screens/Product/components/Book.js | 56 +++++++++++++------------ src/screens/Product/components/Rates.js | 53 ++++++++++++++++------- yarn.lock | 7 ++++ 4 files changed, 74 insertions(+), 43 deletions(-) diff --git a/package.json b/package.json index e22ced2..19d0b45 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "react-native-awesome-alerts": "^1.5.2", "react-native-openanything": "^0.0.6", "react-native-qrcode-scanner": "^1.5.4", + "react-native-ratings": "^8.1.0", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-restart": "^0.0.22", "react-native-safe-area-context": "3.3.2", diff --git a/src/screens/Product/components/Book.js b/src/screens/Product/components/Book.js index 7d9ab96..b5d9121 100644 --- a/src/screens/Product/components/Book.js +++ b/src/screens/Product/components/Book.js @@ -18,7 +18,6 @@ import { Entypo } from "@expo/vector-icons"; import separate from "../../../utils/separate"; //components -import CustomPressable from "../../../components/Pressable"; import Description from "./Description"; import LinkBox from "./LinkBox"; import Comments from "./Comments"; @@ -27,6 +26,7 @@ import ProductReview from "../../../components/BottomSheetComponents/ProductRevi import ProductQuestion from "../../../components/BottomSheetComponents/ProductQuestion"; import Blur from "../../../components/Blur"; import ImageSlider from "../../../components/ImageSlider"; +import Rates from "./Rates"; //style import tw from "tailwind-rn"; @@ -67,13 +67,12 @@ function Book({ (product) => product?.productId === book?.product[0]?.id )[0]; + console.log(book); + return ( - + {!mobile && } - {(!book || userFavoriteLoading ) && ( + {(!book || userFavoriteLoading) && ( } height={height / 2} /> - {product.rates && ( - - + - امتیازات و نظرات - - - + + امتیازات و نظرات + + + + + + )} - - {/* */} - ); } @@ -639,7 +641,7 @@ const mapStateToProps = (state) => ({ userProducts: state.userProduct.list, userId: state.user.status?.id, userProductsLoading: state.userProduct.loading, - userFavoriteLoading : state.userFavorite.loading, + userFavoriteLoading: state.userFavorite.loading, mobile: state.publicApi.mobile, }); diff --git a/src/screens/Product/components/Rates.js b/src/screens/Product/components/Rates.js index 0374e38..0c73bbb 100644 --- a/src/screens/Product/components/Rates.js +++ b/src/screens/Product/components/Rates.js @@ -1,38 +1,55 @@ import React from "react"; -import { View, Text, Dimensions } from "react-native"; +import { View, Text, Dimensions, Appearance } from "react-native"; +import { Rating } from 'react-native-ratings'; + +//assets import tw from "tailwind-rn"; import fontSize from "../../../constants/fontSize"; +import Colors from "../../../constants/Colors"; const width = Dimensions.get("window").width; -export default function Rates({ rates }) { +export default function Rates({ rate }) { + + const ratingCompleted = (rating) => { + return; + } + return ( - + - {rates.mid} + {rate} + ratingCompleted(rating)} + /> - {"از" + " " + rates.allRates + " " + "نفر"} + {`از بین ${1150} نفر`} - {rates.fields.map((field, index) => ( + {[ + { name: "بخش ۱", value: 40 }, + { name: "بخش ۱", value: 20 }, + { name: "بخش ۱", value: 70 }, + { name: "بخش ۱", value: 10 }, + { name: "بخش ۱", value: 50 }, + ].map((field, index) => ( ))} @@ -40,9 +57,13 @@ export default function Rates({ rates }) { ); } -const Progress = ({ data }) => { +const Progress = ({ data, ...props }) => { + const colorScheme = React.useMemo(() => { + return Appearance.getColorScheme(); + },[props.useless]); + return ( - + { diff --git a/yarn.lock b/yarn.lock index 783c9a0..3b8aa05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5332,6 +5332,13 @@ react-native-qrcode-scanner@^1.5.4: prop-types "^15.5.10" react-native-permissions "^2.0.2" +react-native-ratings@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/react-native-ratings/-/react-native-ratings-8.1.0.tgz#3fa9ad29128dc3a88e59518ba151e61c59dd0647" + integrity sha512-+QOJ4G3NjVkI1D+tk4EGx1dCvVfbD2nQdkrj9cXrcAoEiwmbep4z4bZbCKmWMpQ5h2dqbxABU8/eBnbDmvAc3g== + dependencies: + lodash "^4.17.15" + react-native-raw-bottom-sheet@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/react-native-raw-bottom-sheet/-/react-native-raw-bottom-sheet-2.2.0.tgz#d11dabb86aadb014273767ef7b554924b13633c5"