2019-12-06 18:13:15 +05:00
|
|
|
import React, {useEffect, useState} from 'react';
|
2019-11-29 11:31:43 +05:00
|
|
|
import {View, TouchableOpacity, Platform, Text} from 'react-native';
|
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';
|
|
|
|
|
import {h} from '../../utils/utils';
|
2019-12-06 18:13:15 +05:00
|
|
|
import * as Animatable from 'react-native-animatable';
|
2019-11-29 11:31:43 +05:00
|
|
|
|
2019-12-06 18:13:15 +05:00
|
|
|
export const Header = ({
|
|
|
|
|
heading,
|
|
|
|
|
colors,
|
|
|
|
|
canGoBack = true,
|
|
|
|
|
hide,
|
|
|
|
|
showSearch,
|
|
|
|
|
sendHeight = e => {},
|
|
|
|
|
}) => {
|
2019-11-29 11:31:43 +05:00
|
|
|
return (
|
2019-12-06 18:13:15 +05:00
|
|
|
<Animatable.View
|
|
|
|
|
onLayout={e => {
|
|
|
|
|
if (sendHeight) {
|
|
|
|
|
sendHeight(e.nativeEvent.layout.height);
|
|
|
|
|
}
|
|
|
|
|
}}
|
2019-12-09 08:53:45 +05:00
|
|
|
transition={['height', 'marginBottom']}
|
|
|
|
|
duration={250}
|
2019-11-29 11:31:43 +05:00
|
|
|
style={{
|
2019-12-06 18:13:15 +05:00
|
|
|
height: hide ? 50 : 50,
|
2019-11-29 11:31:43 +05:00
|
|
|
flexDirection: 'row',
|
2019-12-06 18:13:15 +05:00
|
|
|
zIndex: 10,
|
|
|
|
|
justifyContent: 'space-between',
|
2019-11-29 11:31:43 +05:00
|
|
|
alignItems: 'center',
|
|
|
|
|
paddingHorizontal: Platform.isPad ? '2.5%' : '5%',
|
2019-12-06 18:13:15 +05:00
|
|
|
paddingTop: Platform.OS == 'ios' ? h * 0.02 : h * 0.06,
|
2019-12-09 08:53:45 +05:00
|
|
|
marginBottom: hide
|
|
|
|
|
? h * 0.03
|
|
|
|
|
: Platform.OS == 'ios'
|
|
|
|
|
? h * 0.04
|
|
|
|
|
: h * 0.04,
|
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
|
|
|
|
|
style={{
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
paddingRight: 15,
|
2019-12-07 12:05:15 +05:00
|
|
|
height: 40,
|
|
|
|
|
width: 40,
|
|
|
|
|
marginTop: 5,
|
2019-12-06 18:13:15 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<Icon
|
|
|
|
|
color={colors.pri}
|
|
|
|
|
name={'chevron-left'}
|
|
|
|
|
size={hide ? SIZE.xl : SIZE.xxl}
|
|
|
|
|
/>
|
2019-12-06 18:13:15 +05:00
|
|
|
</TouchableOpacity>
|
|
|
|
|
) : (
|
|
|
|
|
undefined
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<Animatable.Text
|
|
|
|
|
transition="fontSize"
|
|
|
|
|
duration={300}
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: hide ? SIZE.xl : SIZE.xxl,
|
|
|
|
|
color: colors.pri,
|
|
|
|
|
fontFamily: WEIGHT.bold,
|
|
|
|
|
}}>
|
|
|
|
|
{heading}
|
|
|
|
|
</Animatable.Text>
|
|
|
|
|
</View>
|
|
|
|
|
<Animatable.View
|
|
|
|
|
transition="opacity"
|
|
|
|
|
duration={500}
|
|
|
|
|
style={{
|
|
|
|
|
opacity: hide ? 1 : 0,
|
|
|
|
|
}}>
|
2019-11-29 11:31:43 +05:00
|
|
|
<TouchableOpacity
|
2019-12-06 18:13:15 +05:00
|
|
|
onPress={() => showSearch()}
|
2019-11-29 11:31:43 +05:00
|
|
|
style={{
|
|
|
|
|
justifyContent: 'center',
|
2019-12-06 18:13:15 +05:00
|
|
|
alignItems: 'flex-end',
|
|
|
|
|
height: 40,
|
|
|
|
|
width: 60,
|
|
|
|
|
paddingRight: 0,
|
|
|
|
|
marginTop: 7,
|
2019-11-29 11:31:43 +05:00
|
|
|
}}>
|
2019-12-07 12:05:15 +05:00
|
|
|
<Icon name={'search'} size={SIZE.xl} color={colors.icon} />
|
2019-11-29 11:31:43 +05:00
|
|
|
</TouchableOpacity>
|
2019-12-06 18:13:15 +05:00
|
|
|
</Animatable.View>
|
|
|
|
|
</Animatable.View>
|
2019-11-29 11:31:43 +05:00
|
|
|
);
|
|
|
|
|
};
|