master
Reza_ashrafi 2 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"),
{ 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
source={{ uri: `https://dnvn.ir/api/v1/file/${book.fileId}` }}
source={{ uri: `https://dnvn.ir/api/v1/file/${book?.fileId}` }}
resizeMode="contain"
style={[
tw("rounded-sm w-full"),
@ -41,7 +41,7 @@ const Book = ({ book, mobile, theme }) => {
},
]}
>
{book.title}
{book?.title}
</Text>
</Pressable>
);

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

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

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

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

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

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

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

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

Loading…
Cancel
Save