tooot/src/screens/Tabs/Shared/Account/Header.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-06-21 23:50:49 +02:00
import GracefullyImage from '@components/GracefullyImage'
2022-12-18 20:55:33 +01:00
import navigationRef from '@helpers/navigationRef'
import { getInstanceActive } from '@utils/slices/instancesSlice'
2021-05-09 21:59:03 +02:00
import React from 'react'
import { Dimensions, Image } from 'react-native'
2021-01-16 00:00:31 +01:00
import { useSafeAreaInsets } from 'react-native-safe-area-context'
2022-12-18 20:55:33 +01:00
import { useSelector } from 'react-redux'
2020-11-22 00:46:23 +01:00
export interface Props {
2020-12-18 00:00:45 +01:00
account?: Mastodon.Account
2020-11-22 00:46:23 +01:00
}
2022-12-18 20:55:33 +01:00
const AccountHeader: React.FC<Props> = ({ account }) => {
const topInset = useSafeAreaInsets().top
2022-12-18 20:55:33 +01:00
useSelector(getInstanceActive)
return (
<GracefullyImage
uri={{ original: account?.header, static: account?.header_static }}
style={{ height: Dimensions.get('window').width / 3 + topInset }}
2022-12-18 20:55:33 +01:00
onPress={() => {
if (account) {
Image.getSize(account.header, (width, height) =>
navigationRef.navigate('Screen-ImagesViewer', {
imageUrls: [{ id: 'avatar', url: account.header, width, height }],
id: 'avatar',
hideCounter: true
})
)
}
}}
/>
2022-12-18 20:55:33 +01:00
)
}
2021-05-09 21:59:03 +02:00
export default AccountHeader