From 714e97b8835eb8a7ef33206ffe60d869c88b1579 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Mon, 25 Apr 2022 23:24:26 +0430 Subject: [PATCH] some fixing --- App.js | 11 ++- navigation/index.js | 9 ++- src/components/Select.js | 5 ++ src/redux/store.js | 70 ++++++++--------- src/screens/Address/index.js | 2 +- src/screens/Contact/index.js | 101 +++++++++++++------------ src/screens/Contact/layouts/Box.js | 6 +- src/screens/Product/components/Book.js | 56 ++++++-------- src/screens/Product/components/Info.js | 4 +- src/screens/Video/index.js | 10 ++- 10 files changed, 141 insertions(+), 133 deletions(-) diff --git a/App.js b/App.js index 5166fab..e596c00 100644 --- a/App.js +++ b/App.js @@ -4,8 +4,11 @@ import AppLoading from "expo-app-loading"; import Navigation from "./navigation/index"; import AlertModal from "./src/components/AlertModal"; import { Provider } from "react-redux"; -import store from "./src/redux/store"; +import buildStore from "./src/redux/store"; import React from "react"; +import { PersistGate } from "redux-persist/integration/react"; + +const { store, persistor } = buildStore(); const App = () => { let [fontsLoaded] = useFonts({ @@ -20,8 +23,10 @@ const App = () => { } return ( - - + + + + ); }; diff --git a/navigation/index.js b/navigation/index.js index 5717d51..503365f 100644 --- a/navigation/index.js +++ b/navigation/index.js @@ -111,7 +111,7 @@ const BottomTabNavigator = ({ theme }) => { data-name="Vector" d="M16.79 25.471v-6.693" fill="none" - stroke="#fff" + stroke={theme === "light" ? "#fff" : Colors.theme1.dark} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} @@ -179,7 +179,7 @@ const BottomTabNavigator = ({ theme }) => { data-name="Vector" d="M17.567 8.851v20.774M29.213 12.298h-3.294M29.159 16.643h-4.392" fill="none" - stroke="#fff" + stroke={theme === "light" ? "#fff" : Colors.theme1.dark} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} @@ -248,7 +248,7 @@ const BottomTabNavigator = ({ theme }) => { data-name="Vector" d="M12.427 14.995v-2.083c0-2.673 1.892-3.766 4.2-2.43l1.805 1.042 1.806 1.041c2.308 1.336 2.308 3.523 0 4.86l-1.806 1.041-1.805 1.046c-2.308 1.332-4.2.239-4.2-2.434v-2.083Z" fill="none" - stroke="#fff" + stroke={theme === "light" ? "#fff" : Colors.theme1.dark} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} @@ -313,6 +313,7 @@ const BottomTabNavigator = ({ theme }) => { xmlns="http://www.w3.org/2000/svg" width={31.017} height={31.017} + style={{ transform: [{scale : 1.2}]}} > { ? Colors.theme1.green79 : Colors.theme1.greenCF } - stroke={"white"} + stroke={theme === 'light' ? "white" : Colors.theme1.dark} strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} diff --git a/src/components/Select.js b/src/components/Select.js index f2ea245..b04062b 100644 --- a/src/components/Select.js +++ b/src/components/Select.js @@ -31,6 +31,7 @@ function Select({ rowTextStyle={{ fontSize: fontSize.sm, fontFamily: "regular", + color: theme === "light" ? Colors.theme1.gray20 : Colors.theme1.grayF9, }} defaultButtonText={defaultValue} statusBarTranslucent={true} @@ -68,6 +69,10 @@ function Select({ /> )} + dropdownStyle={{ + backgroundColor: + theme === "light" ? Colors.theme1.white : Colors.theme1.gray2077, + }} /> ); } diff --git a/src/redux/store.js b/src/redux/store.js index e277467..ebcb78f 100644 --- a/src/redux/store.js +++ b/src/redux/store.js @@ -1,6 +1,5 @@ import AsyncStorage from "@react-native-async-storage/async-storage"; import { applyMiddleware, createStore, compose, combineReducers } from "redux"; -import { createLogger } from "redux-logger"; import thunk from "redux-thunk"; import { persistStore, persistReducer } from "redux-persist"; import autoMergeLevel2 from "redux-persist/lib/stateReconciler/autoMergeLevel2"; @@ -13,10 +12,10 @@ import faq from "./reducers/faq"; import file from "./reducers/file"; import userFactor from "./reducers/userFactor"; import userProduct from "./reducers/userProduct"; -import qr from './reducers/qr'; +import qr from "./reducers/qr"; import userAddress from "./reducers/userAddress"; -import transport from "./reducers/transport" -import comment from './reducers/comment'; +import transport from "./reducers/transport"; +import comment from "./reducers/comment"; import form from "./reducers/form"; import userFavorite from "./reducers/userFavorite"; import vote from "./reducers/vote"; @@ -32,40 +31,37 @@ const initialState = {}; const middleWare = [thunk]; -// const loggerMiddleware = createLogger({ -// predicate: () => process.env.NODE_ENV === "development", -// }); -// middleWare.push(loggerMiddleware); - -const store = createStore( - persistReducer( - persistConfig, - combineReducers({ - publicApi, - user, - book, - blog, - product, - faq, - file, - userFactor, - userProduct, - qr, - userAddress, - transport, - comment, - form, - userFavorite, - vote - }) - ), - initialState, - compose(applyMiddleware(...middleWare)) +const persistedReducer = persistReducer( + persistConfig, + combineReducers({ + publicApi, + user, + book, + blog, + product, + faq, + file, + userFactor, + userProduct, + qr, + userAddress, + transport, + comment, + form, + userFavorite, + vote, + }) ); -const persistor = persistStore(store); - - console.disableYellowBox = true; -export default store; +export default () => { + let store = createStore( + persistedReducer, + initialState, + compose(applyMiddleware(...middleWare)) + ); + const persistor = persistStore(store); + + return { store, persistor }; +}; diff --git a/src/screens/Address/index.js b/src/screens/Address/index.js index ebe836a..e62cd86 100644 --- a/src/screens/Address/index.js +++ b/src/screens/Address/index.js @@ -271,7 +271,7 @@ const Address = ({ }} /> - +
{ + return { + onlineSupport: { + icon: onlineSupportIcon, + title: { text: "پشتیبانی آنلاین", color: "#D3B702" }, + description: { + text: "همکاران ما در قسمت فروش و پشتیبانی، پاسخگوی شما هستند هر سوالی در مورد کتاب‌های ما داشتید بپرسید", + color: theme === 'light' ? "#766600" : "#D3B702", + }, + link: { + title: "ارتباط با بخش پشتیبانی", + link: "/support", + color: theme === 'light' ? "#766600" : "#D3B702", + }, + bg: "#D3B70233", + borderColor: "#D3B70255", + onPress : navigation.push("Tickets") + }, + call: { + icon: callIcon, + title: { text: "شماره تماس", color: "#06A02A" }, + description: { + text: "در صورت هرگونه سوال شما می‌توانید در ساعات اداری 9 الی 17 با شماره 021۸۸۸۱۴۶۳۷ تماس حاصل فرمایید", + color: theme === 'light' ? "#025816" : "#06A02A", + }, + link: null, + bg: "#69FF5F33", + borderColor: "#69FF5F55", + onPress : () => {} + }, + address: { + icon: addressIcon, + title: { text: "نشانی", color: "#0EAD98" }, + description: { + text: "نشانی دفتر مرکزی: تهران میدان فردوسی خیابان عباس موسوی پلاک 30", + color: theme === 'light' ? "#066A5C" : "#0EAD98", + }, + link: { + title: "لیست نمایندگی‌های فروش", + link: "/sell", + color: theme === 'light' ? "#0A7769" : "#0EAD98", + }, + bg: "#0A776933", + borderColor: "#0A776955", + onPress : () => {} + }, + }; + }, [theme]); return ( ({ - theme: state.publicApi.theme + theme: state.publicApi.theme, }); const mapDispatchToProps = {}; export default connect(mapStateToProps, mapDispatchToProps)(Contact); - -Contact.defaultProps = { - info: { - onlineSupport: { - icon: onlineSupportIcon, - title: { text: "پشتیبانی آنلاین", color: "#D3B702" }, - description: { - text: "همکاران ما در قسمت فروش و پشتیبانی، پاسخگوی شما هستند هر سوالی در مورد کتاب‌های ما داشتید بپرسید", - color: "#766600", - }, - link: { - title: "ارتباط با بخش پشتیبانی", - link: "/support", - color: "#766600", - }, - bg: "#D3B70233", - borderColor: "#D3B70255", - }, - call: { - icon: callIcon, - title: { text: "شماره تماس", color: "#06A02A" }, - description: { - text: "در صورت هرگونه سوال شما می‌توانید در ساعات اداری 9 الی 17 با شماره 021۸۸۸۱۴۶۳۷ تماس حاصل فرمایید", - color: "#025816", - }, - link: null, - bg: "#69FF5F33", - borderColor: "#69FF5F55", - }, - address: { - icon: addressIcon, - title: { text: "نشانی", color: "#0EAD98" }, - description: { - text: "نشانی دفتر مرکزی: تهران میدان فردوسی خیابان عباس موسوی پلاک 30", - color: "#066A5C", - }, - link: { - title: "لیست نمایندگی‌های فروش", - link: "/sell", - color: "#0A7769", - }, - bg: "#0A776933", - borderColor: "#0A776955", - }, - }, -}; diff --git a/src/screens/Contact/layouts/Box.js b/src/screens/Contact/layouts/Box.js index 948c201..f6bb372 100644 --- a/src/screens/Contact/layouts/Box.js +++ b/src/screens/Contact/layouts/Box.js @@ -8,7 +8,6 @@ import { } from "react-native"; import React from "react"; import { connect } from "react-redux"; -import { useNavigation } from "@react-navigation/native"; //style import tw from "tailwind-rn"; @@ -18,9 +17,6 @@ const ios = Platform.OS === "ios"; const { height, width } = Dimensions.get("window"); const Box = ({ info, mobile }) => { - const navigation = useNavigation(); - const refRBSheet = React.useRef(); - return ( { borderWidth: 1, }, ]} - onPress={() => navigation.push("Tickets")} + onPress={() => info.onPress()} > - navigation.navigate("ShoppingCartTab", { - screen: "ShoppingCart", + navigation.navigate("Root", { + screen: "ShoppingCartTab", }), confirmText: "مشاهده سبد خرید", cancelText: "ادامه خرید", @@ -98,8 +98,8 @@ function Book({ asyncAwesomeAlert("", "به سبد خرید اضافه شد", { showCancelButton: true, onConfirm: () => - navigation.navigate("ShoppingCartTab", { - screen: "ShoppingCart", + navigation.navigate("Root", { + screen: "ShoppingCartTab", }), confirmText: "مشاهده سبد خرید", cancelText: "ادامه خرید", @@ -108,8 +108,8 @@ function Book({ asyncAwesomeAlert("", "به سبد خرید اضافه شد", { showCancelButton: true, onConfirm: () => - navigation.navigate("ShoppingCartTab", { - screen: "ShoppingCart", + navigation.navigate("Root", { + screen: "ShoppingCartTab", }), confirmText: "مشاهده سبد خرید", cancelText: "ادامه خرید", @@ -123,21 +123,6 @@ function Book({ return ( {!mobile ? : null} - {!book ? ( - - - - ) : null} {imageSlider ? : null} - {book?.name} + {book?.name || ""} - {"پایه" + " " + grades[book?.gradeId]} + {"پایه" + " " + (grades[book?.gradeId] || " ")} - {book?.text} + {book?.text || " "} @@ -209,7 +194,7 @@ function Book({ }} > {" "} - {book?.pagesNum + "\n" + "صفحه"} + {(book?.pagesNum || " ") + "\n" + "صفحه"} navigation.push("ShoppingCart"), + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), confirmText: "مشاهده سبد خرید", cancelText: "باشه", } @@ -338,7 +326,7 @@ function Book({ }, ]} > - {separate(book?.product[1]?.price) + " " + "تومان"} + {(separate(book?.product[1]?.price) || " ") + " " + "تومان"} @@ -363,7 +351,10 @@ function Book({ "این محصول قبلا به سبد خرید شما اضافه شده است.", { showCancelButton: true, - onConfirm: () => navigation.push("ShoppingCart"), + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), confirmText: "مشاهده سبد خرید", cancelText: "باشه", } @@ -410,7 +401,7 @@ function Book({ }, ]} > - {separate(book?.product[0]?.price) + " " + "تومان"} + {(separate(book?.product[0]?.price) || " ") + " " + "تومان"} @@ -463,7 +454,10 @@ function Book({ "این محصول قبلا به سبد خرید شما اضافه شده است.", { showCancelButton: true, - onConfirm: () => navigation.push("ShoppingCart"), + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), confirmText: "مشاهده سبد خرید", cancelText: "باشه", } @@ -509,7 +503,7 @@ function Book({ }, ]} > - {separate(book?.product[2]?.price) + " " + "تومان"} + {(separate(book?.product[2]?.price) || " ") + " " + "تومان"} diff --git a/src/screens/Product/components/Info.js b/src/screens/Product/components/Info.js index c6035a8..e54b8be 100644 --- a/src/screens/Product/components/Info.js +++ b/src/screens/Product/components/Info.js @@ -178,7 +178,7 @@ const ProductReviews = ({ list, mobile, theme }) => { style={[ { fontSize: mobile ? fontSize.tiny : fontSize.lg, - color: Colors.theme1.green79, + color: theme === 'light' ? Colors.theme1.green79 : Colors.theme1.white, fontFamily: "bold", }, ]} @@ -190,7 +190,7 @@ const ProductReviews = ({ list, mobile, theme }) => { style={{ fontSize: mobile ? fontSize.tiny : fontSize.base, fontFamily: "light", - color: "#275077", + color: theme === 'light' ? "#275077" : Colors.theme1.white, lineHeight: 25, textAlign: ios ? "right" : "auto", }} diff --git a/src/screens/Video/index.js b/src/screens/Video/index.js index f89f9ed..b9c9eea 100644 --- a/src/screens/Video/index.js +++ b/src/screens/Video/index.js @@ -76,7 +76,10 @@ function Product({ setAddedFlag(false); asyncAwesomeAlert("", "به سبد خرید اضافه شد", { showCancelButton: false, - onConfirm: () => navigation.push("ShoppingCart"), + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), confirmText: "مشاهده سبد خرید", }); } @@ -182,7 +185,10 @@ function Product({ "این محصول قبلا به سبد خرید شما اضافه شده است.", { showCancelButton: true, - onConfirm: () => navigation.push("ShoppingCart"), + onConfirm: () => + navigation.navigate("Root", { + screen: "ShoppingCartTab", + }), confirmText: "مشاهده سبد خرید", cancelText: "ادامه خرید", }