import React, { useEffect, useState } from 'react'; import { View, Text, TouchableOpacity, Image, StyleSheet } from 'react-native'; import Icon from 'react-native-vector-icons/FontAwesome6'; import { useNavigation } from '@react-navigation/native'; import { StackNavigationProp } from '@react-navigation/stack'; import firestore from '@react-native-firebase/firestore'; type RootStackParamList = { MainTabs: undefined; Notifikasi: undefined; }; type NavigationProps = StackNavigationProp; const Header: React.FC = () => { const navigation = useNavigation(); const [notificationCount, setNotificationCount] = useState(0); useEffect(() => { const unsubscribe = firestore() .collection('notifications') .onSnapshot(snapshot => { setNotificationCount(snapshot.size); // total notifikasi }); return () => unsubscribe(); }, []); return ( HYDROZONER PKM-KC 2024 navigation.navigate('Notifikasi')} > {notificationCount > 0 && ( {notificationCount > 99 ? '99+' : notificationCount} )} ); }; const styles = StyleSheet.create({ container: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', paddingHorizontal: 20, paddingVertical: 15, backgroundColor: '#FFFFFF', }, logoContainer: { flexDirection: 'row', alignItems: 'center', }, logo: { width: 45, height: 45, resizeMode: 'contain', marginRight: 10, }, title: { fontSize: 12, fontWeight: 'bold', color: '#0F172A', }, menuButton: { padding: 10, position: 'relative', }, badge: { position: 'absolute', right: 4, top: 4, backgroundColor: 'red', borderRadius: 8, minWidth: 16, height: 16, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 3, }, badgeText: { color: 'white', fontSize: 10, fontWeight: 'bold', }, }); export default Header;