import React from 'react' import {Pressable, StyleSheet, View} from 'react-native' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {useNavigation} from '@react-navigation/native' import {usePalette} from 'lib/hooks/usePalette' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {Text} from '../util/text/Text' import {TextLink} from '../util/Link' import {UserAvatar, UserAvatarType} from '../util/UserAvatar' import {LoadingPlaceholder} from '../util/LoadingPlaceholder' import {CenteredView} from '../util/Views' import {sanitizeHandle} from 'lib/strings/handles' import {makeProfileLink} from 'lib/routes/links' import {NavigationProp} from 'lib/routes/types' import {BACK_HITSLOP} from 'lib/constants' import {isNative} from 'platform/detection' import {useLightboxControls, ImagesLightbox} from '#/state/lightbox' import {useLingui} from '@lingui/react' import {Trans, msg} from '@lingui/macro' import {useSetDrawerOpen} from '#/state/shell' import {emitSoftReset} from '#/state/events' export function ProfileSubpageHeader({ isLoading, href, title, avatar, isOwner, creator, avatarType, children, }: React.PropsWithChildren<{ isLoading?: boolean href: string title: string | undefined avatar: string | undefined isOwner: boolean | undefined creator: | { did: string handle: string } | undefined avatarType: UserAvatarType }>) { const setDrawerOpen = useSetDrawerOpen() const navigation = useNavigation() const {_} = useLingui() const {isMobile} = useWebMediaQueries() const {openLightbox} = useLightboxControls() const pal = usePalette('default') const canGoBack = navigation.canGoBack() const onPressBack = React.useCallback(() => { if (navigation.canGoBack()) { navigation.goBack() } else { navigation.navigate('Home') } }, [navigation]) const onPressMenu = React.useCallback(() => { setDrawerOpen(true) }, [setDrawerOpen]) const onPressAvi = React.useCallback(() => { if ( avatar // TODO && !(view.moderation.avatar.blur && view.moderation.avatar.noOverride) ) { openLightbox(new ImagesLightbox([{uri: avatar}], 0)) } }, [openLightbox, avatar]) return ( {isMobile && ( {canGoBack ? ( ) : ( )} {children} )} {isLoading ? ( ) : ( )} {isLoading ? ( ) : ( {!creator ? ( by — ) : isOwner ? ( by you ) : ( by{' '} )} )} {!isMobile && ( {children} )} ) } const styles = StyleSheet.create({ backBtn: { width: 20, height: 30, }, backBtnWide: { width: 20, height: 30, paddingHorizontal: 6, }, backIcon: { marginTop: 6, }, })