import moment from 'moment'; import React from 'react'; import { FlatList, StyleSheet, Text, View } from 'react-native'; import { Strings } from '../../resources/localization/Strings'; import { ICallLogInfo } from '../../store/callLogs/types'; import { Header } from '../common/Header'; import { IImageButtonStyleProps } from '../common/types'; import { CallStateImageView } from './CallStateImageView'; import { CallHistoryNavigationProp, CallHistoryRouteProp } from '../../RootStackParamList'; import { Divider, useTheme } from 'react-native-paper'; interface IProps { navigation: CallHistoryNavigationProp; route: CallHistoryRouteProp } const defaultButtonStyle: IImageButtonStyleProps = { image: { width: 30, height: 30, }, }; export const CallHistory: React.FunctionComponent = ({ route }) => { const callLog = route.params.callLog; const ListEmpty = () => { return ( {Strings.noDataFound} ); }; const formatCallDate = (dateInput: number | string ) => { // if (!dateInput) return ' '; const dateString = String(dateInput); // Check if it's a Unix timestamp (from Android) if (!isNaN(Number(dateString))) { return moment(Number(dateString)).format('MMM DD, YYYY'); } // Handle iOS format: "Thu Oct 03 09:43:07 2024" return moment(dateString, 'ddd MMM DD HH:mm:ss YYYY').format('MMM DD, YYYY'); }; const renderCallHistory = ({ item }: { item: ICallLogInfo }) => { return ( {item.state} Call {item.duration != null ? ( - {item.duration} ) : null} {formatCallDate(item.date)} ) }; const keyExtractor = (callLogItem: ICallLogInfo) => { return callLogItem.date; }; const renderCenterHeader = () => { return {callLog.contact.name}; } return ( < >
); }; const styles = StyleSheet.create({ center: { justifyContent: 'center', alignItems: 'center', flex: 1, }, container: { paddingLeft: 16, paddingRight: 20, paddingVertical: 8, borderBottomWidth: 0, // React Native Paper doesn't use borderBottomWidth }, row: { flexDirection: 'row', justifyContent: 'space-between', width: '100%', }, callStateContainer: { flexDirection: 'row', alignItems: 'center', }, infoContainer: { justifyContent: 'center', marginLeft: 16, }, infoRow: { flexDirection: 'row', justifyContent: 'flex-start', }, callText: { fontSize: 14, // Adjust font size as needed }, dateText: { fontSize: 14, // Adjust font size as needed }, headerText: { fontSize :16, color: 'white', marginHorizontal :5 } });