tooot/src/components/Timeline/Shared/Avatar.tsx

47 lines
1.3 KiB
TypeScript
Raw Normal View History

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'
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
2020-10-31 21:04:46 +01:00
}
2021-02-27 16:33:54 +01:00
const TimelineAvatar = React.memo(
({ queryKey, account }: Props) => {
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
onPress={onPress}
uri={{ original: account.avatar_static }}
dimension={{
width: StyleConstants.Avatar.M,
height: StyleConstants.Avatar.M
}}
style={{
borderRadius: 4,
overflow: 'hidden',
marginRight: StyleConstants.Spacing.S
}}
/>
)
},
() => true
)
2020-10-25 01:35:41 +02:00
2021-02-27 16:33:54 +01:00
export default TimelineAvatar