Все классы моего React Native
кода имеют свой собственный заголовок, реализованный с использованием navigationOptions
, и я создал bottomTabNavigator
, который имеет свой собственный заголовок, перезаписывая существующий заголовок и их функциональность. Как скрыть заголовок bottomTabNavigator
, когда собственные заголовки классов работают правильно и соответственно?
Я использовал header: null
и navigationOptions: { header: null, }
в стеке bottomTabNavigator
, а также header: { visible: false, }
, но это не сработало, поскольку заголовок все еще виден.
import React from 'react';
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
import { createBottomTabNavigator, createAppContainer } from 'react-navigation';
import { Input, Icon, SearchBar, ListItem } from 'react-native-elements';
import Notification from './notification.js';
import Nearby from './nearby.js';
import Add from './add.js';
class MainScreen extends React.Component {
constructor(props){
super(props);
this.state = { search: '' };
}
static navigationOptions = {
title: 'Contacts',
headerLeft: null,
headerRight: (
<TouchableOpacity
activeOpacity={0.6}
style={{marginRight: 10,}}
onPress={() => alert('Map is shown!')}>
<Text style={{ color: '#3090C7', fontSize: 16 }}>View on Map</Text>
</TouchableOpacity>
),
headerTitleStyle: { width: '110%', textAlign: 'center', },
headerStyle: { backgroundColor: '#E4E4E2' }
};
render() {
return (
<View style={{ flex: 1, justifyContent: 'flex-start', alignItems: 'center', backgroundColor: '#F3F3F3' }}>
<SearchBar
autoCorrect={false}
placeholder='Search From Contacts'
platform = 'ios'
inputStyle = {styles.txt}
onChangeText = {search => this.setState ({search})}
value={this.state.search}
/>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F3F3F3' }}>
<Text> Successfully Logged-In </Text>
</View>
</View>
);
}
}
const HomeStack = createBottomTabNavigator({
Home: { screen: MainScreen, header: { visible: false, } },
Notification: { screen: Notification, header: null, },
Nearby: { screen: Nearby, header: null, },
Add: { screen: Add, header: null, },
});
const Home = createAppContainer(HomeStack);
export default Home;
const styles = StyleSheet.create({
txt: {
color: '#3090C7',
fontSize: 18,
fontWeight: '500',
},
btn: {
alignItems: 'center',
justifyContent: 'center',
alignSelf: 'center',
},
})
Я ожидаю, что заголовок bottomTabNavigator
должен быть скрыт, а заголовки каждого класса должны быть видны.