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

77 lines
2.1 KiB
TypeScript
Raw Normal View History

import Icon from '@components/Icon'
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'
import { useTranslation } from 'react-i18next'
import { StyleSheet, Text, View } from 'react-native'
import ShimmerPlaceholder, {
createShimmerPlaceholder
} from 'react-native-shimmer-placeholder'
export interface Props {
account: Mastodon.Account | undefined
}
const AccountInformationCreated = forwardRef<ShimmerPlaceholder, Props>(
({ account }, ref) => {
2021-01-17 22:37:05 +01:00
const { i18n } = useTranslation()
2020-12-27 16:25:29 +01:00
const { theme } = useTheme()
const { t } = useTranslation('sharedAccount')
const ShimmerPlaceholder = createShimmerPlaceholder(LinearGradient)
return (
<ShimmerPlaceholder
ref={ref}
visible={account?.created_at !== undefined}
width={StyleConstants.Font.Size.S * 8}
2021-01-15 01:15:27 +01:00
height={StyleConstants.Font.LineHeight.S}
2020-12-27 16:25:29 +01:00
style={{ marginBottom: StyleConstants.Spacing.M }}
2021-01-17 22:37:05 +01:00
shimmerColors={[
theme.shimmerDefault,
theme.shimmerHighlight,
theme.shimmerDefault
]}
2020-12-27 16:25:29 +01:00
>
<View style={styles.created}>
<Icon
name='Calendar'
2020-12-27 16:25:29 +01:00
size={StyleConstants.Font.Size.S}
color={theme.secondary}
style={styles.icon}
/>
<Text
style={{
color: theme.secondary,
...StyleConstants.FontStyle.S
2020-12-27 16:25:29 +01:00
}}
>
{t('content.created_at', {
2021-01-22 01:34:20 +01:00
date: new Date(account?.created_at || '').toLocaleDateString(
2021-01-17 22:37:05 +01:00
i18n.language,
{
year: 'numeric',
month: 'long',
day: 'numeric'
}
)
2020-12-27 16:25:29 +01:00
})}
</Text>
</View>
</ShimmerPlaceholder>
)
}
)
const styles = StyleSheet.create({
created: {
flexDirection: 'row',
alignItems: 'center'
},
icon: {
marginRight: StyleConstants.Spacing.XS
}
})
export default AccountInformationCreated