reza fixed some error

master
Reza_ashrafi 3 years ago
parent 6415649000
commit e0c8e500b2
  1. 4
      App.js
  2. 6
      navigation/index.js
  3. 5
      src/redux/reducers/public.js
  4. 2
      src/screens/AR/components/Book.js
  5. 1
      src/screens/Home/components/MyBooks.js
  6. 25
      src/screens/Home/components/Scroll.js
  7. 17
      src/screens/Home/components/Videos.js
  8. 28
      src/screens/Home/index.js
  9. 51
      src/screens/Product/components/Comments.js

@ -21,10 +21,10 @@ const App = () => {
} }
return ( return (
<Provider store={store}> <Provider store={store}>
<PersistGate loading={null} persistor={persistor}> {/* <PersistGate loading={null} persistor={persistor}> */}
<Navigation /> <Navigation />
<AlertModal /> <AlertModal />
</PersistGate> {/* </PersistGate> */}
</Provider> </Provider>
); );
}; };

@ -1,6 +1,6 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { Restart } from "fiction-expo-restart"; import { Restart } from "fiction-expo-restart";
import { I18nManager } from "react-native"; import { I18nManager, StatusBar } 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 { NavigationContainer } from "@react-navigation/native"; import { NavigationContainer } from "@react-navigation/native";
@ -580,6 +580,10 @@ const Navigation = ({
Restart(); Restart();
} }
getStatus(); getStatus();
StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`,
true
);
}, []); }, []);
return ( return (

@ -1,10 +1,10 @@
import { Dimensions } from "react-native"; import { Dimensions, AsyncStorage } from "react-native";
const width = Dimensions.get("window").width; const width = Dimensions.get("window").width;
const initialState = { const initialState = {
ltr: false, ltr: false,
theme: 'dark', theme: 'light',
mobile : width < 720, mobile : width < 720,
homeData: [], homeData: [],
newProducts: [], newProducts: [],
@ -80,7 +80,6 @@ const publicApi = (state = initialState, action) => {
case "public/setLtr": case "public/setLtr":
return { ...state, ltr : true }; return { ...state, ltr : true };
case "public/setIsDark": case "public/setIsDark":
// AsyncStorage.setItem("isDark", data);
return { ...state, location: false, error: null, theme: data }; return { ...state, location: false, error: null, theme: data };
case "active/video": case "active/video":
return { return {

@ -1,7 +1,6 @@
import { Pressable, Text, Image, Dimensions } from "react-native"; import { Pressable, Text, Image, Dimensions } from "react-native";
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native";
import * as Linking from "expo-linking"; import * as Linking from "expo-linking";
//style //style
@ -12,7 +11,6 @@ import Colors from "../../../constants/Colors";
const { width, height } = Dimensions.get("window"); const { width, height } = Dimensions.get("window");
const Book = ({ book, mobile, theme }) => { const Book = ({ book, mobile, theme }) => {
const navigation = useNavigation();
return ( return (
<Pressable <Pressable
style={[ style={[

@ -12,6 +12,7 @@ import fontSize from "../../../constants/fontSize";
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
function MyBooks({ books, grades, theme }) { function MyBooks({ books, grades, theme }) {
console.log(books);
return books?.filter((book) => book.condition >= 2).length ? ( return books?.filter((book) => book.condition >= 2).length ? (
<View style={[tw("flex w-full mb-5")]}> <View style={[tw("flex w-full mb-5")]}>
<View <View

@ -1,11 +1,5 @@
import React from "react"; import React from "react";
import { import { View, Image, Pressable, FlatList, Platform } from "react-native";
View,
Image,
Pressable,
FlatList,
Platform,
} from "react-native";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -25,9 +19,10 @@ function Scroll({ books, mobile }) {
style={[ style={[
tw("mr-1 overflow-hidden"), tw("mr-1 overflow-hidden"),
{ {
width: position === 0 ? mobile ? 170 : 240 : mobile ? 84 : 125, width: position === 0 ? (mobile ? 170 : 240) : mobile ? 84 : 125,
height: position === 0 ? mobile ? 240 : 350 : mobile ? 118 : 170, height:
marginLeft : position === 0 ? 16 : 4, position === 0 ? (mobile ? 240 : 350) : mobile ? 118 : 170,
marginLeft: position === 0 ? 16 : 4,
}, },
]} ]}
> >
@ -43,14 +38,12 @@ function Scroll({ books, mobile }) {
<View <View
style={[ style={[
tw( tw(
`flex justify-between ${ `flex justify-between ${ios ? "flex-wrap" : "flex-wrap-reverse"}`
ios ? "flex-wrap" : "flex-wrap-reverse"
}`
), ),
{ 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>
@ -58,6 +51,7 @@ function Scroll({ books, mobile }) {
}; };
return ( return (
<View style={[tw(`flex mb-5`)]}> <View style={[tw(`flex mb-5`)]}>
{books?.length ? (
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
horizontal={true} horizontal={true}
@ -67,12 +61,13 @@ function Scroll({ books, mobile }) {
renderItem={({}) => <Box books={books} />} renderItem={({}) => <Box books={books} />}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
/> />
) : null}
</View> </View>
); );
} }
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
mobile : state.publicApi.mobile mobile: state.publicApi.mobile,
}); });
export default connect(mapStateToProps, {})(Scroll); export default connect(mapStateToProps, {})(Scroll);

@ -20,6 +20,7 @@ function Videos({ videos, grades, mobile, theme }) {
<View style={tw("flex px-4")}> <View style={tw("flex px-4")}>
<Header title="دورههای ویدئویی شما" route={"VOD"} /> <Header title="دورههای ویدئویی شما" route={"VOD"} />
</View> </View>
{videos.length ? (
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
style={[tw("py-3")]} style={[tw("py-3")]}
@ -27,10 +28,16 @@ function Videos({ videos, grades, mobile, theme }) {
inverted={true} inverted={true}
data={videos.slice(0, 7)} data={videos.slice(0, 7)}
renderItem={({ item }) => ( renderItem={({ item }) => (
<Video video={item} grades={grades} mobile={mobile} theme={theme} /> <Video
video={item}
grades={grades}
mobile={mobile}
theme={theme}
/>
)} )}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
/> />
) : null}
</View> </View>
</View> </View>
); );
@ -50,7 +57,7 @@ const Video = ({ video, mobile, grades, theme }) => {
source={{ uri: `https://dnvn.ir/api/v1/file/${video.fileIds}` }} source={{ uri: `https://dnvn.ir/api/v1/file/${video.fileIds}` }}
// resizeMode="contain" // resizeMode="contain"
style={[ style={[
tw('bg-gray-100'), tw("bg-gray-100"),
{ {
height: mobile ? 130 : 130, height: mobile ? 130 : 130,
}, },
@ -60,7 +67,8 @@ const Video = ({ video, mobile, grades, theme }) => {
style={[ style={[
tw("mt-2 px-1"), tw("mt-2 px-1"),
{ {
color: theme === 'light' ? Colors.theme1.gray20 : Colors.theme1.white, color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontFamily: "bold", fontFamily: "bold",
fontSize: mobile ? fontSize.sm : fontSize.xl, fontSize: mobile ? fontSize.sm : fontSize.xl,
textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",
@ -73,7 +81,8 @@ const Video = ({ video, mobile, grades, theme }) => {
style={[ style={[
tw("mt-1 pr-1"), tw("mt-1 pr-1"),
{ {
color: theme === 'light' ? Colors.theme1.gray20 : Colors.theme1.white, color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontFamily: "regular", fontFamily: "regular",
fontSize: mobile ? fontSize.xs : fontSize.base, fontSize: mobile ? fontSize.xs : fontSize.base,
textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",

@ -1,6 +1,7 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native"; import { blog, book, userProduct } from "../../redux/actions";
import { import {
View, View,
StyleSheet, StyleSheet,
@ -24,7 +25,16 @@ import Header from "./components/Header";
import tw from "tailwind-rn"; import tw from "tailwind-rn";
// Within your render function // Within your render function
const Home = ({ route, blogs, books, userProducts, mobile }) => { const Home = ({
route,
blogs,
books,
userProducts,
mobile,
getBlogs,
getBooks,
getUserProducts,
}) => {
const [position, setPosition] = useState("100%"); const [position, setPosition] = useState("100%");
const setBoxPosition = () => { const setBoxPosition = () => {
@ -32,6 +42,16 @@ const Home = ({ route, blogs, books, userProducts, mobile }) => {
setPosition(position === "100%" ? "0%" : "100%"); setPosition(position === "100%" ? "0%" : "100%");
}; };
React.useEffect(() => {
if (blogs.length === 0) {
getBlogs();
} else if (books.length === 0) {
getBooks({ vod: true });
} else if (userProducts.length === 0) {
getUserProducts();
}
}, [books, userProducts, blogs]);
return ( return (
<SafeAreaView style={styles.safeStyle}> <SafeAreaView style={styles.safeStyle}>
<Navbar <Navbar
@ -90,7 +110,9 @@ const mapStateToProps = (state) => ({
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
// getVideos: product.listVOD getBlogs: blog.list,
getBooks: book.list,
getUserProducts: userProduct.list,
}; };
export default connect(mapStateToProps, mapDispatchToProps)(Home); export default connect(mapStateToProps, mapDispatchToProps)(Home);

@ -22,7 +22,7 @@ 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 {width} = Dimensions.get("window"); const { width } = Dimensions.get("window");
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
function Commnets({ function Commnets({
@ -31,7 +31,7 @@ function Commnets({
productId, productId,
getFullList, getFullList,
orderFullList, orderFullList,
theme theme,
}) { }) {
React.useEffect(() => { React.useEffect(() => {
if (!orderFullList.length) { if (!orderFullList.length) {
@ -50,11 +50,7 @@ function Commnets({
renderItem={({ item }) => <Comment comment={item} theme={theme} />} renderItem={({ item }) => <Comment comment={item} theme={theme} />}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
/> />
<AddComment <AddComment addComment={addComment} productId={productId} theme={theme} />
addComment={addComment}
productId={productId}
theme={theme}
/>
</View> </View>
); );
} }
@ -150,43 +146,59 @@ const AddComment = ({ addComment, productId, theme, ...props }) => {
style={[ style={[
tw("w-full mt-4 px-2 rounded-md"), tw("w-full mt-4 px-2 rounded-md"),
{ {
backgroundColor: theme === 'light' ? Colors.theme1.grayF9 : null, backgroundColor: theme === "light" ? Colors.theme1.grayF9 : null,
color: theme === 'light' ? Colors.theme1.gray20 : Colors.theme1.white, color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontSize: fontSize.base, fontSize: fontSize.base,
textAlign: "right", textAlign: "right",
fontFamily: "light", fontFamily: "light",
borderWidth: 1, borderWidth: 1,
borderColor: theme === 'light' ? Colors.theme1.grayE3 : Colors.theme1.white + '55', borderColor:
height : fontSize.base + 30 theme === "light"
? Colors.theme1.grayE3
: Colors.theme1.white + "55",
height: fontSize.base + 30,
}, },
]} ]}
value={comment.title} value={comment.title}
placeholder="عنوان نظر ..." placeholder="عنوان نظر ..."
onChangeText={(text) => setCommentForm({...commentForm, title : text})} onChangeText={(text) => setCommentForm({ ...commentForm, title: text })}
placeholderTextColor={theme === 'light' ? Colors.theme1.gray2077 : Colors.theme1.white + 'aa'} placeholderTextColor={
theme === "light"
? Colors.theme1.gray2077
: Colors.theme1.white + "aa"
}
/> />
<TextInput <TextInput
style={[ style={[
tw("w-full mt-4 py-4 px-2 rounded-md h-40"), tw("w-full mt-4 py-4 px-2 rounded-md h-40"),
{ {
backgroundColor: theme === 'light' ? Colors.theme1.grayF9 : null, backgroundColor: theme === "light" ? Colors.theme1.grayF9 : null,
color: theme === 'light' ? Colors.theme1.gray20 : Colors.theme1.white, color:
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.white,
fontSize: fontSize.tiny, fontSize: fontSize.tiny,
textAlign: "right", textAlign: "right",
fontFamily: "light", fontFamily: "light",
borderWidth: 1, borderWidth: 1,
borderColor: theme === 'light' ? Colors.theme1.grayE3 : Colors.theme1.white + '55', borderColor:
theme === "light"
? Colors.theme1.grayE3
: Colors.theme1.white + "55",
}, },
]} ]}
value={comment.text} value={comment.text}
multiline={true} multiline={true}
textAlignVertical="top" textAlignVertical="top"
placeholder="متن نظر ..." placeholder="متن نظر ..."
onChangeText={(text) => setCommentForm({...commentForm, text})} onChangeText={(text) => setCommentForm({ ...commentForm, text })}
placeholderTextColor={theme === 'light' ? Colors.theme1.gray2077 : Colors.theme1.white + 'aa'} placeholderTextColor={
theme === "light"
? Colors.theme1.gray2077
: Colors.theme1.white + "aa"
}
/> />
{commentForm.title && commentForm.text ? (
<View style={tw("w-full mt-4")}> <View style={tw("w-full mt-4")}>
<Pressable <Pressable
title="ارسال نظر" title="ارسال نظر"
@ -197,6 +209,7 @@ const AddComment = ({ addComment, productId, theme, ...props }) => {
onPress={() => addComment(commentForm)} onPress={() => addComment(commentForm)}
/> />
</View> </View>
) : null}
</KeyboardAvoidingView> </KeyboardAvoidingView>
); );
}; };

Loading…
Cancel
Save