tooot/src/components/Instance/Info.tsx

62 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-01-07 19:13:09 +01:00
import { StyleConstants } from '@utils/styles/constants'
import { useTheme } from '@utils/styles/ThemeManager'
import React from 'react'
2021-01-23 02:41:50 +01:00
import { StyleSheet, Text, View, ViewStyle } from 'react-native'
import { PlaceholderLine } from 'rn-placeholder'
2021-01-07 19:13:09 +01:00
export interface Props {
style?: ViewStyle
header: string
content?: string
potentialWidth?: number
}
const InstanceInfo = React.memo(
2021-03-06 21:01:38 +01:00
({ style, header, content, potentialWidth }: Props) => {
2021-01-07 19:13:09 +01:00
const { theme } = useTheme()
return (
<View style={[styles.base, style]}>
<Text style={[styles.header, { color: theme.primaryDefault }]}>{header}</Text>
2021-01-23 02:41:50 +01:00
{content ? (
<Text style={[styles.content, { color: theme.primaryDefault }]}>
2021-03-10 10:22:53 +01:00
{content}
</Text>
2021-01-23 02:41:50 +01:00
) : (
2021-03-06 21:01:38 +01:00
<PlaceholderLine
width={
potentialWidth
? potentialWidth * StyleConstants.Font.Size.M
: undefined
}
height={StyleConstants.Font.LineHeight.M}
color={theme.shimmerDefault}
noMargin
style={{ borderRadius: 0 }}
/>
2021-01-23 02:41:50 +01:00
)}
2021-01-07 19:13:09 +01:00
</View>
)
2021-03-06 21:01:38 +01:00
},
(prev, next) => prev.content === next.content
2021-01-07 19:13:09 +01:00
)
const styles = StyleSheet.create({
base: {
flex: 1,
marginTop: StyleConstants.Spacing.M,
paddingLeft: StyleConstants.Spacing.Global.PagePadding,
paddingRight: StyleConstants.Spacing.Global.PagePadding
},
header: {
...StyleConstants.FontStyle.S,
fontWeight: StyleConstants.Font.Weight.Bold,
marginBottom: StyleConstants.Spacing.XS
2021-03-10 10:22:53 +01:00
},
content: {
...StyleConstants.FontStyle.M
2021-01-07 19:13:09 +01:00
}
})
export default InstanceInfo