import {useCallback} from 'react' import {GestureResponderEvent, View} from 'react-native' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useNavigation} from '@react-navigation/native' import {HITSLOP_30} from '#/lib/constants' import {NavigationProp} from '#/lib/routes/types' import {sanitizeHandle} from '#/lib/strings/handles' import {useFeedSourceInfoQuery} from '#/state/queries/feed' import {UserAvatar} from '#/view/com/util/UserAvatar' import {VideoFeedSourceContext} from '#/screens/VideoFeed/types' import {atoms as a, useBreakpoints} from '#/alf' import {Button, ButtonProps} from '#/components/Button' import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeft} from '#/components/icons/Arrow' import * as Layout from '#/components/Layout' import {BUTTON_VISUAL_ALIGNMENT_OFFSET} from '#/components/Layout/const' import {Text} from '#/components/Typography' export function HeaderPlaceholder() { return ( ) } export function Header({ sourceContext, }: { sourceContext: VideoFeedSourceContext }) { let content = null switch (sourceContext.type) { case 'feedgen': { content = break } case 'author': // TODO default: { break } } return ( {content} ) } export function FeedHeader({ sourceContext, }: { sourceContext: Exclude }) { const {gtMobile} = useBreakpoints() const { data: info, isLoading, error, } = useFeedSourceInfoQuery({uri: sourceContext.uri}) if (sourceContext.sourceInterstitial !== undefined) { // For now, don't show the header if coming from an interstitial. return null } if (isLoading) { return } else if (error || !info) { return null } return ( {info.avatar && } {info.displayName} {sanitizeHandle(info.creatorHandle, '@')} ) } // TODO: This customization should be a part of the layout component export function BackButton({onPress, style, ...props}: Partial) { const {_} = useLingui() const navigation = useNavigation() const onPressBack = useCallback( (evt: GestureResponderEvent) => { onPress?.(evt) if (evt.defaultPrevented) return if (navigation.canGoBack()) { navigation.goBack() } else { navigation.navigate('Home') } }, [onPress, navigation], ) return ( ) }