I'll like to hide the navigation header when clicked on the icon, the code bellow hides the header but do not restore it when search back button is pressed ....
Here is the code:
static navigationOptions = ({ navigation }) => {
const {params} = navigation.state;
return {
title: 'Chats',
titleStyle: {
color: '#ffffff',
},
tintColor: '#ffffff',
headerTintColor: '#ffffff',
headerStyle: {
backgroundColor: "#E6A919"
},
header: navigation.state.params ? navigation.state.params.header : undefined,
headerTitleStyle: {
color: '#ffffff'
},
headerRight: () =>
<TouchableOpacity
onPress={
() => {
navigation.setParams({ header: null });
navigation.setParams({ showSearch: true });
}
}
>
<Icon
style={{ width: 24, height: 24, margin: 15, color: '#ffffff', backgroundColor: 'transparent'}}
name={"search"}
/>
</TouchableOpacity>
}
}
onBackPressed = () => {
console.log("Back pressed!");
this.props.navigation.setParams({ showSearch: false });
this.props.navigation.setParams({ header: true });
this.resetSearchText();
};
What can I do?
Thanks