import HeaderRightAnnouncementList from "@/components/announcement/headerAnnouncementList"; import ButtonBackHeader from "@/components/buttonBackHeader"; import HeaderDiscussionGeneral from "@/components/discussion_general/headerDiscussionGeneral"; import HeaderRightDivisionList from "@/components/division/headerDivisionList"; import HeaderRightGroupList from "@/components/group/headerGroupList"; import HeaderMemberList from "@/components/member/headerMemberList"; import HeaderRightPositionList from "@/components/position/headerRightPositionList"; import HeaderRightProjectList from "@/components/project/headerProjectList"; import { Headers } from "@/constants/Headers"; import { apiReadOneNotification } from "@/lib/api"; import { pushToPage } from "@/lib/pushToPage"; import store from "@/lib/store"; import { useAuthSession } from "@/providers/AuthProvider"; import messaging from "@react-native-firebase/messaging"; import { Redirect, router, Stack } from "expo-router"; import { StatusBar } from 'expo-status-bar'; import { useEffect } from "react"; import { Text } from "react-native"; import { Easing, Notifier } from 'react-native-notifier'; import { Provider } from "react-redux"; export default function RootLayout() { const { token, decryptToken, isLoading } = useAuthSession() async function handleReadNotification(id: string, category: string, idContent: string) { try { const hasil = await decryptToken(String(token?.current)) const response = await apiReadOneNotification({ user: hasil, id: id }) pushToPage(category, idContent) } catch (error) { console.error(error) } } useEffect(() => { const unsubscribe = messaging().onMessage(async remoteMessage => { const id = remoteMessage?.data?.id; const category = remoteMessage?.data?.category; const content = remoteMessage?.data?.content; if (remoteMessage.notification != undefined && remoteMessage.notification.title != undefined && remoteMessage.notification.body != undefined) { Notifier.showNotification({ title: remoteMessage.notification?.title, description: remoteMessage.notification?.body, duration: 3000, animationDuration: 300, showEasing: Easing.ease, onPress: () => handleReadNotification(String(id), String(category), String(content)), hideOnPress: true, }); } }); return unsubscribe; }, []); if (isLoading) { return Loading...; } if (!token?.current) { return ; } return ( { router.back() }} />, headerTitle: 'Notifikasi', headerTitleAlign: 'center' }} /> { router.back() }} />, title: 'Anggota', headerTitleAlign: 'center', headerRight: () => }} /> { router.back() }} />, title: 'Diskusi Umum', headerTitleAlign: 'center', headerRight: () => }} /> { router.back() }} />, title: 'Kegiatan', headerTitleAlign: 'center', headerRight: () => }} /> { router.back() }} />, title: 'Divisi', headerTitleAlign: 'center', headerRight: () => }} /> { router.back() }} />, headerTitle: 'Lembaga Desa', headerTitleAlign: 'center', headerRight: () => }} /> { router.back() }} />, headerTitle: 'Jabatan', headerTitleAlign: 'center', headerRight: () => }} /> { router.back() }} />, headerTitle: 'Pengumuman', headerTitleAlign: 'center', headerRight: () => }} /> ) }