update 5 files

master
Reza_ashrafi 2 years ago
parent a0b60570b2
commit 412bcc732d
  1. 1
      src/components/Navbar.js
  2. 7
      src/navigation.js
  3. 5
      src/screens/Video/components/Season.js
  4. 157
      src/screens/Video/index.js

@ -93,6 +93,7 @@ const Navbar = ({
: Colors.theme1.dark, : Colors.theme1.dark,
height: 64, height: 64,
zIndex: 100, zIndex: 100,
position : 'relative'
}, },
]} ]}
> >

@ -25,7 +25,7 @@ import Product from "../src/screens/Product";
// import Faq from "../src/screens/Faq"; // import Faq from "../src/screens/Faq";
// import Activation from "../src/screens/Activation"; // import Activation from "../src/screens/Activation";
import Videos from '../src/screens/Videos'; 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 VideoDisplay from "../src/screens/VideoDisplay";
// import Contact from "../src/screens/Contact"; // import Contact from "../src/screens/Contact";
// import Tests from "../src/screens/Tests"; // import Tests from "../src/screens/Tests";
@ -475,8 +475,8 @@ const HomeStackScreen = ({theme, startUserGuide}) => {
<HomeStack.Screen name="Products" component={Products} /> <HomeStack.Screen name="Products" component={Products} />
<HomeStack.Screen name="VOD" component={Videos} /> <HomeStack.Screen name="VOD" component={Videos} />
<HomeStack.Screen name="Product" component={Product} /> <HomeStack.Screen name="Product" component={Product} />
{/*
<HomeStack.Screen name="Video" component={Video} unmountOnExit={true} /> <HomeStack.Screen name="Video" component={Video} unmountOnExit={true} />
{/*
<HomeStack.Screen name="VideoDisplay" component={VideoDisplay} /> <HomeStack.Screen name="VideoDisplay" component={VideoDisplay} />
<HomeStack.Screen name="Sample" component={Sample} /> <HomeStack.Screen name="Sample" component={Sample} />
<HomeStack.Screen name="Blogs" component={Blogs} /> <HomeStack.Screen name="Blogs" component={Blogs} />
@ -523,7 +523,8 @@ const VODStackScreen = ({theme}) => {
}} }}
initialRouteName="VOD"> initialRouteName="VOD">
<VODStack.Screen name="VOD" children={() => <Videos />} /> <VODStack.Screen name="VOD" children={() => <Videos />} />
{/* <VODStack.Screen name="Video" component={Video} unmountOnExit={true} /> <VODStack.Screen name="Video" component={Video} unmountOnExit={true} />
{/*
<VODStack.Screen name="VideoDisplay" component={VideoDisplay} /> */} <VODStack.Screen name="VideoDisplay" component={VideoDisplay} /> */}
</VODStack.Navigator> </VODStack.Navigator>
); );

