import React from 'react' import {Pressable, StyleSheet, View} from 'react-native' import {observer} from 'mobx-react-lite' 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 {useStores} from 'state/index' import {NavigationProp} from 'lib/routes/types' import {BACK_HITSLOP} from 'lib/constants' import {isNative} from 'platform/detection' import {ImagesLightbox} from 'state/models/ui/shell' export const ProfileSubpageHeader = observer(function HeaderImpl({ 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 store = useStores() const navigation = useNavigation() const {isMobile} = useWebMediaQueries() 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(() => { store.shell.openDrawer() }, [store]) const onPressAvi = React.useCallback(() => { if ( avatar // TODO && !(view.moderation.avatar.blur && view.moderation.avatar.noOverride) ) { store.shell.openLightbox(new ImagesLightbox([{uri: avatar}], 0)) } }, [store, avatar]) return ( {isMobile && ( {canGoBack ? ( ) : ( )} {children} )} {isLoading ? ( ) : ( store.emitScreenSoftReset()} numberOfLines={4} /> )} {isLoading ? ( ) : ( by{' '} {!creator ? ( '—' ) : isOwner ? ( 'you' ) : ( )} )} {!isMobile && ( {children} )} ) }) const styles = StyleSheet.create({ backBtn: { width: 20, height: 30, }, backBtnWide: { width: 20, height: 30, paddingHorizontal: 6, }, backIcon: { marginTop: 6, }, })