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

53 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-01-01 16:48:16 +01:00
import { ParseEmojis } from '@components/Parse'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
2020-12-27 16:25:29 +01:00
import { LinearGradient } from 'expo-linear-gradient'
import React, { forwardRef } from 'react'
2021-01-01 16:48:16 +01:00
import { StyleSheet } from 'react-native'
2020-12-27 16:25:29 +01:00
import ShimmerPlaceholder, {
createShimmerPlaceholder
} from 'react-native-shimmer-placeholder'
export interface Props {
account: Mastodon.Account | undefined
}
const AccountInformationName = forwardRef<ShimmerPlaceholder, Props>(
({ account }, ref) => {
const { theme } = useTheme()
const ShimmerPlaceholder = createShimmerPlaceholder(LinearGradient)
return (
<ShimmerPlaceholder
ref={ref}
visible={
account?.display_name !== undefined || account?.username !== undefined
}
width={StyleConstants.Font.Size.L * 8}
2021-01-15 01:15:27 +01:00
height={StyleConstants.Font.LineHeight.L}
2020-12-27 16:25:29 +01:00
style={styles.name}
2021-01-07 19:13:09 +01:00
shimmerColors={[theme.shimmerDefault, theme.shimmerHighlight, theme.shimmerDefault]}
2020-12-27 16:25:29 +01:00
>
2021-01-01 16:48:16 +01:00
{account ? (
<ParseEmojis
content={account.display_name || account.username}
emojis={account.emojis}
size='L'
fontBold
/>
) : null}
2020-12-27 16:25:29 +01:00
</ShimmerPlaceholder>
)
}
)
const styles = StyleSheet.create({
name: {
flexDirection: 'row',
marginTop: StyleConstants.Spacing.M,
marginBottom: StyleConstants.Spacing.XS
}
})
export default AccountInformationName