2021-01-04 10:50:24 +01:00
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2021-02-02 22:50:38 +01:00
|
|
|
import React, { useContext } from 'react'
|
2021-03-19 21:44:52 +01:00
|
|
|
import { Dimensions, Image } from 'react-native'
|
2021-01-16 00:00:31 +01:00
|
|
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
2021-01-03 02:00:26 +01:00
|
|
|
import AccountContext from './utils/createContext'
|
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
|
|
|
limitHeight?: boolean
|
|
|
|
}
|
|
|
|
|
2021-01-03 02:00:26 +01:00
|
|
|
const AccountHeader: React.FC<Props> = ({ account, limitHeight = false }) => {
|
2021-02-02 22:50:38 +01:00
|
|
|
const { accountState } = useContext(AccountContext)
|
2020-12-27 16:25:29 +01:00
|
|
|
const { theme } = useTheme()
|
2021-01-16 00:00:31 +01:00
|
|
|
const topInset = useSafeAreaInsets().top
|
2020-12-17 09:44:03 +01:00
|
|
|
|
2020-11-22 00:46:23 +01:00
|
|
|
return (
|
2021-03-19 21:44:52 +01:00
|
|
|
<Image
|
2021-01-15 01:15:27 +01:00
|
|
|
source={{ uri: account?.header }}
|
2021-02-02 22:50:38 +01:00
|
|
|
style={{
|
|
|
|
height:
|
|
|
|
Dimensions.get('screen').width * accountState.headerRatio + topInset,
|
|
|
|
backgroundColor: theme.disabled
|
|
|
|
}}
|
2021-01-04 10:50:24 +01:00
|
|
|
/>
|
2020-11-22 00:46:23 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-01-03 02:00:26 +01:00
|
|
|
export default React.memo(
|
|
|
|
AccountHeader,
|
|
|
|
(_, next) => next.account === undefined
|
|
|
|
)
|