reza fixed some error

master
Reza_ashrafi 3 years ago
parent 6415649000
commit e0c8e500b2
  1. 4
      App.js
  2. 8
      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. 43
      src/screens/Home/components/Scroll.js
  7. 37
      src/screens/Home/components/Videos.js
  8. 28
      src/screens/Home/index.js
  9. 73
      src/screens/Product/components/Comments.js

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

@ -1,6 +1,6 @@
import React, { useEffect } from "react";
import { Restart } from "fiction-expo-restart";
import { I18nManager } from "react-native";
import { I18nManager, StatusBar } from "react-native";
import * as Linking from "expo-linking";
import Svg, { G, Path } from "react-native-svg";
import { NavigationContainer } from "@react-navigation/native";
@ -57,7 +57,7 @@ const BottomTabNavigator = ({ theme, userProducts }) => {
setHeaderShown(false);
}, 600);
}, []);
return (
<Tab.Navigator
initialRouteName="HomeTab"
@ -580,6 +580,10 @@ const Navigation = ({
Restart();
}
getStatus();
StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`,
true
);
}, []);
return (

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

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

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

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

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

@ -1,6 +1,7 @@
import React, { useState } from "react";
import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native";
import { blog, book, userProduct } from "../../redux/actions";
import {
View,
StyleSheet,
@ -24,7 +25,16 @@ import Header from "./components/Header";
import tw from "tailwind-rn";
// 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 setBoxPosition = () => {
@ -32,6 +42,16 @@ const Home = ({ route, blogs, books, userProducts, mobile }) => {
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 (
<SafeAreaView style={styles.safeStyle}>
<Navbar
@ -90,7 +110,9 @@ const mapStateToProps = (state) => ({
});
const mapDispatchToProps = {
// getVideos: product.listVOD
getBlogs: blog.list,
getBooks: book.list,
getUserProducts: userProduct.list,
};
export default connect(mapStateToProps, mapDispatchToProps)(Home);

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

Loading…
Cancel
Save