2020-01-18 01:04:33 +05:00
|
|
|
import React from 'react';
|
|
|
|
|
import {Platform, StatusBar, Text, TouchableOpacity, View} from 'react-native';
|
|
|
|
|
import * as Animatable from 'react-native-animatable';
|
2019-11-30 19:56:40 +05:00
|
|
|
import Icon from 'react-native-vector-icons/Feather';
|
2019-11-29 11:31:43 +05:00
|
|
|
import {SIZE, WEIGHT} from '../../common/common';
|
2020-01-17 21:26:01 +05:00
|
|
|
import {useTracked} from '../../provider';
|
2020-01-18 01:04:33 +05:00
|
|
|
import NavigationService from '../../services/NavigationService';
|
|
|
|
|
import {SideMenuEvent} from '../../utils/utils';
|
2020-01-14 17:33:48 +05:00
|
|
|
let isOpen = false;
|
2019-12-06 18:13:15 +05:00
|
|
|
export const Header = ({
|
|
|
|
|
heading,
|
|
|
|
|
canGoBack = true,
|
|
|
|
|
hide,
|
|
|
|
|
showSearch,
|
2019-12-11 15:20:18 +05:00
|
|
|
menu,
|
2020-01-01 01:26:23 +05:00
|
|
|
verticalMenu = false,
|
2019-12-06 18:13:15 +05:00
|
|
|
sendHeight = e => {},
|
|
|
|
|
}) => {
|
2020-01-17 21:26:01 +05:00
|
|
|
const [state, dispatch] = useTracked();
|
|
|
|
|
const {colors} = state;
|
2019-12-14 16:00:16 +05:00
|
|
|
|
2019-11-29 11:31:43 +05:00
|
|
|
return (
|
2019-12-06 18:13:15 +05:00
|
|
|
<Animatable.View
|
2019-12-09 13:17:40 +05:00
|
|
|
transition={['minHeight', 'marginBottom']}
|
2019-12-09 08:53:45 +05:00
|
|
|
duration={250}
|
2019-11-29 11:31:43 +05:00
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
2019-12-06 18:13:15 +05:00
|
|
|
zIndex: 10,
|
2019-12-21 09:46:08 +05:00
|
|
|
height: 50,
|
2020-01-07 18:14:36 +05:00
|
|
|
marginTop: Platform.OS === 'ios' ? 0 : StatusBar.currentHeight,
|
2019-12-21 09:46:08 +05:00
|
|
|
marginBottom: 10,
|
2019-12-06 18:13:15 +05:00
|
|
|
justifyContent: 'space-between',
|
2019-11-29 11:31:43 +05:00
|
|
|
alignItems: 'center',
|
2020-01-08 11:25:26 +05:00
|
|
|
paddingHorizontal: 12,
|
|
|
|
|
width: '100%',
|
2019-11-29 11:31:43 +05:00
|
|
|
}}>
|
2019-12-06 18:13:15 +05:00
|
|
|
<View
|
|
|
|
|
style={{
|
|
|
|
|
flexDirection: 'row',
|
|
|
|
|
justifyContent: 'flex-start',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
}}>
|
|
|
|
|
{canGoBack ? (
|
|
|
|
|
<TouchableOpacity
|
2019-12-11 15:20:18 +05:00
|
|
|
hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}
|
|
|
|
|
onPress={() => {
|
|
|
|
|
NavigationService.goBack();
|
|
|
|
|
}}
|
2019-12-06 18:13:15 +05:00
|
|
|
style={{
|
2020-01-07 16:26:30 +05:00
|
|
|
justifyContent: 'center',
|
2019-12-11 15:20:18 +05:00
|
|
|
alignItems: 'flex-start',
|
2019-12-07 12:05:15 +05:00
|
|
|
height: 40,
|
2020-01-07 16:26:30 +05:00
|
|
|
width: 50,
|
|
|
|
|
marginTop: 2.5,
|
2019-12-06 18:13:15 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<Icon
|
2019-12-11 15:20:18 +05:00
|
|
|
style={{
|
2020-01-08 11:31:43 +05:00
|
|
|
marginLeft: -5,
|
2019-12-11 15:20:18 +05:00
|
|
|
}}
|
2019-12-07 12:05:15 +05:00
|
|
|
color={colors.pri}
|
|
|
|
|
name={'chevron-left'}
|
2020-01-07 16:26:30 +05:00
|
|
|
size={SIZE.xxxl - 3}
|
2019-12-07 12:05:15 +05:00
|
|
|
/>
|
2019-12-06 18:13:15 +05:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
) : (
|
|
|
|
|
undefined
|
|
|
|
|
)}
|
2019-12-11 15:20:18 +05:00
|
|
|
{menu ? (
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
hitSlop={{top: 20, bottom: 20, left: 50, right: 40}}
|
|
|
|
|
onPress={() => {
|
2020-01-14 17:33:48 +05:00
|
|
|
SideMenuEvent.open();
|
2019-12-11 15:20:18 +05:00
|
|
|
}}
|
|
|
|
|
style={{
|
2019-12-14 16:00:16 +05:00
|
|
|
justifyContent: 'center',
|
2019-12-11 15:20:18 +05:00
|
|
|
alignItems: 'flex-start',
|
|
|
|
|
height: 40,
|
2019-12-21 09:46:08 +05:00
|
|
|
marginTop: 2.5,
|
2020-01-01 00:04:59 +05:00
|
|
|
width: 60,
|
2019-12-11 15:20:18 +05:00
|
|
|
}}>
|
2019-12-21 09:46:08 +05:00
|
|
|
<Icon color={colors.pri} name={'menu'} size={SIZE.xxxl - 3} />
|
2019-12-11 15:20:18 +05:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
) : (
|
|
|
|
|
undefined
|
|
|
|
|
)}
|
2019-12-06 18:13:15 +05:00
|
|
|
|
2019-12-21 09:46:08 +05:00
|
|
|
<Text
|
2019-12-06 18:13:15 +05:00
|
|
|
style={{
|
2019-12-21 09:46:08 +05:00
|
|
|
fontSize: SIZE.xl,
|
2019-12-06 18:13:15 +05:00
|
|
|
color: colors.pri,
|
|
|
|
|
fontFamily: WEIGHT.bold,
|
|
|
|
|
}}>
|
|
|
|
|
{heading}
|
2019-12-21 09:46:08 +05:00
|
|
|
</Text>
|
2019-12-06 18:13:15 +05:00
|
|
|
</View>
|
2020-01-01 00:04:59 +05:00
|
|
|
<View
|
2019-12-06 18:13:15 +05:00
|
|
|
style={{
|
2020-01-01 00:04:59 +05:00
|
|
|
flexDirection: 'row',
|
|
|
|
|
alignItems: 'center',
|
2019-12-06 18:13:15 +05:00
|
|
|
}}>
|
2020-01-01 00:04:59 +05:00
|
|
|
<Animatable.View
|
|
|
|
|
transition="opacity"
|
2020-01-07 11:12:55 +05:00
|
|
|
useNativeDriver={true}
|
2020-01-01 00:04:59 +05:00
|
|
|
duration={500}
|
|
|
|
|
style={{
|
|
|
|
|
opacity: hide ? 1 : 0,
|
|
|
|
|
}}>
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
onPress={() => showSearch()}
|
|
|
|
|
style={{
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
|
height: 40,
|
|
|
|
|
width: 60,
|
|
|
|
|
paddingRight: 0,
|
|
|
|
|
}}>
|
2020-01-07 16:29:49 +05:00
|
|
|
<Icon name={'search'} size={SIZE.xl} color={colors.icon} />
|
2020-01-01 00:04:59 +05:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
</Animatable.View>
|
2020-01-01 01:26:23 +05:00
|
|
|
{verticalMenu ? (
|
|
|
|
|
<TouchableOpacity
|
|
|
|
|
style={{
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
|
height: 40,
|
|
|
|
|
width: 60,
|
|
|
|
|
}}>
|
2020-01-07 11:12:55 +05:00
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
transform: [
|
|
|
|
|
{
|
|
|
|
|
translateX: 0,
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-01-08 11:25:26 +05:00
|
|
|
translateY: 5,
|
2020-01-07 11:12:55 +05:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
|
|
|
|
name="arrow-down"
|
|
|
|
|
size={SIZE.lg}
|
2020-01-07 16:29:49 +05:00
|
|
|
color={colors.icon}
|
2020-01-07 11:12:55 +05:00
|
|
|
/>
|
|
|
|
|
<Icon
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
transform: [
|
|
|
|
|
{
|
|
|
|
|
translateX: -15,
|
|
|
|
|
},
|
|
|
|
|
{
|
2020-01-08 11:25:26 +05:00
|
|
|
translateY: -5,
|
2020-01-07 11:12:55 +05:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}}
|
|
|
|
|
name="arrow-up"
|
|
|
|
|
size={SIZE.lg}
|
2020-01-07 16:29:49 +05:00
|
|
|
color={colors.icon}
|
2020-01-07 11:12:55 +05:00
|
|
|
/>
|
2020-01-01 01:26:23 +05:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
) : null}
|
2020-01-01 00:04:59 +05:00
|
|
|
</View>
|
2019-12-06 18:13:15 +05:00
|
|
|
</Animatable.View>
|
2019-11-29 11:31:43 +05:00
|
|
|
);
|
|
|
|
|
};
|