import { useEffect } from 'react';
import { View, Text, FlatList, Pressable, RefreshControl } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useRouter } from 'expo-router';
import { Ionicons } from '@expo/vector-icons';
import { HeroShieldCheck } from '../../components/HeroShieldCheck';
import { useTranslation } from 'react-i18next';
import { EmptyState } from '../../components/EmptyState';
import { useNotificationStore, type AppNotification } from '../../stores/notifications';
import { colors } from '../../lib/theme';
export default function NotificationsScreen() {
const router = useRouter();
const { t } = useTranslation();
const items = useNotificationStore((s) => s.items);
const loaded = useNotificationStore((s) => s.loaded);
const load = useNotificationStore((s) => s.load);
const markRead = useNotificationStore((s) => s.markRead);
const remove = useNotificationStore((s) => s.remove);
useEffect(() => {
load();
const tm = setTimeout(() => {
markRead();
}, 400);
return () => clearTimeout(tm);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
router.back()}
className="w-9 h-9 rounded-full bg-neutral-100 border border-neutral-200 items-center justify-center"
>
{t('notifications.title')}
{items.length === 0 ? (
) : (
n.id}
contentContainerStyle={{ paddingVertical: 8 }}
refreshControl={
}
renderItem={({ item }) => (
{
if (item.postId) {
router.push(`/?postId=${item.postId}` as never);
}
}}
onDelete={() => remove(item.id)}
/>
)}
/>
)}
);
}
function NotificationRow({
notif,
onPress,
onDelete,
}: {
notif: AppNotification;
onPress: () => void;
onDelete: () => void;
}) {
const isUnread = !notif.readAt;
return (
({
opacity: pressed ? 0.7 : 1,
backgroundColor: isUnread ? '#fff7ed' : '#fff',
})}
>
{/* Pure-Icon — KEIN bg-Circle (User-Wunsch: kein extra Rand). */}
{notif.type === 'domain_accepted' ? (
) : (
)}
{notif.actorName}
{notif.preview && (
{notif.preview}
)}
);
}
function iconForType(type: string): React.ComponentProps['name'] {
if (type.includes('like')) return 'heart';
if (type.includes('comment')) return 'chatbubble';
if (type.includes('follow')) return 'person-add';
if (type.includes('domain')) return 'shield-checkmark';
return 'notifications';
}