import { HeaderRight } from '@components/Header' import Icon from '@components/Icon' import CustomText from '@components/Text' import Timeline from '@components/Timeline' import { NativeStackScreenProps } from '@react-navigation/native-stack' import { TabLocalStackParamList } from '@utils/navigation/navigators' import { useListsQuery } from '@utils/queryHooks/lists' import { QueryKeyTimeline } from '@utils/queryHooks/timeline' import { setAccountStorage, useAccountStorage } from '@utils/storage/actions' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { View } from 'react-native' import * as DropdownMenu from 'zeego/dropdown-menu' const Root: React.FC> = ({ navigation }) => { const { colors, mode } = useTheme() const { t } = useTranslation('screenTabs') const { data: lists } = useListsQuery() const [pageLocal] = useAccountStorage.object('page_local') const [queryKey, setQueryKey] = useState([ 'Timeline', { page: 'Following', ...pageLocal } ]) useEffect(() => { const page = queryKey[1] navigation.setOptions({ headerTitle: () => ( {page.page === 'List' ? ( ) : null} list.id === page.list)?.title : t('tabs.local.name') } /> {page.page === 'Following' && !pageLocal?.showBoosts ? ( ) : null} {page.page === 'Following' && !pageLocal?.showReplies ? ( ) : null} setQueryKey(['Timeline', { page: 'Following', ...pageLocal }])} disabled={page.page === 'Following'} > { setQueryKey([ 'Timeline', { page: 'Following', showBoosts: !pageLocal?.showBoosts, showReplies: pageLocal?.showReplies } ]) setAccountStorage([ { key: 'page_local', value: { ...pageLocal, showBoosts: !pageLocal?.showBoosts } } ]) }} > { setQueryKey([ 'Timeline', { page: 'Following', showBoosts: pageLocal?.showBoosts, showReplies: !pageLocal?.showReplies } ]) setAccountStorage([ { key: 'page_local', value: { ...pageLocal, showReplies: !pageLocal?.showReplies } } ]) }} > {lists?.length ? [ ...lists?.map(list => ({ key: list.id, item: { onSelect: () => setQueryKey(['Timeline', { page: 'List', list: list.id }]), disabled: page.page === 'List' && page.list === list.id, destructive: false, hidden: false }, title: list.title, icon: 'list.bullet' as any })) ].map(menu => ( )) : undefined} ), headerRight: () => ( navigation.navigate('Tab-Shared-Search')} /> ) }) navigation.setParams({ queryKey: queryKey }) }, [mode, queryKey[1], pageLocal, lists]) return } export default Root