2021-02-14 00:27:21 +01:00
|
|
|
import analytics from '@components/analytics'
|
2021-01-16 00:00:31 +01:00
|
|
|
import GracefullyImage from '@components/GracefullyImage'
|
2021-02-14 00:27:21 +01:00
|
|
|
import { useNavigation } from '@react-navigation/native'
|
2021-01-24 02:25:43 +01:00
|
|
|
import { StackNavigationProp } from '@react-navigation/stack'
|
2021-02-14 00:27:21 +01:00
|
|
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import React, { useCallback } from 'react'
|
2021-04-09 21:43:12 +02:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2020-11-23 00:07:32 +01:00
|
|
|
|
2020-10-31 21:04:46 +01:00
|
|
|
export interface Props {
|
2021-01-07 19:13:09 +01:00
|
|
|
queryKey?: QueryKeyTimeline
|
2020-12-03 01:28:56 +01:00
|
|
|
account: Mastodon.Account
|
2021-04-09 21:43:12 +02:00
|
|
|
highlighted: boolean
|
2020-10-31 21:04:46 +01:00
|
|
|
}
|
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
const TimelineAvatar = React.memo(
|
2021-04-09 21:43:12 +02:00
|
|
|
({ queryKey, account, highlighted }: Props) => {
|
|
|
|
const { t } = useTranslation('componentTimeline')
|
2021-02-27 16:33:54 +01:00
|
|
|
const navigation = useNavigation<
|
|
|
|
StackNavigationProp<Nav.TabLocalStackParamList>
|
|
|
|
>()
|
|
|
|
// Need to fix go back root
|
|
|
|
const onPress = useCallback(() => {
|
|
|
|
analytics('timeline_shared_avatar_press', {
|
|
|
|
page: queryKey && queryKey[1].page
|
|
|
|
})
|
|
|
|
queryKey && navigation.push('Tab-Shared-Account', { account })
|
|
|
|
}, [])
|
2020-11-28 17:07:30 +01:00
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
return (
|
|
|
|
<GracefullyImage
|
2021-04-09 21:43:12 +02:00
|
|
|
{...(highlighted && {
|
|
|
|
accessibilityLabel: t('shared.avatar.accessibilityLabel', {
|
|
|
|
name: account.display_name
|
|
|
|
}),
|
|
|
|
accessibilityHint: t('shared.avatar.accessibilityHint', {
|
|
|
|
name: account.display_name
|
|
|
|
})
|
|
|
|
})}
|
2021-02-27 16:33:54 +01:00
|
|
|
onPress={onPress}
|
|
|
|
uri={{ original: account.avatar_static }}
|
|
|
|
dimension={{
|
|
|
|
width: StyleConstants.Avatar.M,
|
|
|
|
height: StyleConstants.Avatar.M
|
|
|
|
}}
|
|
|
|
style={{
|
2021-03-27 00:02:32 +01:00
|
|
|
borderRadius: StyleConstants.Avatar.M,
|
2021-02-27 16:33:54 +01:00
|
|
|
overflow: 'hidden',
|
2021-04-09 21:43:12 +02:00
|
|
|
marginRight: StyleConstants.Spacing.S
|
2021-02-27 16:33:54 +01:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
() => true
|
|
|
|
)
|
2020-10-25 01:35:41 +02:00
|
|
|
|
2021-02-27 16:33:54 +01:00
|
|
|
export default TimelineAvatar
|