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

48 lines
1.2 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-02-02 22:50:38 +01:00
import React 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
return (
2021-01-24 02:25:43 +01:00
<Pressable
disabled={!myInfo}
onPress={() => {
analytics('account_avatar_press')
2021-02-02 22:50:38 +01:00
myInfo && account && navigation.push('Tab-Shared-Account', { account })
2021-01-24 02:25:43 +01:00
}}
2021-02-02 22:50:38 +01:00
style={styles.base}
2021-01-24 02:25:43 +01:00
>
<GracefullyImage
2021-02-02 22:50:38 +01:00
key={account?.avatar}
style={styles.image}
2021-03-19 21:44:52 +01:00
uri={{ original: account?.avatar }}
2021-01-24 02:25:43 +01:00
/>
</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({
2021-02-02 22:50:38 +01:00
base: {
borderRadius: 8,
overflow: 'hidden',
width: StyleConstants.Avatar.L,
height: StyleConstants.Avatar.L
},
image: { flex: 1 }
2021-01-20 12:35:24 +01:00
})
2020-12-27 16:25:29 +01:00
export default AccountInformationAvatar