tooot/src/components/Header/Center.tsx

48 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-08-14 22:18:41 +02:00
import Icon from '@components/Icon'
import CustomText from '@components/Text'
2022-08-14 22:18:41 +02:00
import { StyleConstants } from '@utils/styles/constants'
2021-01-14 00:43:35 +01:00
import { useTheme } from '@utils/styles/ThemeManager'
import React from 'react'
2022-08-14 22:18:41 +02:00
import { View } from 'react-native'
2021-01-14 00:43:35 +01:00
export interface Props {
2022-08-14 22:18:41 +02:00
content?: string
2021-02-10 00:40:44 +01:00
inverted?: boolean
2022-08-13 00:48:20 +02:00
onPress?: () => void
2022-08-14 22:18:41 +02:00
dropdown?: boolean
2021-01-14 00:43:35 +01:00
}
// Used for Android mostly
2022-08-13 00:48:20 +02:00
const HeaderCenter: React.FC<Props> = ({
content,
inverted = false,
2022-08-14 22:18:41 +02:00
onPress,
dropdown = false
2022-08-13 00:48:20 +02:00
}) => {
const { colors } = useTheme()
2021-01-14 00:43:35 +01:00
2022-08-13 00:48:20 +02:00
return (
2022-08-19 12:22:30 +02:00
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
2022-08-14 22:18:41 +02:00
<CustomText
style={{
color: inverted ? colors.primaryOverlay : colors.primaryDefault
}}
fontSize='L'
fontWeight='Bold'
numberOfLines={1}
children={content}
{...(onPress && { onPress })}
/>
2022-08-19 12:22:30 +02:00
<Icon
name='ChevronDown'
size={StyleConstants.Font.Size.M}
color={colors.primaryDefault}
style={{ marginLeft: StyleConstants.Spacing.XS, opacity: dropdown ? undefined : 0 }}
strokeWidth={3}
/>
2022-08-14 22:18:41 +02:00
</View>
2022-08-13 00:48:20 +02:00
)
}
2021-01-14 00:43:35 +01:00
export default HeaderCenter