import React, { useState } from 'react'; import { View, Text, TouchableOpacity, TextInput, StyleSheet, ScrollView, Modal } from 'react-native'; import Icon from 'react-native-vector-icons/Feather'; import { Switch } from 'react-native'; // Simple Avatar component const Avatar = ({ name }: { name: string }) => ( {name[0]} ); const formatDistanceToNow = (date: Date) => { const now = new Date(); const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000); if (diffInSeconds < 60) return 'just now'; if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)} minutes ago`; if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)} hours ago`; if (diffInSeconds < 2592000) return `${Math.floor(diffInSeconds / 86400)} days ago`; if (diffInSeconds < 31536000) return `${Math.floor(diffInSeconds / 2592000)} months ago`; return `${Math.floor(diffInSeconds / 31536000)} years ago`; }; // Simple Separator component const Separator = () => ; // Simple Tooltip component (placeholder) const Tooltip = ({ content, children }: { content: string; children: React.ReactNode }) => ( {children} {/* Implement tooltip logic here */} ); // Simple Calendar component (placeholder) const Calendar = () => ( Calendar Placeholder ); // Helper function to format date const formatDate = (date: Date) => { return date.toLocaleString('en-US', { weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', hour12: true, }); }; // Helper function to add hours to a date const addHours = (date: Date, hours: number) => { const newDate = new Date(date); newDate.setHours(date.getHours() + hours); return newDate; }; // Helper function to add days to a date const addDays = (date: Date, days: number) => { const newDate = new Date(date); newDate.setDate(date.getDate() + days); return newDate; }; // Helper function to get next Saturday const nextSaturday = (date: Date) => { const newDate = new Date(date); newDate.setDate(date.getDate() + ((6 - date.getDay() + 7) % 7)); return newDate; }; // Define Mail type interface Mail { name: string; subject: string; email: string; date: string; text: string; } interface MailDisplayProps { mail: Mail | null; } export function MailDisplay({ mail }: MailDisplayProps) { const [isPopoverVisible, setIsPopoverVisible] = useState(false); const today = new Date(); const renderToolbarButton = (icon: string, label: string, onPress: () => void) => ( ); return ( {renderToolbarButton('archive', 'Archive', () => {})} {renderToolbarButton('x-square', 'Move to junk', () => {})} {renderToolbarButton('trash-2', 'Move to trash', () => {})} setIsPopoverVisible(true)} disabled={!mail} > {renderToolbarButton('reply', 'Reply', () => {})} {renderToolbarButton('reply-all', 'Reply all', () => {})} {renderToolbarButton('corner-up-right', 'Forward', () => {})} {mail ? ( {mail.name} {mail.subject} Reply-To: {mail.email} {mail.date && ( {formatDate(new Date(mail.date))} )} {mail.text} Mute this thread Send ) : ( No message selected )} setIsPopoverVisible(false)} > Snooze until Later today {formatDate(addHours(today, 4))} Tomorrow {formatDate(addDays(today, 1))} This weekend {formatDate(nextSaturday(today))} Next week {formatDate(addDays(today, 7))} ); } const styles = StyleSheet.create({ container: { flex: 1, }, toolbar: { flexDirection: 'row', justifyContent: 'space-between', padding: 8, }, toolbarGroup: { flexDirection: 'row', }, toolbarButton: { padding: 8, }, mailContent: { flex: 1, }, mailHeader: { flexDirection: 'row', justifyContent: 'space-between', padding: 16, }, mailSender: { flexDirection: 'row', }, mailSenderInfo: { marginLeft: 16, }, mailSenderName: { fontWeight: 'bold', }, mailSubject: { fontSize: 12, }, mailReplyTo: { fontSize: 12, }, mailReplyToLabel: { fontWeight: 'bold', }, mailDate: { fontSize: 12, color: '#666', }, mailBody: { padding: 16, fontSize: 14, }, replyForm: { padding: 16, }, replyInput: { borderWidth: 1, borderColor: '#ccc', borderRadius: 4, padding: 8, minHeight: 100, }, replyFormFooter: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginTop: 8, }, muteThreadContainer: { flexDirection: 'row', alignItems: 'center', }, muteThreadLabel: { marginLeft: 8, fontSize: 12, }, sendButton: { backgroundColor: '#007AFF', padding: 8, borderRadius: 4, }, sendButtonText: { color: '#fff', }, noMailSelected: { flex: 1, justifyContent: 'center', alignItems: 'center', }, modalOverlay: { flex: 1, backgroundColor: 'rgba(0, 0, 0, 0.5)', justifyContent: 'center', alignItems: 'center', }, modalContent: { backgroundColor: '#fff', padding: 16, borderRadius: 8, width: '80%', }, modalTitle: { fontSize: 18, fontWeight: 'bold', marginBottom: 16, }, snoozeOption: { flexDirection: 'row', justifyContent: 'space-between', paddingVertical: 8, }, snoozeTime: { color: '#666', }, avatar: { width: 40, height: 40, borderRadius: 20, backgroundColor: '#ccc', justifyContent: 'center', alignItems: 'center', }, avatarText: { fontSize: 18, color: '#fff', }, separator: { height: 1, backgroundColor: '#e0e0e0', marginVertical: 8, }, });