import React, { useLayoutEffect, useState } from 'react';
import {
View,
Text,
FlatList,
TouchableOpacity,
StatusBar,
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
import Icon from 'react-native-vector-icons/Ionicons';
import { useTheme } from '../../theme';
import { getStyles } from './notification.styles';
import { INITIAL_NOTIFICATIONS } from '@mock-data';
export const NotificationScreen = () => {
const navigation = useNavigation();
const { theme: colors } = useTheme();
const styles = getStyles(colors);
const [notifications, setNotifications] = useState(INITIAL_NOTIFICATIONS);
// Mark all as read header button action
const handleMarkAllRead = () => {
setNotifications(prev =>
prev.map(item => ({ ...item, unread: false }))
);
};
useLayoutEffect(() => {
navigation.setOptions({
headerTitle: 'Notifications',
headerRight: () => {
const hasUnread = notifications.some(n => n.unread);
if (!hasUnread) return null;
return (
Read All
);
},
});
}, [navigation, notifications, styles]);
const toggleSingleRead = (id: string) => {
setNotifications(prev =>
prev.map(item =>
item.id === id ? { ...item, unread: !item.unread } : item
)
);
};
const renderItem = ({ item }: { item: typeof INITIAL_NOTIFICATIONS[0] }) => {
return (
toggleSingleRead(item.id)}
>
{/* Left Side Styled Icon Circle */}
{/* Content Section */}
{item.title}
{item.unread && }
{item.description}
{item.time}
);
};
return (
{/* */}
{notifications.length > 0 ? (
item.id}
renderItem={renderItem}
contentContainerStyle={styles.listContent}
showsVerticalScrollIndicator={false}
/>
) : (
All caught up!
When you get new updates or alerts, they will show up here.
)}
);
};