import menuAccount from '@components/contextMenu/account' import menuShare from '@components/contextMenu/share' import { HeaderLeft, HeaderRight } from '@components/Header' import Timeline from '@components/Timeline' import TimelineDefault from '@components/Timeline/Default' import SegmentedControl from '@react-native-community/segmented-control' import { useQueryClient } from '@tanstack/react-query' import { TabSharedStackScreenProps } from '@utils/navigation/navigators' import { useAccountQuery } from '@utils/queryHooks/account' import { QueryKeyTimeline } from '@utils/queryHooks/timeline' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import React, { useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { Text, View } from 'react-native' import { useSharedValue } from 'react-native-reanimated' import * as DropdownMenu from 'zeego/dropdown-menu' import AccountAttachments from './Account/Attachments' import AccountHeader from './Account/Header' import AccountInformation from './Account/Information' import AccountNav from './Account/Nav' const TabSharedAccount: React.FC> = ({ navigation, route: { params: { account } } }) => { const { t } = useTranslation('screenTabs') const { colors, mode } = useTheme() const mShare = menuShare({ type: 'account', url: account.url }) const mAccount = menuAccount({ type: 'account', openChange: true, account }) useEffect(() => { navigation.setOptions({ headerTransparent: true, headerStyle: { backgroundColor: `rgba(255, 255, 255, 0)` }, title: '', headerLeft: () => navigation.goBack()} background />, headerRight: () => { return ( {}} background /> {[mShare, mAccount].map(type => ( <> {type.map((mGroup, index) => ( {mGroup.map(menu => ( ))} ))} ))} ) } }) }, [mAccount]) const { data } = useAccountQuery({ id: account.id }) const scrollY = useSharedValue(0) const queryClient = useQueryClient() const [queryKey, setQueryKey] = useState([ 'Timeline', { page: 'Account', account: account.id, exclude_reblogs: true, only_media: false } ]) const page = queryKey[1] const [segment, setSegment] = useState(0) const ListHeaderComponent = useMemo(() => { return ( <> {!data?.suspended ? : null} {!data?.suspended ? ( { setSegment(nativeEvent.selectedSegmentIndex) switch (nativeEvent.selectedSegmentIndex) { case 0: setQueryKey([ queryKey[0], { ...page, page: 'Account', account: account.id, exclude_reblogs: true, only_media: false } ]) break case 1: setQueryKey([ queryKey[0], { ...page, page: 'Account', account: account.id, exclude_reblogs: false, only_media: false } ]) break } }} style={{ marginTop: StyleConstants.Spacing.M, marginHorizontal: StyleConstants.Spacing.Global.PagePadding }} /> ) : null} {data?.suspended ? ( {t('shared.account.suspended')} ) : null} ) }, [segment, data, queryKey[1].page, mode]) return ( <> {data?.suspended ? ( ListHeaderComponent ) : ( , onScroll: ({ nativeEvent }) => (scrollY.value = nativeEvent.contentOffset.y), ListHeaderComponent, maintainVisibleContentPosition: undefined, onRefresh: () => queryClient.refetchQueries(queryKey), refreshing: false }} /> )} ) } export default TabSharedAccount