Add: - components/Notification/ - hooks/use-notification-store.tsx.back Fix: - app.config.js - app/(application)/(user)/_layout.tsx - app/(application)/(user)/home.tsx - app/(application)/(user)/test-notifications.tsx - app/(application)/_layout.tsx - app/_layout.tsx - components/_Icon/IconComponent.tsx - components/_Icon/IconPlus.tsx - components/_ShareComponent/NotificationInitializer.tsx - context/AuthContext.tsx - hooks/use-notification-store.tsx - ios/HIPMIBadungConnect/Info.plist - screens/Home/HeaderBell.tsx - service/api-device-token.ts - service/api-notifications.ts ### No Issue
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
// components/HeaderBell.tsx
|
|
import { MainColor } from "@/constants/color-palet";
|
|
import { useNotificationStore } from "@/hooks/use-notification-store";
|
|
import { Ionicons } from "@expo/vector-icons";
|
|
import { router } from "expo-router";
|
|
import { useEffect } from "react";
|
|
import { Text, View } from "react-native";
|
|
|
|
export default function HeaderBell() {
|
|
const { notifications , unreadCount} = useNotificationStore();
|
|
// console.log("NOTIF:", JSON.stringify(notifications, null, 2));
|
|
|
|
return (
|
|
<View style={{ position: "relative" }}>
|
|
<Ionicons
|
|
name="notifications"
|
|
size={20}
|
|
color={MainColor.yellow}
|
|
onPress={() => {
|
|
router.push("/notifications");
|
|
}}
|
|
/>
|
|
{unreadCount > 0 && (
|
|
<View
|
|
style={{
|
|
position: "absolute",
|
|
top: -4,
|
|
right: -4,
|
|
backgroundColor: "red",
|
|
borderRadius: 8,
|
|
minWidth: 16,
|
|
height: 16,
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
paddingHorizontal: 2,
|
|
}}
|
|
>
|
|
<Text style={{ color: "white", fontSize: 10, fontWeight: "bold" }}>
|
|
{unreadCount > 9 ? "9+" : unreadCount}
|
|
</Text>
|
|
</View>
|
|
)}
|
|
</View>
|
|
);
|
|
}
|