Initial commit

This commit is contained in:
Brent Vatne
2018-08-03 14:59:12 -07:00
parent 3afe8d4261
commit b19c56a544
58 changed files with 15617 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
{
"presets": [
"expo"
],
"plugins": [
["module-resolver", {
"alias": {
"react-navigation-stack": "../src"
}
}]
]
}

View File

@@ -0,0 +1,6 @@
[android]
target = Google Inc.:Google APIs:23
[maven_repositories]
central = https://repo1.maven.org/maven2

View File

@@ -0,0 +1,11 @@
{
"extends": "../.eslintrc",
"settings": {
"import/core-modules": [ "expo", "react-navigation-stack" ]
},
"rules": {
"react/prop-types": "off"
}
}

View File

@@ -0,0 +1 @@
{}

View 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);

View 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

View 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": ""
}
}
}

View 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"
}
}

View 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/*`)]);
},
};

View 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',
}
);

File diff suppressed because it is too large Load Diff