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

99 lines
2.8 KiB
TypeScript
Raw Normal View History

2021-01-04 18:29:02 +01:00
import { useNavigation } from '@react-navigation/native'
2020-12-27 16:25:29 +01:00
import { StyleConstants } from '@root/utils/styles/constants'
import { useTheme } from '@root/utils/styles/ThemeManager'
2021-01-23 02:41:50 +01:00
import React from 'react'
2020-12-27 16:25:29 +01:00
import { useTranslation } from 'react-i18next'
import { StyleSheet, Text, 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
2021-01-23 02:41:50 +01:00
ownAccount?: boolean
2020-12-27 16:25:29 +01:00
}
2021-01-23 02:41:50 +01:00
const AccountInformationStats: React.FC<Props> = ({ account, ownAccount }) => {
2021-01-04 18:29:02 +01:00
const navigation = useNavigation()
2020-12-27 16:25:29 +01:00
const { theme } = useTheme()
const { t } = useTranslation('sharedAccount')
return (
2021-01-23 02:41:50 +01:00
<View style={[styles.stats, { flexDirection: 'row' }]}>
{account ? (
<Text
style={[styles.stat, { color: theme.primary }]}
children={t('content.summary.statuses_count', {
2020-12-27 16:25:29 +01:00
count: account?.statuses_count || 0
})}
2021-01-23 02:41:50 +01:00
onPress={() =>
ownAccount && navigation.push('Screen-Shared-Account', { account })
}
/>
) : (
<PlaceholderLine
width={StyleConstants.Font.Size.S * 1.25}
height={StyleConstants.Font.LineHeight.S}
color={theme.shimmerDefault}
noMargin
style={{ borderRadius: 0 }}
/>
)}
{account ? (
2020-12-27 16:25:29 +01:00
<Text
2021-01-04 18:29:02 +01:00
style={[styles.stat, { color: theme.primary, textAlign: 'right' }]}
2021-01-23 02:41:50 +01:00
children={t('content.summary.following_count', {
count: account?.following_count || 0
})}
2021-01-04 18:29:02 +01:00
onPress={() =>
navigation.push('Screen-Shared-Relationships', {
account,
initialType: 'following'
})
}
2021-01-23 02:41:50 +01:00
/>
) : (
<PlaceholderLine
width={StyleConstants.Font.Size.S * 1.25}
height={StyleConstants.Font.LineHeight.S}
color={theme.shimmerDefault}
noMargin
style={{ borderRadius: 0 }}
/>
)}
{account ? (
2020-12-27 16:25:29 +01:00
<Text
2021-01-04 18:29:02 +01:00
style={[styles.stat, { color: theme.primary, textAlign: 'center' }]}
2021-01-23 02:41:50 +01:00
children={t('content.summary.followers_count', {
count: account?.followers_count || 0
})}
2021-01-04 18:29:02 +01:00
onPress={() =>
navigation.push('Screen-Shared-Relationships', {
account,
initialType: 'followers'
})
}
2021-01-23 02:41:50 +01:00
/>
) : (
<PlaceholderLine
width={StyleConstants.Font.Size.S * 1.25}
height={StyleConstants.Font.LineHeight.S}
color={theme.shimmerDefault}
noMargin
style={{ borderRadius: 0 }}
/>
)}
2020-12-27 16:25:29 +01:00
</View>
)
2021-01-23 02:41:50 +01:00
}
2020-12-27 16:25:29 +01:00
const styles = StyleSheet.create({
stats: {
flex: 1,
justifyContent: 'space-between'
},
stat: {
...StyleConstants.FontStyle.S
2020-12-27 16:25:29 +01:00
}
})
export default AccountInformationStats