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

65 lines
1.7 KiB
TypeScript
Raw Normal View History

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'
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-05-09 21:59:03 +02:00
import { Pressable, StyleSheet, View } 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
2021-05-09 21:59:03 +02:00
edit?: boolean
2020-12-27 16:25:29 +01:00
}
2021-05-09 21:59:03 +02:00
const AccountInformationAvatar: React.FC<Props> = ({
account,
myInfo,
edit
}) => {
2022-02-12 18:25:53 +01:00
const navigation =
useNavigation<StackNavigationProp<TabLocalStackParamList>>()
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
}}
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}
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
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