2021-01-26 12:17:25 +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 TimelineDefault from '@components/Timeline/Default'
|
2021-08-21 01:45:43 +02:00
|
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack'
|
2021-08-29 15:25:38 +02:00
|
|
|
import {
|
|
|
|
ScreenTabsScreenProps,
|
|
|
|
TabLocalStackParamList
|
|
|
|
} from '@utils/navigation/navigators'
|
2021-02-27 16:33:54 +01:00
|
|
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
2022-01-16 23:26:05 +01:00
|
|
|
import { getInstanceTimelinesLookback } from '@utils/slices/instancesSlice'
|
2021-02-08 23:19:55 +01:00
|
|
|
import React, { useCallback, useMemo } from 'react'
|
2021-01-26 12:17:25 +01:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { Platform } from 'react-native'
|
2022-01-16 23:26:05 +01:00
|
|
|
import { useSelector } from 'react-redux'
|
2021-08-29 15:25:38 +02:00
|
|
|
import TabSharedRoot from './Shared/Root'
|
2021-01-26 12:17:25 +01:00
|
|
|
|
2021-08-29 15:25:38 +02:00
|
|
|
const Stack = createNativeStackNavigator<TabLocalStackParamList>()
|
2021-01-30 01:29:15 +01:00
|
|
|
|
|
|
|
const TabLocal = React.memo(
|
2021-08-29 15:25:38 +02:00
|
|
|
({ navigation }: ScreenTabsScreenProps<'Tab-Local'>) => {
|
2021-03-28 23:31:10 +02:00
|
|
|
const { t, i18n } = useTranslation('screenTabs')
|
2021-01-26 12:17:25 +01:00
|
|
|
|
2021-02-08 23:19:55 +01:00
|
|
|
const screenOptionsRoot = useMemo(
|
|
|
|
() => ({
|
2021-12-18 23:44:08 +01:00
|
|
|
title: t('tabs.local.name'),
|
2021-02-08 23:19:55 +01:00
|
|
|
...(Platform.OS === 'android' && {
|
2021-03-28 23:31:10 +02:00
|
|
|
headerCenter: () => <HeaderCenter content={t('tabs.local.name')} />
|
2021-02-08 23:19:55 +01:00
|
|
|
}),
|
|
|
|
headerRight: () => (
|
|
|
|
<HeaderRight
|
2021-04-09 21:43:12 +02:00
|
|
|
accessibilityLabel={t('common.search.accessibilityLabel')}
|
|
|
|
accessibilityHint={t('common.search.accessibilityHint')}
|
2021-02-08 23:19:55 +01:00
|
|
|
content='Search'
|
|
|
|
onPress={() => {
|
|
|
|
analytics('search_tap', { page: 'Local' })
|
2021-03-14 00:47:55 +01:00
|
|
|
navigation.navigate('Tab-Local', {
|
|
|
|
screen: 'Tab-Shared-Search',
|
|
|
|
params: { text: undefined }
|
|
|
|
})
|
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
|
|
|
|
2022-01-16 23:26:05 +01:00
|
|
|
const timelinesLookback = useSelector(
|
|
|
|
getInstanceTimelinesLookback,
|
|
|
|
() => true
|
2021-02-27 16:33:54 +01:00
|
|
|
)
|
2022-01-16 23:26:05 +01:00
|
|
|
const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Following' }]
|
|
|
|
const renderItem = useCallback(({ item }) => {
|
|
|
|
if (timelinesLookback?.['Following']?.ids?.[0] === item.id) {
|
2022-01-31 12:32:19 +01:00
|
|
|
return <TimelineDefault item={item} queryKey={queryKey} />
|
2022-01-16 23:26:05 +01:00
|
|
|
}
|
|
|
|
return <TimelineDefault item={item} queryKey={queryKey} />
|
|
|
|
}, [])
|
2021-02-08 23:19:55 +01:00
|
|
|
const children = useCallback(
|
2022-01-16 23:26:05 +01:00
|
|
|
() => (
|
|
|
|
<Timeline
|
|
|
|
queryKey={queryKey}
|
|
|
|
lookback='Following'
|
|
|
|
customProps={{ renderItem }}
|
|
|
|
/>
|
|
|
|
),
|
2021-02-08 23:19:55 +01:00
|
|
|
[]
|
|
|
|
)
|
2021-01-26 12:17:25 +01:00
|
|
|
|
|
|
|
return (
|
2021-08-21 01:45:43 +02:00
|
|
|
<Stack.Navigator screenOptions={{ headerShadowVisible: false }}>
|
2021-01-30 01:29:15 +01:00
|
|
|
<Stack.Screen
|
|
|
|
name='Tab-Local-Root'
|
2021-02-08 23:19:55 +01:00
|
|
|
options={screenOptionsRoot}
|
|
|
|
children={children}
|
|
|
|
/>
|
2021-08-29 15:25:38 +02:00
|
|
|
{TabSharedRoot({ Stack })}
|
2021-01-26 12:17:25 +01:00
|
|
|
</Stack.Navigator>
|
|
|
|
)
|
2021-01-22 01:34:20 +01:00
|
|
|
},
|
|
|
|
() => true
|
|
|
|
)
|
2020-10-31 21:04:46 +01:00
|
|
|
|
2021-01-30 01:29:15 +01:00
|
|
|
export default TabLocal
|