import React from 'react' import {View, StyleSheet} from 'react-native' import Animated from 'react-native-reanimated' import {TabBar} from 'view/com/pager/TabBar' import {RenderTabBarFnProps} from 'view/com/pager/Pager' import {usePalette} from 'lib/hooks/usePalette' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {FeedsTabBar as FeedsTabBarMobile} from './FeedsTabBarMobile' import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode' import {useShellLayout} from '#/state/shell/shell-layout' import {usePinnedFeedsInfos} from '#/state/queries/feed' import {useSession} from '#/state/session' import {TextLink} from '#/view/com/util/Link' import {CenteredView} from '../util/Views' import {isWeb} from 'platform/detection' import {useNavigation} from '@react-navigation/native' import {NavigationProp} from 'lib/routes/types' export function FeedsTabBar( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, ) { const {isMobile, isTablet} = useWebMediaQueries() const {hasSession} = useSession() if (isMobile) { return } else if (isTablet) { if (hasSession) { return } else { return } } else { return null } } function FeedsTabBarPublic() { const pal = usePalette('default') const {isSandbox} = useSession() return ( {isSandbox ? 'SANDBOX' : 'Bluesky'}{' '} {/*hasNew && ( )*/} } // onPress={emitSoftReset} /> ) } function FeedsTabBarTablet( props: RenderTabBarFnProps & {testID?: string; onPressSelected: () => void}, ) { const {feeds, hasPinnedCustom} = usePinnedFeedsInfos() const pal = usePalette('default') const {hasSession} = useSession() const navigation = useNavigation() const {headerMinimalShellTransform} = useMinimalShellMode() const {headerHeight} = useShellLayout() const pinnedDisplayNames = hasSession ? feeds.map(f => f.displayName) : [] const showFeedsLinkInTabBar = hasSession && !hasPinnedCustom const items = showFeedsLinkInTabBar ? pinnedDisplayNames.concat('Feeds ✨') : pinnedDisplayNames const onPressDiscoverFeeds = React.useCallback(() => { if (isWeb) { navigation.navigate('Feeds') } else { navigation.navigate('FeedsTab') navigation.popToTop() } }, [navigation]) const onSelect = React.useCallback( (index: number) => { if (showFeedsLinkInTabBar && index === items.length - 1) { onPressDiscoverFeeds() } else if (props.onSelect) { props.onSelect(index) } }, [items.length, onPressDiscoverFeeds, props, showFeedsLinkInTabBar], ) return ( // @ts-ignore the type signature for transform wrong here, translateX and translateY need to be in separate objects -prf { headerHeight.value = e.nativeEvent.layout.height }}> ) } const styles = StyleSheet.create({ tabBar: { position: 'absolute', zIndex: 1, // @ts-ignore Web only -prf left: 'calc(50% - 299px)', width: 598, top: 0, flexDirection: 'row', alignItems: 'center', }, })