import type { ConversationSummary } from '@chat-app/shared/chat'; import { Pressable, StyleSheet, Text, View } from 'react-native'; import { formatRelativeTime } from '../lib/timeFormat'; import { colors } from '../theme/colors'; import { Avatar } from './Avatar'; interface Props { conversation: ConversationSummary; lastMessagePreview: string; onPress: () => void; } export function ConversationRow({ conversation, lastMessagePreview, onPress }: Props) { const title = conversation.type === 'group' ? (conversation.name ?? 'Gruppe') : (conversation.peer?.displayName ?? '—'); const subtitle = conversation.type === 'group' ? conversation.members.length + ' Mitglieder' : '@' + (conversation.peer?.username ?? ''); return ( [styles.row, pressed && { backgroundColor: colors.surface }]} onPress={onPress} > {title} {formatRelativeTime(conversation.lastMessageAt)} {lastMessagePreview || subtitle} ); } const styles = StyleSheet.create({ row: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 16, paddingVertical: 12, gap: 12, }, center: { flex: 1, minWidth: 0 }, titleLine: { flexDirection: 'row', alignItems: 'baseline', gap: 8 }, title: { color: colors.text, fontSize: 15, fontWeight: '600', flex: 1 }, time: { color: colors.textDim, fontSize: 11 }, preview: { color: colors.textMuted, fontSize: 13, marginTop: 2 }, });