delete 3 files and update 18 files

master
Reza_ashrafi 3 years ago
parent e4c74efad6
commit 0145002b2a
  1. 24
      bottomNavigation.json
  2. 10
      filters.json
  3. 24
      navigation/bottomNavigation.js
  4. 38
      navigation/index.js
  5. 6
      src/redux/actions/config.js
  6. 2
      src/redux/reducers/blog.js
  7. 15
      src/redux/reducers/book.js
  8. 7
      src/redux/reducers/config.js
  9. 13
      src/redux/reducers/userProduct.js
  10. 2
      src/redux/store.js
  11. 4
      src/screens/Blogs/index.js
  12. 8
      src/screens/Home/components/Scroll.js
  13. 10
      src/screens/Home/components/Videos.js
  14. 18
      src/screens/Home/index.js
  15. 2
      src/screens/OrderDetails/index.js
  16. 2
      src/screens/Product/components/Book.js
  17. 380
      src/screens/Products/components/Main.js
  18. 13
      src/screens/Products/index.js
  19. 69
      src/screens/Splash/index.js
  20. 2
      src/screens/Videos/components/MostViewedVideo.js

@ -1,24 +0,0 @@
{
"bottomNavigationList": {
"home": {
"label": "خانه",
"isActive": true
},
"products": {
"label": "کتابها",
"isActive": true
},
"vod": {
"label": "ویدئوها",
"isActive": true
},
"cart": {
"label": "سبد خرید",
"isActive": true
},
"profile": {
"label": "پروفایل",
"isActive": true
}
}
}

@ -1,10 +0,0 @@
{
"sort": ["مرتب سازی", "مرتب سازی", "محبوب ترین", "جدیدترین"],
"productTypes" : [
"نوع محصول",
"کتاب فیزیکی",
"کتاب دیجیتال",
"دوره ویدئویی",
"بسته های آموزشی"
]
}

@ -1,24 +0,0 @@
const bottomNavigationList = {
home: {
label: "خانه",
isActive: true,
},
products: {
label: "کتابها",
isActive: true,
},
vod: {
label: "ویدئوها",
isActive: true,
},
cart: {
label: "سبد خرید",
isActive: true,
},
profile: {
label: "پروفایل",
isActive: true,
},
};
export default bottomNavigationList;

