|
|
@ -7,15 +7,20 @@ import { |
|
|
|
StatusBar, |
|
|
|
StatusBar, |
|
|
|
LayoutAnimation, |
|
|
|
LayoutAnimation, |
|
|
|
FlatList, |
|
|
|
FlatList, |
|
|
|
|
|
|
|
Dimensions, |
|
|
|
|
|
|
|
Image, |
|
|
|
|
|
|
|
Text, |
|
|
|
|
|
|
|
Pressable |
|
|
|
} from "react-native"; |
|
|
|
} from "react-native"; |
|
|
|
|
|
|
|
|
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { blog } from "../../redux/actions"; |
|
|
|
import { blog } from "../../redux/actions"; |
|
|
|
|
|
|
|
import {useNavigation} from "@react-navigation/native"; |
|
|
|
|
|
|
|
|
|
|
|
//components
|
|
|
|
//components
|
|
|
|
import Navbar from "../../components/Navbar"; |
|
|
|
import Navbar from "../../components/Navbar"; |
|
|
|
import Drawer from "../../components/Drawer"; |
|
|
|
import Drawer from "../../components/Drawer"; |
|
|
|
// import Hashtags from "./layouts/Hashtags";
|
|
|
|
import Hashtags from "./layouts/Hashtags"; |
|
|
|
import Header from "./layouts/Header"; |
|
|
|
import Header from "./layouts/Header"; |
|
|
|
import Single from "./layouts/Single"; |
|
|
|
import Single from "./layouts/Single"; |
|
|
|
import New from "./layouts/New"; |
|
|
|
import New from "./layouts/New"; |
|
|
@ -23,12 +28,18 @@ import Target from "./layouts/Target"; |
|
|
|
|
|
|
|
|
|
|
|
//style
|
|
|
|
//style
|
|
|
|
import tw from "tailwind-rn"; |
|
|
|
import tw from "tailwind-rn"; |
|
|
|
|
|
|
|
import fontSize from "../../constants/fontSize"; |
|
|
|
|
|
|
|
import Colors from "../../constants/Colors"; |
|
|
|
|
|
|
|
|
|
|
|
function Blogs({ getList, blogs }) { |
|
|
|
const { width, height } = Dimensions.get("window"); |
|
|
|
|
|
|
|
const ios = Platform.OS === "ios"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Blogs({ getList, blogs, hashtag, setHashtag, theme }) { |
|
|
|
const [position, setPosition] = React.useState("100%"); |
|
|
|
const [position, setPosition] = React.useState("100%"); |
|
|
|
|
|
|
|
|
|
|
|
React.useEffect(() => { |
|
|
|
React.useEffect(() => { |
|
|
|
getList(); |
|
|
|
getList(); |
|
|
|
|
|
|
|
setHashtag(null); |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
const setBoxPosition = () => { |
|
|
|
const setBoxPosition = () => { |
|
|
@ -56,53 +67,99 @@ function Blogs({ getList, blogs }) { |
|
|
|
}} |
|
|
|
}} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Drawer setBoxPosition={setBoxPosition} position={position} /> |
|
|
|
<Drawer setBoxPosition={setBoxPosition} position={position} /> |
|
|
|
<ScrollView |
|
|
|
<Hashtags /> |
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
{hashtag ? ( |
|
|
|
style={[styles.container, tw("flex px-4")]} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{/* <Hashtags /> */} |
|
|
|
|
|
|
|
<Single /> |
|
|
|
|
|
|
|
<Header title={"تازهترینها از وبلاگ"} /> |
|
|
|
|
|
|
|
<FlatList |
|
|
|
<FlatList |
|
|
|
showsHorizontalScrollIndicator={false} |
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
horizontal={true} |
|
|
|
style={tw("px-4")} |
|
|
|
inverted={true} |
|
|
|
data={blogs.filter((blog) => blog.tag === hashtag)} |
|
|
|
style={[tw("flex flex-row mt-3 pb-3")]} |
|
|
|
renderItem={({ item }) => ( |
|
|
|
data={blogs.slice(0, 7)} |
|
|
|
<HashtagBlog blog={item} blogsPage={true} theme={theme} /> |
|
|
|
renderItem={({ item }) => <New blog={item} />} |
|
|
|
)} |
|
|
|
keyExtractor={(item) => item.id} |
|
|
|
keyExtractor={(item) => item.id} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Header title={"پیشنهاد سردبیر"} /> |
|
|
|
) : ( |
|
|
|
<FlatList |
|
|
|
<ScrollView |
|
|
|
showsHorizontalScrollIndicator={false} |
|
|
|
contentContainerStyle={styles.contentContainerStyle} |
|
|
|
horizontal={true} |
|
|
|
style={[styles.container, tw("flex px-4")]} |
|
|
|
inverted={true} |
|
|
|
> |
|
|
|
style={[tw("flex flex-row mt-3 pb-3")]} |
|
|
|
<Single /> |
|
|
|
data={blogs.slice(0, 7)} |
|
|
|
<Header title={"تازهترینها از وبلاگ"} /> |
|
|
|
renderItem={({ item }) => <New blog={item} />} |
|
|
|
<FlatList |
|
|
|
keyExtractor={(item) => item.id} |
|
|
|
showsHorizontalScrollIndicator={false} |
|
|
|
/> |
|
|
|
horizontal={true} |
|
|
|
<Header title={"از دنیای آموزش"} /> |
|
|
|
inverted={true} |
|
|
|
<Target blogs={blogs.slice(0, 3)} /> |
|
|
|
style={[tw("flex flex-row mt-3 pb-3")]} |
|
|
|
</ScrollView> |
|
|
|
data={blogs.slice(0, 7)} |
|
|
|
|
|
|
|
renderItem={({ item }) => <New blog={item} />} |
|
|
|
|
|
|
|
keyExtractor={(item) => item.id} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<Header title={"پیشنهاد سردبیر"} /> |
|
|
|
|
|
|
|
<FlatList |
|
|
|
|
|
|
|
showsHorizontalScrollIndicator={false} |
|
|
|
|
|
|
|
horizontal={true} |
|
|
|
|
|
|
|
inverted={true} |
|
|
|
|
|
|
|
style={[tw("flex flex-row mt-3 pb-3")]} |
|
|
|
|
|
|
|
data={blogs.slice(0, 7)} |
|
|
|
|
|
|
|
renderItem={({ item }) => <New blog={item} />} |
|
|
|
|
|
|
|
keyExtractor={(item) => item.id} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<Header title={"از دنیای آموزش"} /> |
|
|
|
|
|
|
|
<Target blogs={blogs.slice(0, 3)} /> |
|
|
|
|
|
|
|
</ScrollView> |
|
|
|
|
|
|
|
)} |
|
|
|
</SafeAreaView> |
|
|
|
</SafeAreaView> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const HashtagBlog = ({ blog, theme }) => { |
|
|
|
|
|
|
|
const navigation = useNavigation(); |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<Pressable |
|
|
|
|
|
|
|
style={[tw("w-full flex pb-4 mb-4")]} |
|
|
|
|
|
|
|
onPress={() => navigation.push("Blog", { id: blog?.id })} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Image |
|
|
|
|
|
|
|
source={{ uri: `https://dnvn.ir/api/v1/file/${blog?.fileIds}` }} |
|
|
|
|
|
|
|
resizeMode="contain" |
|
|
|
|
|
|
|
style={[ |
|
|
|
|
|
|
|
tw("rounded-sm"), |
|
|
|
|
|
|
|
{ width: "100%", height: ((width - 32) * 3) / 4 }, |
|
|
|
|
|
|
|
]} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<Text |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
fontSize: fontSize.lg, |
|
|
|
|
|
|
|
fontFamily: "bold", |
|
|
|
|
|
|
|
color: |
|
|
|
|
|
|
|
theme === "light" ? Colors.theme1.gray20 : Colors.theme1.grayF9, |
|
|
|
|
|
|
|
marginTop: 5, |
|
|
|
|
|
|
|
textAlign: ios ? "right" : "auto", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{blog?.title} |
|
|
|
|
|
|
|
</Text> |
|
|
|
|
|
|
|
</Pressable> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
const mapStateToProps = (state) => ({ |
|
|
|
blogs: state.blog.list, |
|
|
|
blogs: state.blog.list, |
|
|
|
|
|
|
|
hashtag: state.blog.hashtag, |
|
|
|
|
|
|
|
theme : state.publicApi.theme |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
|
getList: blog.list, |
|
|
|
getList: blog.list, |
|
|
|
|
|
|
|
setHashtag: blog.setHashtag, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Blogs); |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Blogs); |
|
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
const styles = StyleSheet.create({ |
|
|
|
contentContainerStyle: { |
|
|
|
contentContainerStyle: { |
|
|
|
paddingBottom: 80, |
|
|
|
paddingBottom: height / 4, |
|
|
|
paddingTop : 30 |
|
|
|
paddingTop: 0, |
|
|
|
}, |
|
|
|
}, |
|
|
|
container: { |
|
|
|
container: { |
|
|
|
paddingVertical: 0, |
|
|
|
paddingVertical: 0, |
|
|
|