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

70 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-01-01 16:48:16 +01:00
import { ParseEmojis } from '@components/Parse'
import CustomText from '@components/Text'
2021-01-01 16:48:16 +01:00
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import React, { useMemo } from 'react'
import { View } from 'react-native'
2021-01-23 02:41:50 +01:00
import { PlaceholderLine } from 'rn-placeholder'
2020-12-27 16:25:29 +01:00
export interface Props {
account: Mastodon.Account | undefined
}
const AccountInformationName: React.FC<Props> = ({ account }) => {
2022-02-12 14:51:01 +01:00
const { colors } = useTheme()
2020-12-27 16:25:29 +01:00
2021-01-23 02:41:50 +01:00
const movedContent = useMemo(() => {
if (account?.moved) {
return (
<View style={{ marginLeft: StyleConstants.Spacing.S }}>
2021-01-23 02:41:50 +01:00
<ParseEmojis
content={account.moved.display_name || account.moved.username}
emojis={account.moved.emojis}
size='L'
fontBold
/>
</View>
)
}
}, [account?.moved])
2021-04-24 15:03:17 +02:00
return (
<View
style={{
borderRadius: 0,
marginTop: StyleConstants.Spacing.S,
marginBottom: StyleConstants.Spacing.XS,
flexDirection: 'row'
}}
>
2021-04-24 15:03:17 +02:00
{account ? (
<>
<CustomText
style={{
2022-11-06 23:39:31 +01:00
textDecorationLine: account?.moved || account.suspended ? 'line-through' : undefined
}}
>
<ParseEmojis
content={account.display_name || account.username}
emojis={account.emojis}
size='L'
fontBold
/>
</CustomText>
{movedContent}
</>
2021-04-24 15:03:17 +02:00
) : (
<PlaceholderLine
width={StyleConstants.Font.Size.L * 2}
height={StyleConstants.Font.LineHeight.L}
2022-02-12 14:51:01 +01:00
color={colors.shimmerDefault}
2021-04-24 15:03:17 +02:00
noMargin
style={{ borderRadius: 0 }}
/>
)}
</View>
)
2021-01-23 02:41:50 +01:00
}
2020-12-27 16:25:29 +01:00
2022-12-12 20:43:45 +01:00
export default AccountInformationName