@ -3,14 +3,13 @@ import { Restart } from "fiction-expo-restart";
import { I18nManager, StatusBar, Dimensions } from "react-native"; import { I18nManager, StatusBar, Dimensions } from "react-native";
import * as Linking from "expo-linking"; import * as Linking from "expo-linking";
import Svg, { G, Path } from "react-native-svg"; import Svg, { G, Path } from "react-native-svg";
import {asyncAwesomeAlert} from "../src/utils/AsyncWrappers"; import { asyncAwesomeAlert } from "../src/utils/AsyncWrappers";
import { NavigationContainer } from "@react-navigation/native"; import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack"; import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { user, publicApi } from "../src/redux/actions"; import { user, publicApi } from "../src/redux/actions";
import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useSafeAreaInsets } from "react-native-safe-area-context";
import bottomNavigationList from "./bottomNavigation";
//components //components
import OrderDetails from "../src/screens/OrderDetails"; import OrderDetails from "../src/screens/OrderDetails";
@ -53,7 +52,7 @@ import Colors from "../src/constants/Colors";
import fontSize from "../src/constants/fontSize"; import fontSize from "../src/constants/fontSize";
const Tab = createBottomTabNavigator(); const Tab = createBottomTabNavigator();
const BottomTabNavigator = ({ theme, userProducts }) => { const BottomTabNavigator = ({ theme, userProducts, bottomNavigation }) => {
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
const [headerShown, setHeaderShown] = React.useState(true); const [headerShown, setHeaderShown] = React.useState(true);
React.useEffect(() => { React.useEffect(() => {
@ -95,12 +94,12 @@ const BottomTabNavigator = ({ theme, userProducts }) => {
tabBarShowLabel: true, tabBarShowLabel: true,
}} }}
> >
{bottomNavigationList.home.isActive ? ( {bottomNavigation.home.isActive ? (
<Tab.Screen <Tab.Screen
name="HomeTab" name="HomeTab"
children={() => <HomeStackScreen theme={theme} />} children={() => <HomeStackScreen theme={theme} />}
options={{ options={{
title: bottomNavigationList.home.label, title: bottomNavigation.home.label,
tabBarIcon: ({ focused, color }) => tabBarIcon: ({ focused, color }) =>
focused ? ( focused ? (
<Svg <Svg
@ -166,12 +165,12 @@ const BottomTabNavigator = ({ theme, userProducts }) => {
/> />
) : null} ) : null}
{bottomNavigationList.products.isActive ? ( {bottomNavigation.products.isActive ? (
<Tab.Screen <Tab.Screen
name="ProductsTab" name="ProductsTab"
children={() => <ProductsStackScreen theme={theme} />} children={() => <ProductsStackScreen theme={theme} />}
options={{ options={{
title: bottomNavigationList.products.label, title: bottomNavigation.products.label,
tabBarIcon: ({ focused, color }) => tabBarIcon: ({ focused, color }) =>
focused ? ( focused ? (
<Svg <Svg
@ -229,14 +228,14 @@ const BottomTabNavigator = ({ theme, userProducts }) => {
/> />
) : null} ) : null}
{bottomNavigationList.vod.isActive ? ( {bottomNavigation.vod.isActive ? (
<Tab.Screen <Tab.Screen
name="VODTab" name="VODTab"
children={() => <VODStackScreen theme={theme} />} children={() => <VODStackScreen theme={theme} />}
options={{ options={{
unmountOnExit: true, unmountOnExit: true,
unmountOnBlur: true, unmountOnBlur: true,
title: bottomNavigationList.vod.label, title: bottomNavigation.vod.label,
tabBarIcon: ({ focused, color }) => tabBarIcon: ({ focused, color }) =>
focused ? ( focused ? (
<Svg <Svg
@ -316,14 +315,14 @@ const BottomTabNavigator = ({ theme, userProducts }) => {
/> />
) : null} ) : null}
{bottomNavigationList.cart.isActive ? ( {bottomNavigation.cart.isActive ? (
<Tab.Screen <Tab.Screen
name="ShoppingCartTab" name="ShoppingCartTab"
children={() => <CARTStackScreen theme={theme} />} children={() => <CARTStackScreen theme={theme} />}
options={{ options={{
tabBarBadge: userProducts.filter((product) => product.condition < 2) tabBarBadge: userProducts?.filter((product) => product?.condition < 2)
.length .length
? userProducts.filter((product) => product.condition < 2).length ? userProducts?.filter((product) => product?.condition < 2)?.length
: null, : null,
tabBarBadgeStyle: { tabBarBadgeStyle: {
color: "white", color: "white",
@ -340,7 +339,7 @@ const BottomTabNavigator = ({ theme, userProducts }) => {
theme === "light" ? Colors.theme1.greenCF : Colors.theme1.dark, theme === "light" ? Colors.theme1.greenCF : Colors.theme1.dark,
fontFamily: "bold", fontFamily: "bold",
}, },
title: bottomNavigationList.cart.label, title: bottomNavigation.cart.label,
tabBarIcon: ({ focused, color }) => tabBarIcon: ({ focused, color }) =>
focused ? ( focused ? (
<Svg <Svg
@ -401,12 +400,12 @@ const BottomTabNavigator = ({ theme, userProducts }) => {
/> />
) : null} ) : null}
{bottomNavigationList.profile.isActive ? ( {bottomNavigation.profile.isActive ? (
<Tab.Screen <Tab.Screen
name="ProfileTab" name="ProfileTab"
children={() => <PROFILEStackScreen theme={theme} />} children={() => <PROFILEStackScreen theme={theme} />}
options={{ options={{
title: bottomNavigationList.profile.label, title: bottomNavigation.profile.label,
tabBarIcon: ({ focused, color }) => tabBarIcon: ({ focused, color }) =>
focused ? ( focused ? (
<Svg <Svg
@ -589,6 +588,7 @@ const Navigation = ({
setLTR, setLTR,
theme, theme,
setOrientation, setOrientation,
bottomNavigation,
}) => { }) => {
const linking = { const linking = {
prefixes: [prefix], prefixes: [prefix],
@ -611,7 +611,6 @@ const Navigation = ({
); );
}, []); }, []);
Dimensions.addEventListener("change", () => { Dimensions.addEventListener("change", () => {
const dim = Dimensions.get("window"); const dim = Dimensions.get("window");
setOrientation(dim.height > dim.width ? "portrait" : "landscape"); setOrientation(dim.height > dim.width ? "portrait" : "landscape");
@ -636,7 +635,11 @@ const Navigation = ({
<Stack.Screen <Stack.Screen
name="Root" name="Root"
children={() => ( children={() => (
<BottomTabNavigator theme={theme} userProducts={userProducts} /> <BottomTabNavigator
theme={theme}
userProducts={userProducts}
bottomNavigation={bottomNavigation}
/>
)} )}
/> />
<Stack.Screen name="QR" component={QR} /> <Stack.Screen name="QR" component={QR} />
@ -662,6 +665,7 @@ const mapStateToProps = (state) => ({
userProducts: state.userProduct.list, userProducts: state.userProduct.list,
theme: state.publicApi.theme, theme: state.publicApi.theme,
ltr: state.publicApi.ltr, ltr: state.publicApi.ltr,
bottomNavigation: state.config.bottomNavigation,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
getStatus: user.getStatus, getStatus: user.getStatus,

@ -4,7 +4,11 @@ const config = {
getBottomNavigation: getBottomNavigation:
(data = {}) => (data = {}) =>
async (dispatch) => async (dispatch) =>
await proxy.get("config/bottomNavigations", data, { dispatch }), await proxy.get("config/bottomNavigationList", data, { dispatch }),
getFilters:
(data = {}) =>
async (dispatch) =>
await proxy.get("config/filters", data, { dispatch }),
}; };
export default config; export default config;

@ -1,7 +1,7 @@
const initialState = { const initialState = {
loading: false, loading: false,
error: null, error: null,
list: [], list: null,
info: null, info: null,
hashtags : [], hashtags : [],
hashtag : null, hashtag : null,

@ -1,9 +1,9 @@
import {asyncAwesomeAlert} from '../../utils/AsyncWrappers'; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
const initialState = { const initialState = {
loading: false, loading: false,
error: null, error: null,
list: [], list: null,
info: null, info: null,
searchResult: [], searchResult: [],
filterResult: [], filterResult: [],
@ -18,7 +18,7 @@ const initialState = {
filterOptions: { filterOptions: {
grade: "", grade: "",
subject: "", subject: "",
productType: '', productType: "",
available: false, available: false,
sort: null, sort: null,
search: "", search: "",
@ -51,6 +51,13 @@ const grades = [
export default function book(state = initialState, action) { export default function book(state = initialState, action) {
let { type, data } = action; let { type, data } = action;
switch (type) { switch (type) {
case "config/filters":
return {
...state,
error: false,
loading: false,
productTypes: ["نوع محصول", ...data.productTypes],
};
case "book/list": case "book/list":
let itemsSubject = (Array.isArray(data) ? data : []).map( let itemsSubject = (Array.isArray(data) ? data : []).map(
(item, index) => item.name (item, index) => item.name
@ -87,7 +94,7 @@ export default function book(state = initialState, action) {
case "book/error": case "book/error":
asyncAwesomeAlert("خطا", data.message, { asyncAwesomeAlert("خطا", data.message, {
showCancelButton: false, showCancelButton: false,
confirmText: "باشه" confirmText: "باشه",
}); });
return { ...state, loading: false, error: data.message }; return { ...state, loading: false, error: data.message };
default: default:

@ -1,18 +1,17 @@
const initialState = { const initialState = {
loading: false, loading: false,
error: null, error: null,
bottomNavigations: null, bottomNavigation: null,
}; };
export default function config(state = initialState, action) { export default function config(state = initialState, action) {
let { type, data } = action; let { type, data } = action;
switch (type) { switch (type) {
case "config/bottomNavigations": case "config/bottomNavigationList":
console.log(data);
return { return {
...state, ...state,
loading: false, loading: false,
bottomNavigations: data, bottomNavigation: data.bottomNavigationList,
error: null, error: null,
}; };
case "config/loading": case "config/loading":

@ -3,7 +3,7 @@ import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
const initialState = { const initialState = {
loading: false, loading: false,
error: null, error: null,
list: [], list: null,
myList: [], myList: [],
info: null, info: null,
sum: null, sum: null,
@ -19,20 +19,13 @@ export default function userFactor(state = initialState, action) {
case "userProduct/myList": case "userProduct/myList":
return { ...state, loading: false, myList: data, error: null }; return { ...state, loading: false, myList: data, error: null };
case "userProduct/list": case "userProduct/list":
const checkEmpty = data.filter(
(item) => item.condition === 2 && item.product.productType === (1 || 3)
);
const hasPhysical =
data.filter((item) => item.product.productType === 2).length > 0
? true
: false;
return { return {
...state, ...state,
loading: false, loading: false,
list: data, list: data,
checkEmpty: checkEmpty.length > 0 ? false : true, // checkEmpty: checkEmpty.length > 0 ? false : true,
error: null, error: null,
hasPhysical: hasPhysical, // hasPhysical: hasPhysical,
}; };
case "userProduct/info": case "userProduct/info":
return { ...state, loading: false, info: data, error: null }; return { ...state, loading: false, info: data, error: null };

@ -19,6 +19,7 @@ import comment from "./reducers/comment";
import form from "./reducers/form"; import form from "./reducers/form";
import userFavorite from "./reducers/userFavorite"; import userFavorite from "./reducers/userFavorite";
import vote from "./reducers/vote"; import vote from "./reducers/vote";
import config from "./reducers/config";
const persistConfig = { const persistConfig = {
key: "root", key: "root",
@ -50,6 +51,7 @@ const persistedReducer = persistReducer(
form, form,
userFavorite, userFavorite,
vote, vote,
config
}) })
); );

@ -97,7 +97,7 @@ function Blogs({ getList, blogs, hashtag, setHashtag, theme }) {
horizontal={true} horizontal={true}
inverted={true} inverted={true}
style={[tw("flex flex-row mt-3 pb-3")]} style={[tw("flex flex-row mt-3 pb-3")]}
data={blogs.slice(0, 7)} data={blogs?.slice(0, 7)}
renderItem={({ item }) => <New blog={item} />} renderItem={({ item }) => <New blog={item} />}
keyExtractor={(item) => item?.id} keyExtractor={(item) => item?.id}
/> />
@ -107,7 +107,7 @@ function Blogs({ getList, blogs, hashtag, setHashtag, theme }) {
horizontal={true} horizontal={true}
inverted={true} inverted={true}
style={[tw("flex flex-row mt-3 pb-3")]} style={[tw("flex flex-row mt-3 pb-3")]}
data={blogs.slice(0, 7)} data={blogs?.slice(0, 7)}
renderItem={({ item }) => <New blog={item} />} renderItem={({ item }) => <New blog={item} />}
keyExtractor={(item) => item?.id} keyExtractor={(item) => item?.id}
/> />

@ -6,6 +6,7 @@ import tw from "tailwind-rn";
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
import { connect } from "react-redux"; import { connect } from "react-redux";
import Tab from "../../QRContent/Tab";
function Scroll({ books, mobile }) { function Scroll({ books, mobile }) {
const Box = ({ books }) => { const Box = ({ books }) => {
@ -14,7 +15,10 @@ function Scroll({ books, mobile }) {
return ( return (
<Pressable <Pressable
onPress={() => onPress={() =>
navigation.navigate("Product", { id: book?.id, type: "book" }) navigation.push("Product", {
id: book?.id,
type: "book",
})
} }
style={[ style={[
tw("mr-1 overflow-hidden"), tw("mr-1 overflow-hidden"),
@ -43,7 +47,7 @@ function Scroll({ books, mobile }) {
{ height: mobile ? 242 : 350, direction: "rtl" }, { height: mobile ? 242 : 350, direction: "rtl" },
]} ]}
> >
{books.slice(0, 14)?.map((book, index) => ( {books?.slice(0, 14)?.map((book, index) => (
<Product book={book} position={Number(index)} key={index} /> <Product book={book} position={Number(index)} key={index} />
))} ))}
</View> </View>

@ -24,7 +24,7 @@ function Videos({ videos, grades, mobile, theme }) {
</View> </View>
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
style={[tw("py-3")]} style={[tw("py-3 px-4")]}
horizontal={true} horizontal={true}
inverted={true} inverted={true}
data={videos?.slice(0, 7)} data={videos?.slice(0, 7)}
@ -51,7 +51,7 @@ const Video = ({ video, mobile, grades, theme }) => {
<Pressable <Pressable
style={[ style={[
tw(`flex relative ${mobile ? "mr-4" : "ml-5"}`), tw(`flex relative ${mobile ? "mr-4" : "ml-5"}`),
{ width: mobile ? 200 : 200, height: mobile ? 210 : 210 }, { width: mobile ? 200 : 260, height: mobile ? 210 : 250 },
]} ]}
onPress={() => navigation.navigate("Video", { id: video?.id })} onPress={() => navigation.navigate("Video", { id: video?.id })}
> >
@ -61,7 +61,7 @@ const Video = ({ video, mobile, grades, theme }) => {
style={[ style={[
tw("bg-gray-100"), tw("bg-gray-100"),
{ {
height: mobile ? 130 : 130, height: mobile ? 130 : 170,
}, },
]} ]}
/> />
@ -72,7 +72,7 @@ const Video = ({ video, mobile, grades, theme }) => {
color: color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white, theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontFamily: "bold", fontFamily: "bold",
fontSize: mobile ? fontSize.sm : fontSize.xl, fontSize: mobile ? fontSize.sm : fontSize.tiny,
textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",
}, },
]} ]}
@ -86,7 +86,7 @@ const Video = ({ video, mobile, grades, theme }) => {
color: color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white, theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontFamily: "regular", fontFamily: "regular",
fontSize: mobile ? fontSize.xs : fontSize.base, fontSize: mobile ? fontSize.xs : fontSize.sm,
textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",
}, },
]} ]}

@ -1,7 +1,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { blog, book, userProduct } from "../../redux/actions"; import { blog, book, user, userProduct } from "../../redux/actions";
import {useNavigation} from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import { import {
View, View,
@ -37,6 +37,7 @@ const Home = ({
getBlogs, getBlogs,
getBooks, getBooks,
getUserProducts, getUserProducts,
bottomNavigation,
}) => { }) => {
const navigation = useNavigation(); const navigation = useNavigation();
const [position, setPosition] = useState("100%"); const [position, setPosition] = useState("100%");
@ -47,15 +48,15 @@ const Home = ({
}; };
React.useEffect(() => { React.useEffect(() => {
if (blogs?.length === 0) { if (!blogs) {
getBlogs(); getBlogs();
} else if (books?.length === 0) { } else if (!books) {
getBooks({ vod: true }); getBooks({ vod: true });
} else if (userProducts?.length === 0) { } else if (!userProducts) {
getUserProducts(); getUserProducts();
} }
}, [books, userProducts, blogs]); }, []);
return ( return (
<SafeAreaView style={styles.safeStyle}> <SafeAreaView style={styles.safeStyle}>
<Navbar <Navbar
@ -84,7 +85,7 @@ const Home = ({
) : null} ) : null}
<Scroll books={books} /> <Scroll books={books} />
{/* <Videos videos={books} /> */} {bottomNavigation.vod.isActive ? <Videos videos={books} /> : null}
<Blogs blogs={blogs} /> <Blogs blogs={blogs} />
</ScrollView> </ScrollView>
</SafeAreaView> </SafeAreaView>
@ -114,6 +115,7 @@ const mapStateToProps = (state) => ({
books: state.book.list, books: state.book.list,
userProducts: state.userProduct.list, userProducts: state.userProduct.list,
mobile: state.publicApi.isMobile, mobile: state.publicApi.isMobile,
bottomNavigation: state.config.bottomNavigation,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {

@ -284,7 +284,7 @@ function OrderDetails({ mobile, route, theme }) {
</Text> </Text>
</View> </View>
<View style={tw("w-full flex items-end")}> <View style={tw("w-full flex items-end")}>
{order?.userProducts.map((item, index) => ( {order?.userProducts?.map((item, index) => (
<Book book={item} key={index} /> <Book book={item} key={index} />
))} ))}
</View> </View>

@ -278,7 +278,7 @@ function Book({
? Colors.theme1.green79 ? Colors.theme1.green79
: Colors.theme1.white, : Colors.theme1.white,
fontSize: mobile ? fontSize.tiny : fontSize.lg, fontSize: mobile ? fontSize.tiny : fontSize.base,
fontFamily: "demi", fontFamily: "demi",
}, },
]} ]}

@ -68,198 +68,200 @@ const Main = ({ books, filterOptions, grades, mobile, theme, orientation }) => {
bySearchFilter = byAvailableFilter; bySearchFilter = byAvailableFilter;
} }
return filterOptions?.productType === "دوره ویدئویی" return filterOptions?.productType === "محصولات ویدیویی"
? bySearchFilter?.map((product, index) => ( ? bySearchFilter?.map((product, index) => (
// <Pressable <Pressable
// style={[ style={[
// { {
// width: mobile ? "auto" : width / 2.2, width: mobile ? "auto" : width / 2.2,
// borderWidth: 1, borderWidth: 1,
// borderColor: borderColor:
// Colors.theme1.grayE3 + (theme === "light" ? "" : "55"), Colors.theme1.grayE3 + (theme === "light" ? "" : "55"),
// }, },
// tw(`flex mb-5 p-2 rounded-md ${mobile ? "w-full" : ""}`), tw(`flex mb-5 p-2 rounded-md ${mobile ? "w-full" : ""}`),
// ]} ]}
// key={index} key={index}
// onPress={() => navigation.navigate("Video", { id: product.id })} onPress={() => navigation.navigate("Video", { id: product.id })}
// > >
// <View style={[tw("relative w-full mb-1")]}> <View style={[tw("relative w-full mb-1")]}>
// <Image <Image
// source={{ source={{
// uri: `https://dnvn.ir/api/v1/file/${product?.fileIds}`, uri: `https://dnvn.ir/api/v1/file/${product?.fileIds}`,
// }} }}
// style={[ style={[
// tw("w-full rounded-sm"), tw("w-full rounded-sm"),
// { height: ((mobile ? width - 25 : width / 2.2) * 9) / 16 }, { height: ((mobile ? width - 25 : width / 2.2) * 9) / 16 },
// ]} ]}
// /> />
// </View> </View>
// <Text <Text
// style={[ style={[
// tw("mb-1"), tw("mb-1"),
// { {
// fontFamily: "bold", fontFamily: "bold",
// fontSize: fontSize.lg, fontSize: mobile ? fontSize.lg : fontSize.base,
// color: color:
// theme === "light" theme === "light"
// ? Colors.theme1.gray20 ? Colors.theme1.gray20
// : Colors.theme1.white, : Colors.theme1.white,
// textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",
// }, },
// ]} ]}
// > >
// {"دوره ویدئویی" + " " + product?.name} {"دوره ویدئویی" + " " + product?.name}
// </Text> </Text>
// <Text <Text
// style={[ style={[
// tw("mb-4"), tw("mb-4"),
// { {
// fontSize: fontSize.tiny, fontSize: mobile ? fontSize.tiny : fontSize.sm,
// fontFamily: "regular", fontFamily: "regular",
// color: Colors.theme1.greenBA, color: Colors.theme1.greenBA,
// textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",
// }, },
// ]} ]}
// > >
// {"پایه" + " " + grades[product?.gradeId]} {"پایه" + " " + grades[product?.gradeId]}
// </Text> </Text>
// <Text <Text
// style={[ style={[
// tw("w-full flex flex-row text-left"), tw("w-full flex flex-row text-left"),
// { {
// fontSize: fontSize.xl, fontSize: mobile ? fontSize.xl : fontSize.lg,
// fontFamily: "bold", fontFamily: "bold",
// color: color:
// theme === "light" theme === "light"
// ? Colors.theme1.gray20 ? Colors.theme1.gray20
// : Colors.theme1.white, : Colors.theme1.white,
// }, },
// ]} ]}
// > >
// {separate( {separate(
// product?.product?.filter( product?.product?.filter(
// (product) => product?.productType === 4 (product) => product?.productType === 4
// )[0].price )[0].price
// )}{" "} )}{" "}
// <Text style={{ fontSize: fontSize.sm }}>تومان</Text> <Text style={{ fontSize: fontSize.sm }}>تومان</Text>
// </Text> </Text>
// </Pressable> </Pressable>
<></>
)) ))
: bySearchFilter?.map((product, index) => ( : bySearchFilter?.map((product, index) => (
<React.Fragment key={index}> <React.Fragment key={index}>
{( {(
productType productType
? productType === ("کتاب دیجیتال" || "همه محصولات") ? productType === ("محصولات دیجیتال" || "همه محصولات")
: true : true
) ? ( ) ? (
// <Pressable <Pressable
// key={product?.product[0]?.id} key={product?.product[0]?.id}
// style={[ style={[
// { {
// width: mobile ? width / 2 - 25 : width / 3.2, width: mobile
// marginBottom: 15, ? width / 2 - 25
// borderWidth: 1, : orientation === "portrait"
// borderColor: ? width / 4.2
// Colors.theme1.grayE3 + (theme === "light" ? "" : "55"), : width / 5.2,
// }, marginBottom: 15,
// tw("flex justify-between px-2 pt-2 rounded-md"), borderWidth: 1,
// ]} borderColor:
// onPress={() => Colors.theme1.grayE3 + (theme === "light" ? "" : "55"),
// navigation.navigate("Product", { },
// id: product?.id, tw("flex justify-between px-2 pt-2 rounded-md"),
// type: "book", ]}
// }) onPress={() =>
// } navigation.navigate("Product", {
// > id: product?.id,
// <View style={tw("w-full flex")}> type: "book",
// <Image })
// resizeMode="contain" }
// source={{ >
// uri: `https://dnvn.ir/api/v1/file/${product?.fileIds}`, <View style={tw("w-full flex")}>
// }} <Image
// style={[ resizeMode="contain"
// tw("rounded-sm"), source={{
// { uri: `https://dnvn.ir/api/v1/file/${product?.fileIds}`,
// flex: 1, }}
// height: mobile style={[
// ? ((width / 2 - 25) * 4) / 2.9 tw("rounded-sm"),
// : ((width / 3.2) * 16) / 14, {
// }, flex: 1,
// ]} height: mobile
// /> ? ((width / 2 - 25) * 4) / 2.9
// <Text : ((width / 3.2) * 16) / 16,
// style={{ },
// fontSize: fontSize.base, ]}
// marginTop: 5, />
// fontFamily: "bold", <Text
// width: "100%", style={{
// textAlign: ios ? "right" : "auto", fontSize: mobile ? fontSize.base : fontSize.tiny,
// color: marginTop: 5,
// theme === "light" fontFamily: "bold",
// ? Colors.theme1.gray20 width: "100%",
// : Colors.theme1.white, textAlign: ios ? "right" : "auto",
// }} color:
// > theme === "light"
// {"کتاب دیجیتال" + " " + product?.name} ? Colors.theme1.gray20
// </Text> : Colors.theme1.white,
// <Text }}
// style={{ >
// color: Colors.theme1.greenBA, {"کتاب دیجیتال" + " " + product?.name}
// fontSize: fontSize.tiny, </Text>
// marginTop: 5, <Text
// fontFamily: "regular", style={{
// width: "100%", color: Colors.theme1.greenBA,
// textAlign: ios ? "right" : "auto", fontSize: mobile ? fontSize.tiny : fontSize.sm,
// }} marginTop: 5,
// > fontFamily: "regular",
// {"پایه" + " " + grades[product?.gradeId]} width: "100%",
// </Text> textAlign: ios ? "right" : "auto",
// </View> }}
// <View >
// style={tw( {"پایه" + " " + grades[product?.gradeId]}
// "flex flex-row-reverse items-center justify-center pb-1 pt-2" </Text>
// )} </View>
// > <View
// <Text style={tw(
// style={[ "flex flex-row-reverse items-center justify-center pb-1 mt-3"
// tw("text-center ml-1"), )}
// { >
// color: <Text
// theme === "light" style={[
// ? Colors.theme1.gray20 tw("text-center ml-1"),
// : Colors.theme1.white, {
// fontFamily: "bold", color:
// fontSize: fontSize.xl2, theme === "light"
// }, ? Colors.theme1.gray20
// ]} : Colors.theme1.white,
// > fontFamily: "bold",
// {separate( fontSize: mobile ? fontSize.xl2 : fontSize.lg,
// product?.product?.filter( },
// (product) => product?.productType === 1 ]}
// )[0]?.price >
// )} {separate(
// </Text> product?.product?.filter(
// <Text (product) => product?.productType === 1
// style={{ )[0]?.price
// fontSize: fontSize.sm, )}
// color: </Text>
// theme === "light" <Text
// ? Colors.theme1.gray20 style={{
// : Colors.theme1.white, fontSize: fontSize.sm,
// fontFamily: "regular", color:
// }} theme === "light"
// > ? Colors.theme1.gray20
// تومان : Colors.theme1.white,
// </Text> fontFamily: "regular",
// </View> }}
// </Pressable> >
<></> تومان
</Text>
</View>
</Pressable>
) : null} ) : null}
{( {(
productType productType
? productType === ("کتاب فیزیکی" || "همه محصولات") ? productType === ("محصولات فیزیکی" || "همه محصولات")
: true : true
) ? ( ) ? (
<Pressable <Pressable
@ -297,15 +299,13 @@ const Main = ({ books, filterOptions, grades, mobile, theme, orientation }) => {
flex: 1, flex: 1,
height: mobile height: mobile
? ((width / 2 - 25) * 4) / 2.9 ? ((width / 2 - 25) * 4) / 2.9
: orientation === "portrait" : ((width / 3.2) * 16) / 16,
? ((width / 4.2) * 16) / 11
: ((width / 5.2) * 16) / 11,
}, },
]} ]}
/> />
<Text <Text
style={{ style={{
fontSize: fontSize.base, fontSize: mobile ? fontSize.base : fontSize.tiny,
marginTop: 5, marginTop: 5,
color: color:
theme === "light" theme === "light"
@ -321,7 +321,7 @@ const Main = ({ books, filterOptions, grades, mobile, theme, orientation }) => {
<Text <Text
style={{ style={{
color: Colors.theme1.greenBA, color: Colors.theme1.greenBA,
fontSize: fontSize.tiny, fontSize: mobile ? fontSize.tiny : fontSize.sm,
marginTop: 5, marginTop: 5,
fontFamily: "regular", fontFamily: "regular",
width: "100%", width: "100%",
@ -333,7 +333,7 @@ const Main = ({ books, filterOptions, grades, mobile, theme, orientation }) => {
</View> </View>
<View <View
style={tw( style={tw(
"flex flex-row-reverse items-center justify-center pb-1" "flex flex-row-reverse items-center justify-center pb-1 mt-2"
)} )}
> >
<Text <Text
@ -345,7 +345,7 @@ const Main = ({ books, filterOptions, grades, mobile, theme, orientation }) => {
? Colors.theme1.gray20 ? Colors.theme1.gray20
: Colors.theme1.white, : Colors.theme1.white,
fontFamily: "bold", fontFamily: "bold",
fontSize: fontSize.xl2, fontSize: mobile ? fontSize.xl2 : fontSize.lg,
}, },
]} ]}
> >
@ -381,9 +381,9 @@ const Main = ({ books, filterOptions, grades, mobile, theme, orientation }) => {
), ),
]} ]}
> >
{/* {filterOptions?.productType === "دوره ویدئویی" ? Items(2) : null} */} {filterOptions?.productType === "محصولات ویدیویی" ? Items(2) : null}
{/* {filterOptions?.productType === "کتاب دیجیتال" ? Items(0) : null} */} {filterOptions?.productType === "محصولات دیجیتال" ? Items(0) : null}
{filterOptions?.productType === "کتاب فیزیکی" ? Items(1) : null} {filterOptions?.productType === "محصولات فیزیکی" ? Items(1) : null}
{!filterOptions?.productType ? Items(0) : null} {!filterOptions?.productType ? Items(0) : null}
{/* {filterLoading && ( {/* {filterLoading && (
<View style="w-full h-screen flex justify-center items-center bg-white bg-opacity-20 backdrop-filter backdrop-blur-xl fixed left-0 top-0"> <View style="w-full h-screen flex justify-center items-center bg-white bg-opacity-20 backdrop-filter backdrop-blur-xl fixed left-0 top-0">

@ -9,7 +9,7 @@ import {
LayoutAnimation, LayoutAnimation,
} from "react-native"; } from "react-native";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { book } from "../../redux/actions"; import { book, config } from "../../redux/actions";
//components //components
import Drawer from "../../components/Drawer"; import Drawer from "../../components/Drawer";
@ -29,10 +29,12 @@ function Products({
route, route,
setFilterOptions, setFilterOptions,
filterOptions, filterOptions,
getFilters
}) { }) {
const [position, setPosition] = useState("100%"); const [position, setPosition] = useState("100%");
useEffect(() => { useEffect(() => {
getFilters();
getBooks({ vod: true }); getBooks({ vod: true });
}, []); }, []);
@ -43,7 +45,7 @@ function Products({
useEffect(() => { useEffect(() => {
if (route?.params?.productType === "دوره ویدئویی") { if (route?.params?.productType === "دوره ویدئویی") {
setFilterOptions({ ...filterOptions, productType: "دوره ویدئویی" }); setFilterOptions({ ...filterOptions, productType: "محصولات ویدیویی" });
} }
}, [route]); }, [route]);
@ -84,10 +86,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = { const mapDispatchToProps = {
getBooks: book.list, getBooks: book.list,
setFilterOptions: book.setFilterOptions, setFilterOptions: book.setFilterOptions,
getFilters: config.getFilters
}; };
export default connect(mapStateToProps, mapDispatchToProps)(Products); export default connect(mapStateToProps, mapDispatchToProps)(Products);
Products.defaultProps = {
productTypes: ["کتاب فیزیکی", "کتاب دیجیتال", "ویدئوها", "اشتراک"],
};

@ -29,9 +29,7 @@ function Splash({
navigation, navigation,
theme, theme,
isLogin, isLogin,
blogs,
getBlogs, getBlogs,
books,
getBooks, getBooks,
userProducts, userProducts,
getUserProducts, getUserProducts,
@ -39,9 +37,7 @@ function Splash({
getBottomNavigation, getBottomNavigation,
bottomNavigation, bottomNavigation,
}) { }) {
const isFocused = useIsFocused(); const [sendRequest, setSendRequest] = React.useState(false);
const [out, setOut] = React.useState(false);
React.useEffect(() => { React.useEffect(() => {
StatusBar.setBarStyle( StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`, `${theme === "light" ? "dark" : "light"}-content`,
@ -54,33 +50,27 @@ function Splash({
setIsDark(!theme ? "light" : theme); setIsDark(!theme ? "light" : theme);
}; };
const setOutHandler = React.useCallback(
(value) => {
setOut(value);
},
[out]
);
useEffect(() => { useEffect(() => {
getTheme(); getTheme();
if (isLogin !== null) { if (isLogin !== null) {
if (isLogin === false) { if (isLogin === false) {
setOutHandler(true); setTimeout(() => {
navigation.reset({ getBottomNavigation();
index: 0, navigation.reset({
routes: [{ name: "Login" }], index: 0,
}); routes: [{ name: "Login" }],
});
}, 700);
} else { } else {
if (!blogs.length) { if (!sendRequest) {
setSendRequest(true);
getBottomNavigation();
getUserProducts();
getBlogs(); getBlogs();
} else if (!books.length) {
getBooks({ vod: true }); getBooks({ vod: true });
} else if (!userProducts.length) { }
getUserProducts();
} else if (!bottomNavigation) { if (bottomNavigation) {
getBottomNavigation();
} else {
setOutHandler(true);
navigation.reset({ navigation.reset({
index: 0, index: 0,
routes: [{ name: "Root" }], routes: [{ name: "Root" }],
@ -88,32 +78,7 @@ function Splash({
} }
} }
} }
}, [isLogin, books, userProducts, blogs, bottomNavigation]); }, [isLogin, bottomNavigation, userProducts]);
// if (isFocused && out) {
// setOutHandler(false);
// BackHandler.exitApp();
// }
// if (isFocused && !out) {
// if (isLogin !== null) {
// if (isLogin === false) {
// setOutHandler(true);
// navigation.push("Login");
// } else {
// if (blogs.length === 0) {
// getBlogs();
// } else if (books.length === 0) {
// getBooks({ vod: true });
// } else if (userProducts.length === 0) {
// getUserProducts();
// } else {
// setOutHandler(true);
// navigation.push("Root");
// }
// }
// }
// }
return ( return (
<View <View
@ -145,8 +110,6 @@ function Splash({
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
isLogin: state.user.status, isLogin: state.user.status,
blogs: state.blog.list,
books: state.book.list,
userProducts: state.userProduct.list, userProducts: state.userProduct.list,
theme: state.publicApi.theme, theme: state.publicApi.theme,
bottomNavigation: state.config.bottomNavigation, bottomNavigation: state.config.bottomNavigation,

@ -53,7 +53,7 @@ function MostViewedVideo({ videos, grades, mobile, theme }) {
resizeMode="contain" resizeMode="contain"
style={[ style={[
tw( tw(
`rounded-sm h-full absolute left-2 ${mobile ? "" : "top-1/5"}` `rounded-sm h-full absolute left-2`
), ),
{ {
width: mobile ? 70 : 105, width: mobile ? 70 : 105,

Loading…
Cancel
Save