tooot/src/screens/Tabs/Notifications.tsx

77 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-03-17 15:30:28 +01:00
import { useNavigation } from '@react-navigation/native'
2021-01-30 01:29:15 +01:00
import sharedScreens from '@screens/Tabs/Shared/sharedScreens'
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-01-07 19:13:09 +01:00
import { createNativeStackNavigator } from 'react-native-screens/native-stack'
2020-10-24 18:07:09 +02:00
2021-01-30 01:29:15 +01:00
const Stack = createNativeStackNavigator<Nav.TabNotificationsStackParamList>()
2020-10-23 09:22:17 +02:00
const TabNotifications = React.memo(
() => {
2021-03-17 15:30:28 +01:00
const navigation = useNavigation()
2021-03-28 23:31:10 +02:00
const { t, i18n } = useTranslation('screenTabs')
2020-10-24 18:07:09 +02:00
const screenOptions = useMemo(
2021-03-17 15:30:28 +01:00
() => ({
headerHideShadow: true,
headerTopInsetEnabled: false
}),
[]
)
const screenOptionsRoot = useMemo(
() => ({
2021-03-28 23:31:10 +02:00
headerTitle: 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
content='Filter'
onPress={() => {
analytics('notificationsfilter_tap')
navigation.navigate('Screen-Actions', {
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={screenOptions}>
2021-03-17 15:30:28 +01:00
<Stack.Screen
name='Tab-Notifications-Root'
children={children}
options={screenOptionsRoot}
/>
{sharedScreens(Stack as any)}
</Stack.Navigator>
)
},
() => true
)
2020-10-31 21:04:46 +01:00
2021-01-30 01:29:15 +01:00
export default TabNotifications