@ -1,6 +1,5 @@
import React from "react"; import React from "react";
import { View, Text, Pressable, Appearance } from "react-native"; import { View, Text, Pressable, Appearance } from "react-native";
import { SimpleLineIcons } from "@expo/vector-icons";
import { asyncAwesomeAlert } from "../../../utils/AsyncWrappers"; import { asyncAwesomeAlert } from "../../../utils/AsyncWrappers";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { publicApi } from "../../../redux/actions"; import { publicApi } from "../../../redux/actions";
@ -178,7 +177,7 @@ const Season = ({
)[0]?.name )[0]?.name
: null} : null}
</Text> </Text>
<SimpleLineIcons {/* <SimpleLineIcons
name={ name={
season[0].categoryId === activeSeason ? "arrow-up" : "arrow-down" season[0].categoryId === activeSeason ? "arrow-up" : "arrow-down"
} }
@ -186,7 +185,7 @@ const Season = ({
color={ color={
theme === "light" ? Colors.theme1.green79 : Colors.theme1.greenC8 theme === "light" ? Colors.theme1.green79 : Colors.theme1.greenC8
} }
/> /> */}
</View> </View>
{season[0]?.categoryId === activeSeason {season[0]?.categoryId === activeSeason
? season?.map((unit, index) => ( ? season?.map((unit, index) => (

@ -1,35 +1,35 @@
import React, { useState, useEffect } from "react"; import React, {useState, useEffect} from 'react';
import { import {
View, View,
StyleSheet, StyleSheet,
Dimensions, Dimensions,
ScrollView, ScrollView,
SafeAreaView,
StatusBar, StatusBar,
LayoutAnimation, LayoutAnimation,
Image, Image,
Text, Text,
Appearance, Appearance,
} from "react-native"; } from 'react-native';
import { useNavigation } from "@react-navigation/native"; import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
import { connect } from "react-redux"; import {useNavigation} from '@react-navigation/native';
import { publicApi, userProduct, config } from "../../redux/actions"; import {connect} from 'react-redux';
import separate from "../../utils/separate"; import {publicApi, userProduct, config} from '../../redux/actions';
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; import separate from '../../utils/separate';
import {asyncAwesomeAlert} from '../../utils/AsyncWrappers';
//components //components
import Navbar from "../../components/Navbar"; import Navbar from '../../components/Navbar';
import Drawer from "../../components/Drawer"; import Drawer from '../../components/Drawer';
import Divider from "../../components/Divider"; import Divider from '../../components/Divider';
import Season from "./components/Season"; import Season from './components/Season';
import CustomPressable from "../../components/Pressable"; import CustomPressable from '../../components/Pressable';
//style //style
import tw from "tailwind-rn"; import tw from 'tailwind-rn';
import fontSize from "../../constants/fontSize"; import fontSize from '../../constants/fontSize';
import Colors from "../../constants/Colors"; import Colors from '../../constants/Colors';
const { height, width } = Dimensions.get("window"); const {height, width} = Dimensions.get('window');
function Product({ function Product({
route, route,
@ -47,79 +47,75 @@ function Product({
getAvailableForSell, getAvailableForSell,
availableForSell, availableForSell,
}) { }) {
const [position, setPosition] = useState("100%"); const insets = useSafeAreaInsets();
const [position, setPosition] = useState('100%');
const navigation = useNavigation(); const navigation = useNavigation();
const [addedFlag, setAddedFlag] = React.useState(false); const [addedFlag, setAddedFlag] = React.useState(false);
useEffect(() => { useEffect(() => {
getAvailableForSell(); 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 = () => { const setBoxPosition = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setPosition(position === "100%" ? "0%" : "100%"); setPosition(position === '100%' ? '0%' : '100%');
}; };
const videoProduct = React.useMemo(() => { const videoProduct = React.useMemo(() => {
return book?.product?.filter((product) => product?.productType === 4)[0]; return book?.product?.filter(product => product?.productType === 4)[0];
}, [book]); }, [book]);
const videoAvailabileInCart = React.useMemo(() => { const videoAvailabileInCart = React.useMemo(() => {
return userProducts?.filter( return userProducts?.filter(
(product) => product =>
product?.productId === videoProduct?.id && product?.condition < 2 product?.productId === videoProduct?.id && product?.condition < 2,
)?.length; )?.length;
}, [userProducts, book]); }, [userProducts, book]);
const videoBuyed = React.useMemo(() => { const videoBuyed = React.useMemo(() => {
return userProducts?.filter( return userProducts?.filter(
(product) => product =>
product?.productId === videoProduct?.id && product?.condition >= 2 product?.productId === videoProduct?.id && product?.condition >= 2,
)?.length; )?.length;
}, [userProducts, book]); }, [userProducts, book]);
const videoAvailableForSell = React.useMemo(() => { const videoAvailableForSell = React.useMemo(() => {
return availableForSell?.filter((product) => product === 4)?.length; return availableForSell?.filter(product => product === 4)?.length;
}, [availableForSell]); }, [availableForSell]);
const addToCart = React.useCallback( const addToCart = React.useCallback(
async (action) => { async action => {
setAddedFlag(true); setAddedFlag(true);
await action(); await action();
}, },
[book, userId] [book, userId],
); );
React.useEffect(() => { React.useEffect(() => {
if (videoAvailabileInCart && addedFlag) { if (videoAvailabileInCart && addedFlag) {
setAddedFlag(false); setAddedFlag(false);
asyncAwesomeAlert("", "به سبد خرید اضافه شد", { asyncAwesomeAlert('', 'به سبد خرید اضافه شد', {
showCancelButton: false, showCancelButton: false,
onConfirm: () => onConfirm: () =>
navigation.navigate("Root", { navigation.navigate('Root', {
screen: "ShoppingCartTab", screen: 'ShoppingCartTab',
}), }),
confirmText: "مشاهده سبد خرید", confirmText: 'مشاهده سبد خرید',
}); });
} }
}, [userProducts]); }, [userProducts]);
return ( return (
<SafeAreaView <SafeAreaView
style={{ style={{flex: 1, paddingTop: insets.top, paddingBottom: insets.bottom}}>
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative",
}}
>
<Navbar <Navbar
setBoxPosition={setBoxPosition} setBoxPosition={setBoxPosition}
headerOptions={{ headerOptions={{
logo: true, logo: true,
menu: false, menu: false,
hamburgerMenu: false, hamburgerMenu: false,
title: "", title: '',
bookmark: false, bookmark: false,
qr: true, qr: true,
back: true, back: true,
@ -128,95 +124,88 @@ function Product({
<Drawer setBoxPosition={setBoxPosition} position={position} /> <Drawer setBoxPosition={setBoxPosition} position={position} />
<ScrollView <ScrollView
contentContainerStyle={styles.contentContainerStyle} contentContainerStyle={styles.contentContainerStyle}
style={styles.container} style={styles.container}>
> {!mobile ? <View style={tw('mt-5')}></View> : null}
{!mobile ? <View style={tw("mt-5")}></View> : null} <View style={[tw(' w-full flex ')]}>
<View style={[tw(" w-full flex ")]}>
<View <View
style={[ style={[
tw( tw(
"w-full flex flex-row-reverse flex-1 relative overflow-hidden" 'w-full flex flex-row-reverse flex-1 relative overflow-hidden',
), ),
]} ]}>
>
<Image <Image
source={{ uri: `https://dnvn.ir/api/v1/file/${book?.fileIds}` }} source={{uri: `https://dnvn.ir/api/v1/file/${book?.fileIds}`}}
resizeMode="contain" resizeMode="contain"
style={[ style={[
tw("rounded-sm ml-2"), tw('rounded-sm ml-2'),
{ {
height: mobile ? ((width / 3) * 4) / 2.6 : 300, height: mobile ? ((width / 3) * 4) / 2.6 : 300,
width: mobile ? width / 3 : 210, width: mobile ? width / 3 : 210,
}, },
]} ]}
/> />
<View style={tw("flex items-end flex-1")}> <View style={tw('flex items-end flex-1')}>
<Text <Text
style={{ style={{
marginTop: 5, marginTop: 5,
color: color:
theme === "light" theme === 'light'
? Colors.theme1.green79 ? Colors.theme1.green79
: Colors.theme1.white, : Colors.theme1.white,
fontSize: mobile ? fontSize.base : fontSize.xl, fontSize: mobile ? fontSize.base : fontSize.xl,
marginBottom: 0, marginBottom: 0,
fontFamily: "DemiBold", fontFamily: 'DemiBold',
}} }}>
> {book?.name || ' '}
{book?.name || " "}
</Text> </Text>
<Text <Text
style={{ style={{
color: color:
theme === "light" theme === 'light'
? Colors.theme1.green79 ? Colors.theme1.green79
: Colors.theme1.white, : Colors.theme1.white,
fontSize: mobile ? fontSize.tiny : fontSize.lg, fontSize: mobile ? fontSize.tiny : fontSize.lg,
marginTop: 10, marginTop: 10,
fontFamily: "Regular", fontFamily: 'Regular',
}} }}>
> {'پایه' + ' ' + (grades[book?.gradeId] || ' ')}
{"پایه" + " " + (grades[book?.gradeId] || " ")}
</Text> </Text>
</View> </View>
</View> </View>
<View <View
style={[ style={[
tw("flex flex-1 justify-between"), tw('flex flex-1 justify-between'),
{ {
paddingRight: 10, paddingRight: 10,
}, },
]} ]}>
> <Divider type={'vertical'} />
<Divider type={"vertical"} />
</View> </View>
<CustomPressable <CustomPressable
title={ title={
videoAvailableForSell videoAvailableForSell
? `خرید با قیمت ${separate( ? `خرید با قیمت ${separate(videoProduct?.price || ' ')} تومان`
videoProduct?.price || " " : 'ناموجود'
)} تومان`
: "ناموجود"
} }
backgroundColor={Colors.theme1.greenCF} backgroundColor={Colors.theme1.greenCF}
color={"white"} color={'white'}
border={{ color: "#196EC0", width: 0 }} border={{color: '#196EC0', width: 0}}
width={"100%"} width={'100%'}
loading={loading} loading={loading}
onPress={() => onPress={() =>
videoAvailabileInCart videoAvailabileInCart
? asyncAwesomeAlert( ? asyncAwesomeAlert(
"", '',
"این محصول قبلا به سبد خرید شما اضافه شده است.", 'این محصول قبلا به سبد خرید شما اضافه شده است.',
{ {
showCancelButton: true, showCancelButton: true,
onConfirm: () => onConfirm: () =>
navigation.navigate("Root", { navigation.navigate('Root', {
screen: "ShoppingCartTab", screen: 'ShoppingCartTab',
}), }),
confirmText: "مشاهده سبد خرید", confirmText: 'مشاهده سبد خرید',
cancelText: "ادامه خرید", cancelText: 'ادامه خرید',
} },
) )
: videoAvailableForSell : videoAvailableForSell
? addToCart( ? addToCart(
@ -224,17 +213,23 @@ function Product({
productId: videoProduct?.id, productId: videoProduct?.id,
userId: userId, userId: userId,
count: 1, count: 1,
}) }),
) )
: null : null
} }
/> />
</View> </View>
<View style={tw("flex")}> <View style={tw('flex')}>
{seasons {seasons
?.sort((a, b) => a[0]?.categoryId - b[0]?.categoryId) ?.sort((a, b) => a[0]?.categoryId - b[0]?.categoryId)
?.map((season, index) => ( ?.map((season, index) => (
<Season season={season} key={index} id={book?.id} index={index} videoBuyed={videoBuyed} /> <Season
season={season}
key={index}
id={book?.id}
index={index}
videoBuyed={videoBuyed}
/>
))} ))}
</View> </View>
</ScrollView> </ScrollView>
@ -252,7 +247,7 @@ const styles = StyleSheet.create({
}, },
}); });
const mapStateToProps = (state) => ({ const mapStateToProps = state => ({
book: state.book.info, book: state.book.info,
userProducts: state.userProduct.list, userProducts: state.userProduct.list,
seasons: state.publicApi.categories, seasons: state.publicApi.categories,

Loading…
Cancel
Save