diff --git a/packages/stack/.babelrc b/packages/stack/.babelrc new file mode 100644 index 00000000..a9ce1369 --- /dev/null +++ b/packages/stack/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["react-native"] +} diff --git a/packages/stack/.circleci/config.yml b/packages/stack/.circleci/config.yml new file mode 100644 index 00000000..5b6a0dae --- /dev/null +++ b/packages/stack/.circleci/config.yml @@ -0,0 +1,62 @@ +version: 2 + +defaults: &defaults + docker: + - image: circleci/node:7.10 + working_directory: ~/project + +jobs: + install-dependencies: + <<: *defaults + steps: + - checkout + - attach_workspace: + at: ~/project + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + - v1-dependencies- + - restore_cache: + keys: + - v1-dependencies-example-{{ checksum "example/package.json" }} + - v1-dependencies-example- + - run: | + yarn install + yarn install --cwd example + - save_cache: + key: v1-dependencies-{{ checksum "package.json" }} + paths: node_modules + - save_cache: + key: v1-dependencies-example-{{ checksum "example/package.json" }} + paths: example/node_modules + - persist_to_workspace: + root: . + paths: . + lint: + <<: *defaults + steps: + - attach_workspace: + at: ~/project + - run: | + yarn run lint + unit-tests: + <<: *defaults + steps: + - attach_workspace: + at: ~/project + - run: yarn test -- --coverage + - store_artifacts: + path: coverage + destination: coverage + +workflows: + version: 2 + build-and-test: + jobs: + - install-dependencies + - lint: + requires: + - install-dependencies + - unit-tests: + requires: + - install-dependencies diff --git a/packages/stack/.editorconfig b/packages/stack/.editorconfig new file mode 100644 index 00000000..1f22710e --- /dev/null +++ b/packages/stack/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] + +# change these settings to your own preference +indent_style = space +indent_size = 2 + +# we recommend you to keep these unchanged +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/packages/stack/.eslintignore b/packages/stack/.eslintignore new file mode 100644 index 00000000..503b0110 --- /dev/null +++ b/packages/stack/.eslintignore @@ -0,0 +1,3 @@ +node_modules/ +dist/ +jest-setup.js diff --git a/packages/stack/.eslintrc b/packages/stack/.eslintrc new file mode 100644 index 00000000..448eedc9 --- /dev/null +++ b/packages/stack/.eslintrc @@ -0,0 +1,14 @@ +{ + "extends": "eslint-config-satya164", + + "plugins": ["react-native-globals"], + + "env": { + "es6": true, + "react-native-globals/all": true, + }, + + "rules": { + "import/no-unresolved": "off", + } +} diff --git a/packages/stack/.gitignore b/packages/stack/.gitignore new file mode 100644 index 00000000..f968dd3b --- /dev/null +++ b/packages/stack/.gitignore @@ -0,0 +1,53 @@ +# OSX +# +.DS_Store + +# XDE +.expo/ + +# VSCode +.vscode/ +tsconfig.json +jsconfig.json + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IJ +# +.idea +.gradle +local.properties + +# node.js +# +node_modules/ +npm-debug.log +yarn-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +android/app/libs +android/keystores/debug.keystore + +# Build +dist/ diff --git a/packages/stack/LICENSE.md b/packages/stack/LICENSE.md new file mode 100644 index 00000000..001d6a9b --- /dev/null +++ b/packages/stack/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 React Native Community + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/stack/README.md b/packages/stack/README.md new file mode 100644 index 00000000..f9deb8db --- /dev/null +++ b/packages/stack/README.md @@ -0,0 +1,30 @@ +# React Navigation Stack + +[![CircleCI badge](https://circleci.com/gh/react-navigation/react-navigation-stack/tree/master.svg?style=shield)](https://circleci.com/gh/react-navigation/react-navigation-stack/tree/master) + +Stack navigator for use on iOS and Android. + +## Installation + +Open a Terminal in your project's folder and run, + +```sh +yarn add react-navigation-stack +``` + +## Usage + +```js +import { createStackNavigator } from 'react-navigation-stack'; + +export default createStackNavigator({ + Inbox: InboxScreen + Drafts: DraftsScreen, +}, { + initialRouteName: 'Inbox', +}); +``` + +## Docs + +Documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/en/stack-navigator.html). diff --git a/packages/stack/example/.babelrc b/packages/stack/example/.babelrc new file mode 100644 index 00000000..ebf89b91 --- /dev/null +++ b/packages/stack/example/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + "expo" + ], + "plugins": [ + ["module-resolver", { + "alias": { + "react-navigation-stack": "../src" + } + }] + ] +} diff --git a/packages/stack/example/.buckconfig b/packages/stack/example/.buckconfig new file mode 100644 index 00000000..934256cb --- /dev/null +++ b/packages/stack/example/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/packages/stack/example/.eslintrc b/packages/stack/example/.eslintrc new file mode 100644 index 00000000..8e4c1d65 --- /dev/null +++ b/packages/stack/example/.eslintrc @@ -0,0 +1,11 @@ +{ + "extends": "../.eslintrc", + + "settings": { + "import/core-modules": [ "expo", "react-navigation-stack" ] + }, + + "rules": { + "react/prop-types": "off" + } +} diff --git a/packages/stack/example/.watchmanconfig b/packages/stack/example/.watchmanconfig new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/packages/stack/example/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/stack/example/App.js b/packages/stack/example/App.js new file mode 100644 index 00000000..c836ad24 --- /dev/null +++ b/packages/stack/example/App.js @@ -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 }) => ( + this.props.navigation.navigate(item.routeName)} + /> + ); + + _keyExtractor = item => item.routeName; + + render() { + return ( + + ); + } +} + +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); diff --git a/packages/stack/example/README.md b/packages/stack/example/README.md new file mode 100644 index 00000000..66e95589 --- /dev/null +++ b/packages/stack/example/README.md @@ -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 diff --git a/packages/stack/example/app.json b/packages/stack/example/app.json new file mode 100644 index 00000000..075de566 --- /dev/null +++ b/packages/stack/example/app.json @@ -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": "" + } + } +} diff --git a/packages/stack/example/package.json b/packages/stack/example/package.json new file mode 100644 index 00000000..311e65f4 --- /dev/null +++ b/packages/stack/example/package.json @@ -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" + } +} diff --git a/packages/stack/example/rn-cli.config.js b/packages/stack/example/rn-cli.config.js new file mode 100644 index 00000000..c049b595 --- /dev/null +++ b/packages/stack/example/rn-cli.config.js @@ -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/*`)]); + }, +}; diff --git a/packages/stack/example/src/SimpleStack.js b/packages/stack/example/src/SimpleStack.js new file mode 100644 index 00000000..4b39df46 --- /dev/null +++ b/packages/stack/example/src/SimpleStack.js @@ -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 ( + + List Screen + A list may go here +