From 8d7e687d73db179ed43a1d239824555536de8d08 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Tue, 12 Apr 2022 18:46:45 +0430 Subject: [PATCH] reza fixed compo colors before Video --- src/screens/ShoppingCart/components/Code.js | 12 ++-- .../ShoppingCart/components/Product.js | 27 ++++---- src/screens/ShoppingCart/index.js | 65 ++++++++++++------- 3 files changed, 58 insertions(+), 46 deletions(-) diff --git a/src/screens/ShoppingCart/components/Code.js b/src/screens/ShoppingCart/components/Code.js index f0874c6..7baa066 100644 --- a/src/screens/ShoppingCart/components/Code.js +++ b/src/screens/ShoppingCart/components/Code.js @@ -4,9 +4,7 @@ import { Text, Pressable, TextInput, - Dimensions, KeyboardAvoidingView, - Appearance, } from "react-native"; import { connect } from "react-redux"; import { userFactor } from "../../../redux/actions"; @@ -16,8 +14,7 @@ import fontSize from "../../../constants/fontSize"; import Colors from "../../../constants/Colors"; import tw from "tailwind-rn"; -function Code({ codeId, setCodeId, userId, factorId }) { - const colorScheme = Appearance.getColorScheme(); +function Code({ codeId, setCodeId, userId, factorId, theme }) { const [value, setValue] = React.useState(codeId || ""); const setOff = () => { @@ -32,7 +29,7 @@ function Code({ codeId, setCodeId, userId, factorId }) { setOff()} style={[ tw("py-3 px-5"), { - backgroundColor: Colors.theme1[colorScheme].greenCF, + backgroundColor: Colors.theme1[theme].greenCF, borderTopLeftRadius: 1, borderBottomLeftRadius: 1, }, @@ -73,6 +70,7 @@ const mapStateToProps = (state) => ({ codeId: state.userFactor.info?.codeId, userId: state.user.status?.id, factorId: state.userFactor.info?.id, + theme: state.publicApi.theme }); const mapDispatchToProps = { diff --git a/src/screens/ShoppingCart/components/Product.js b/src/screens/ShoppingCart/components/Product.js index 494e4e1..c827aeb 100644 --- a/src/screens/ShoppingCart/components/Product.js +++ b/src/screens/ShoppingCart/components/Product.js @@ -5,7 +5,6 @@ import { Image, Dimensions, Pressable, - Appearance, ActivityIndicator, Platform, } from "react-native"; @@ -22,8 +21,7 @@ import tw from "tailwind-rn"; const width = Dimensions.get("window").width; const ios = Platform.OS === "ios"; -function Product({ product, grades, pushToCart, loading, mobile }) { - const colorScheme = Appearance.getColorScheme(); +function Product({ product, grades, pushToCart, loading, mobile, theme }) { return ( @@ -118,7 +116,7 @@ function Product({ product, grades, pushToCart, loading, mobile }) { pushToCart( { @@ -152,14 +150,14 @@ function Product({ product, grades, pushToCart, loading, mobile }) { }` ), { - borderColor: Colors.theme1[colorScheme].greenCF, + borderColor: Colors.theme1[theme].greenCF, }, ]} > @@ -170,7 +168,7 @@ function Product({ product, grades, pushToCart, loading, mobile }) { ) : ( @@ -247,6 +245,7 @@ function Product({ product, grades, pushToCart, loading, mobile }) { const mapStateToProps = (state) => ({ grades: state.publicApi.grades, mobile: state.publicApi.mobile, + theme: state.publicApi.theme }); const mapDispatchToProps = { diff --git a/src/screens/ShoppingCart/index.js b/src/screens/ShoppingCart/index.js index ae39ef1..92c4e44 100644 --- a/src/screens/ShoppingCart/index.js +++ b/src/screens/ShoppingCart/index.js @@ -17,7 +17,6 @@ import { Ionicons } from "@expo/vector-icons"; import { useNavigation } from "@react-navigation/native"; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; import separate from "../../utils/separate"; -import * as Linking from "expo-linking"; //components import Product from "./components/Product"; @@ -32,10 +31,9 @@ import fontSize from "../../constants/fontSize"; import Colors from "../../constants/Colors"; import tw from "tailwind-rn"; -const { width, height } = Dimensions.get("window"); +const { height } = Dimensions.get("window"); -const PriceStatus = ({ name, value, type }) => { - const colorScheme = Appearance.getColorScheme(); +const PriceStatus = ({ name, value, type, theme }) => { return ( { tw(""), { fontSize: fontSize.tiny, - color: Colors.theme1[colorScheme].gray20, + color: Colors.theme1[theme].gray20, fontFamily: "bold", }, ]} @@ -56,8 +54,8 @@ const PriceStatus = ({ name, value, type }) => { { color: type === "error" - ? Colors.theme1[colorScheme].redFF1 - : Colors.theme1[colorScheme].green79, + ? Colors.theme1[theme].redFF1 + : Colors.theme1[theme].green79, fontSize: fontSize.xl, fontFamily: "bold", }, @@ -70,8 +68,8 @@ const PriceStatus = ({ name, value, type }) => { { color: type === "error" - ? Colors.theme1[colorScheme].redFF1 - : Colors.theme1[colorScheme].green79, + ? Colors.theme1[theme].redFF1 + : Colors.theme1[theme].green79, fontSize: fontSize.sm, fontFamily: "regular", marginRight: 4, @@ -93,15 +91,22 @@ function ShoppingCart({ getFactorInfo, loading, payFactor, + theme }) { const navigation = useNavigation(); - const colorScheme = Appearance.getColorScheme(); const [position, setPosition] = useState("100%"); - const isEmpty = list.filter((product) => product.condition < 2).length === 0; - const hasPhysical = - list.filter((product) => product.condition < 2 && product.productType === 2) - .length !== 0; + const isEmpty = React.useMemo(() => { + return list.filter((product) => product.condition < 2).length === 0; + }, [list]); + + const hasPhysical = React.useMemo(() => { + return ( + list.filter( + (product) => product.condition < 2 && product.productType === 2 + ).length !== 0 + ); + }, [list]); useEffect(() => { if (list.length === 0) { @@ -157,20 +162,29 @@ function ShoppingCart({ > - {isEmpty ? 0 : separate(factorInfo?.payPrice || '')} + {isEmpty ? 0 : separate(factorInfo?.payPrice || "")} ({ userId: state.user.status?.id, hasPhysical: state.userProduct.hasPhysical, loading: state.userProduct.loading, + theme: state.publicApi.theme }); const mapDispatchToProps = {