You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PostDetailsScreen.jsx 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React, { useEffect, useState } from "react";
  2. import { Text, Image, StyleSheet } from "react-native";
  3. import { globalStyles } from "@styles/global";
  4. import { windowWidth } from "@utils/Dimensions";
  5. import Layout from "@components/Layout/Layout";
  6. import { useTheme } from "@styles";
  7. import { useSinglePostQuery } from "@features/posts/postsApiSlice";
  8. import Loader from "@components/Loader";
  9. const PostDetailsScreen = ({ navigation, route }) => {
  10. const { colors } = useTheme();
  11. const { data: post, isLoading } = useSinglePostQuery(route.params.id);
  12. return (
  13. <Layout>
  14. {isLoading ? (
  15. <Loader visible={isLoading} />
  16. ) : (
  17. <>
  18. <Image
  19. style={styles.image}
  20. source={{
  21. uri: `https://strapi.dilig.net${post.data?.attributes?.profileImage.data.attributes.url}`,
  22. }}
  23. />
  24. <Text
  25. style={[
  26. globalStyles.boldText,
  27. styles.title,
  28. { color: colors.textPrimary },
  29. ]}
  30. >
  31. {post?.data?.attributes?.title}
  32. </Text>
  33. <Text
  34. style={[
  35. globalStyles.regularText,
  36. styles.description,
  37. { color: colors.textPrimary },
  38. ]}
  39. >
  40. {post?.data?.attributes?.description}
  41. </Text>
  42. </>
  43. )}
  44. </Layout>
  45. );
  46. };
  47. const styles = StyleSheet.create({
  48. image: {
  49. width: windowWidth,
  50. height: 300,
  51. },
  52. title: {
  53. marginTop: 20,
  54. textAlign: "center",
  55. },
  56. description: {
  57. marginHorizontal: 20,
  58. },
  59. });
  60. export default PostDetailsScreen;