2020-11-30 00:24:53 +01:00
|
|
|
import { Feather } from '@expo/vector-icons'
|
|
|
|
import React from 'react'
|
|
|
|
import { Pressable, StyleSheet, Text } from 'react-native'
|
|
|
|
|
2020-12-13 14:04:25 +01:00
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2020-11-30 00:24:53 +01:00
|
|
|
|
|
|
|
type PropsBase = {
|
2020-12-03 01:28:56 +01:00
|
|
|
disabled?: boolean
|
2020-11-30 00:24:53 +01:00
|
|
|
onPress: () => void
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface PropsText extends PropsBase {
|
|
|
|
text: string
|
2020-12-12 12:49:29 +01:00
|
|
|
icon?: any
|
2020-11-30 00:24:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PropsIcon extends PropsBase {
|
|
|
|
text?: string
|
2020-12-12 12:49:29 +01:00
|
|
|
icon: any
|
2020-11-30 00:24:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const HeaderRight: React.FC<PropsText | PropsIcon> = ({
|
2020-12-03 01:28:56 +01:00
|
|
|
disabled,
|
2020-11-30 00:24:53 +01:00
|
|
|
onPress,
|
|
|
|
text,
|
|
|
|
icon
|
|
|
|
}) => {
|
|
|
|
const { theme } = useTheme()
|
|
|
|
|
|
|
|
return (
|
2020-12-03 01:28:56 +01:00
|
|
|
<Pressable {...(!disabled && { onPress })} style={styles.base}>
|
|
|
|
{text && (
|
|
|
|
<Text
|
|
|
|
style={[
|
|
|
|
styles.text,
|
|
|
|
{ color: disabled ? theme.secondary : theme.primary }
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
{text}
|
|
|
|
</Text>
|
|
|
|
)}
|
2020-11-30 00:24:53 +01:00
|
|
|
{icon && (
|
|
|
|
<Feather
|
|
|
|
name={icon}
|
2020-12-03 01:28:56 +01:00
|
|
|
color={disabled ? theme.secondary : theme.primary}
|
2020-11-30 00:24:53 +01:00
|
|
|
size={StyleConstants.Font.Size.L}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Pressable>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
base: {
|
|
|
|
paddingLeft: StyleConstants.Spacing.S
|
|
|
|
},
|
|
|
|
text: {
|
2020-12-03 01:28:56 +01:00
|
|
|
fontSize: StyleConstants.Font.Size.M
|
2020-11-30 00:24:53 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-12-12 12:49:29 +01:00
|
|
|
export default HeaderRight
|