Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import React from "react";
  2. import { View, Text, Image, TouchableOpacity, StyleSheet } from "react-native";
  3. import { globalStyles } from "../../styles/global";
  4. import { windowWidth } from "../../utils/Dimensions";
  5. const ListItem = ({ photo, title, onPress, publishedAt }) => {
  6. const formatDate = (date) => {
  7. const tempDate = new Date(date);
  8. const fDate =
  9. tempDate.getDate() +
  10. "/" +
  11. (tempDate.getMonth() + 1) +
  12. "/" +
  13. tempDate.getFullYear();
  14. return fDate;
  15. };
  16. return (
  17. <View style={styles.cardContainer}>
  18. <View style={styles.imageContainer}>
  19. <Image
  20. style={styles.image}
  21. source={{ uri: `http://localhost:1337${photo.small.url}` }}
  22. />
  23. <View style={{ width: windowWidth - 220 }}>
  24. <Text
  25. style={{
  26. color: "#333",
  27. fontFamily: "poppins-regular",
  28. fontSize: 14,
  29. textTransform: "uppercase",
  30. }}
  31. >
  32. {title}
  33. </Text>
  34. <Text
  35. style={{
  36. color: "#333",
  37. fontFamily: "poppins-regular",
  38. fontSize: 14,
  39. textTransform: "uppercase",
  40. }}
  41. >
  42. Published At {formatDate(publishedAt)}
  43. </Text>
  44. </View>
  45. </View>
  46. <TouchableOpacity style={globalStyles.button} onPress={onPress}>
  47. <Text style={styles.buttonText}>Read More</Text>
  48. </TouchableOpacity>
  49. </View>
  50. );
  51. };
  52. const styles = StyleSheet.create({
  53. cardContainer: {
  54. flexDirection: "row",
  55. justifyContent: "space-between",
  56. alignItems: "center",
  57. marginBottom: 20,
  58. },
  59. imageContainer: {
  60. flexDirection: "row",
  61. alignItems: "center",
  62. flex: 1,
  63. },
  64. image: {
  65. width: 55,
  66. height: 55,
  67. borderRadius: 10,
  68. marginRight: 8,
  69. },
  70. buttonText: {
  71. color: "#fff",
  72. textAlign: "center",
  73. fontFamily: "poppins-regular",
  74. fontSize: 14,
  75. },
  76. });
  77. export default ListItem;