tooot/src/screens/Tabs/Shared/Account/Information/Avatar.tsx

50 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-01-24 02:25:43 +01:00
import analytics from '@components/analytics'
2021-01-16 00:00:31 +01:00
import GracefullyImage from '@components/GracefullyImage'
2021-01-24 02:25:43 +01:00
import { useNavigation } from '@react-navigation/native'
import { StackNavigationProp } from '@react-navigation/stack'
2021-01-16 00:00:31 +01:00
import { StyleConstants } from '@utils/styles/constants'
2021-01-23 02:41:50 +01:00
import React, { useMemo } from 'react'
2021-01-24 02:25:43 +01:00
import { Pressable, StyleSheet } from 'react-native'
2020-12-27 16:25:29 +01:00
export interface Props {
account: Mastodon.Account | undefined
2021-01-24 02:25:43 +01:00
myInfo: boolean
2020-12-27 16:25:29 +01:00
}
2021-01-24 02:25:43 +01:00
const AccountInformationAvatar: React.FC<Props> = ({ account, myInfo }) => {
const navigation = useNavigation<
2021-01-30 01:29:15 +01:00
StackNavigationProp<Nav.TabLocalStackParamList>
2021-01-24 02:25:43 +01:00
>()
2021-01-23 02:41:50 +01:00
const dimension = useMemo(
() => ({
width: StyleConstants.Avatar.L,
height: StyleConstants.Avatar.L
}),
[]
)
return (
2021-01-24 02:25:43 +01:00
<Pressable
disabled={!myInfo}
onPress={() => {
analytics('account_avatar_press')
myInfo &&
account &&
2021-01-30 01:29:15 +01:00
navigation.push('Tab-Shared-Account', { account })
2021-01-24 02:25:43 +01:00
}}
>
<GracefullyImage
style={styles.base}
2021-01-28 01:14:00 +01:00
uri={{ original: account?.avatar || '' }}
2021-01-24 02:25:43 +01:00
dimension={dimension}
/>
</Pressable>
2021-01-23 02:41:50 +01:00
)
}
2020-12-27 16:25:29 +01:00
2021-01-20 12:35:24 +01:00
const styles = StyleSheet.create({
base: { borderRadius: 8, overflow: 'hidden' }
})
2020-12-27 16:25:29 +01:00
export default AccountInformationAvatar