2021-01-26 12:17:25 +01:00
|
|
|
import analytics from '@components/analytics'
|
|
|
|
import { HeaderCenter, HeaderRight } from '@components/Header'
|
2022-08-13 00:48:20 +02:00
|
|
|
import Icon from '@components/Icon'
|
|
|
|
import CustomText from '@components/Text'
|
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'
|
2022-08-13 00:48:20 +02:00
|
|
|
import { useListsQuery } from '@utils/queryHooks/lists'
|
2021-02-27 16:33:54 +01:00
|
|
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
2022-08-13 00:48:20 +02:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import layoutAnimation from '@utils/styles/layoutAnimation'
|
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
|
|
|
import React, { useEffect, useState } from 'react'
|
2021-01-26 12:17:25 +01:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2022-08-13 00:48:20 +02:00
|
|
|
import { Pressable, StyleSheet, Text, View } from 'react-native'
|
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'>) => {
|
2022-08-13 00:48:20 +02:00
|
|
|
const { colors } = useTheme()
|
|
|
|
const { t } = useTranslation('screenTabs')
|
2021-01-26 12:17:25 +01:00
|
|
|
|
2022-08-13 00:48:20 +02:00
|
|
|
const { data: lists } = useListsQuery({})
|
|
|
|
const [listsShown, setListsShown] = useState(false)
|
|
|
|
useEffect(() => {
|
|
|
|
layoutAnimation()
|
|
|
|
}, [listsShown])
|
2021-02-27 16:33:54 +01:00
|
|
|
|
2022-08-13 00:48:20 +02:00
|
|
|
const [queryKey, setQueryKey] = useState<QueryKeyTimeline>([
|
|
|
|
'Timeline',
|
|
|
|
{ page: 'Following' }
|
|
|
|
])
|
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'
|
2022-08-13 00:48:20 +02:00
|
|
|
options={{
|
|
|
|
headerTitle: () => (
|
|
|
|
<HeaderCenter
|
|
|
|
onPress={() => {
|
|
|
|
if (lists?.length) {
|
|
|
|
setListsShown(!listsShown)
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
content={
|
|
|
|
<>
|
|
|
|
<Text>{t('tabs.local.name')}</Text>
|
|
|
|
{lists?.length ? (
|
|
|
|
<Icon
|
|
|
|
name='ChevronDown'
|
|
|
|
size={StyleConstants.Font.Size.M}
|
|
|
|
color={colors.primaryDefault}
|
|
|
|
style={{ marginLeft: StyleConstants.Spacing.S }}
|
|
|
|
strokeWidth={3}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
headerRight: () => (
|
|
|
|
<HeaderRight
|
|
|
|
accessibilityLabel={t('common.search.accessibilityLabel')}
|
|
|
|
accessibilityHint={t('common.search.accessibilityHint')}
|
|
|
|
content='Search'
|
|
|
|
onPress={() => {
|
|
|
|
analytics('search_tap', { page: 'Local' })
|
|
|
|
navigation.navigate('Tab-Local', {
|
|
|
|
screen: 'Tab-Shared-Search',
|
|
|
|
params: { text: undefined }
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
children={() => (
|
|
|
|
<>
|
|
|
|
<Timeline
|
|
|
|
queryKey={queryKey}
|
|
|
|
lookback='Following'
|
|
|
|
customProps={{
|
|
|
|
renderItem: ({ item }) => (
|
|
|
|
<TimelineDefault item={item} queryKey={queryKey} />
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{listsShown ? (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
backgroundColor: colors.backgroundDefault,
|
|
|
|
width: '100%',
|
|
|
|
paddingVertical: StyleConstants.Spacing.S
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Pressable
|
|
|
|
style={{
|
|
|
|
padding: StyleConstants.Spacing.S * 1.5,
|
|
|
|
borderColor: colors.border,
|
|
|
|
borderTopWidth: StyleSheet.hairlineWidth,
|
|
|
|
borderBottomWidth: StyleSheet.hairlineWidth
|
|
|
|
}}
|
|
|
|
onPress={() => {
|
|
|
|
setQueryKey(['Timeline', { page: 'Following' }])
|
|
|
|
setListsShown(!listsShown)
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<CustomText fontSize='M' style={{ textAlign: 'center' }}>
|
|
|
|
Default
|
|
|
|
</CustomText>
|
|
|
|
</Pressable>
|
|
|
|
{lists?.map(list => (
|
|
|
|
<Pressable
|
|
|
|
style={{
|
|
|
|
padding: StyleConstants.Spacing.S,
|
|
|
|
borderColor: colors.border,
|
|
|
|
borderBottomWidth: StyleSheet.hairlineWidth
|
|
|
|
}}
|
|
|
|
onPress={() => {
|
|
|
|
setQueryKey([
|
|
|
|
'Timeline',
|
|
|
|
{ page: 'List', list: list.id }
|
|
|
|
])
|
|
|
|
setListsShown(!listsShown)
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<CustomText
|
|
|
|
key={list.id}
|
|
|
|
fontSize='M'
|
|
|
|
style={{ textAlign: 'center' }}
|
|
|
|
>
|
|
|
|
{list.title}
|
|
|
|
</CustomText>
|
|
|
|
</Pressable>
|
|
|
|
))}
|
|
|
|
</View>
|
|
|
|
) : null}
|
|
|
|
</>
|
|
|
|
)}
|
2021-02-08 23:19:55 +01:00
|
|
|
/>
|
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
|