From 412bcc732d3d88ad54b7ac6895d62aa19e0a19f2 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Sun, 5 Jun 2022 19:11:16 +0430 Subject: [PATCH] update 5 files --- src/components/Navbar.js | 1 + src/navigation.js | 7 +- src/screens/Video/components/Season.js | 5 +- src/screens/Video/index.js | 157 ++++++++++++------------- 4 files changed, 83 insertions(+), 87 deletions(-) diff --git a/src/components/Navbar.js b/src/components/Navbar.js index fa05c93..2efe557 100644 --- a/src/components/Navbar.js +++ b/src/components/Navbar.js @@ -93,6 +93,7 @@ const Navbar = ({ : Colors.theme1.dark, height: 64, zIndex: 100, + position : 'relative' }, ]} > diff --git a/src/navigation.js b/src/navigation.js index 72a4f5a..9c075e0 100644 --- a/src/navigation.js +++ b/src/navigation.js @@ -25,7 +25,7 @@ import Product from "../src/screens/Product"; // import Faq from "../src/screens/Faq"; // import Activation from "../src/screens/Activation"; import Videos from '../src/screens/Videos'; -// import Video from "../src/screens/Video"; +import Video from "../src/screens/Video"; // import VideoDisplay from "../src/screens/VideoDisplay"; // import Contact from "../src/screens/Contact"; // import Tests from "../src/screens/Tests"; @@ -475,8 +475,8 @@ const HomeStackScreen = ({theme, startUserGuide}) => { - {/* + {/* @@ -523,7 +523,8 @@ const VODStackScreen = ({theme}) => { }} initialRouteName="VOD"> } /> - {/* + + {/* */} ); diff --git a/src/screens/Video/components/Season.js b/src/screens/Video/components/Season.js index 5d89deb..d786dfd 100644 --- a/src/screens/Video/components/Season.js +++ b/src/screens/Video/components/Season.js @@ -1,6 +1,5 @@ import React from "react"; import { View, Text, Pressable, Appearance } from "react-native"; -import { SimpleLineIcons } from "@expo/vector-icons"; import { asyncAwesomeAlert } from "../../../utils/AsyncWrappers"; import { connect } from "react-redux"; import { publicApi } from "../../../redux/actions"; @@ -178,7 +177,7 @@ const Season = ({ )[0]?.name : null} - + /> */} {season[0]?.categoryId === activeSeason ? season?.map((unit, index) => ( diff --git a/src/screens/Video/index.js b/src/screens/Video/index.js index 878dd93..1ba2542 100644 --- a/src/screens/Video/index.js +++ b/src/screens/Video/index.js @@ -1,35 +1,35 @@ -import React, { useState, useEffect } from "react"; +import React, {useState, useEffect} from 'react'; import { View, StyleSheet, Dimensions, ScrollView, - SafeAreaView, StatusBar, LayoutAnimation, Image, Text, Appearance, -} from "react-native"; -import { useNavigation } from "@react-navigation/native"; -import { connect } from "react-redux"; -import { publicApi, userProduct, config } from "../../redux/actions"; -import separate from "../../utils/separate"; -import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; +} from 'react-native'; +import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'; +import {useNavigation} from '@react-navigation/native'; +import {connect} from 'react-redux'; +import {publicApi, userProduct, config} from '../../redux/actions'; +import separate from '../../utils/separate'; +import {asyncAwesomeAlert} from '../../utils/AsyncWrappers'; //components -import Navbar from "../../components/Navbar"; -import Drawer from "../../components/Drawer"; -import Divider from "../../components/Divider"; -import Season from "./components/Season"; -import CustomPressable from "../../components/Pressable"; +import Navbar from '../../components/Navbar'; +import Drawer from '../../components/Drawer'; +import Divider from '../../components/Divider'; +import Season from './components/Season'; +import CustomPressable from '../../components/Pressable'; //style -import tw from "tailwind-rn"; -import fontSize from "../../constants/fontSize"; -import Colors from "../../constants/Colors"; +import tw from 'tailwind-rn'; +import fontSize from '../../constants/fontSize'; +import Colors from '../../constants/Colors'; -const { height, width } = Dimensions.get("window"); +const {height, width} = Dimensions.get('window'); function Product({ route, @@ -47,79 +47,75 @@ function Product({ getAvailableForSell, availableForSell, }) { - const [position, setPosition] = useState("100%"); + const insets = useSafeAreaInsets(); + const [position, setPosition] = useState('100%'); const navigation = useNavigation(); const [addedFlag, setAddedFlag] = React.useState(false); useEffect(() => { getAvailableForSell(); - getBook({ bookId: route.params.id }, { id: route.params.id, vod: true }); + getBook({bookId: route.params.id}, {id: route.params.id, vod: true}); }, []); const setBoxPosition = () => { LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); - setPosition(position === "100%" ? "0%" : "100%"); + setPosition(position === '100%' ? '0%' : '100%'); }; const videoProduct = React.useMemo(() => { - return book?.product?.filter((product) => product?.productType === 4)[0]; + return book?.product?.filter(product => product?.productType === 4)[0]; }, [book]); const videoAvailabileInCart = React.useMemo(() => { return userProducts?.filter( - (product) => - product?.productId === videoProduct?.id && product?.condition < 2 + product => + product?.productId === videoProduct?.id && product?.condition < 2, )?.length; }, [userProducts, book]); const videoBuyed = React.useMemo(() => { return userProducts?.filter( - (product) => - product?.productId === videoProduct?.id && product?.condition >= 2 + product => + product?.productId === videoProduct?.id && product?.condition >= 2, )?.length; }, [userProducts, book]); - const videoAvailableForSell = React.useMemo(() => { - return availableForSell?.filter((product) => product === 4)?.length; + return availableForSell?.filter(product => product === 4)?.length; }, [availableForSell]); const addToCart = React.useCallback( - async (action) => { + async action => { setAddedFlag(true); await action(); }, - [book, userId] + [book, userId], ); React.useEffect(() => { if (videoAvailabileInCart && addedFlag) { setAddedFlag(false); - asyncAwesomeAlert("", "به سبد خرید اضافه شد", { + asyncAwesomeAlert('', 'به سبد خرید اضافه شد', { showCancelButton: false, onConfirm: () => - navigation.navigate("Root", { - screen: "ShoppingCartTab", + navigation.navigate('Root', { + screen: 'ShoppingCartTab', }), - confirmText: "مشاهده سبد خرید", + confirmText: 'مشاهده سبد خرید', }); } }, [userProducts]); return ( + style={{flex: 1, paddingTop: insets.top, paddingBottom: insets.bottom}}> - {!mobile ? : null} - + style={styles.container}> + {!mobile ? : null} + + ]}> - + - {book?.name || " "} + fontFamily: 'DemiBold', + }}> + {book?.name || ' '} - {"پایه" + " " + (grades[book?.gradeId] || " ")} + fontFamily: 'Regular', + }}> + {'پایه' + ' ' + (grades[book?.gradeId] || ' ')} - + ]}> + videoAvailabileInCart ? asyncAwesomeAlert( - "", - "این محصول قبلا به سبد خرید شما اضافه شده است.", + '', + 'این محصول قبلا به سبد خرید شما اضافه شده است.', { showCancelButton: true, onConfirm: () => - navigation.navigate("Root", { - screen: "ShoppingCartTab", + navigation.navigate('Root', { + screen: 'ShoppingCartTab', }), - confirmText: "مشاهده سبد خرید", - cancelText: "ادامه خرید", - } + confirmText: 'مشاهده سبد خرید', + cancelText: 'ادامه خرید', + }, ) : videoAvailableForSell ? addToCart( @@ -224,17 +213,23 @@ function Product({ productId: videoProduct?.id, userId: userId, count: 1, - }) + }), ) : null } /> - + {seasons ?.sort((a, b) => a[0]?.categoryId - b[0]?.categoryId) ?.map((season, index) => ( - + ))} @@ -252,7 +247,7 @@ const styles = StyleSheet.create({ }, }); -const mapStateToProps = (state) => ({ +const mapStateToProps = state => ({ book: state.book.info, userProducts: state.userProduct.list, seasons: state.publicApi.categories,