2021-01-03 02:00:26 +01:00
|
|
|
import Icon from '@components/Icon'
|
2020-12-13 14:04:25 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2020-12-26 23:27:53 +01:00
|
|
|
import { useTheme } from '@utils/styles/ThemeManager'
|
2021-01-03 02:00:26 +01:00
|
|
|
import React, { useMemo } from 'react'
|
|
|
|
import { Pressable, StyleSheet, Text } from 'react-native'
|
2020-11-30 00:24:53 +01:00
|
|
|
|
2020-12-26 23:27:53 +01:00
|
|
|
export interface Props {
|
|
|
|
type?: 'icon' | 'text'
|
|
|
|
content?: string
|
2021-01-30 01:29:15 +01:00
|
|
|
native?: boolean
|
2020-11-30 00:24:53 +01:00
|
|
|
|
2020-12-26 23:27:53 +01:00
|
|
|
onPress: () => void
|
2020-12-14 22:33:19 +01:00
|
|
|
}
|
|
|
|
|
2021-01-30 01:29:15 +01:00
|
|
|
const HeaderLeft: React.FC<Props> = ({
|
|
|
|
type = 'icon',
|
|
|
|
content,
|
|
|
|
native = true,
|
|
|
|
onPress
|
|
|
|
}) => {
|
2020-11-30 00:24:53 +01:00
|
|
|
const { theme } = useTheme()
|
|
|
|
|
2020-12-26 23:27:53 +01:00
|
|
|
const children = useMemo(() => {
|
|
|
|
switch (type) {
|
|
|
|
case 'icon':
|
|
|
|
return (
|
2021-01-03 02:00:26 +01:00
|
|
|
<Icon
|
2020-12-26 23:27:53 +01:00
|
|
|
color={theme.primary}
|
2021-01-03 02:00:26 +01:00
|
|
|
name={content || 'ChevronLeft'}
|
2020-12-26 23:27:53 +01:00
|
|
|
size={StyleConstants.Spacing.M * 1.25}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
case 'text':
|
|
|
|
return (
|
|
|
|
<Text
|
|
|
|
style={[styles.text, { color: theme.primary }]}
|
|
|
|
children={content}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}, [theme])
|
|
|
|
|
2020-11-30 00:24:53 +01:00
|
|
|
return (
|
2020-12-13 23:38:37 +01:00
|
|
|
<Pressable
|
|
|
|
onPress={onPress}
|
2020-12-26 23:27:53 +01:00
|
|
|
children={children}
|
2020-12-13 23:38:37 +01:00
|
|
|
style={[
|
|
|
|
styles.base,
|
|
|
|
{
|
|
|
|
backgroundColor: theme.backgroundGradientStart,
|
2021-01-30 01:29:15 +01:00
|
|
|
...(type === 'icon' && {
|
|
|
|
height: 44,
|
|
|
|
width: 44,
|
|
|
|
marginLeft: native ? -9 : 9
|
|
|
|
})
|
2020-12-13 23:38:37 +01:00
|
|
|
}
|
|
|
|
]}
|
2020-12-26 23:27:53 +01:00
|
|
|
/>
|
2020-11-30 00:24:53 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
base: {
|
2020-12-13 23:38:37 +01:00
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
borderRadius: 100
|
2020-11-30 00:24:53 +01:00
|
|
|
},
|
|
|
|
text: {
|
2020-12-29 00:21:05 +01:00
|
|
|
...StyleConstants.FontStyle.M
|
2020-11-30 00:24:53 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2020-12-12 12:49:29 +01:00
|
|
|
export default HeaderLeft
|