| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import React from "react";
- import { View, Text, Image, TouchableOpacity, StyleSheet } from "react-native";
- import { globalStyles } from "../../styles/global";
- import { windowWidth } from "../../utils/Dimensions";
-
- const ListItem = ({ photo, title, onPress, publishedAt }) => {
- const formatDate = (date) => {
- const tempDate = new Date(date);
- const fDate =
- tempDate.getDate() +
- "/" +
- (tempDate.getMonth() + 1) +
- "/" +
- tempDate.getFullYear();
-
- return fDate;
- };
-
- return (
- <View style={styles.cardContainer}>
- <View style={styles.imageContainer}>
- <Image
- style={styles.image}
- source={{ uri: `http://localhost:1337${photo.small.url}` }}
- />
- <View style={{ width: windowWidth - 220 }}>
- <Text
- style={{
- color: "#333",
- fontFamily: "poppins-regular",
- fontSize: 14,
- textTransform: "uppercase",
- }}
- >
- {title}
- </Text>
- <Text
- style={{
- color: "#333",
- fontFamily: "poppins-regular",
- fontSize: 14,
- textTransform: "uppercase",
- }}
- >
- Published At {formatDate(publishedAt)}
- </Text>
- </View>
- </View>
- <TouchableOpacity style={globalStyles.button} onPress={onPress}>
- <Text style={styles.buttonText}>Read More</Text>
- </TouchableOpacity>
- </View>
- );
- };
-
- const styles = StyleSheet.create({
- cardContainer: {
- flexDirection: "row",
- justifyContent: "space-between",
- alignItems: "center",
- marginBottom: 20,
- },
- imageContainer: {
- flexDirection: "row",
- alignItems: "center",
- flex: 1,
- },
- image: {
- width: 55,
- height: 55,
- borderRadius: 10,
- marginRight: 8,
- },
- buttonText: {
- color: "#fff",
- textAlign: "center",
- fontFamily: "poppins-regular",
- fontSize: 14,
- },
- });
-
- export default ListItem;
|