Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

PostDetailsScreen.jsx 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React, { useContext, useEffect, useState } from "react";
  2. import { View, Text, Image, StyleSheet } from "react-native";
  3. import { getRequest } from "../request";
  4. import { globalStyles } from "../styles/global";
  5. import { windowWidth } from "../utils/Dimensions";
  6. const PostDetailsScreen = ({ navigation, route }) => {
  7. const [post, setPost] = useState({});
  8. const fetchPost = async () => {
  9. const { data } = await getRequest(`api/posts/${route.params.id}?populate=*`);
  10. if (data) {
  11. setPost(data.data);
  12. }
  13. };
  14. useEffect(() => {
  15. fetchPost();
  16. }, []);
  17. return (
  18. <View style={{ flex: 1 }}>
  19. <Image
  20. style={styles.image}
  21. source={{
  22. uri: `http://localhost:1337${post?.attributes?.profileImage.data.attributes.url}`,
  23. }}
  24. />
  25. <Text style={[globalStyles.boldText, styles.title]}>
  26. {post?.attributes?.title}
  27. </Text>
  28. <Text style={[globalStyles.regularText ,styles.description]}>{post?.attributes?.description}</Text>
  29. </View>
  30. );
  31. };
  32. const styles = StyleSheet.create({
  33. image: {
  34. width: windowWidth,
  35. height: 300,
  36. },
  37. title: {
  38. marginTop: 20,
  39. textAlign: "center",
  40. },
  41. description: {
  42. marginHorizontal: 20
  43. }
  44. });
  45. export default PostDetailsScreen;