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

82 lines
2.4 KiB
TypeScript
Raw Normal View History

2021-06-01 22:27:27 +02:00
import { useRoute } from '@react-navigation/native'
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'
2022-08-07 01:18:10 +02:00
import React from 'react'
2021-01-23 02:41:50 +01:00
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-05-09 21:59:03 +02:00
const AccountInformation = React.memo(
2021-06-01 22:27:27 +02:00
({ account }: Props) => {
2022-08-07 01:18:10 +02:00
const { colors } = useTheme()
2021-01-23 02:41:50 +01:00
2021-06-01 22:27:27 +02:00
const { name } = useRoute()
const myInfo = name !== 'Tab-Shared-Account'
2021-05-09 21:59:03 +02:00
return (
<View style={styles.base}>
2022-08-07 01:18:10 +02:00
<Placeholder
Animation={props => (
2022-12-12 20:43:45 +01:00
<Fade {...props} style={{ backgroundColor: colors.shimmerHighlight }} />
2022-08-07 01:18:10 +02:00
)}
>
2021-05-09 21:59:03 +02:00
<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
2022-12-12 20:43:45 +01:00
<AccountInformationAccount account={account} />
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} />
2021-06-01 22:27:27 +02:00
<AccountInformationStats account={account} myInfo={myInfo} />
2021-05-09 21:59:03 +02:00
</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