import moment from 'moment'; import React from 'react'; import { FlatList, ImageStyle, Platform, RefreshControl, Text, TextStyle, View, ViewStyle, } from 'react-native'; import { Strings } from '../../resources/localization/Strings'; import { ICallLog } from '../../store/callLogs/types'; import { ImageButton } from '../common/ImageButton'; import { IImageButtonStyleProps, IStyledProps } from '../common/types'; import { AvatarPresenceBadge } from '../presence/AvatarPresenceBadge'; import { CallStateImageView } from './CallStateImageView'; import { Divider, TouchableRipple } from 'react-native-paper'; import infoIcon from '../../resources/images/infoIcon.png'; import { useNavigation } from '@react-navigation/native'; interface ICallLogActionsProps extends IStyledProps { callLogs: ICallLog[]; loading: boolean; refreshData: () => void; onClickCallLogAction?: (callLog: ICallLog) => void; } interface ICallLogViewStyleProps { noDataMessage?: ViewStyle; bodyContainer?: ViewStyle; noDataMessageText?: TextStyle; callIDate?: ViewStyle; presenceIcon?: ImageStyle; testText?: TextStyle; } const defaultButtonStyle: IImageButtonStyleProps = { image: { width: 22, height: 22, }, }; export const CallLogsView: React.FunctionComponent = React.memo( ({ callLogs, loading, refreshData, style, onClickCallLogAction }) => { const mergedStyle = { ...defaultStyle, ...style }; const navigation = useNavigation(); const ListEmpty = () => { return ( {Strings.noDataFound} ); }; const renderCallLogsList = ({ item }: { item: ICallLog }) => { const goToCallLog = (item: ICallLog) => { navigation.navigate('CallHistory', { callLog: item }) } return ( onClickCallLogAction(item) : undefined}> {item.contact.name} {Strings[item.contact.presence]} {item.lastCall && ( {moment(item.lastCall.date, 'ddd MMM DD HH:mm:ss YYYY').format('MMM DD, YYYY')} )} goToCallLog(item)} /> ); }; const contentStyle: ViewStyle = Platform.OS === 'ios' ? { paddingBottom: 120 } : { paddingBottom: 0 }; return ( index.toString()} contentContainerStyle={contentStyle} refreshControl={ } nestedScrollEnabled={true} /> ); } ); const defaultStyle: ICallLogViewStyleProps = { noDataMessage: { justifyContent: 'center', flex: 1, marginTop: 100, }, noDataMessageText: { textAlign: 'center', fontSize: 10, }, };