2021-03-17 15:30:28 +01:00
|
|
|
import analytics from '@components/analytics'
|
|
|
|
import { HeaderCenter, HeaderRight } from '@components/Header'
|
2021-02-08 23:47:20 +01:00
|
|
|
import Timeline from '@components/Timeline'
|
2021-02-27 16:33:54 +01:00
|
|
|
import TimelineNotifications from '@components/Timeline/Notifications'
|
2021-08-29 15:25:38 +02:00
|
|
|
import navigationRef from '@helpers/navigationRef'
|
2021-08-21 01:45:43 +02:00
|
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
2021-08-29 15:25:38 +02:00
|
|
|
import { TabNotificationsStackParamList } from '@utils/navigation/navigators'
|
2021-02-27 16:33:54 +01:00
|
|
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
2021-02-08 23:19:55 +01:00
|
|
|
import React, { useCallback, useMemo } from 'react'
|
2020-11-29 13:11:23 +01:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2021-03-01 00:28:14 +01:00
|
|
|
import { Platform } from 'react-native'
|
2021-08-29 15:25:38 +02:00
|
|
|
import TabSharedRoot from './Shared/Root'
|
2020-10-24 18:07:09 +02:00
|
|
|
|
2021-08-29 15:25:38 +02:00
|
|
|
const Stack = createNativeStackNavigator<TabNotificationsStackParamList>()
|
2020-10-23 09:22:17 +02:00
|
|
|
|
2021-02-08 23:19:55 +01:00
|
|
|
const TabNotifications = React.memo(
|
|
|
|
() => {
|
2021-03-28 23:31:10 +02:00
|
|
|
const { t, i18n } = useTranslation('screenTabs')
|
2020-10-24 18:07:09 +02:00
|
|
|
|
2021-03-17 15:30:28 +01:00
|
|
|
const screenOptionsRoot = useMemo(
|
2021-02-08 23:19:55 +01:00
|
|
|
() => ({
|
2021-12-18 23:44:08 +01:00
|
|
|
title: t('tabs.notifications.name'),
|
2021-01-14 00:43:35 +01:00
|
|
|
...(Platform.OS === 'android' && {
|
|
|
|
headerCenter: () => (
|
2021-03-28 23:31:10 +02:00
|
|
|
<HeaderCenter content={t('tabs.notifications.name')} />
|
2021-01-14 00:43:35 +01:00
|
|
|
)
|
|
|
|
}),
|
2021-03-17 15:30:28 +01:00
|
|
|
headerRight: () => (
|
|
|
|
<HeaderRight
|
2021-04-09 21:43:12 +02:00
|
|
|
accessibilityLabel={t('notifications.filter.accessibilityLabel')}
|
|
|
|
accessibilityHint={t('notifications.filter.accessibilityHint')}
|
2021-03-17 15:30:28 +01:00
|
|
|
content='Filter'
|
|
|
|
onPress={() => {
|
|
|
|
analytics('notificationsfilter_tap')
|
2021-08-29 15:25:38 +02:00
|
|
|
navigationRef.navigate('Screen-Actions', {
|
2021-03-17 15:30:28 +01:00
|
|
|
type: 'notifications_filter'
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
2021-02-08 23:19:55 +01:00
|
|
|
}),
|
2021-03-17 15:30:28 +01:00
|
|
|
[i18n.language]
|
2021-02-08 23:19:55 +01:00
|
|
|
)
|
2021-02-27 16:33:54 +01:00
|
|
|
|
|
|
|
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Notifications' }]
|
|
|
|
const renderItem = useCallback(
|
|
|
|
({ item }) => (
|
|
|
|
<TimelineNotifications notification={item} queryKey={queryKey} />
|
|
|
|
),
|
|
|
|
[]
|
|
|
|
)
|
2021-02-08 23:19:55 +01:00
|
|
|
const children = useCallback(
|
2021-03-01 00:28:14 +01:00
|
|
|
() => <Timeline queryKey={queryKey} customProps={{ renderItem }} />,
|
2021-02-08 23:19:55 +01:00
|
|
|
[]
|
|
|
|
)
|
2020-10-30 20:03:44 +01:00
|
|
|
|
2021-02-08 23:19:55 +01:00
|
|
|
return (
|
2021-08-21 01:45:43 +02:00
|
|
|
<Stack.Navigator screenOptions={{ headerShadowVisible: false }}>
|
2021-03-17 15:30:28 +01:00
|
|
|
<Stack.Screen
|
|
|
|
name='Tab-Notifications-Root'
|
|
|
|
children={children}
|
|
|
|
options={screenOptionsRoot}
|
|
|
|
/>
|
2021-08-29 15:25:38 +02:00
|
|
|
{TabSharedRoot({ Stack })}
|
2021-02-08 23:19:55 +01:00
|
|
|
</Stack.Navigator>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
() => true
|
|
|
|
)
|
2020-10-31 21:04:46 +01:00
|
|
|
|
2021-01-30 01:29:15 +01:00
|
|
|
export default TabNotifications
|