mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-27 21:08:02 +08:00
navigationOptions in navigator config is renamed to defaultNavigationOptions.
The new meaning of navigationOptions in navigator config is the navigation options for that navigator, not for screens inside of it.
This commit is contained in:
@@ -346,7 +346,11 @@ const AppNavigator = createStackNavigator(
|
||||
}
|
||||
);
|
||||
|
||||
export default AppNavigator;
|
||||
export default class App extends React.Component {
|
||||
render() {
|
||||
return <AppNavigator /* persistenceKey="if-you-want-it" */ />;
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
item: {
|
||||
|
||||
@@ -46,33 +46,39 @@ DraftsScreen.navigationOptions = {
|
||||
headerTitle: 'Drafts',
|
||||
};
|
||||
|
||||
const InboxStack = createStackNavigator({
|
||||
Inbox: { screen: InboxScreen },
|
||||
Email: { screen: EmailScreen },
|
||||
});
|
||||
const InboxStack = createStackNavigator(
|
||||
{
|
||||
Inbox: { screen: InboxScreen },
|
||||
Email: { screen: EmailScreen },
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
drawerLabel: 'Inbox',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons
|
||||
name="move-to-inbox"
|
||||
size={24}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
InboxStack.navigationOptions = {
|
||||
drawerLabel: 'Inbox',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons
|
||||
name="move-to-inbox"
|
||||
size={24}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
const DraftsStack = createStackNavigator({
|
||||
Drafts: { screen: DraftsScreen },
|
||||
Email: { screen: EmailScreen },
|
||||
});
|
||||
|
||||
DraftsStack.navigationOptions = {
|
||||
drawerLabel: 'Drafts',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons name="drafts" size={24} style={{ color: tintColor }} />
|
||||
),
|
||||
};
|
||||
const DraftsStack = createStackNavigator(
|
||||
{
|
||||
Drafts: { screen: DraftsScreen },
|
||||
Email: { screen: EmailScreen },
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
drawerLabel: 'Drafts',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons name="drafts" size={24} style={{ color: tintColor }} />
|
||||
),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const DrawerExample = createDrawerNavigator(
|
||||
{
|
||||
@@ -85,6 +91,7 @@ const DrawerExample = createDrawerNavigator(
|
||||
screen: DraftsStack,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
initialRouteName: 'Drafts',
|
||||
contentOptions: {
|
||||
|
||||
@@ -70,7 +70,7 @@ const ProfileNavigator = createStackNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
defaultNavigationOptions: {
|
||||
headerLeft: null,
|
||||
},
|
||||
mode: 'modal',
|
||||
@@ -97,7 +97,7 @@ const ModalStack = createStackNavigator(
|
||||
HeaderTest: { screen: MyHeaderTestScreen },
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
defaultNavigationOptions: {
|
||||
header: null,
|
||||
},
|
||||
mode: 'modal',
|
||||
|
||||
@@ -122,7 +122,7 @@ const StackWithCustomHeaderBackImage = createStackNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
defaultNavigationOptions: {
|
||||
headerBackImage: MyCustomHeaderBackImage,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ const StackWithTranslucentHeader = createStackNavigator(
|
||||
HeaderStyleInterpolator.forBackgroundWithTranslation,
|
||||
}),
|
||||
|
||||
navigationOptions: {
|
||||
defaultNavigationOptions: {
|
||||
headerTransparent: true,
|
||||
headerStyle: {
|
||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||
|
||||
@@ -133,7 +133,7 @@ const StackNavigator = createStackNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
defaultNavigationOptions: {
|
||||
headerStyle: styles.stackHeader,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { polyfill } from 'react-lifecycles-compat';
|
||||
function createNavigator(NavigatorView, router, navigationConfig) {
|
||||
class Navigator extends React.Component {
|
||||
static router = router;
|
||||
static navigationOptions = null;
|
||||
static navigationOptions = navigationConfig.navigationOptions;
|
||||
|
||||
state = {
|
||||
descriptors: {},
|
||||
|
||||
@@ -564,7 +564,7 @@ export default (routeConfigs, stackConfig = {}) => {
|
||||
|
||||
getScreenOptions: createConfigGetter(
|
||||
routeConfigs,
|
||||
stackConfig.navigationOptions
|
||||
stackConfig.defaultNavigationOptions
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -321,7 +321,7 @@ export default (routeConfigs, config = {}) => {
|
||||
|
||||
getScreenOptions: createConfigGetter(
|
||||
routeConfigs,
|
||||
config.navigationOptions
|
||||
config.defaultNavigationOptions
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user