mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-26 13:35:32 +08:00
Initial commit
This commit is contained in:
12
packages/stack/example/.babelrc
Normal file
12
packages/stack/example/.babelrc
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"presets": [
|
||||
"expo"
|
||||
],
|
||||
"plugins": [
|
||||
["module-resolver", {
|
||||
"alias": {
|
||||
"react-navigation-stack": "../src"
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
6
packages/stack/example/.buckconfig
Normal file
6
packages/stack/example/.buckconfig
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
[android]
|
||||
target = Google Inc.:Google APIs:23
|
||||
|
||||
[maven_repositories]
|
||||
central = https://repo1.maven.org/maven2
|
||||
11
packages/stack/example/.eslintrc
Normal file
11
packages/stack/example/.eslintrc
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "../.eslintrc",
|
||||
|
||||
"settings": {
|
||||
"import/core-modules": [ "expo", "react-navigation-stack" ]
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"react/prop-types": "off"
|
||||
}
|
||||
}
|
||||
1
packages/stack/example/.watchmanconfig
Normal file
1
packages/stack/example/.watchmanconfig
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
53
packages/stack/example/App.js
Normal file
53
packages/stack/example/App.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import React from 'react';
|
||||
import Expo from 'expo';
|
||||
import { FlatList } from 'react-native';
|
||||
import { createSwitchNavigator } from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { ListSection, Divider } from 'react-native-paper';
|
||||
import SimpleStack from './src/SimpleStack';
|
||||
|
||||
const data = [
|
||||
{ component: SimpleStack, title: 'Simple', routeName: 'SimpleStack' },
|
||||
];
|
||||
|
||||
class Home extends React.Component {
|
||||
static navigationOptions = {
|
||||
title: 'Examples',
|
||||
};
|
||||
|
||||
_renderItem = ({ item }) => (
|
||||
<ListSection.Item
|
||||
title={item.title}
|
||||
onPress={() => this.props.navigation.navigate(item.routeName)}
|
||||
/>
|
||||
);
|
||||
|
||||
_keyExtractor = item => item.routeName;
|
||||
|
||||
render() {
|
||||
return (
|
||||
<FlatList
|
||||
ItemSeparatorComponent={Divider}
|
||||
renderItem={this._renderItem}
|
||||
keyExtractor={this._keyExtractor}
|
||||
data={data}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const App = createSwitchNavigator({
|
||||
Home: createStackNavigator({ Home }),
|
||||
...data.reduce((acc, it) => {
|
||||
acc[it.routeName] = {
|
||||
screen: it.component,
|
||||
navigationOptions: {
|
||||
title: it.title,
|
||||
},
|
||||
};
|
||||
|
||||
return acc;
|
||||
}, {}),
|
||||
});
|
||||
|
||||
Expo.registerRootComponent(App);
|
||||
8
packages/stack/example/README.md
Normal file
8
packages/stack/example/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
## Run the example
|
||||
|
||||
- [View it with Expo](https://expo.io/@satya164/react-navigation-tabs-demos)
|
||||
- Run the example locally
|
||||
+ Clone the repository and `cd` to this directory
|
||||
+ Run `yarn` to install the dependencies
|
||||
+ Run `yarn start` to start the packager
|
||||
+ Scan the QR Code with the Expo app
|
||||
17
packages/stack/example/app.json
Normal file
17
packages/stack/example/app.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "React Navigation Stack Example",
|
||||
"description": "Demonstrates the various capabilities of react-navigation-stack",
|
||||
"slug": "react-navigation-stack-demo",
|
||||
"sdkVersion": "29.0.0",
|
||||
"version": "1.0.0",
|
||||
"primaryColor": "#2196f3",
|
||||
"packagerOpts": {
|
||||
"assetExts": [
|
||||
"ttf"
|
||||
],
|
||||
"config": "./rn-cli.config.js",
|
||||
"projectRoots": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
32
packages/stack/example/package.json
Normal file
32
packages/stack/example/package.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "drawerexample",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "expo start",
|
||||
"android": "expo start --android",
|
||||
"ios": "expo start --ios",
|
||||
"postinstall": "rm -rf node_modules/expo-react-native-adapter/node_modules/react && rm -rf node_modules/expo-gl/node_modules/react"
|
||||
},
|
||||
"dependencies": {
|
||||
"expo": "~29.0.0",
|
||||
"hoist-non-react-statics": "^2.5.0",
|
||||
"prop-types": "^15.6.0",
|
||||
"react": "16.3.1",
|
||||
"react-native": "~0.55.4",
|
||||
"react-navigation": "^2.11.1",
|
||||
"react-native-paper": "2.0.0-alpha.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-module-resolver": "^3.0.0",
|
||||
"babel-preset-expo": "^4.0.0",
|
||||
"glob-to-regexp": "^0.3.0"
|
||||
},
|
||||
"main": "App.js",
|
||||
"resolutions": {
|
||||
"**/react": "16.3.1",
|
||||
"**/prop-types": "15.6.0",
|
||||
"**/react-lifecycles-compat": "3.0.4",
|
||||
"**/hoist-non-react-statics": "2.5.0"
|
||||
}
|
||||
}
|
||||
21
packages/stack/example/rn-cli.config.js
Normal file
21
packages/stack/example/rn-cli.config.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
const path = require('path');
|
||||
const glob = require('glob-to-regexp');
|
||||
const blacklist = require('metro/src/blacklist');
|
||||
const pak = require('../package.json');
|
||||
|
||||
const dependencies = Object.keys(pak.dependencies);
|
||||
const peerDependencies = Object.keys(pak.peerDependencies);
|
||||
|
||||
module.exports = {
|
||||
getProjectRoots() {
|
||||
return [__dirname, path.resolve(__dirname, '..')];
|
||||
},
|
||||
getProvidesModuleNodeModules() {
|
||||
return [...dependencies, ...peerDependencies];
|
||||
},
|
||||
getBlacklistRE() {
|
||||
return blacklist([glob(`${path.resolve(__dirname, '..')}/node_modules/*`)]);
|
||||
},
|
||||
};
|
||||
58
packages/stack/example/src/SimpleStack.js
Normal file
58
packages/stack/example/src/SimpleStack.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import React from 'react';
|
||||
import { Button, View, Text } from 'react-native';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
|
||||
class ListScreen extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||
<Text>List Screen</Text>
|
||||
<Text>A list may go here</Text>
|
||||
<Button
|
||||
title="Go to Details"
|
||||
onPress={() => this.props.navigation.navigate('Details')}
|
||||
/>
|
||||
<Button
|
||||
title="Go back to all examples"
|
||||
onPress={() => this.props.navigation.navigate('Home')}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DetailsScreen extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||
<Text>Details Screen</Text>
|
||||
<Button
|
||||
title="Go to Details... again"
|
||||
onPress={() => this.props.navigation.push('Details')}
|
||||
/>
|
||||
<Button
|
||||
title="Go to List"
|
||||
onPress={() => this.props.navigation.navigate('List')}
|
||||
/>
|
||||
<Button
|
||||
title="Go back"
|
||||
onPress={() => this.props.navigation.goBack()}
|
||||
/>
|
||||
<Button
|
||||
title="Go back to all examples"
|
||||
onPress={() => this.props.navigation.navigate('Home')}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default createStackNavigator(
|
||||
{
|
||||
List: ListScreen,
|
||||
Details: DetailsScreen,
|
||||
},
|
||||
{
|
||||
initialRouteName: 'List',
|
||||
}
|
||||
);
|
||||
4651
packages/stack/example/yarn.lock
Normal file
4651
packages/stack/example/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user