tooot/src/screens/Tabs/Notifications.tsx

74 lines
2.2 KiB
TypeScript
Raw Normal View History

2021-03-17 15:30:28 +01:00
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'
2022-11-14 15:54:51 +01:00
import usePopToTop from '@utils/navigation/usePopToTop'
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'
2022-11-20 16:14:08 +01:00
import TabShared from './Shared'
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' && {
2022-11-14 15:54:51 +01:00
headerCenter: () => <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'
2022-11-29 23:44:11 +01:00
onPress={() =>
2021-08-29 15:25:38 +02:00
navigationRef.navigate('Screen-Actions', {
2021-03-17 15:30:28 +01:00
type: 'notifications_filter'
})
2022-11-29 23:44:11 +01:00
}
2021-03-17 15:30:28 +01:00
/>
)
}),
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 children = useCallback(
2022-08-07 01:18:10 +02:00
() => (
<Timeline
queryKey={queryKey}
customProps={{
renderItem: ({ item }) => (
<TimelineNotifications notification={item} queryKey={queryKey} />
)
}}
/>
),
[]
)
2020-10-30 20:03:44 +01:00
2022-11-14 15:54:51 +01:00
usePopToTop()
return (
<Stack.Navigator screenOptions={{ headerShadowVisible: false }}>
2021-03-17 15:30:28 +01:00
<Stack.Screen
name='Tab-Notifications-Root'
children={children}
options={screenOptionsRoot}
/>
2022-11-20 16:14:08 +01:00
{TabShared({ Stack })}
</Stack.Navigator>
)
},
() => true
)
2020-10-31 21:04:46 +01:00
2021-01-30 01:29:15 +01:00
export default TabNotifications