reza added some change

master
Reza_ashrafi 3 years ago
parent 7b16deabe0
commit 9400f85860
  1. 2
      navigation/index.js
  2. 81
      src/components/BottomSheetComponents/ProductQuestion.js
  3. 44
      src/components/Empty.js
  4. 2
      src/components/Navbar.js
  5. 7
      src/redux/reducers/userFavorite.js
  6. 7
      src/screens/Home/components/Blogs.js
  7. 80
      src/screens/Home/components/MyBooks.js
  8. 6
      src/screens/Home/components/Scroll.js
  9. 12
      src/screens/Home/components/Videos.js
  10. 6
      src/screens/Product/components/Book.js
  11. 13
      src/screens/Profile/components/ProfileAddress/index.js
  12. 33
      src/screens/Profile/components/ProfileBookmark/index.js
  13. 3
      src/screens/Profile/components/User.js
  14. 15
      src/screens/ShoppingCart/index.js
  15. 2
      src/screens/VideoDisplay/index.js

@ -67,7 +67,7 @@ const BottomTabNavigator = ({}) => {
tabBarActiveTintColor: Colors.theme1[colorScheme].green79, tabBarActiveTintColor: Colors.theme1[colorScheme].green79,
tabBarInactiveTintColor: "grey", tabBarInactiveTintColor: "grey",
tabBarStyle: { tabBarStyle: {
backgroundColor: Colors.theme1[colorScheme].greenFF1, backgroundColor: Colors.theme1[colorScheme].white,
}, },
tabBarLabelStyle: { tabBarLabelStyle: {
// fontSize: fontSize.sm, // fontSize: fontSize.sm,

@ -15,12 +15,48 @@ import fontSize from "../../constants/fontSize";
import tw from "tailwind-rn"; import tw from "tailwind-rn";
import Colors from "../../constants/Colors"; import Colors from "../../constants/Colors";
const { width } = Dimensions.get("window");
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
const ProductQuestion = ({ list, mobile }) => { const ProductQuestion = ({ list, mobile }) => {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
const Question = ({ question }) => { return (
<View style={{ flex: 1, paddingHorizontal: 16 }}>
<View
onPress={() => refRBSheet.current.open()}
style={[
tw(
`flex flex-row-reverse justify-between items-center mt-3 rounded-md px-2 ${
mobile ? "py-3" : "py-4"
} mb-4`
),
{
backgroundColor: Colors.theme1[colorScheme].greenFF1,
},
]}
>
<Text
style={[
{
fontSize: mobile ? fontSize.sm : fontSize.xl3,
color: Colors.theme1[colorScheme].green79,
fontFamily: "demi",
},
]}
>
پرسش و پاسخ
</Text>
</View>
<ScrollView style={tw("flex-1")}>
{/* {list?.map((question, index) => (
<Question question={question} key={index} mobile={mobile} />
))} */}
</ScrollView>
</View>
);
};
const Question = ({ question, mobile }) => {
const colorScheme = Appearance.getColorScheme();
return ( return (
<View style={[tw("flex mb-3")]}> <View style={[tw("flex mb-3")]}>
<Text <Text
@ -41,9 +77,9 @@ const ProductQuestion = ({ list, mobile }) => {
textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",
}} }}
> >
{question.question} {question?.question}
</Text> </Text>
{question.answer && ( {question?.answer && (
<> <>
<Text <Text
style={{ style={{
@ -65,7 +101,7 @@ const ProductQuestion = ({ list, mobile }) => {
marginTop: mobile ? "" : 10, marginTop: mobile ? "" : 10,
}} }}
> >
{question.question} {question?.answer}
</Text> </Text>
</> </>
)} )}
@ -74,41 +110,6 @@ const ProductQuestion = ({ list, mobile }) => {
</View> </View>
); );
}; };
return (
<View style={{ flex: 1, paddingHorizontal: 16 }}>
<View
onPress={() => refRBSheet.current.open()}
style={[
tw(
`flex flex-row-reverse justify-between items-center mt-3 rounded-md px-2 ${
mobile ? "py-3" : "py-4"
} mb-4`
),
{
backgroundColor: Colors.theme1[colorScheme].greenFF1,
},
]}
>
<Text
style={[
{
fontSize: mobile ? fontSize.sm : fontSize.xl3,
color: Colors.theme1[colorScheme].green79,
fontFamily: "demi",
},
]}
>
پرسش و پاسخ
</Text>
</View>
<ScrollView style={tw("flex-1")}>
{list.map((question, index) => (
<Question question={question} key={index} />
))}
</ScrollView>
</View>
);
};
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
mobile: state.publicApi.mobile, mobile: state.publicApi.mobile,

@ -0,0 +1,44 @@
import { View, Text, Pressable, Appearance } from "react-native";
import React from "react";
//style
import Colors from "../constants/Colors";
import tw from "tailwind-rn";
import fontSize from "../constants/fontSize";
const Empty = ({ text, buttonText, buttonAction }) => {
const colorScheme = Appearance.getColorScheme();
return (
<View style={tw("flex-1 flex justify-center items-center")}>
<Text
style={[
tw("text-gray-500"),
{
fontFamily: "regular",
fontSize: fontSize.tiny,
transform: [{ translateY: -50 }],
},
]}
>
{text + " " + ":("}
</Text>
{buttonText && (
<Pressable style={[tw('py-2 px-5 rounded-sm'),{ backgroundColor: Colors.theme1[colorScheme].greenCF }]} onPress={() => buttonAction()}>
<Text
style={[
tw("text-white"),
{
fontFamily: "regular",
fontSize: fontSize.tiny,
},
]}
>
{buttonText}
</Text>
</Pressable>
)}
</View>
);
};
export default Empty;

@ -80,7 +80,7 @@ const Navbar = ({
<Text <Text
style={{ style={{
fontFamily: "bold", fontFamily: "bold",
fontSize: fontSize.xl, fontSize: fontSize.lg,
color: Color.theme1[colorScheme].green79, color: Color.theme1[colorScheme].green79,
paddingRight: 16, paddingRight: 16,
}} }}

@ -1,3 +1,6 @@
import { toastMessage} from '../../utils/message';
import { asyncAwesomeAlert } from '../../utils/AsyncWrappers';
const initialState = { const initialState = {
loading: false, loading: false,
error: null, error: null,
@ -16,12 +19,16 @@ export default function userAddress(state = initialState, action) {
case "userAddress/update": case "userAddress/update":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userAddress/add": case "userAddress/add":
toastMessage('به لیست علاقهمندیها اضافه شد.');
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userAddress/delete": case "userAddress/delete":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userAddress/loading": case "userAddress/loading":
return { ...state, loading: true }; return { ...state, loading: true };
case "userAddress/error": case "userAddress/error":
asyncAwesomeAlert("خطا", data.message, {
showCancelButton: false,
});
return { ...state, loading: false, error: data.message }; return { ...state, loading: false, error: data.message };
default: default:
return state; return state;

@ -29,8 +29,8 @@ const ios = Platform.OS === "ios";
function Blogs({ blogs, mobile }) { function Blogs({ blogs, mobile }) {
return ( return (
<View style={[tw("flex pr-3 mb-5")]}> <View style={[tw("flex mb-5")]}>
<View style={tw("w-full pl-3")}> <View style={tw("w-full px-4")}>
<Header title={"خواندنیها"} route={"Blogs"} /> <Header title={"خواندنیها"} route={"Blogs"} />
</View> </View>
<FlatList <FlatList
@ -54,7 +54,7 @@ const Blog = ({ blog, mobile }) => {
return ( return (
<Pressable <Pressable
style={[ style={[
tw("rounded-md ml-3 rounded-md relative"), tw("rounded-md mr-4 rounded-md relative"),
{ width: mobile ? 250 : width / 2.2 }, { width: mobile ? 250 : width / 2.2 },
]} ]}
onPress={() => navigation.push("Blog", { id: blog?.id })} onPress={() => navigation.push("Blog", { id: blog?.id })}
@ -106,7 +106,6 @@ const Blog = ({ blog, mobile }) => {
style={[tw("rounded-full ml-1"), { width: 20, flex: 1 }]} style={[tw("rounded-full ml-1"), { width: 20, flex: 1 }]}
/> />
</View> </View>
<Text <Text
style={[ style={[
{ {

@ -22,12 +22,50 @@ const ios = Platform.OS === "ios";
function MyBooks({ books, grades }) { function MyBooks({ books, grades }) {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
return (
<View style={[tw("flex w-full mb-5")]}>
<View
style={[
tw(`w-full flex rounded-md pt-3 overflow-hidden`),
{
backgroundColor: Colors.theme1[colorScheme].greenCF + "0F",
borderColor: Colors.theme1[colorScheme].greenD9 + "",
borderWidth: 1,
},
]}
>
<Text
style={[
tw(`pr-4 ${ios ? "text-right" : ""} w-full`),
{
color: Colors.theme1[colorScheme].green79,
fontFamily: "demi",
fontSize: fontSize.lg,
},
]}
>
کتابهای من
</Text>
<FlatList
showsHorizontalScrollIndicator={false}
style={[tw("py-3")]}
horizontal={true}
inverted={true}
data={books}
renderItem={({ item }) => <Book book={item} grades={grades} />}
keyExtractor={(book) => book?.id}
/>
</View>
</View>
);
}
const Book = ({ book }) => { const Book = ({ book, grades }) => {
const colorScheme = Appearance.getColorScheme();
const navigation = useNavigation(); const navigation = useNavigation();
return ( return (
<Pressable <Pressable
style={tw(`flex ml-3 ${ios ? "items-end" : ""}`)} style={tw(`flex mr-4 ${ios ? "items-end" : ""}`)}
onPress={() => {}} onPress={() => {}}
> >
<View style={{ height: 165 }}> <View style={{ height: 165 }}>
@ -73,44 +111,6 @@ function MyBooks({ books, grades }) {
); );
}; };
return (
<View style={[tw("flex w-full px-4 mb-5")]}>
<View
style={[
tw(`w-full flex rounded-md pt-3 px-2 overflow-hidden`),
{
backgroundColor: Colors.theme1[colorScheme].greenCF + "0F",
borderColor: Colors.theme1[colorScheme].greenD9 + "",
borderWidth: 1,
},
]}
>
<Text
style={[
tw(`${ios ? "text-right" : ""} w-full`),
{
color: Colors.theme1[colorScheme].green79,
fontFamily: "demi",
fontSize: fontSize.lg,
},
]}
>
کتابهای من
</Text>
<FlatList
showsHorizontalScrollIndicator={false}
style={[tw("py-3")]}
horizontal={true}
inverted={true}
data={books}
renderItem={({ item }) => <Book book={item} />}
keyExtractor={(book) => book?.id}
/>
</View>
</View>
);
}
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
grades: state.publicApi.grades, grades: state.publicApi.grades,
}); });

@ -25,10 +25,11 @@ function Scroll({ books, mobile }) {
navigation.navigate("Product", { id: book?.id, type: "book" }) navigation.navigate("Product", { id: book?.id, type: "book" })
} }
style={[ style={[
tw("mx-1 overflow-hidden"), tw("mr-1 overflow-hidden"),
{ {
width: position === 0 ? mobile ? 163 : 240 : mobile ? 84 : 125, width: position === 0 ? mobile ? 163 : 240 : mobile ? 84 : 125,
height: position === 0 ? mobile ? 245 : 350 : mobile ? 118 : 170, height: position === 0 ? mobile ? 245 : 350 : mobile ? 118 : 170,
marginLeft : position === 0 ? 16 : 4,
}, },
]} ]}
> >
@ -58,7 +59,7 @@ function Scroll({ books, mobile }) {
); );
}; };
return ( return (
<View style={[tw(`flex pr-3 mb-5`)]}> <View style={[tw(`flex mb-5`)]}>
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
horizontal={true} horizontal={true}
@ -67,7 +68,6 @@ function Scroll({ books, mobile }) {
data={[{ id: 0 }]} data={[{ id: 0 }]}
renderItem={({}) => <Box books={books} />} renderItem={({}) => <Box books={books} />}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
/> />
</View> </View>
); );

@ -23,13 +23,11 @@ const ios = Platform.OS === "ios";
function Videos({ videos, grades, mobile }) { function Videos({ videos, grades, mobile }) {
return ( return (
<View style={[tw("w-full px-2 mb-5")]}> <View style={[tw("w-full mb-5")]}>
<View <View style={[tw("w-full flex rounded-md pt-2 overflow-hidden")]}>
style={[ <View style={tw('flex px-4')}>
tw("w-full flex rounded-md pt-2 px-2 overflow-hidden"),
]}
>
<Header title="دورههای ویدئویی شما" route={"VOD"} /> <Header title="دورههای ویدئویی شما" route={"VOD"} />
</View>
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
style={[tw("py-3")]} style={[tw("py-3")]}
@ -52,7 +50,7 @@ const Video = ({ video, mobile, grades }) => {
return ( return (
<Pressable <Pressable
style={[ style={[
tw(`flex relative ${mobile ? "ml-3" : "ml-5"}`), tw(`flex relative ${mobile ? "mr-4" : "ml-5"}`),
{ width: mobile ? 130 : 200, height: mobile ? 280 : 280 }, { width: mobile ? 130 : 200, height: mobile ? 280 : 280 },
]} ]}
onPress={() => navigation.navigate("Video", { id: video.id })} onPress={() => navigation.navigate("Video", { id: video.id })}

@ -594,19 +594,19 @@ function Book({
component={ component={
<ProductSpecifications list={book?.product[type]?.properties} /> <ProductSpecifications list={book?.product[type]?.properties} />
} }
height={height - height / 4} height={height / 2}
/> />
<LinkBox <LinkBox
title="نقد بررسی و توضیحات تکمیلی محصول" title="نقد بررسی و توضیحات تکمیلی محصول"
key={"1"} key={"1"}
component={<ProductReview />} component={<ProductReview />}
height={height - height / 4} height={height / 2}
/> />
<LinkBox <LinkBox
title="پرسش و پاسخ" title="پرسش و پاسخ"
key={"2"} key={"2"}
component={<ProductQuestion />} component={<ProductQuestion />}
height={height - height / 4} height={height / 2}
/> />
{product.rates && ( {product.rates && (
<View <View

@ -21,6 +21,7 @@ import Svg, { G, Path } from "react-native-svg";
//components //components
import Navbar from "../../../../components/Navbar"; import Navbar from "../../../../components/Navbar";
import CustomPressable from "../../../../components/Pressable"; import CustomPressable from "../../../../components/Pressable";
import Empty from "../../../../components/Empty";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -106,11 +107,7 @@ const ProfileAddress = ({
</Svg> </Svg>
</View> </View>
)} )}
<View <View style={tw(`flex w-full ${active ? "" : "flex-row-reverse"}`)}>
style={tw(
`flex w-full ${active ? "" : "flex-row-reverse"}`
)}
>
<View style={tw("flex flex-1 mb-4")}> <View style={tw("flex flex-1 mb-4")}>
<Text <Text
style={[ style={[
@ -209,7 +206,7 @@ const ProfileAddress = ({
position: "relative", position: "relative",
backgroundColor: "white", backgroundColor: "white",
flex: 1, flex: 1,
paddingBottom : 20 paddingBottom: 20,
}} }}
> >
<Navbar <Navbar
@ -223,6 +220,7 @@ const ProfileAddress = ({
back: true, back: true,
}} }}
/> />
{addresses.length > 0 ? (
<ScrollView <ScrollView
contentContainerStyle={styles.contentContainerStyle} contentContainerStyle={styles.contentContainerStyle}
style={[styles.container]} style={[styles.container]}
@ -240,6 +238,9 @@ const ProfileAddress = ({
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
) : (
<Empty text="هیچ آدرسی ثبت نشده :(" />
)}
<View style={tw("w-full px-4")}> <View style={tw("w-full px-4")}>
<TouchableOpacity <TouchableOpacity
style={[ style={[

@ -16,10 +16,11 @@ import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import Svg, { Path } from "react-native-svg"; import Svg, { Path } from "react-native-svg";
import {userFavorite} from '../../../../redux/actions'; import { userFavorite } from "../../../../redux/actions";
//components //components
import Navbar from "../../../../components/Navbar"; import Navbar from "../../../../components/Navbar";
import Empty from "../../../../components/Empty";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -33,7 +34,6 @@ const { height, width } = Dimensions.get("window");
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
const ProfileBookmark = ({ bookmarkList, getList }) => { const ProfileBookmark = ({ bookmarkList, getList }) => {
React.useEffect(() => { React.useEffect(() => {
getList(); getList();
}, []); }, []);
@ -57,28 +57,33 @@ const ProfileBookmark = ({ bookmarkList, getList }) => {
back: true, back: true,
}} }}
/> />
{bookmarkList?.length > 0 ? (
<ScrollView <ScrollView
contentContainerStyle={styles.contentContainerStyle} contentContainerStyle={styles.contentContainerStyle}
style={styles.container} style={styles.container}
> >
<View style={tw("w-full mt-2 px-4")}> <View style={tw("w-full mt-2 px-4")}>
<View style={tw("p-0 m-0 flex")}> <View style={tw("p-0 m-0 flex")}>
{bookmarkList.map((bookmark, index) => ( {bookmarkList?.map((bookmark, index) => (
<Bookmark key={index} bookmark={bookmark} /> <Bookmark key={index} bookmark={bookmark} />
))} ))}
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
) : (
<Empty text="لیست علاقهمندیها خالی است." />
)}
</SafeAreaView> </SafeAreaView>
); );
}; };
const Bookmark = ({ bookmark }) => { const Bookmark = ({ bookmark }) => {
const colorScheme = Appearance.getColorScheme(); const colorScheme = Appearance.getColorScheme();
return ( return (
<Pressable <Pressable
style={[ style={[
tw("flex flex-row-reverse rounded-md justify-between px-3.5 py-2"), tw("flex flex-row-reverse rounded-md justify-between px-3.5 py-2 bg-red-100"),
{ {
borderWidth: 1.5, borderWidth: 1.5,
borderColor: Colors.theme1[colorScheme].greenCF, borderColor: Colors.theme1[colorScheme].greenCF,
@ -144,7 +149,7 @@ const Bookmark = ({ bookmark }) => {
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
loading: state.userFactor.loading, loading: state.userFactor.loading,
mobile: state.publicApi.mobile, mobile: state.publicApi.mobile,
bookmarkList : state.userFavorite.list bookmarkList: state.userFavorite.list,
}); });
const mapDispatchToProps = { const mapDispatchToProps = {
@ -166,12 +171,12 @@ const styles = StyleSheet.create({
}, },
}); });
ProfileBookmark.defaultProps = { // ProfileBookmark.defaultProps = {
bookmarkList: [ // bookmarkList: [
{ // {
name: "کتاب آموزشی علوم تجربی", // name: "کتاب آموزشی علوم تجربی",
grade: "پایه ششم ابتدایی", // grade: "پایه ششم ابتدایی",
image: bookImage, // image: bookImage,
}, // },
], // ],
}; // };

@ -58,7 +58,7 @@ const User = ({ user, mobile }) => {
fontFamily: "bold", fontFamily: "bold",
}} }}
> >
{user?.firstName + " " + user?.lastName} {(user?.firstName || " ") + " " + (user?.lastName || " ")}
</Text> </Text>
<Text <Text
style={{ style={{
@ -93,7 +93,6 @@ const User = ({ user, mobile }) => {
}` }`
)} )}
> >
<View <View
style={[ style={[
tw(`flex items-center w-full pb-3 mb-3 flex-row-reverse`), tw(`flex items-center w-full pb-3 mb-3 flex-row-reverse`),

@ -17,7 +17,7 @@ import { Ionicons } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers"; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
import separate from "../../utils/separate"; import separate from "../../utils/separate";
import * as Linking from 'expo-linking'; import * as Linking from "expo-linking";
//components //components
import Product from "./components/Product"; import Product from "./components/Product";
@ -25,6 +25,7 @@ import Code from "./components/Code";
import CustomPressable from "../../components/Pressable"; import CustomPressable from "../../components/Pressable";
import Navbar from "../../components/Navbar"; import Navbar from "../../components/Navbar";
import Drawer from "../../components/Drawer"; import Drawer from "../../components/Drawer";
import Empty from "../../components/Empty";
//style //style
import fontSize from "../../constants/fontSize"; import fontSize from "../../constants/fontSize";
@ -135,6 +136,7 @@ function ShoppingCart({
}} }}
/> />
<Drawer setBoxPosition={setBoxPosition} position={position} /> <Drawer setBoxPosition={setBoxPosition} position={position} />
{list?.filter((product) => product.condition < 2)?.length > 0 ? (
<ScrollView <ScrollView
contentContainerStyle={styles.contentContainerStyle} contentContainerStyle={styles.contentContainerStyle}
style={styles.container} style={styles.container}
@ -252,11 +254,20 @@ function ShoppingCart({
? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", { ? asyncAwesomeAlert("خطا", "سبد خرید شما خالی است.", {
showCancelButton: false, showCancelButton: false,
}) })
: hasPhysical ? navigation.push("DeliveryForm") : payFactor({userId}) : hasPhysical
? navigation.push("DeliveryForm")
: payFactor({ userId })
} }
/> />
</View> </View>
</ScrollView> </ScrollView>
) : (
<Empty
text={"سبد خرید شما خالی است"}
buttonText={"فروشگاه"}
buttonAction={() => navigation.navigate("Products")}
/>
)}
</SafeAreaView> </SafeAreaView>
); );
} }

@ -35,8 +35,6 @@ function VideoDisplay({ route, mobile }) {
const [status, setStatus] = React.useState({}); const [status, setStatus] = React.useState({});
const [position, setPosition] = useState("100%"); const [position, setPosition] = useState("100%");
useEffect(() => {}, []);
const setBoxPosition = () => { const setBoxPosition = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setPosition(position === "100%" ? "0%" : "100%"); setPosition(position === "100%" ? "0%" : "100%");

Loading…
Cancel
Save