master
Reza_ashrafi 3 years ago
parent f629f48a40
commit d86d4b99af
  1. 6
      src/screens/AR/components/Book.js
  2. 16
      src/screens/Address/index.js
  3. 26
      src/screens/Blog/index.js
  4. 10
      src/screens/Blogs/index.js
  5. 2
      src/screens/Blogs/layouts/More.js
  6. 33
      src/screens/Blogs/layouts/Single.js
  7. 27
      src/screens/Blogs/layouts/Target.js
  8. 2
      src/screens/Home/index.js
  9. 69
      src/screens/Splash/index.js

@ -17,10 +17,10 @@ const Book = ({ book, mobile, theme }) => {
tw("flex items-end rounded-md p-2 my-2"), tw("flex items-end rounded-md p-2 my-2"),
{ width: mobile ? "48%" : width / 4.2 }, { width: mobile ? "48%" : width / 4.2 },
]} ]}
onPress={() => Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book.id}`)} onPress={() => Linking.openURL(`https://ar.dnvn.ir/lunch?id=${book?.id}`)}
> >
<Image <Image
source={{ uri: `https://dnvn.ir/api/v1/file/${book.fileId}` }} source={{ uri: `https://dnvn.ir/api/v1/file/${book?.fileId}` }}
resizeMode="contain" resizeMode="contain"
style={[ style={[
tw("rounded-sm w-full"), tw("rounded-sm w-full"),
@ -41,7 +41,7 @@ const Book = ({ book, mobile, theme }) => {
}, },
]} ]}
> >
{book.title} {book?.title}
</Text> </Text>
</Pressable> </Pressable>
); );

