mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-03-27 22:56:07 +08:00
Change to stack on example
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { FlatList } from 'react-native';
|
||||
import { createSwitchNavigator } from '@react-navigation/core';
|
||||
import { createAppContainer } from '@react-navigation/native';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { List, Divider } from 'react-native-paper';
|
||||
@@ -45,18 +44,27 @@ class Home extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const MainNavigator = createSwitchNavigator({
|
||||
Home: createStackNavigator({ Home }),
|
||||
...data.reduce((acc, it) => {
|
||||
acc[it.routeName] = {
|
||||
screen: it.component,
|
||||
navigationOptions: {
|
||||
title: it.title,
|
||||
},
|
||||
};
|
||||
const MainNavigator = createStackNavigator(
|
||||
{
|
||||
Home: createStackNavigator({ Home }),
|
||||
...data.reduce((acc, it) => {
|
||||
acc[it.routeName] = {
|
||||
screen: it.component,
|
||||
navigationOptions: {
|
||||
title: it.title,
|
||||
},
|
||||
};
|
||||
|
||||
return acc;
|
||||
}, {}),
|
||||
});
|
||||
return acc;
|
||||
}, {}),
|
||||
},
|
||||
{
|
||||
headerMode: 'none',
|
||||
mode: 'modal',
|
||||
defaultNavigationOptions: {
|
||||
gesturesEnabled: false,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export default createAppContainer(MainNavigator);
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-navigation/core": "^3.0.0-alpha.4",
|
||||
"@react-navigation/core": "3.0.0-alpha.7",
|
||||
"@react-navigation/native": "^3.0.0-alpha.5",
|
||||
"react-navigation-stack": "^1.0.0-alpha.15",
|
||||
"expo": "~30.0.0",
|
||||
"hoist-non-react-statics": "^2.5.0",
|
||||
"prop-types": "^15.6.0",
|
||||
"react": "16.3.1",
|
||||
"react-native": "~0.55.0",
|
||||
"react-native-paper": "^2.1.3"
|
||||
"react-native-paper": "^2.1.3",
|
||||
"react-navigation-stack": "^1.0.0-alpha.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-module-resolver": "^3.0.0",
|
||||
|
||||
@@ -43,9 +43,15 @@ const MyNavScreen = ({ navigation, banner }) => (
|
||||
onPress={() => navigation.navigate('Email')}
|
||||
title="Open other screen"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Button onPress={() => navigation.goBack()} title="Go back" />
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Home')}
|
||||
onPress={() => {
|
||||
if (navigation.goBack(null)) {
|
||||
// cool
|
||||
} else {
|
||||
alert('goBack(null) not handled');
|
||||
}
|
||||
}}
|
||||
title="Go back to list"
|
||||
/>
|
||||
</SafeAreaView>
|
||||
|
||||
@@ -565,6 +565,17 @@
|
||||
pouchdb-collections "^1.0.1"
|
||||
tiny-queue "^0.2.1"
|
||||
|
||||
"@react-navigation/core@3.0.0-alpha.7":
|
||||
version "3.0.0-alpha.7"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.0.0-alpha.7.tgz#10116867febd74a371a7cc393c3dd6071e25ceae"
|
||||
integrity sha512-aUbUAUgNpOppxj59E++S39gBiRCLlttzmwxeZoIJJ57q3IQ2vXNjXiAl66xJeRTIGT5GsEn0nOJO4YeSd5FOfQ==
|
||||
dependencies:
|
||||
create-react-context "^0.2.3"
|
||||
hoist-non-react-statics "^3.0.1"
|
||||
path-to-regexp "^1.7.0"
|
||||
query-string "^6.2.0"
|
||||
react-lifecycles-compat "^3.0.4"
|
||||
|
||||
"@react-navigation/core@^3.0.0-alpha.4":
|
||||
version "3.0.0-alpha.4"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/core/-/core-3.0.0-alpha.4.tgz#0167a8352e867ebd09e444aac42b315f569fb81d"
|
||||
@@ -5525,6 +5536,13 @@ path-to-regexp@0.1.7:
|
||||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
|
||||
integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=
|
||||
|
||||
path-to-regexp@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
|
||||
integrity sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=
|
||||
dependencies:
|
||||
isarray "0.0.1"
|
||||
|
||||
path-to-regexp@^2.4.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-2.4.0.tgz#35ce7f333d5616f1c1e1bfe266c3aba2e5b2e704"
|
||||
|
||||
Reference in New Issue
Block a user