| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import React from "react";
- import { View, Text, Image, TouchableOpacity, StyleSheet } from "react-native";
- import { globalStyles } from "@styles/global";
- import { windowWidth } from "@utils/Dimensions";
- import { useTheme } from "@styles";
- import { useTranslation } from "react-i18next";
-
- const ListItem = ({ photo, title, onPress, publishedAt }) => {
- const { colors } = useTheme();
- const { t } = useTranslation();
- 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: colors.textPrimary,
- fontFamily: "poppins-regular",
- fontSize: 14,
- textTransform: "uppercase",
- }}
- >
- {title}
- </Text>
- <Text
- style={{
- color: colors.textPrimary,
- fontFamily: "poppins-regular",
- fontSize: 14,
- textTransform: "uppercase",
- }}
- >
- Published At {formatDate(publishedAt)}
- </Text>
- </View>
- </View>
- <TouchableOpacity style={globalStyles.button} onPress={onPress}>
- <Text style={styles.buttonText}>{t('common.readMore')}</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;
|