2021-05-09 21:59:03 +02:00
|
|
|
import Button from '@components/Button'
|
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-08-29 15:25:38 +02:00
|
|
|
import { TabLocalStackParamList } from '@utils/navigation/navigators'
|
2022-12-12 23:59:38 +01:00
|
|
|
import { getInstanceActive } from '@utils/slices/instancesSlice'
|
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'
|
2022-12-12 20:43:45 +01:00
|
|
|
import { Pressable, View } from 'react-native'
|
2022-12-12 23:59:38 +01:00
|
|
|
import { useSelector } from 'react-redux'
|
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
|
2021-05-09 21:59:03 +02:00
|
|
|
edit?: boolean
|
2020-12-27 16:25:29 +01:00
|
|
|
}
|
|
|
|
|
2022-12-12 20:43:45 +01:00
|
|
|
const AccountInformationAvatar: React.FC<Props> = ({ account, myInfo, edit }) => {
|
|
|
|
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
2022-12-12 23:59:38 +01:00
|
|
|
useSelector(getInstanceActive)
|
2021-01-23 02:41:50 +01:00
|
|
|
return (
|
2021-01-24 02:25:43 +01:00
|
|
|
<Pressable
|
|
|
|
disabled={!myInfo}
|
|
|
|
onPress={() => {
|
2021-02-02 22:50:38 +01:00
|
|
|
myInfo && account && navigation.push('Tab-Shared-Account', { account })
|
2021-01-24 02:25:43 +01:00
|
|
|
}}
|
2022-12-12 20:43:45 +01:00
|
|
|
style={{
|
|
|
|
borderRadius: 8,
|
|
|
|
overflow: 'hidden',
|
|
|
|
width: StyleConstants.Avatar.L,
|
|
|
|
height: StyleConstants.Avatar.L
|
|
|
|
}}
|
2021-01-24 02:25:43 +01:00
|
|
|
>
|
|
|
|
<GracefullyImage
|
2021-02-02 22:50:38 +01:00
|
|
|
key={account?.avatar}
|
2022-12-12 20:43:45 +01:00
|
|
|
style={{ flex: 1 }}
|
2022-02-12 18:25:53 +01:00
|
|
|
uri={{ original: account?.avatar, static: account?.avatar_static }}
|
2021-01-24 02:25:43 +01:00
|
|
|
/>
|
2021-05-09 21:59:03 +02:00
|
|
|
{edit ? (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
alignContent: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center'
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Button type='icon' content='Edit' round onPress={() => {}} />
|
|
|
|
</View>
|
|
|
|
) : null}
|
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
|
|
|
|
|
|
|
export default AccountInformationAvatar
|