2020-12-13 14:04:25 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2021-01-23 02:41:50 +01:00
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
|
|
|
import React, { useCallback } from 'react'
|
|
|
|
import { StyleSheet, View } from 'react-native'
|
|
|
|
import { Placeholder, Fade } from 'rn-placeholder'
|
2020-12-27 16:25:29 +01:00
|
|
|
import AccountInformationAccount from './Information/Account'
|
|
|
|
import AccountInformationActions from './Information/Actions'
|
2021-01-07 19:13:09 +01:00
|
|
|
import AccountInformationAvatar from './Information/Avatar'
|
|
|
|
import AccountInformationCreated from './Information/Created'
|
2020-12-27 16:25:29 +01:00
|
|
|
import AccountInformationFields from './Information/Fields'
|
2021-01-07 19:13:09 +01:00
|
|
|
import AccountInformationName from './Information/Name'
|
2021-05-09 21:59:03 +02:00
|
|
|
import AccountInformationNote from './Information/Note'
|
2021-01-07 19:13:09 +01:00
|
|
|
import AccountInformationStats from './Information/Stats'
|
2020-11-22 00:46:23 +01:00
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
account: Mastodon.Account | undefined
|
2021-01-24 02:25:43 +01:00
|
|
|
myInfo?: boolean // Showing from my info page
|
2020-11-22 00:46:23 +01:00
|
|
|
}
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
const AccountInformation = React.memo(
|
|
|
|
({ account, myInfo = false }: Props) => {
|
|
|
|
const { mode, theme } = useTheme()
|
2021-01-23 02:41:50 +01:00
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
const animation = useCallback(
|
|
|
|
props => (
|
|
|
|
<Fade {...props} style={{ backgroundColor: theme.shimmerHighlight }} />
|
|
|
|
),
|
|
|
|
[mode]
|
|
|
|
)
|
2020-12-14 23:44:57 +01:00
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
return (
|
|
|
|
<View style={styles.base}>
|
|
|
|
<Placeholder Animation={animation}>
|
|
|
|
<View style={styles.avatarAndActions}>
|
|
|
|
<AccountInformationAvatar account={account} myInfo={myInfo} />
|
|
|
|
<AccountInformationActions account={account} myInfo={myInfo} />
|
2021-01-23 02:41:50 +01:00
|
|
|
</View>
|
2020-11-22 00:46:23 +01:00
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
<AccountInformationName account={account} />
|
2020-12-14 23:44:57 +01:00
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
<AccountInformationAccount account={account} localInstance={myInfo} />
|
2020-11-22 00:46:23 +01:00
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
<AccountInformationFields account={account} myInfo={myInfo} />
|
2020-11-23 00:07:32 +01:00
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
<AccountInformationNote account={account} myInfo={myInfo} />
|
|
|
|
|
|
|
|
<AccountInformationCreated account={account} hidden={myInfo} />
|
|
|
|
|
|
|
|
<AccountInformationStats account={account} />
|
|
|
|
</Placeholder>
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
(prev, next) => {
|
|
|
|
let skipUpdate = true
|
|
|
|
if (prev.account?.id !== next.account?.id) {
|
|
|
|
skipUpdate = false
|
|
|
|
}
|
|
|
|
if (prev.account?.acct === next.account?.acct) {
|
|
|
|
skipUpdate = false
|
|
|
|
}
|
|
|
|
return skipUpdate
|
|
|
|
}
|
|
|
|
)
|
2020-11-22 00:46:23 +01:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2020-12-21 21:47:15 +01:00
|
|
|
base: {
|
2021-02-01 02:16:53 +01:00
|
|
|
marginTop: -StyleConstants.Avatar.L / 2,
|
2021-01-16 00:00:31 +01:00
|
|
|
padding: StyleConstants.Spacing.Global.PagePadding
|
2020-11-23 00:07:32 +01:00
|
|
|
},
|
2020-12-21 21:47:15 +01:00
|
|
|
avatarAndActions: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'space-between'
|
2021-01-07 19:13:09 +01:00
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
alignSelf: 'flex-end',
|
|
|
|
flexDirection: 'row'
|
2020-11-22 00:46:23 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-05-09 21:59:03 +02:00
|
|
|
export default AccountInformation
|