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

91 lines
2.4 KiB
TypeScript
Raw Normal View History

import Icon from '@components/Icon'
2021-01-01 16:48:16 +01:00
import { ParseHTML } from '@components/Parse'
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
2020-12-27 16:25:29 +01:00
import React from 'react'
import { StyleSheet, View } from 'react-native'
export interface Props {
account: Mastodon.Account
}
2021-01-15 01:15:27 +01:00
const AccountInformationFields = React.memo(
({ account }: Props) => {
const { theme } = useTheme()
2020-12-27 16:25:29 +01:00
2021-01-15 01:15:27 +01:00
return (
<View style={[styles.fields, { borderTopColor: theme.border }]}>
{account.fields.map((field, index) => (
<View
key={index}
style={[styles.field, { borderBottomColor: theme.border }]}
>
<View
style={[styles.fieldLeft, { borderRightColor: theme.border }]}
>
<ParseHTML
content={field.name}
2021-02-01 02:16:53 +01:00
size={'S'}
2021-01-15 01:15:27 +01:00
emojis={account.emojis}
showFullLink
2021-01-17 22:37:05 +01:00
numberOfLines={5}
2020-12-27 16:25:29 +01:00
/>
2021-01-15 01:15:27 +01:00
{field.verified_at ? (
<Icon
name='CheckCircle'
size={StyleConstants.Font.Size.M}
color={theme.primaryDefault}
2021-01-15 01:15:27 +01:00
style={styles.fieldCheck}
/>
) : null}
</View>
<View style={styles.fieldRight}>
<ParseHTML
content={field.value}
2021-02-01 02:16:53 +01:00
size={'S'}
2021-01-15 01:15:27 +01:00
emojis={account.emojis}
showFullLink
2021-01-17 22:37:05 +01:00
numberOfLines={5}
2021-01-15 01:15:27 +01:00
/>
</View>
2020-12-27 16:25:29 +01:00
</View>
2021-01-15 01:15:27 +01:00
))}
</View>
)
},
() => true
)
2020-12-27 16:25:29 +01:00
const styles = StyleSheet.create({
fields: {
borderTopWidth: StyleSheet.hairlineWidth,
marginBottom: StyleConstants.Spacing.M
},
field: {
flex: 1,
flexDirection: 'row',
borderBottomWidth: StyleSheet.hairlineWidth,
paddingTop: StyleConstants.Spacing.S,
paddingBottom: StyleConstants.Spacing.S
},
fieldLeft: {
2021-01-01 23:10:47 +01:00
flex: 1,
2020-12-27 16:25:29 +01:00
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
borderRightWidth: 1,
paddingLeft: StyleConstants.Spacing.S,
paddingRight: StyleConstants.Spacing.S
},
fieldCheck: { marginLeft: StyleConstants.Spacing.XS },
fieldRight: {
2021-01-01 23:10:47 +01:00
flex: 3,
2020-12-27 16:25:29 +01:00
alignItems: 'center',
justifyContent: 'center',
paddingLeft: StyleConstants.Spacing.S,
paddingRight: StyleConstants.Spacing.S
}
})
export default AccountInformationFields