tooot/src/screens/Tabs/Notifications.tsx

72 lines
2.3 KiB
TypeScript
Raw Normal View History

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'
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'
import React, { useCallback, useMemo } from 'react'
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
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-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-03-17 15:30:28 +01:00
[i18n.language]
)
2021-02-27 16:33:54 +01:00
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Notifications' }]
const renderItem = useCallback(
({ item }) => (
<TimelineNotifications notification={item} queryKey={queryKey} />
),
[]
)
const children = useCallback(
2021-03-01 00:28:14 +01:00
() => <Timeline queryKey={queryKey} customProps={{ renderItem }} />,
[]
)
2020-10-30 20:03:44 +01:00
return (
<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 })}
</Stack.Navigator>
)
},
() => true
)
2020-10-31 21:04:46 +01:00
2021-01-30 01:29:15 +01:00
export default TabNotifications