@ -370,7 +370,7 @@ const Address = ({
maxlength="40" maxlength="40"
value={ value={
profilePage profilePage
? profileFields.firstName ? profileFields?.firstName
: addressFields?.firstName : addressFields?.firstName
} }
onChange={(name, value) => onChange={(name, value) =>
@ -390,7 +390,7 @@ const Address = ({
name="lastName" name="lastName"
maxlength="60" maxlength="60"
value={ value={
profilePage ? profileFields.lastName : addressFields?.lastName profilePage ? profileFields?.lastName : addressFields?.lastName
} }
onChange={(name, value) => onChange={(name, value) =>
profilePage profilePage
@ -408,7 +408,7 @@ const Address = ({
textAlign="left" textAlign="left"
name="nationalId" name="nationalId"
maxLength={10} maxLength={10}
value={profileFields.nationalId} value={profileFields?.nationalId}
onChange={(name, value) => onChange={(name, value) =>
setProfileFields({ ...profileFields, nationalId: value }) setProfileFields({ ...profileFields, nationalId: value })
} }
@ -433,7 +433,7 @@ const Address = ({
maxLength={11} maxLength={11}
value={ value={
profilePage profilePage
? profileFields.cellphone ? profileFields?.cellphone
: addressFields?.cellphone : addressFields?.cellphone
} }
onChange={(name, value) => onChange={(name, value) =>
@ -451,7 +451,7 @@ const Address = ({
textAlign="left" textAlign="left"
name="phone" name="phone"
maxLength={11} maxLength={11}
value={profilePage ? profileFields.phone : addressFields?.phone} value={profilePage ? profileFields?.phone : addressFields?.phone}
onChange={(name, value) => onChange={(name, value) =>
profilePage profilePage
? setProfileFields({ ...profileFields, phone: value }) ? setProfileFields({ ...profileFields, phone: value })
@ -471,7 +471,7 @@ const Address = ({
defaultValue={ defaultValue={
profilePage profilePage
? provinces?.filter( ? provinces?.filter(
(province) => province.id === profileFields.provinceId (province) => province.id === profileFields?.provinceId
)[0]?.name || province[0] )[0]?.name || province[0]
: province[0] : province[0]
} }
@ -488,7 +488,7 @@ const Address = ({
defaultValue={ defaultValue={
profilePage profilePage
? cities?.filter( ? cities?.filter(
(city) => city.id === profileFields.cityId (city) => city.id === profileFields?.cityId
)[0]?.name || city[0] )[0]?.name || city[0]
: city[0] : city[0]
} }
@ -544,7 +544,7 @@ const Address = ({
maxLength={10} maxLength={10}
value={ value={
profilePage profilePage
? profileFields.postalCode ? profileFields?.postalCode
: addressFields?.postalCode : addressFields?.postalCode
} }
onChange={(name, value) => onChange={(name, value) =>

@ -33,12 +33,12 @@ const { width } = Dimensions.get("window");
//func //func
const renderNode = (node, index, siblings, parent, defaultRenderer) => { const renderNode = (node, index, siblings, parent, defaultRenderer) => {
if (node.name == "img") { if (node?.name == "img") {
const a = node.attribs; const a = node?.attribs;
return ( return (
<Image <Image
style={{ width: 300, height: 300 }} style={{ width: 300, height: 300 }}
source={{ uri: node.attribs.src }} source={{ uri: node?.attribs?.src }}
/> />
); );
} }
@ -46,8 +46,8 @@ const renderNode = (node, index, siblings, parent, defaultRenderer) => {
export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => { export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => {
useEffect(() => { useEffect(() => {
getInfo({ id: route.params.id }); getInfo({ id: route?.params?.id });
if (blogs.length === 0) { if (blogs?.length === 0) {
getList(); getList();
} }
}, []); }, []);
@ -114,7 +114,7 @@ export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => {
> >
<View style={tw("flex")}> <View style={tw("flex")}>
<View style={tw("flex py-2 justify-center")}> <View style={tw("flex py-2 justify-center")}>
<Text {/* <Text
style={{ style={{
fontFamily: "regular", fontFamily: "regular",
color: Colors.theme1.white, color: Colors.theme1.white,
@ -122,8 +122,8 @@ export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => {
textAlign: ios ? "right" : "auto", textAlign: ios ? "right" : "auto",
}} }}
> >
{/* {"نوشته از:" + " " + "کامران ایزدی"} */} {"نوشته از:" + " " + "کامران ایزدی"}
</Text> </Text> */}
<Text <Text
style={{ style={{
fontFamily: "regular", fontFamily: "regular",
@ -269,16 +269,16 @@ export const Blog = ({ getInfo, blog, getList, blogs, route, theme }) => {
</View> </View>
</View> </View>
<Header title={"پیشنهادی "} /> <Header title={"پیشنهادی "} />
{blogs.length ? ( {blogs?.length ? (
<FlatList <FlatList
showsHorizontalScrollIndicator={false} showsHorizontalScrollIndicator={false}
horizontal={true} horizontal={true}
inverted={true} inverted={true}
style={[tw("flex flex-row mt-3 pb-3")]} style={[tw("flex flex-row mt-3 pb-3")]}
data={blogs.filter((blog) => blog.id !== route.params.id)} data={blogs?.filter((blog) => blog?.id !== route?.params?.id)}
renderItem={({ item }) => <New blog={item} />} renderItem={({ item }) => <New blog={item} />}
keyExtractor={(item, index) => { keyExtractor={(item, index) => {
return item.id; return item?.id;
}} }}
/> />
) : null} ) : null}
@ -300,10 +300,6 @@ const mapDispatchToProps = {
setHeaderOptions: publicApi.setHeaderOptions, setHeaderOptions: publicApi.setHeaderOptions,
}; };
const Tag = ({ tag }) => {
return;
};
export default connect(mapStateToProps, mapDispatchToProps)(Blog); export default connect(mapStateToProps, mapDispatchToProps)(Blog);
const styles = StyleSheet.create({ const styles = StyleSheet.create({

@ -79,11 +79,11 @@ function Blogs({ getList, blogs, hashtag, setHashtag, theme }) {
<FlatList <FlatList
contentContainerStyle={styles.contentContainerStyle} contentContainerStyle={styles.contentContainerStyle}
style={tw("px-4")} style={tw("px-4")}
data={blogs.filter((blog) => blog.tag === hashtag)} data={blogs?.filter((blog) => blog?.tag === hashtag)}
renderItem={({ item }) => ( renderItem={({ item }) => (
<HashtagBlog blog={item} blogsPage={true} theme={theme} /> <HashtagBlog blog={item} blogsPage={true} theme={theme} />
)} )}
keyExtractor={(item) => item.id} keyExtractor={(item) => item?.id}
/> />
) : ( ) : (
<ScrollView <ScrollView
@ -99,7 +99,7 @@ function Blogs({ getList, blogs, hashtag, setHashtag, theme }) {
style={[tw("flex flex-row mt-3 pb-3")]} style={[tw("flex flex-row mt-3 pb-3")]}
data={blogs.slice(0, 7)} data={blogs.slice(0, 7)}
renderItem={({ item }) => <New blog={item} />} renderItem={({ item }) => <New blog={item} />}
keyExtractor={(item) => item.id} keyExtractor={(item) => item?.id}
/> />
<Header title={"پیشنهاد سردبیر"} /> <Header title={"پیشنهاد سردبیر"} />
<FlatList <FlatList
@ -109,10 +109,10 @@ function Blogs({ getList, blogs, hashtag, setHashtag, theme }) {
style={[tw("flex flex-row mt-3 pb-3")]} style={[tw("flex flex-row mt-3 pb-3")]}
data={blogs.slice(0, 7)} data={blogs.slice(0, 7)}
renderItem={({ item }) => <New blog={item} />} renderItem={({ item }) => <New blog={item} />}
keyExtractor={(item) => item.id} keyExtractor={(item) => item?.id}
/> />
<Header title={"از دنیای آموزش"} /> <Header title={"از دنیای آموزش"} />
<Target blogs={blogs.slice(0, 3)} /> <Target blogs={blogs?.slice(0, 3)} />
</ScrollView> </ScrollView>
)} )}
</SafeAreaView> </SafeAreaView>

@ -65,7 +65,7 @@ const MoreBlog = ({ mobile, theme, blogs, blogsPage }) => {
data={blogs} data={blogs}
style={tw("px-4")} style={tw("px-4")}
renderItem={({ item }) => <Blog blog={item} theme={theme} />} renderItem={({ item }) => <Blog blog={item} theme={theme} />}
keyExtractor={(item) => item.id} keyExtractor={(item) => item?.id}
contentContainerStyle={{ paddingBottom: height / 2 }} contentContainerStyle={{ paddingBottom: height / 2 }}
/> />
</SafeAreaView> </SafeAreaView>

@ -10,6 +10,7 @@ import {
import { connect } from "react-redux"; import { connect } from "react-redux";
import { LinearGradient } from "expo-linear-gradient"; import { LinearGradient } from "expo-linear-gradient";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import moment from "jalali-moment";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -56,7 +57,7 @@ export const Single = ({ blog, theme }) => {
]} ]}
></View> ></View>
<View style="flex py-2 justify-center"> <View style="flex py-2 justify-center">
<Text {/* <Text
style={[ style={[
tw("text-gray-100"), tw("text-gray-100"),
{ {
@ -67,7 +68,7 @@ export const Single = ({ blog, theme }) => {
]} ]}
> >
{"نوشته از:" + " " + "کامران ایزدی"} {"نوشته از:" + " " + "کامران ایزدی"}
</Text> </Text> */}
<Text <Text
style={[ style={[
tw("text-gray-100 mt-2"), tw("text-gray-100 mt-2"),
@ -82,22 +83,28 @@ export const Single = ({ blog, theme }) => {
</Text> </Text>
</View> </View>
</View> </View>
<View style={tw("flex justify-center items-start")}> <View style="flex justify-center items-end">
{blog?.duration ? (
<Text <Text
style={[ style={{
tw("text-gray-100"), fontFamily: "regular",
{ fontFamily: "bold", fontSize: fontSize.sm }, color: Colors.theme1.white,
]} fontSize: fontSize.sm,
textAlign: ios ? "left" : "left",
}}
> >
{"زمان مطالعه" + " " + "۳۰ دقیقه"} {"زمان مطالعه" + " " + blog?.duration + " دقیقه"}
</Text> </Text>
) : null}
<Text <Text
style={[ style={{
tw("mt-2 text-gray-100"), fontFamily: "regular",
{ fontFamily: "bold", fontSize: fontSize.sm }, color: Colors.theme1.white,
]} fontSize: fontSize.sm,
textAlign: ios ? "left" : "left",
}}
> >
{"1400/11/24"} {moment(blog?.createdAt).format("jYYYY/jMM/jDD")}
</Text> </Text>
</View> </View>
</View> </View>

@ -11,6 +11,7 @@ import {
import { connect } from "react-redux"; import { connect } from "react-redux";
import { useNavigation } from "@react-navigation/native"; import { useNavigation } from "@react-navigation/native";
import { LinearGradient } from "expo-linear-gradient"; import { LinearGradient } from "expo-linear-gradient";
import moment from "jalali-moment";
//style //style
import tw from "tailwind-rn"; import tw from "tailwind-rn";
@ -71,7 +72,7 @@ const Target = ({ blogs, theme }) => {
<View <View
style={tw(`flex py-2 justify-center ${ios ? "items-end" : ""}`)} style={tw(`flex py-2 justify-center ${ios ? "items-end" : ""}`)}
> >
<Text {/* <Text
style={[ style={[
{ {
fontFamily: "bold", fontFamily: "bold",
@ -84,7 +85,7 @@ const Target = ({ blogs, theme }) => {
]} ]}
> >
{"نوشته از:" + " " + "کامران ایزدی"} {"نوشته از:" + " " + "کامران ایزدی"}
</Text> </Text> */}
<Text <Text
style={[ style={[
{ {
@ -102,6 +103,7 @@ const Target = ({ blogs, theme }) => {
</View> </View>
</View> </View>
<View style={tw("flex justify-center items-start")}> <View style={tw("flex justify-center items-start")}>
{blog?.duration ? (
<Text <Text
style={[ style={[
{ {
@ -114,22 +116,19 @@ const Target = ({ blogs, theme }) => {
}, },
]} ]}
> >
{"زمان مطالعه" + " " + "۳۰ دقیقه"} {"زمان مطالعه" + " " + blog?.duration + " دقیقه"}
</Text> </Text>
) : null}
<Text <Text
style={[ style={{
tw("mt-0"), fontFamily: "regular",
{ color: Colors.theme1.white,
fontFamily: "bold",
color:
theme === "light"
? Colors.theme1.gray20
: Colors.theme1.grayF9,
fontSize: fontSize.sm, fontSize: fontSize.sm,
}, textAlign: ios ? "left" : "left",
]} }}
> >
{"1400/11/24"} {moment(blog?.createdAt).format("jYYYY/jMM/jDD")}
</Text> </Text>
</View> </View>
</View> </View>

@ -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 { blog, book, userProduct } from "../../redux/actions"; import { blog, book, userProduct } from "../../redux/actions";
import {useNavigation} from "@react-navigation/native";
import { import {
View, View,
@ -37,6 +38,7 @@ const Home = ({
getBooks, getBooks,
getUserProducts, getUserProducts,
}) => { }) => {
const navigation = useNavigation();
const [position, setPosition] = useState("100%"); const [position, setPosition] = useState("100%");
const setBoxPosition = () => { const setBoxPosition = () => {

@ -30,6 +30,7 @@ function Splash({
}) { }) {
const isFocused = useIsFocused(); const isFocused = useIsFocused();
const [out, setOut] = React.useState(false); const [out, setOut] = React.useState(false);
React.useEffect(() => { React.useEffect(() => {
StatusBar.setBarStyle( StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`, `${theme === "light" ? "dark" : "light"}-content`,
@ -42,12 +43,22 @@ function Splash({
setIsDark(theme); setIsDark(theme);
}; };
const setOutHandler = React.useCallback(
(value) => {
setOut(value);
},
[out]
);
useEffect(() => { useEffect(() => {
getTheme(); getTheme();
if (isLogin !== null) { if (isLogin !== null) {
if (isLogin === false) { if (isLogin === false) {
setOut(true); setOutHandler(true);
navigation.navigate("Login"); navigation.reset({
index: 0,
routes: [{ name: "Login" }],
});
} else { } else {
if (blogs.length === 0) { if (blogs.length === 0) {
getBlogs(); getBlogs();
@ -56,38 +67,40 @@ function Splash({
} else if (userProducts.length === 0) { } else if (userProducts.length === 0) {
getUserProducts(); getUserProducts();
} else { } else {
setOut(true); setOutHandler(true);
navigation.navigate("Root"); navigation.reset({
index: 0,
routes: [{ name: "Root" }],
});
} }
} }
} else {
} }
}, [isLogin, books, userProducts, blogs]); }, [isLogin, books, userProducts, blogs]);
if (isFocused && out) { // if (isFocused && out) {
setOut(false); // setOutHandler(false);
BackHandler.exitApp(); // BackHandler.exitApp();
} // }
if (isFocused && !out) { // if (isFocused && !out) {
if (isLogin !== null) { // if (isLogin !== null) {
if (isLogin === false) { // if (isLogin === false) {
setOut(true); // setOutHandler(true);
navigation.navigate("Login"); // navigation.push("Login");
} else { // } else {
if (blogs.length === 0) { // if (blogs.length === 0) {
getBlogs(); // getBlogs();
} else if (books.length === 0) { // } else if (books.length === 0) {
getBooks({ vod: true }); // getBooks({ vod: true });
} else if (userProducts.length === 0) { // } else if (userProducts.length === 0) {
getUserProducts(); // getUserProducts();
} else { // } else {
setOut(true); // setOutHandler(true);
navigation.navigate("Root"); // navigation.push("Root");
} // }
} // }
} // }
} // }
return ( return (
<View <View

Loading…
Cancel
Save