Compare commits
5 Commits
v4.0.3
...
@ericvicen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ea01673e5 | ||
|
|
71adb7cc4f | ||
|
|
77343cb096 | ||
|
|
accee76951 | ||
|
|
bbb8c4d8d3 |
@@ -1,65 +1,40 @@
|
||||
version: 2
|
||||
|
||||
defaults: &defaults
|
||||
docker:
|
||||
- image: circleci/node:10.9.0
|
||||
working_directory: ~/project
|
||||
|
||||
jobs:
|
||||
install-dependencies:
|
||||
<<: *defaults
|
||||
build:
|
||||
docker:
|
||||
- image: reactcommunity/node-ci:8.4.0-0 # custom image -- includes ocaml, libelf1, Yarn
|
||||
parallelism: 2
|
||||
working_directory: ~/react-navigation
|
||||
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 --frozen-lockfile
|
||||
yarn install --frozen-lockfile --cwd example
|
||||
# cache by branch + package.json, by branch, and then master
|
||||
keys:
|
||||
- v3-react-navigation-{{ .Branch }}-{{ checksum "package.json" }}
|
||||
- v3-react-navigation-{{ .Branch }}
|
||||
- v3-react-navigation-master
|
||||
- run: yarn # install root deps
|
||||
- run: ./scripts/test.sh # run tests
|
||||
- setup_remote_docker
|
||||
- deploy:
|
||||
command: |
|
||||
set -x
|
||||
VER="17.03.0-ce"
|
||||
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
|
||||
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
|
||||
mv /tmp/docker/* /usr/bin
|
||||
|
||||
yarn global add exp
|
||||
set +x
|
||||
exp login -u "$EXPO_USERNAME" -p "$EXPO_PASSWORD"
|
||||
set -x
|
||||
cd examples/NavigationPlayground && yarn && exp publish --release-channel "${CIRCLE_SHA1}"
|
||||
- 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-and-typecheck:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/project
|
||||
- run: |
|
||||
yarn lint
|
||||
yarn typescript
|
||||
unit-tests:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ~/project
|
||||
- run: |
|
||||
yarn test --coverage
|
||||
yarn codecov
|
||||
- store_artifacts:
|
||||
path: coverage
|
||||
destination: coverage
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build-and-test:
|
||||
jobs:
|
||||
- install-dependencies
|
||||
- lint-and-typecheck:
|
||||
requires:
|
||||
- install-dependencies
|
||||
- unit-tests:
|
||||
requires:
|
||||
- install-dependencies
|
||||
key: v3-react-navigation-{{ .Branch }}-{{ checksum "package.json" }}
|
||||
paths:
|
||||
- ~/.cache/yarn
|
||||
- ~/react-navigation/examples/NavigationPlayground/node_modules
|
||||
- ~/react-navigation/examples/ReduxExample/node_modules
|
||||
notify:
|
||||
webhooks:
|
||||
- url: https://react-navigation-ci.now.sh
|
||||
@@ -1,6 +1,8 @@
|
||||
coverage/
|
||||
flow/
|
||||
node_modules/
|
||||
lib/
|
||||
build/
|
||||
typescript/
|
||||
coverage
|
||||
flow
|
||||
node_modules
|
||||
lib*
|
||||
build
|
||||
|
||||
## Temporary
|
||||
examples
|
||||
|
||||
63
.eslintrc
@@ -1,21 +1,56 @@
|
||||
{
|
||||
"extends": "eslint-config-satya164",
|
||||
|
||||
"plugins": ["react-native-globals"],
|
||||
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "detect"
|
||||
},
|
||||
},
|
||||
|
||||
"extends": [
|
||||
"plugin:react/recommended",
|
||||
"plugin:import/errors",
|
||||
"plugin:import/warnings",
|
||||
"prettier",
|
||||
"prettier/react"
|
||||
],
|
||||
"parser": "babel-eslint",
|
||||
"plugins": [
|
||||
"react",
|
||||
"prettier"
|
||||
],
|
||||
"env": {
|
||||
"es6": true,
|
||||
"react-native-globals/all": true,
|
||||
"jasmine": true
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"prettier/prettier": ["error", {
|
||||
"trailingComma": "es5",
|
||||
"singleQuote": true
|
||||
}],
|
||||
|
||||
"no-underscore-dangle": "off",
|
||||
"no-use-before-define": "off",
|
||||
"no-unused-expressions": "off",
|
||||
"new-cap": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-class-assign": "off",
|
||||
"no-duplicate-imports": "off",
|
||||
|
||||
"import/extensions": "off",
|
||||
"import/no-extraneous-dependencies": "off",
|
||||
"import/no-unresolved": "off",
|
||||
"react/sort-comp": "off"
|
||||
|
||||
"react/jsx-filename-extension": [
|
||||
"off", { "extensions": [".js", ".jsx"] }
|
||||
],
|
||||
|
||||
"react/sort-comp": "off",
|
||||
"react/prefer-stateless-function": "off",
|
||||
|
||||
"react/forbid-prop-types": "warn",
|
||||
"react/prop-types": "off",
|
||||
"react/require-default-props": "off",
|
||||
"react/no-unused-prop-types": "off",
|
||||
},
|
||||
"settings": {
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"modules": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
.github/ISSUE_TEMPLATE.md
vendored
@@ -25,7 +25,7 @@ Bugs with react-navigation must be reproducible *without any external libraries
|
||||
|
||||
### How to reproduce
|
||||
|
||||
- You must provide a way to reproduce the problem. If you are having an issue with your machine or build tools, the issue belongs on another repository as that is outside of the scope of React Navigation.
|
||||
- You must provide a way to reproduce the problem. If you are having an issue with your machine or build tools, the issue belongs on another repoistory as that is outside of the scope of Rect Navigation.
|
||||
- Either re-create the bug on [Snack](https://snack.expo.io) or link to a GitHub repository with code that reproduces the bug.
|
||||
- Explain how to run the example app and any steps that we need to take to reproduce the issue from the example app.
|
||||
|
||||
|
||||
12
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,17 +1,17 @@
|
||||
Please provide enough information so that others can review your pull request:
|
||||
|
||||
## Motivation
|
||||
|
||||
Explain the **motivation** for making this change. What existing problem does the pull request solve?
|
||||
|
||||
## Test plan
|
||||
Prefer **small pull requests**. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise split it.
|
||||
|
||||
Demonstrate the code is solid. Example: the exact commands you ran and their output, screenshots / videos if the pull request changes UI.
|
||||
**Test plan (required)**
|
||||
|
||||
Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
|
||||
|
||||
Make sure you test on both platforms if your change affects both platforms.
|
||||
|
||||
The code must pass tests.
|
||||
|
||||
## Code formatting
|
||||
**Code formatting**
|
||||
|
||||
Look around. Match the style of the rest of the codebase. Run `yarn format` before committing.
|
||||
Look around. Match the style of the rest of the codebase.
|
||||
|
||||
4
.gitignore
vendored
@@ -13,8 +13,8 @@ yarn-error.log
|
||||
# OS X
|
||||
.DS_Store
|
||||
|
||||
# Expo
|
||||
.expo
|
||||
# Exponent
|
||||
.exponent
|
||||
|
||||
# Jest
|
||||
coverage
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"git": {
|
||||
"commitMessage": "chore: release %s",
|
||||
"tagName": "v%s"
|
||||
},
|
||||
"npm": {
|
||||
"publish": true
|
||||
},
|
||||
"github": {
|
||||
"release": true
|
||||
},
|
||||
"plugins": {
|
||||
"@release-it/conventional-changelog": {
|
||||
"preset": "angular"
|
||||
}
|
||||
}
|
||||
}
|
||||
39
LICENSE
@@ -1,21 +1,26 @@
|
||||
MIT License
|
||||
BSD License
|
||||
|
||||
Copyright (c) 2017 React Native Community
|
||||
For React Navigation software
|
||||
|
||||
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:
|
||||
Copyright (c) 2016-present, React Navigation Contributors. All rights reserved.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
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.
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import { _TESTING_ONLY_reset_container_count } from '@react-navigation/native/src/createAppContainer';
|
||||
|
||||
export default {
|
||||
resetInternalState: () => {
|
||||
_TESTING_ONLY_reset_container_count();
|
||||
},
|
||||
};
|
||||
22
README.md
@@ -1,12 +1,22 @@
|
||||
# React Navigation
|
||||
|
||||
[](https://badge.fury.io/js/react-navigation) [](https://circleci.com/gh/react-navigation/react-navigation/tree/master) [](https://reactnavigation.org/docs/contributing.html)
|
||||
[](https://badge.fury.io/js/react-navigation) [](https://codecov.io/gh/react-community/react-navigation) [](https://reactnavigation.org/docs/guides/contributors)
|
||||
|
||||
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution based on Javascript.
|
||||
|
||||
## Installation
|
||||
|
||||
See: https://reactnavigation.org/docs/en/getting-started.html
|
||||
Since the library is a JS-based solution, to install the latest version of react-navigation you only need to run:
|
||||
|
||||
```bash
|
||||
yarn add react-navigation
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
npm install --save react-navigation
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
@@ -17,10 +27,6 @@ See: https://reactnavigation.org/docs/en/getting-started.html
|
||||
* The [Community Resources](https://github.com/react-navigation/react-navigation/blob/master/COMMUNITY_RESOURCES.md) document lists some other resources submitted to us by people who use React Navigation. Feel free to open a pull request to add your resource to the list.
|
||||
* You can contribute improvements to the documentation [in the website repository](https://github.com/react-navigation/react-navigation.github.io).
|
||||
|
||||
## Changelog
|
||||
|
||||
The changes for each release are outlined on [the Github releases page](https://github.com/react-navigation/react-navigation/releases).
|
||||
|
||||
## Try it out
|
||||
|
||||
You can also try out the [Navigation Playground app](https://exp.host/@react-navigation/NavigationPlayground) to get a sense for some of the tools built in to React Navigation. The "Fundamentals" in the documentation also include examples you can play with.
|
||||
@@ -37,7 +43,7 @@ See our [Contributing Guide](CONTRIBUTING.md)!
|
||||
|
||||
#### Is this the only library available for navigation?
|
||||
|
||||
Certainly not! There are other libraries - which, depending on your needs, can be better or worse suited for your project. Read more in the [alternative libraries](https://reactnavigation.org/docs/alternatives.html) documentation, and read React Navigation's [pitch & anti-pitch](https://reactnavigation.org/docs/pitch.html) to understand the tradeoffs.
|
||||
Certainly not! There other libraries - which, depending on your needs, can be better or worse suited for your project. Read more in the [alternative libraries](https://reactnavigation.org/docs/alternatives.html) documentation, and read React Navigation's [pitch & anti-pitch](https://reactnavigation.org/docs/pitch.html) to understand the tradeoffs.
|
||||
|
||||
#### Can I use this library for web?
|
||||
|
||||
@@ -49,4 +55,4 @@ This library has adopted a Code of Conduct that we expect project participants t
|
||||
|
||||
## License
|
||||
|
||||
React Navigation is licensed under the [MIT](https://github.com/react-community/react-navigation/blob/master/LICENSE).
|
||||
React-navigation is licensed under the [BSD 2-clause "Simplified" License](https://github.com/react-community/react-navigation/blob/master/LICENSE).
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
/**
|
||||
* This file is needed to hijack asset imports so that test files don't attempt
|
||||
* to import them as JavaScript modules.
|
||||
* See https://github.com/facebook/jest/issues/2663#issuecomment-317109798
|
||||
*/
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
process(src, filename) {
|
||||
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
|
||||
},
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
module.exports = {
|
||||
presets: ['module:metro-react-native-babel-preset'],
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
module.exports = {
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"presets": ["expo"]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
[android]
|
||||
target = Google Inc.:Google APIs:23
|
||||
|
||||
[maven_repositories]
|
||||
central = https://repo1.maven.org/maven2
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
'extends': '../.eslintrc',
|
||||
|
||||
'settings':
|
||||
{
|
||||
'import/core-modules':
|
||||
[
|
||||
'expo-asset',
|
||||
'react-navigation-stack',
|
||||
'react-native-gesture-handler',
|
||||
'react-native-reanimated',
|
||||
],
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"react-native/no-inline-styles": "off"
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
454
example/App.tsx
@@ -1,454 +0,0 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Animated,
|
||||
Image,
|
||||
Platform,
|
||||
StatusBar,
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import {
|
||||
NativeViewGestureHandler,
|
||||
RectButton,
|
||||
} from 'react-native-gesture-handler';
|
||||
import {
|
||||
SupportedThemes,
|
||||
ThemeColors,
|
||||
ThemeContext,
|
||||
Themed,
|
||||
createAppContainer,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
||||
import CustomTabs from './src/CustomTabs';
|
||||
import CustomTabUI from './src/CustomTabUI';
|
||||
import Drawer from './src/Drawer';
|
||||
import ModalStack from './src/ModalStack';
|
||||
import SimpleStack from './src/SimpleStack';
|
||||
import SimpleTabs from './src/SimpleTabs';
|
||||
import StacksInTabs from './src/StacksInTabs';
|
||||
import StacksOverTabs from './src/StacksOverTabs';
|
||||
import StacksOverTopTabs from './src/StacksOverTopTabs';
|
||||
import StacksAndKeys from './src/StacksAndKeys';
|
||||
import StackWithCustomHeaderBackImage from './src/StackWithCustomHeaderBackImage';
|
||||
import StackWithHeaderPreset from './src/StackWithHeaderPreset';
|
||||
import StackWithTranslucentHeader from './src/StackWithTranslucentHeader';
|
||||
import SwitchWithStacks from './src/SwitchWithStacks';
|
||||
import TabsInDrawer from './src/TabsInDrawer';
|
||||
|
||||
const ExampleInfo: any = {
|
||||
CustomTabUI: {
|
||||
description: 'Render additional views around a Tab navigator',
|
||||
name: 'Custom Tabs UI',
|
||||
},
|
||||
CustomTabs: {
|
||||
description: 'Custom tabs with tab router',
|
||||
name: 'Custom Tabs',
|
||||
},
|
||||
CustomTransitioner: {
|
||||
description: 'Custom transitioner with stack router',
|
||||
name: 'Custom Transitioner',
|
||||
},
|
||||
Drawer: {
|
||||
description: 'Android-style drawer navigation',
|
||||
name: 'Drawer Example',
|
||||
},
|
||||
InactiveStack: {
|
||||
description:
|
||||
'An inactive route in a stack should be given the opportunity to handle actions',
|
||||
name: 'Navigate idempotently to stacks in inactive routes',
|
||||
},
|
||||
KeyboardHandlingExample: {
|
||||
description:
|
||||
'Demo automatic handling of keyboard showing/hiding inside StackNavigator',
|
||||
name: 'Keyboard Handling Example',
|
||||
},
|
||||
LinkStack: {
|
||||
description: 'Deep linking into a route in stack',
|
||||
name: 'Link in Stack',
|
||||
},
|
||||
LinkTabs: {
|
||||
description: 'Deep linking into a route in tab',
|
||||
name: 'Link to Settings Tab',
|
||||
},
|
||||
ModalStack: {
|
||||
description:
|
||||
Platform.OS === 'ios'
|
||||
? 'Stack navigation with modals'
|
||||
: 'Dynamically showing and hiding the header',
|
||||
name:
|
||||
Platform.OS === 'ios'
|
||||
? 'Modal Stack Example'
|
||||
: 'Stack with Dynamic Header',
|
||||
},
|
||||
SimpleStack: {
|
||||
description: 'A card stack',
|
||||
name: 'Stack Example',
|
||||
},
|
||||
SimpleTabs: {
|
||||
description: 'Tabs following platform conventions',
|
||||
name: 'Tabs Example',
|
||||
},
|
||||
StackWithCustomHeaderBackImage: {
|
||||
description: 'Stack with custom header back image',
|
||||
name: 'Custom header back image',
|
||||
},
|
||||
StackWithHeaderPreset: {
|
||||
description: 'Masked back button and sliding header items. iOS only.',
|
||||
name: 'UIKit-style Header Transitions',
|
||||
},
|
||||
StackWithTranslucentHeader: {
|
||||
description: 'Render arbitrary translucent content in header background.',
|
||||
name: 'Translucent Header',
|
||||
},
|
||||
StacksInTabs: {
|
||||
description: 'Nested stack navigation in tabs',
|
||||
name: 'Stacks in Tabs',
|
||||
},
|
||||
StacksOverTabs: {
|
||||
description: 'Nested stack navigation that pushes on top of tabs',
|
||||
name: 'Stacks over Tabs',
|
||||
},
|
||||
StacksOverTopTabs: {
|
||||
description: 'Tab navigator in stack with custom header heights',
|
||||
name: 'Stacks with non-standard header height',
|
||||
},
|
||||
StacksAndKeys: {
|
||||
description: 'Use keys to link between screens',
|
||||
name: 'Link in Stack with keys',
|
||||
},
|
||||
SwitchWithStacks: {
|
||||
description: 'Jump between routes',
|
||||
name: 'Switch between routes',
|
||||
},
|
||||
// MultipleDrawer: {
|
||||
// description: 'Add any drawer you need',
|
||||
// name: 'Multiple Drawer Example',
|
||||
// },
|
||||
TabsInDrawer: {
|
||||
description: 'A drawer combined with tabs',
|
||||
name: 'Drawer + Tabs Example',
|
||||
},
|
||||
TabsWithNavigationEvents: {
|
||||
description:
|
||||
'Declarative NavigationEvents component to subscribe to navigation events',
|
||||
name: 'NavigationEvents',
|
||||
},
|
||||
TabsWithNavigationFocus: {
|
||||
description: 'Receive the focus prop to know when a screen is focused',
|
||||
name: 'withNavigationFocus',
|
||||
},
|
||||
};
|
||||
|
||||
const ExampleRoutes: any = {
|
||||
CustomTabUI,
|
||||
CustomTabs,
|
||||
Drawer,
|
||||
ModalStack,
|
||||
SimpleStack,
|
||||
SimpleTabs,
|
||||
StackWithCustomHeaderBackImage,
|
||||
StackWithTranslucentHeader,
|
||||
StacksAndKeys,
|
||||
StacksOverTabs,
|
||||
SwitchWithStacks,
|
||||
StacksOverTopTabs,
|
||||
StacksInTabs,
|
||||
...Platform.select({
|
||||
android: {},
|
||||
ios: {
|
||||
StackWithHeaderPreset,
|
||||
},
|
||||
}),
|
||||
TabsInDrawer,
|
||||
LinkStack: {
|
||||
screen: SimpleStack,
|
||||
path: 'people/Jordan',
|
||||
},
|
||||
LinkTabs: {
|
||||
screen: SimpleTabs,
|
||||
path: 'settings',
|
||||
},
|
||||
};
|
||||
|
||||
interface State {
|
||||
scrollY: Animated.Value;
|
||||
}
|
||||
|
||||
class MainScreen extends React.Component<any, State> {
|
||||
static contextType = ThemeContext;
|
||||
context!: React.ContextType<typeof ThemeContext>;
|
||||
|
||||
state = {
|
||||
scrollY: new Animated.Value(0),
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
const scale = this.state.scrollY.interpolate({
|
||||
extrapolate: 'clamp',
|
||||
inputRange: [-450, 0, 100],
|
||||
outputRange: [2, 1, 0.8],
|
||||
});
|
||||
|
||||
const translateY = this.state.scrollY.interpolate({
|
||||
inputRange: [-450, 0, 100],
|
||||
outputRange: [-150, 0, 40],
|
||||
});
|
||||
|
||||
const opacity = this.state.scrollY.interpolate({
|
||||
extrapolate: 'clamp',
|
||||
inputRange: [0, 50],
|
||||
outputRange: [1, 0],
|
||||
});
|
||||
|
||||
const underlayOpacity = this.state.scrollY.interpolate({
|
||||
extrapolate: 'clamp',
|
||||
inputRange: [0, 50],
|
||||
outputRange: [0, 1],
|
||||
});
|
||||
|
||||
const backgroundScale = this.state.scrollY.interpolate({
|
||||
extrapolate: 'clamp',
|
||||
inputRange: [-450, 0],
|
||||
outputRange: [3, 1],
|
||||
});
|
||||
|
||||
const backgroundTranslateY = this.state.scrollY.interpolate({
|
||||
inputRange: [-450, 0],
|
||||
outputRange: [0, 0],
|
||||
});
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<NativeViewGestureHandler>
|
||||
<Animated.ScrollView
|
||||
style={{ flex: 1, backgroundColor: ThemeColors[this.context].body }}
|
||||
scrollEventThrottle={1}
|
||||
onScroll={Animated.event(
|
||||
[
|
||||
{
|
||||
nativeEvent: { contentOffset: { y: this.state.scrollY } },
|
||||
},
|
||||
],
|
||||
{ useNativeDriver: true }
|
||||
)}
|
||||
>
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.backgroundUnderlay,
|
||||
{
|
||||
transform: [
|
||||
{ scale: backgroundScale },
|
||||
{ translateY: backgroundTranslateY },
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Animated.View
|
||||
style={{ opacity, transform: [{ scale }, { translateY }] }}
|
||||
>
|
||||
<SafeAreaView
|
||||
style={styles.bannerContainer}
|
||||
forceInset={{ top: 'always', bottom: 'never' }}
|
||||
>
|
||||
<View style={styles.banner}>
|
||||
<Image
|
||||
source={require('./src/assets/NavLogo.png')}
|
||||
style={styles.bannerImage}
|
||||
/>
|
||||
<Text style={styles.bannerTitle}>
|
||||
React Navigation Examples
|
||||
</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</Animated.View>
|
||||
|
||||
<SafeAreaView
|
||||
forceInset={{ top: 'never', bottom: 'always' }}
|
||||
style={{ backgroundColor: '#eee' }}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: ThemeColors[this.context].bodyContent,
|
||||
}}
|
||||
>
|
||||
{Object.keys(ExampleRoutes).map((routeName: string) => (
|
||||
<RectButton
|
||||
key={routeName}
|
||||
underlayColor="#ccc"
|
||||
activeOpacity={0.3}
|
||||
onPress={() => {
|
||||
const route = ExampleRoutes[routeName];
|
||||
if (route.screen || route.path || route.params) {
|
||||
const { path, params, screen } = route;
|
||||
const { router } = screen;
|
||||
const action =
|
||||
path &&
|
||||
router.getActionForPathAndParams(path, params);
|
||||
navigation.navigate(routeName, {}, action);
|
||||
} else {
|
||||
navigation.navigate(routeName);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={[
|
||||
styles.item,
|
||||
this.context === 'dark'
|
||||
? styles.itemDark
|
||||
: styles.itemLight,
|
||||
]}
|
||||
>
|
||||
<Themed.Text style={styles.title}>
|
||||
{ExampleInfo[routeName].name}
|
||||
</Themed.Text>
|
||||
<Text style={styles.description}>
|
||||
{ExampleInfo[routeName].description}
|
||||
</Text>
|
||||
</View>
|
||||
</RectButton>
|
||||
))}
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</Animated.ScrollView>
|
||||
</NativeViewGestureHandler>
|
||||
<StatusBar barStyle="light-content" />
|
||||
<Animated.View
|
||||
style={[styles.statusBarUnderlay, { opacity: underlayOpacity }]}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const Navigation = createAppContainer(
|
||||
createStackNavigator(
|
||||
{
|
||||
...ExampleRoutes,
|
||||
Index: {
|
||||
screen: MainScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
headerMode: 'none',
|
||||
initialRouteName: 'Index',
|
||||
|
||||
/*
|
||||
* Use modal on iOS because the card mode comes from the right,
|
||||
* which conflicts with the drawer example gesture
|
||||
*/
|
||||
mode: Platform.OS === 'ios' ? 'modal' : 'card',
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
export default () => {
|
||||
let [theme, setTheme] = React.useState<SupportedThemes>('light');
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Navigation theme={theme} />
|
||||
<View style={{ position: 'absolute', bottom: 60, right: 20 }}>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
setTheme(theme === 'light' ? 'dark' : 'light');
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: ThemeColors[theme].bodyContent,
|
||||
borderRadius: 25,
|
||||
width: 50,
|
||||
height: 50,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
borderColor: ThemeColors[theme].bodyBorder,
|
||||
borderWidth: 1,
|
||||
shadowColor: ThemeColors[theme].label,
|
||||
shadowOffset: {
|
||||
width: 0,
|
||||
height: 2,
|
||||
},
|
||||
shadowOpacity: 0.4,
|
||||
shadowRadius: 2,
|
||||
|
||||
elevation: 5,
|
||||
}}
|
||||
>
|
||||
<MaterialCommunityIcons
|
||||
name="theme-light-dark"
|
||||
size={30}
|
||||
color={ThemeColors[theme].label}
|
||||
/>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
backgroundUnderlay: {
|
||||
backgroundColor: '#673ab7',
|
||||
height: 300,
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
top: -100,
|
||||
},
|
||||
banner: {
|
||||
alignItems: 'center',
|
||||
flexDirection: 'row',
|
||||
padding: 16,
|
||||
},
|
||||
bannerContainer: {
|
||||
// backgroundColor: '#673ab7',
|
||||
alignItems: 'center',
|
||||
},
|
||||
bannerImage: {
|
||||
height: 36,
|
||||
margin: 8,
|
||||
resizeMode: 'contain',
|
||||
tintColor: '#fff',
|
||||
width: 36,
|
||||
},
|
||||
bannerTitle: {
|
||||
color: '#fff',
|
||||
fontSize: 18,
|
||||
fontWeight: '200',
|
||||
marginRight: 5,
|
||||
marginVertical: 8,
|
||||
},
|
||||
description: {
|
||||
color: '#999',
|
||||
fontSize: 13,
|
||||
},
|
||||
item: {
|
||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 12,
|
||||
},
|
||||
itemLight: {
|
||||
borderBottomColor: ThemeColors.light.bodyBorder,
|
||||
},
|
||||
itemDark: {
|
||||
borderBottomColor: ThemeColors.dark.bodyBorder,
|
||||
},
|
||||
statusBarUnderlay: {
|
||||
backgroundColor: '#673ab7',
|
||||
height: 20,
|
||||
left: 0,
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
top: 0,
|
||||
},
|
||||
title: {
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
});
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "React Navigation Stack Example",
|
||||
"description": "Demonstrates the various capabilities of react-navigation-stack",
|
||||
"slug": "react-navigation-stack-demo",
|
||||
"sdkVersion": "33.0.0",
|
||||
"version": "1.0.0",
|
||||
"primaryColor": "#2196f3",
|
||||
"packagerOpts": {
|
||||
"config": "./metro.config.js",
|
||||
"projectRoots": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies, import/no-commonjs */
|
||||
|
||||
const path = require('path');
|
||||
const blacklist = require('metro-config/src/defaults/blacklist');
|
||||
const project = require('../package.json');
|
||||
const escape = require('escape-string-regexp');
|
||||
|
||||
const projectDependencies = Object.keys({
|
||||
...project.dependencies,
|
||||
...project.peerDependencies,
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
projectRoot: __dirname,
|
||||
watchFolders: [path.resolve(__dirname, '..')],
|
||||
|
||||
resolver: {
|
||||
blacklistRE: blacklist([
|
||||
new RegExp(
|
||||
`^${escape(
|
||||
path.resolve(__dirname, 'node_modules', project.name)
|
||||
)}\\/.*$`
|
||||
),
|
||||
new RegExp(
|
||||
`^${escape(path.resolve(__dirname, '..', 'node_modules'))}\\/.*$`
|
||||
),
|
||||
]),
|
||||
|
||||
providesModuleNodeModules: [
|
||||
'@expo/vector-icons',
|
||||
'@babel/runtime',
|
||||
...projectDependencies,
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "playground",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "node_modules/expo/AppEntry.js",
|
||||
"scripts": {
|
||||
"start": "expo start",
|
||||
"android": "expo start --android",
|
||||
"ios": "expo start --ios"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "^10.0.0",
|
||||
"@react-native-community/masked-view": "^0.1.1",
|
||||
"@react-navigation/core": "^3.5.0",
|
||||
"@react-navigation/native": "^3.6.2",
|
||||
"expo": "^33.0.7",
|
||||
"expo-asset": "^5.0.1",
|
||||
"expo-blur": "~5.0.1",
|
||||
"expo-constants": "~5.0.1",
|
||||
"hoist-non-react-statics": "^3.3.0",
|
||||
"react": "16.8.3",
|
||||
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
|
||||
"react-native-iphone-x-helper": "^1.2.1",
|
||||
"react-native-paper": "^2.15.2",
|
||||
"react-navigation-drawer": "^2.0.1",
|
||||
"react-navigation-header-buttons": "^3.0.2",
|
||||
"react-navigation-stack": "^1.5.1",
|
||||
"react-navigation-tabs": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-module-resolver": "^3.2.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"react-native-safe-area-view": "0.14.6",
|
||||
"react-native-screens": "1.0.0-alpha.23"
|
||||
}
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Alert,
|
||||
TouchableOpacity,
|
||||
LayoutAnimation,
|
||||
StatusBar,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import {
|
||||
Themed,
|
||||
ThemeContext,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import {
|
||||
createMaterialTopTabNavigator,
|
||||
MaterialTopTabBar,
|
||||
} from 'react-navigation-tabs';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
|
||||
interface Props {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class MyHomeScreen extends React.Component<Props> {
|
||||
static navigationOptions = {
|
||||
tabBarLabel: 'Home',
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
focused,
|
||||
horizontal,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
horizontal: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-home' : 'ios-home'}
|
||||
size={horizontal ? 20 : 26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
|
||||
<Themed.Text>Home Screen</Themed.Text>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Home')}
|
||||
title="Go to home tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StarredScreen extends React.Component<Props> {
|
||||
static navigationOptions = {
|
||||
tabBarLabel: 'Starred',
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
focused,
|
||||
horizontal,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
horizontal: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-people' : 'ios-people'}
|
||||
size={horizontal ? 20 : 26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
|
||||
<Themed.Text>Starred Screen</Themed.Text>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Home')}
|
||||
title="Go to home tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
type MaterialTopTabBarProps = React.ComponentProps<typeof MaterialTopTabBar>;
|
||||
|
||||
class MaterialTopTabBarWrapper extends React.Component<MaterialTopTabBarProps> {
|
||||
render() {
|
||||
return (
|
||||
<SafeAreaView
|
||||
style={{ backgroundColor: '#000' }}
|
||||
forceInset={{ top: 'always', horizontal: 'never', bottom: 'never' }}
|
||||
>
|
||||
<MaterialTopTabBar {...this.props} />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FeaturedScreen extends React.Component<Props> {
|
||||
static navigationOptions = {
|
||||
tabBarLabel: 'Featured',
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
focused,
|
||||
horizontal,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
horizontal: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-star' : 'ios-star'}
|
||||
size={horizontal ? 20 : 26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
|
||||
<Themed.Text>Featured Screen</Themed.Text>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Home')}
|
||||
title="Go to home tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const SimpleTabs = createMaterialTopTabNavigator(
|
||||
{
|
||||
Home: MyHomeScreen,
|
||||
Starred: StarredScreen,
|
||||
Featured: FeaturedScreen,
|
||||
},
|
||||
{
|
||||
tabBarComponent: MaterialTopTabBarWrapper,
|
||||
tabBarOptions: {
|
||||
style: {
|
||||
backgroundColor: '#000',
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
class TabNavigator extends React.Component<Props> {
|
||||
static contextType = ThemeContext;
|
||||
|
||||
static router = SimpleTabs.router;
|
||||
componentWillUpdate() {
|
||||
LayoutAnimation.easeInEaseOut();
|
||||
}
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { routes, index } = navigation.state;
|
||||
const activeRoute = routes[index];
|
||||
let bottom = null;
|
||||
if (activeRoute.routeName !== 'Home') {
|
||||
bottom = (
|
||||
<View
|
||||
style={{
|
||||
height: 50,
|
||||
borderTopWidth: StyleSheet.hairlineWidth,
|
||||
backgroundColor: this.context === 'light' ? '#000' : '#fff',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
Alert.alert('hello!');
|
||||
//
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: this.context === 'light' ? '#fff' : '#000',
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
Check out
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<StatusBar barStyle="light-content" />
|
||||
<SimpleTabs navigation={navigation} />
|
||||
{bottom}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default TabNavigator;
|
||||
@@ -1,139 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ScrollView, StyleSheet } from 'react-native';
|
||||
import { BorderlessButton } from 'react-native-gesture-handler';
|
||||
import {
|
||||
createNavigator,
|
||||
NavigationState,
|
||||
SafeAreaView,
|
||||
TabRouter,
|
||||
Themed,
|
||||
useTheme,
|
||||
createAppContainer,
|
||||
NavigationScreenProp,
|
||||
} from 'react-navigation';
|
||||
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({
|
||||
navigation,
|
||||
banner,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
banner: string;
|
||||
}) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => {
|
||||
navigation.goBack(null);
|
||||
}}
|
||||
title="Go back"
|
||||
/>
|
||||
</SafeAreaView>
|
||||
<Themed.StatusBar />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
|
||||
const MyNotificationsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
|
||||
|
||||
const MySettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Settings Screen" navigation={navigation} />;
|
||||
|
||||
const CustomTabBar = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => {
|
||||
const { routes } = navigation.state;
|
||||
return (
|
||||
<SafeAreaView style={styles.tabContainer}>
|
||||
{routes.map(route => (
|
||||
<BorderlessButton
|
||||
onPress={() => navigation.navigate(route.routeName)}
|
||||
style={styles.tab}
|
||||
key={route.routeName}
|
||||
>
|
||||
<Themed.Text>{route.routeName}</Themed.Text>
|
||||
</BorderlessButton>
|
||||
))}
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
// @todo - how does the type definition for a custom navigator work?
|
||||
class CustomTabView extends React.Component<any> {
|
||||
render() {
|
||||
const { navigation, descriptors } = this.props;
|
||||
const { routes, index } = navigation.state;
|
||||
const descriptor = descriptors[routes[index].key];
|
||||
const ActiveScreen = descriptor.getComponent();
|
||||
return (
|
||||
<SafeAreaView forceInset={{ top: 'always' }}>
|
||||
<CustomTabBar navigation={navigation} />
|
||||
<ActiveScreen navigation={descriptor.navigation} />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const CustomTabRouter = TabRouter(
|
||||
{
|
||||
Home: {
|
||||
path: '',
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
Notifications: {
|
||||
path: 'notifications',
|
||||
screen: MyNotificationsScreen,
|
||||
},
|
||||
Settings: {
|
||||
path: 'settings',
|
||||
screen: MySettingsScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Change this to start on a different tab
|
||||
initialRouteName: 'Home',
|
||||
}
|
||||
);
|
||||
|
||||
const CustomTabs = createAppContainer(
|
||||
createNavigator(CustomTabView, CustomTabRouter, {})
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tab: {
|
||||
alignItems: 'center',
|
||||
borderColor: '#ddd',
|
||||
borderRadius: 4,
|
||||
borderWidth: 1,
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
margin: 4,
|
||||
},
|
||||
tabContainer: {
|
||||
flexDirection: 'row',
|
||||
height: 48,
|
||||
},
|
||||
});
|
||||
|
||||
export default () => {
|
||||
// Need to thread the theme through to detached nested navigator
|
||||
let theme = useTheme();
|
||||
|
||||
return <CustomTabs detached theme={theme} />;
|
||||
};
|
||||
@@ -1,118 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ScrollView, StyleProp, TextStyle } from 'react-native';
|
||||
import { MaterialIcons } from '@expo/vector-icons';
|
||||
import {
|
||||
Themed,
|
||||
SafeAreaView,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({
|
||||
navigation,
|
||||
banner,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
banner: string;
|
||||
}) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ top: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button onPress={() => navigation.openDrawer()} title="Open drawer" />
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Email')}
|
||||
title="Open other screen"
|
||||
/>
|
||||
<Button onPress={() => navigation.navigate('Index')} title="Go back" />
|
||||
</SafeAreaView>
|
||||
<Themed.StatusBar />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const InboxScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Inbox Screen" navigation={navigation} />;
|
||||
InboxScreen.navigationOptions = {
|
||||
headerTitle: 'Inbox',
|
||||
};
|
||||
|
||||
const EmailScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Email Screen" navigation={navigation} />;
|
||||
|
||||
const DraftsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Drafts Screen" navigation={navigation} />;
|
||||
DraftsScreen.navigationOptions = {
|
||||
headerTitle: 'Drafts',
|
||||
};
|
||||
|
||||
const InboxStack = createStackNavigator(
|
||||
{
|
||||
Email: { screen: EmailScreen },
|
||||
Inbox: { screen: InboxScreen },
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }: { tintColor: string }) => (
|
||||
<MaterialIcons
|
||||
name="move-to-inbox"
|
||||
size={24}
|
||||
style={{ color: tintColor } as StyleProp<TextStyle>}
|
||||
/>
|
||||
),
|
||||
drawerLabel: 'Inbox',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const DraftsStack = createStackNavigator(
|
||||
{
|
||||
Drafts: { screen: DraftsScreen },
|
||||
Email: { screen: EmailScreen },
|
||||
},
|
||||
{
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }: { tintColor: string }) => (
|
||||
<MaterialIcons
|
||||
name="drafts"
|
||||
size={24}
|
||||
style={{ color: tintColor } as StyleProp<TextStyle>}
|
||||
/>
|
||||
),
|
||||
drawerLabel: 'Drafts',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const DrawerExample = createDrawerNavigator(
|
||||
{
|
||||
Drafts: {
|
||||
path: '/sent',
|
||||
screen: DraftsStack,
|
||||
},
|
||||
Inbox: {
|
||||
path: '/',
|
||||
screen: InboxStack,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
contentOptions: {
|
||||
activeTintColor: '#e91e63',
|
||||
},
|
||||
initialRouteName: 'Drafts',
|
||||
}
|
||||
);
|
||||
|
||||
export default DrawerExample;
|
||||
@@ -1,19 +0,0 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
import { StyleSheet } from 'react-native';
|
||||
import { Themed } from 'react-navigation';
|
||||
|
||||
/**
|
||||
* Used across examples as a screen placeholder.
|
||||
*/
|
||||
|
||||
const SampleText = ({ children }: { children?: ReactNode }) => (
|
||||
<Themed.Text style={styles.sampleText}>{children}</Themed.Text>
|
||||
);
|
||||
|
||||
export default SampleText;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
sampleText: {
|
||||
margin: 14,
|
||||
},
|
||||
});
|
||||
@@ -1,252 +0,0 @@
|
||||
// tslint:disable no-unused-expression
|
||||
|
||||
import * as React from 'react';
|
||||
import {
|
||||
NavigationActions,
|
||||
NavigationEventPayload,
|
||||
NavigationEventSubscription,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
NavigationStateRoute,
|
||||
SafeAreaView,
|
||||
StackActions,
|
||||
Themed,
|
||||
withNavigation,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import { HeaderButtons } from './commonComponents/HeaderButtons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const DEBUG = false;
|
||||
|
||||
interface MyNavScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
banner: React.ReactNode;
|
||||
}
|
||||
|
||||
interface BackButtonProps {
|
||||
navigation: NavigationScreenProp<NavigationStateRoute<any>>;
|
||||
}
|
||||
|
||||
class MyBackButton extends React.Component<BackButtonProps, any> {
|
||||
render() {
|
||||
return (
|
||||
<HeaderButtons>
|
||||
<HeaderButtons.Item title="Back" onPress={this.navigateBack} />
|
||||
</HeaderButtons>
|
||||
);
|
||||
}
|
||||
|
||||
navigateBack = () => {
|
||||
this.props.navigation.goBack(null);
|
||||
};
|
||||
}
|
||||
|
||||
const MyBackButtonWithNavigation: any = withNavigation(MyBackButton);
|
||||
|
||||
class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
render() {
|
||||
const { navigation, banner } = this.props;
|
||||
const { push, replace, popToTop, pop, dismiss } = navigation;
|
||||
return (
|
||||
<SafeAreaView forceInset={{ top: 'never' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => push('Profile', { name: 'Jane' })}
|
||||
title="Push a profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() =>
|
||||
navigation.dispatch(
|
||||
StackActions.reset({
|
||||
actions: [
|
||||
NavigationActions.navigate({
|
||||
params: { name: 'Jane' },
|
||||
routeName: 'Photos',
|
||||
}),
|
||||
],
|
||||
index: 0,
|
||||
})
|
||||
)
|
||||
}
|
||||
title="Reset photos"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
|
||||
title="Navigate to a photos screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => replace('Profile', { name: 'Lucy' })}
|
||||
title="Replace with profile"
|
||||
/>
|
||||
<Button onPress={() => popToTop()} title="Pop to top" />
|
||||
<Button onPress={() => pop()} title="Pop" />
|
||||
<Button
|
||||
onPress={() => {
|
||||
if (navigation.goBack()) {
|
||||
console.log('goBack handled');
|
||||
} else {
|
||||
console.log('goBack unhandled');
|
||||
}
|
||||
}}
|
||||
title="Go back"
|
||||
/>
|
||||
<Button onPress={() => dismiss()} title="Dismiss" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface MyHomeScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
s0: NavigationEventSubscription | null = null;
|
||||
s1: NavigationEventSubscription | null = null;
|
||||
s2: NavigationEventSubscription | null = null;
|
||||
s3: NavigationEventSubscription | null = null;
|
||||
|
||||
componentDidMount() {
|
||||
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
|
||||
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
|
||||
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
|
||||
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this.s0!.remove();
|
||||
this.s1!.remove();
|
||||
this.s2!.remove();
|
||||
this.s3!.remove();
|
||||
}
|
||||
onWF = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('willFocus HomeScreen', a);
|
||||
};
|
||||
onDF = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('didFocus HomeScreen', a);
|
||||
};
|
||||
onWB = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('willBlur HomeScreen', a);
|
||||
};
|
||||
onDB = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('didBlur HomeScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
interface MyPhotosScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
}
|
||||
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = {
|
||||
headerLeft: () => <MyBackButtonWithNavigation />,
|
||||
title: 'Photos',
|
||||
};
|
||||
s0: NavigationEventSubscription | null = null;
|
||||
s1: NavigationEventSubscription | null = null;
|
||||
s2: NavigationEventSubscription | null = null;
|
||||
s3: NavigationEventSubscription | null = null;
|
||||
|
||||
componentDidMount() {
|
||||
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
|
||||
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
|
||||
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
|
||||
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this.s0!.remove();
|
||||
this.s1!.remove();
|
||||
this.s2!.remove();
|
||||
this.s3!.remove();
|
||||
}
|
||||
onWF = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('willFocus PhotosScreen', a);
|
||||
};
|
||||
onDF = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('didFocus PhotosScreen', a);
|
||||
};
|
||||
onWB = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('willBlur PhotosScreen', a);
|
||||
};
|
||||
onDB = (a: NavigationEventPayload) => {
|
||||
DEBUG && console.log('didBlur PhotosScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.getParam('name')}'s Photos`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner={`${
|
||||
navigation.getParam('mode') === 'edit' ? 'Now Editing ' : ''
|
||||
}${navigation.getParam('name')}'s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
MyProfileScreen.navigationOptions = (props: MyHomeScreenProps) => {
|
||||
const { navigation } = props;
|
||||
const { state, setParams } = navigation;
|
||||
const { params } = state;
|
||||
return {
|
||||
headerBackImage: params!.headerBackImage,
|
||||
// Render a button on the right side of the header.
|
||||
// When pressed switches the screen to edit mode.
|
||||
headerRight: (
|
||||
<HeaderButtons>
|
||||
<HeaderButtons.Item
|
||||
title={params!.mode === 'edit' ? 'Done' : 'Edit'}
|
||||
onPress={() =>
|
||||
setParams({ mode: params!.mode === 'edit' ? '' : 'edit' })
|
||||
}
|
||||
/>
|
||||
</HeaderButtons>
|
||||
),
|
||||
headerTitle: `${params!.name}'s Profile!`,
|
||||
};
|
||||
};
|
||||
|
||||
const SimpleStack = createStackNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
Photos: {
|
||||
path: 'photos/:name',
|
||||
screen: MyPhotosScreen,
|
||||
},
|
||||
Profile: {
|
||||
path: 'people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
// headerLayoutPreset: 'center',
|
||||
}
|
||||
);
|
||||
|
||||
export default SimpleStack;
|
||||
@@ -1,271 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import {
|
||||
FlatList,
|
||||
NavigationEventSubscription,
|
||||
NavigationScreenProp,
|
||||
SafeAreaView,
|
||||
Themed,
|
||||
ScrollView,
|
||||
NavigationEventPayload,
|
||||
NavigationState,
|
||||
} from 'react-navigation';
|
||||
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const TEXT = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a hendrerit dui, id consectetur nulla. Curabitur mattis sapien nunc, quis dignissim eros venenatis sit amet. Praesent rutrum dapibus diam quis eleifend. Donec vulputate quis purus sed vulputate. Fusce ipsum felis, cursus at congue vel, consectetur tincidunt purus. Pellentesque et fringilla lorem. In at augue malesuada, sollicitudin ex ut, convallis elit. Curabitur metus nibh, consequat vel libero sit amet, iaculis congue nisl. Maecenas eleifend sodales sapien, fringilla sagittis nisi ornare volutpat. Integer tellus enim, volutpat vitae nisl et, dignissim pharetra leo. Sed sit amet efficitur sapien, at tristique sapien. Aenean dignissim semper sagittis. Nullam sit amet volutpat mi.
|
||||
Curabitur auctor orci et justo molestie iaculis. Integer elementum tortor ac ipsum egestas pharetra. Etiam ultrices elementum pharetra. Maecenas lobortis ultrices risus dignissim luctus. Nunc malesuada cursus posuere. Vestibulum tristique lectus pretium pellentesque pellentesque. Nunc ac nisi lacus. Duis ultrices dui ac viverra ullamcorper. Morbi placerat laoreet lacus sit amet ullamcorper.
|
||||
Nulla convallis pulvinar hendrerit. Nulla mattis sem et aliquam ultrices. Nam egestas magna leo, nec luctus turpis sollicitudin ac. Sed id leo luctus, lobortis tortor ut, rhoncus ex. Aliquam gravida enim ac dapibus ultricies. Vestibulum at interdum est, et vehicula nibh. Phasellus dignissim iaculis rhoncus. Vestibulum tempus leo lectus, quis euismod metus ullamcorper quis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut id ipsum at enim eleifend porttitor id quis metus. Proin bibendum ornare iaculis. Duis elementum lacus vel cursus efficitur. Nunc eu tortor sed risus lacinia scelerisque.
|
||||
Praesent lobortis elit sit amet mauris pulvinar, viverra condimentum massa pellentesque. Curabitur massa ex, dignissim eget neque at, fringilla consectetur justo. Cras sollicitudin vel ligula sed cursus. Aliquam porta sem hendrerit diam porta ultricies. Sed eu mi erat. Curabitur id justo vel tortor hendrerit vestibulum id eget est. Morbi eros magna, placerat id diam ut, varius sollicitudin mi. Curabitur pretium finibus accumsan.`;
|
||||
const MyNavScreen = ({
|
||||
navigation,
|
||||
banner,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
banner: string;
|
||||
}) => (
|
||||
<ScrollView style={{ flex: 1 }}>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Home')}
|
||||
title="Go to home tab"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Settings')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
{TEXT.split('\n').map((p, n) => (
|
||||
<Themed.Text
|
||||
key={n}
|
||||
style={{ marginVertical: 10, marginHorizontal: 8 }}
|
||||
>
|
||||
{p}
|
||||
</Themed.Text>
|
||||
))}
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyListScreen = () => (
|
||||
<FlatList
|
||||
data={TEXT.split('\n')}
|
||||
style={{ paddingTop: 10 }}
|
||||
keyExtractor={(_, index) => index.toString()}
|
||||
renderItem={({ item }) => (
|
||||
<Themed.Text
|
||||
style={{ fontSize: 16, marginVertical: 10, marginHorizontal: 8 }}
|
||||
>
|
||||
{item}
|
||||
</Themed.Text>
|
||||
)}
|
||||
/>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Home Tab" navigation={navigation} />;
|
||||
|
||||
MyHomeScreen.navigationOptions = {
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
horizontal,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
horizontal: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name="ios-home"
|
||||
size={horizontal ? 20 : 26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
tabBarLabel: 'Home',
|
||||
tabBarTestIDProps: {
|
||||
accessibilityLabel: 'TEST_ID_HOME_ACLBL',
|
||||
testID: 'TEST_ID_HOME',
|
||||
},
|
||||
};
|
||||
MyListScreen.navigationOptions = MyHomeScreen.navigationOptions;
|
||||
|
||||
interface MyPeopleScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
class MyPeopleScreen extends React.Component<MyPeopleScreenProps> {
|
||||
static navigationOptions = {
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
horizontal,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
horizontal: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name="ios-people"
|
||||
size={horizontal ? 20 : 26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
tabBarLabel: 'People',
|
||||
};
|
||||
s0: NavigationEventSubscription | null = null;
|
||||
s1: NavigationEventSubscription | null = null;
|
||||
s2: NavigationEventSubscription | null = null;
|
||||
s3: NavigationEventSubscription | null = null;
|
||||
componentDidMount() {
|
||||
// this.s0! = this.props.navigation.addListener('willFocus', this.onEvent);
|
||||
// this.s1! = this.props.navigation.addListener('didFocus', this.onEvent);
|
||||
// this.s2! = this.props.navigation.addListener('willBlur', this.onEvent);
|
||||
// this.s3! = this.props.navigation.addListener('didBlur', this.onEvent);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
// this.s0!.remove();
|
||||
// this.s1!.remove();
|
||||
// this.s2!.remove();
|
||||
// this.s3!.remove();
|
||||
}
|
||||
onEvent = (a: NavigationEventPayload) => {
|
||||
console.log('EVENT ON PEOPLE TAB', a.type, a);
|
||||
};
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="People Tab" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
interface MyChatScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
class MyChatScreen extends React.Component<MyChatScreenProps> {
|
||||
static navigationOptions = {
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
horizontal,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
horizontal: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name="ios-chatboxes"
|
||||
size={horizontal ? 20 : 26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
tabBarLabel: 'Chat',
|
||||
};
|
||||
s0: NavigationEventSubscription | null = null;
|
||||
s1: NavigationEventSubscription | null = null;
|
||||
s2: NavigationEventSubscription | null = null;
|
||||
s3: NavigationEventSubscription | null = null;
|
||||
componentDidMount() {
|
||||
// this.s0! = this.props.navigation.addListener('willFocus', this.onEvent);
|
||||
// this.s1! = this.props.navigation.addListener('didFocus', this.onEvent);
|
||||
// this.s2! = this.props.navigation.addListener('willBlur', this.onEvent);
|
||||
// this.s3! = this.props.navigation.addListener('didBlur', this.onEvent);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
// this.s0!.remove();
|
||||
// this.s1!.remove();
|
||||
// this.s2!.remove();
|
||||
// this.s3!.remove();
|
||||
}
|
||||
onEvent = (a: NavigationEventPayload) => {
|
||||
console.log('EVENT ON CHAT TAB', a.type, a);
|
||||
};
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="Chat Tab" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
const MySettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Settings Tab" navigation={navigation} />;
|
||||
|
||||
MySettingsScreen.navigationOptions = {
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
horizontal,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
horizontal: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name="ios-settings"
|
||||
size={horizontal ? 20 : 26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
tabBarLabel: 'Settings',
|
||||
};
|
||||
|
||||
const SimpleTabs = createBottomTabNavigator(
|
||||
{
|
||||
Chat: {
|
||||
path: 'chat',
|
||||
screen: MyChatScreen,
|
||||
},
|
||||
Home: {
|
||||
path: '',
|
||||
screen: MyListScreen,
|
||||
},
|
||||
People: {
|
||||
path: 'cart',
|
||||
screen: MyPeopleScreen,
|
||||
},
|
||||
Settings: {
|
||||
path: 'settings',
|
||||
screen: MySettingsScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
backBehavior: 'history',
|
||||
tabBarOptions: {
|
||||
activeTintColor: '#e91e63',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
interface SimpleTabsContainerProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class SimpleTabsContainer extends React.Component<SimpleTabsContainerProps> {
|
||||
static router = SimpleTabs.router;
|
||||
s0: NavigationEventSubscription | null = null;
|
||||
s1: NavigationEventSubscription | null = null;
|
||||
s2: NavigationEventSubscription | null = null;
|
||||
s3: NavigationEventSubscription | null = null;
|
||||
|
||||
componentDidMount() {
|
||||
// this.s0! = this.props.navigation.addListener('willFocus', this.onAction);
|
||||
// this.s1! = this.props.navigation.addListener('didFocus', this.onAction);
|
||||
// this.s2! = this.props.navigation.addListener('willBlur', this.onAction);
|
||||
// this.s3! = this.props.navigation.addListener('didBlur', this.onAction);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
// this.s0!.remove();
|
||||
// this.s1!.remove();
|
||||
// this.s2!.remove();
|
||||
// this.s3!.remove();
|
||||
}
|
||||
onAction = (a: NavigationEventPayload) => {
|
||||
console.log('TABS EVENT', a.type, a);
|
||||
};
|
||||
render() {
|
||||
return <SimpleTabs navigation={this.props.navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
export default SimpleTabsContainer;
|
||||
@@ -1,157 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import { Button, Image, StyleSheet } from 'react-native';
|
||||
import {
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
NavigationScreenConfigProps,
|
||||
Themed,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
interface MyNavScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
banner: React.ReactNode;
|
||||
}
|
||||
|
||||
class MyCustomHeaderBackImage extends React.Component<any, any> {
|
||||
render() {
|
||||
const source = require('./assets/back.png');
|
||||
return (
|
||||
<Image
|
||||
source={source}
|
||||
style={[styles.myCustomHeaderBackImage, this.props.style]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
render() {
|
||||
const { navigation, banner } = this.props;
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
|
||||
title="Navigate to a photos screen"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface MyHomeScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
static navigationOptions = {
|
||||
headerBackTitle: null,
|
||||
title: 'Welcome',
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
interface MyPhotosScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
headerBackTitle: null,
|
||||
title: `${navigation.state.params!.name}'s photos`,
|
||||
});
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<SampleText>{`${navigation.state.params!.name}'s Photos`}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Profile', { name: 'Jane' })}
|
||||
title="Navigate to a profile screen"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
interface MyProfileScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
class MyProfileScreen extends React.Component<MyProfileScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Profile',
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<SampleText>{`${navigation.state.params!.name}'s Profile`}</SampleText>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const StackWithCustomHeaderBackImage = createStackNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
Photos: {
|
||||
path: 'photos/:name',
|
||||
screen: MyPhotosScreen,
|
||||
},
|
||||
Profile: {
|
||||
path: 'profile/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
defaultNavigationOptions: ({
|
||||
theme,
|
||||
}: NavigationScreenConfigProps<any>) => ({
|
||||
headerBackImage: (
|
||||
<MyCustomHeaderBackImage
|
||||
style={[
|
||||
styles.myCustomHeaderBackImageAlt,
|
||||
{
|
||||
tintColor: theme === 'light' ? '#000' : '#fff',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
export default StackWithCustomHeaderBackImage;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
myCustomHeaderBackImage: {
|
||||
height: 14.5,
|
||||
marginLeft: 9,
|
||||
marginRight: 12,
|
||||
marginVertical: 12,
|
||||
resizeMode: 'contain',
|
||||
width: 24,
|
||||
},
|
||||
myCustomHeaderBackImageAlt: {},
|
||||
});
|
||||
@@ -1,114 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import { SafeAreaView, Themed } from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
|
||||
interface NavScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
}
|
||||
|
||||
class HomeScreen extends React.Component<NavScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { push } = navigation;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ paddingTop: 30 }}>
|
||||
<Button onPress={() => push('Other')} title="Push another screen" />
|
||||
<Button
|
||||
onPress={() => push('ScreenWithNoHeader')}
|
||||
title="Push screen with no header"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go Home" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OtherScreen extends React.Component<NavScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Your title here',
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { push, pop } = navigation;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ paddingTop: 30 }}>
|
||||
<Button
|
||||
onPress={() => push('ScreenWithLongTitle')}
|
||||
title="Push another screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => push('ScreenWithNoHeader')}
|
||||
title="Push screen with no header"
|
||||
/>
|
||||
<Button onPress={() => pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ScreenWithLongTitle extends React.Component<NavScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: "Another title that's kind of long",
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { pop } = navigation;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ paddingTop: 30 }}>
|
||||
<Button onPress={() => pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ScreenWithNoHeader extends React.Component<NavScreenProps> {
|
||||
static navigationOptions = {
|
||||
header: null,
|
||||
title: 'No Header',
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { push, pop } = navigation;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ paddingTop: 30 }}>
|
||||
<Button onPress={() => push('Other')} title="Push another screen" />
|
||||
<Button onPress={() => pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Themed.StatusBar />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const StackWithHeaderPreset = createStackNavigator(
|
||||
{
|
||||
Home: HomeScreen,
|
||||
Other: OtherScreen,
|
||||
ScreenWithLongTitle,
|
||||
ScreenWithNoHeader,
|
||||
},
|
||||
{
|
||||
headerTransitionPreset: 'uikit',
|
||||
}
|
||||
);
|
||||
|
||||
export default StackWithHeaderPreset;
|
||||
@@ -1,256 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import { Platform, ScrollView, StyleSheet, View } from 'react-native';
|
||||
import { BlurView } from 'expo-blur';
|
||||
import { isIphoneX } from 'react-native-iphone-x-helper';
|
||||
import {
|
||||
NavigationEventPayload,
|
||||
NavigationEventSubscription,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
Themed,
|
||||
SupportedThemes,
|
||||
} from 'react-navigation';
|
||||
import {
|
||||
createStackNavigator,
|
||||
Header,
|
||||
HeaderStyleInterpolator,
|
||||
} from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import { HeaderButtons } from './commonComponents/HeaderButtons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
interface MyNavScreenProps {
|
||||
// TODO: satya164 - use stack's navigation type
|
||||
navigation: any;
|
||||
banner: React.ReactNode;
|
||||
}
|
||||
|
||||
class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
render() {
|
||||
const { navigation, banner } = this.props;
|
||||
const { push, replace, popToTop, pop } = navigation;
|
||||
return (
|
||||
<ScrollView style={{ flex: 1 }} {...this.getHeaderInset()}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => push('Profile', { name: 'Jane' })}
|
||||
title="Push a profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
|
||||
title="Navigate to a photos screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => replace('Profile', { name: 'Lucy' })}
|
||||
title="Replace with profile"
|
||||
/>
|
||||
<Button onPress={() => popToTop()} title="Pop to top" />
|
||||
<Button onPress={() => pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<Themed.StatusBar />
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
// Inset to compensate for navigation bar being transparent.
|
||||
// And improved abstraction for this will be built in to react-navigation
|
||||
// at some point.
|
||||
|
||||
getHeaderInset(): any {
|
||||
const NOTCH_HEIGHT = isIphoneX() ? 25 : 0;
|
||||
|
||||
// $FlowIgnore: we will remove the HEIGHT static soon enough
|
||||
const BASE_HEADER_HEIGHT = Header.HEIGHT;
|
||||
|
||||
const HEADER_HEIGHT =
|
||||
Platform.OS === 'ios'
|
||||
? BASE_HEADER_HEIGHT + NOTCH_HEIGHT
|
||||
: BASE_HEADER_HEIGHT + 20;
|
||||
|
||||
return Platform.select({
|
||||
android: {
|
||||
contentContainerStyle: {
|
||||
paddingTop: HEADER_HEIGHT,
|
||||
},
|
||||
},
|
||||
ios: {
|
||||
contentInset: { top: HEADER_HEIGHT },
|
||||
contentOffset: { y: -HEADER_HEIGHT },
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
interface MyHomeScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
s0: NavigationEventSubscription | null = null;
|
||||
s1: NavigationEventSubscription | null = null;
|
||||
s2: NavigationEventSubscription | null = null;
|
||||
s3: NavigationEventSubscription | null = null;
|
||||
|
||||
componentDidMount() {
|
||||
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
|
||||
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
|
||||
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
|
||||
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this.s0!.remove();
|
||||
this.s1!.remove();
|
||||
this.s2!.remove();
|
||||
this.s3!.remove();
|
||||
}
|
||||
onWF = (a: NavigationEventPayload) => {
|
||||
console.log('willFocus HomeScreen', a);
|
||||
};
|
||||
onDF = (a: NavigationEventPayload) => {
|
||||
console.log('didFocus HomeScreen', a);
|
||||
};
|
||||
onWB = (a: NavigationEventPayload) => {
|
||||
console.log('willBlur HomeScreen', a);
|
||||
};
|
||||
onDB = (a: NavigationEventPayload) => {
|
||||
console.log('didBlur HomeScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
interface MyPhotosScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Photos',
|
||||
};
|
||||
s0: NavigationEventSubscription | null = null;
|
||||
s1: NavigationEventSubscription | null = null;
|
||||
s2: NavigationEventSubscription | null = null;
|
||||
s3: NavigationEventSubscription | null = null;
|
||||
|
||||
componentDidMount() {
|
||||
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
|
||||
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
|
||||
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
|
||||
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this.s0!.remove();
|
||||
this.s1!.remove();
|
||||
this.s2!.remove();
|
||||
this.s3!.remove();
|
||||
}
|
||||
onWF = (a: NavigationEventPayload) => {
|
||||
console.log('willFocus PhotosScreen', a);
|
||||
};
|
||||
onDF = (a: NavigationEventPayload) => {
|
||||
console.log('didFocus PhotosScreen', a);
|
||||
};
|
||||
onWB = (a: NavigationEventPayload) => {
|
||||
console.log('willBlur PhotosScreen', a);
|
||||
};
|
||||
onDB = (a: NavigationEventPayload) => {
|
||||
console.log('didBlur PhotosScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.name}'s Photos`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.mode === 'edit' ? 'Now Editing ' : ''}${
|
||||
navigation.state.params!.name
|
||||
}'s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
MyProfileScreen.navigationOptions = (props: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
theme: SupportedThemes;
|
||||
}) => {
|
||||
const { navigation, theme } = props;
|
||||
const { state, setParams } = navigation;
|
||||
const { params } = state;
|
||||
return {
|
||||
headerBackImage: params!.headerBackImage,
|
||||
// Render a button on the right side of the header.
|
||||
// When pressed switches the screen to edit mode.
|
||||
headerRight: (
|
||||
<HeaderButtons>
|
||||
<HeaderButtons.Item
|
||||
color={theme === 'light' ? '#000' : '#fff'}
|
||||
title={params!.mode === 'edit' ? 'Done' : 'Edit'}
|
||||
onPress={() =>
|
||||
setParams({ mode: params!.mode === 'edit' ? '' : 'edit' })
|
||||
}
|
||||
/>
|
||||
</HeaderButtons>
|
||||
),
|
||||
headerTitle: `${params!.name}'s Profile!`,
|
||||
};
|
||||
};
|
||||
|
||||
const StackWithTranslucentHeader = createStackNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
Photos: {
|
||||
path: 'photos/:name',
|
||||
screen: MyPhotosScreen,
|
||||
},
|
||||
Profile: {
|
||||
path: 'people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: ({ theme }) => ({
|
||||
headerBackground:
|
||||
Platform.OS === 'ios' ? (
|
||||
<BlurView
|
||||
style={{ flex: 1 }}
|
||||
blurType={theme === 'light' ? 'light' : 'dark'}
|
||||
/>
|
||||
) : (
|
||||
<View style={{ flex: 1, backgroundColor: 'rgba(255,255,255,0.7)' }} />
|
||||
),
|
||||
headerStyle: {
|
||||
borderBottomColor: theme === 'light' ? '#A7A7AA' : 'transparent',
|
||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||
},
|
||||
headerTransparent: true,
|
||||
}),
|
||||
headerTransitionPreset: 'uikit',
|
||||
// You can leave this out if you don't want the card shadow to
|
||||
// be visible through the header
|
||||
transitionConfig: () => ({
|
||||
headerBackgroundInterpolator:
|
||||
HeaderStyleInterpolator.forBackgroundWithTranslation,
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
export default StackWithTranslucentHeader;
|
||||
@@ -1,163 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Text } from 'react-native';
|
||||
import {
|
||||
Themed,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
SafeAreaView,
|
||||
ScrollView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const TEXT = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a hendrerit dui, id consectetur nulla. Curabitur mattis sapien nunc, quis dignissim eros venenatis sit amet. Praesent rutrum dapibus diam quis eleifend. Donec vulputate quis purus sed vulputate. Fusce ipsum felis, cursus at congue vel, consectetur tincidunt purus. Pellentesque et fringilla lorem. In at augue malesuada, sollicitudin ex ut, convallis elit. Curabitur metus nibh, consequat vel libero sit amet, iaculis congue nisl. Maecenas eleifend sodales sapien, fringilla sagittis nisi ornare volutpat. Integer tellus enim, volutpat vitae nisl et, dignissim pharetra leo. Sed sit amet efficitur sapien, at tristique sapien. Aenean dignissim semper sagittis. Nullam sit amet volutpat mi.
|
||||
Curabitur auctor orci et justo molestie iaculis. Integer elementum tortor ac ipsum egestas pharetra. Etiam ultrices elementum pharetra. Maecenas lobortis ultrices risus dignissim luctus. Nunc malesuada cursus posuere. Vestibulum tristique lectus pretium pellentesque pellentesque. Nunc ac nisi lacus. Duis ultrices dui ac viverra ullamcorper. Morbi placerat laoreet lacus sit amet ullamcorper.
|
||||
Nulla convallis pulvinar hendrerit. Nulla mattis sem et aliquam ultrices. Nam egestas magna leo, nec luctus turpis sollicitudin ac. Sed id leo luctus, lobortis tortor ut, rhoncus ex. Aliquam gravida enim ac dapibus ultricies. Vestibulum at interdum est, et vehicula nibh. Phasellus dignissim iaculis rhoncus. Vestibulum tempus leo lectus, quis euismod metus ullamcorper quis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut id ipsum at enim eleifend porttitor id quis metus. Proin bibendum ornare iaculis. Duis elementum lacus vel cursus efficitur. Nunc eu tortor sed risus lacinia scelerisque.
|
||||
Praesent lobortis elit sit amet mauris pulvinar, viverra condimentum massa pellentesque. Curabitur massa ex, dignissim eget neque at, fringilla consectetur justo. Cras sollicitudin vel ligula sed cursus. Aliquam porta sem hendrerit diam porta ultricies. Sed eu mi erat. Curabitur id justo vel tortor hendrerit vestibulum id eget est. Morbi eros magna, placerat id diam ut, varius sollicitudin mi. Curabitur pretium finibus accumsan.`;
|
||||
|
||||
interface Props {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
banner: string;
|
||||
}
|
||||
|
||||
class MyNavScreen extends React.Component<Props> {
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const banner = navigation.getParam('banner');
|
||||
|
||||
return (
|
||||
<ScrollView style={{ flex: 1 }}>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
||||
title="Open profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('NotifSettings')}
|
||||
title="Open notifications screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('SettingsTab')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
|
||||
{TEXT.split('\n').map((p, n) => (
|
||||
<Text key={n} style={{ marginVertical: 10, marginHorizontal: 8 }}>
|
||||
{p}
|
||||
</Text>
|
||||
))}
|
||||
</SafeAreaView>
|
||||
|
||||
<Themed.StatusBar />
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.name}s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
const MainTab = createStackNavigator({
|
||||
Home: {
|
||||
navigationOptions: {
|
||||
title: 'Welcome',
|
||||
},
|
||||
params: { banner: 'Home Screen' },
|
||||
path: '/',
|
||||
screen: MyNavScreen,
|
||||
},
|
||||
Profile: {
|
||||
navigationOptions: ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
title: `${navigation.state.params!.name}'s Profile!`,
|
||||
}),
|
||||
path: '/people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
});
|
||||
|
||||
const SettingsTab = createStackNavigator({
|
||||
NotifSettings: {
|
||||
navigationOptions: {
|
||||
title: 'Notifications',
|
||||
},
|
||||
params: { banner: 'Notifications Screen' },
|
||||
screen: MyNavScreen,
|
||||
},
|
||||
Settings: {
|
||||
navigationOptions: () => ({
|
||||
title: 'Settings',
|
||||
}),
|
||||
params: { banner: 'Settings Screen' },
|
||||
path: '/',
|
||||
screen: MyNavScreen,
|
||||
},
|
||||
});
|
||||
|
||||
const StacksInTabs = createBottomTabNavigator(
|
||||
{
|
||||
MainTab: {
|
||||
navigationOptions: {
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
focused,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-home' : 'ios-home'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
tabBarLabel: 'Home',
|
||||
},
|
||||
path: '/',
|
||||
screen: MainTab,
|
||||
},
|
||||
SettingsTab: {
|
||||
screen: SettingsTab,
|
||||
path: '/settings',
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Settings',
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
focused,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-settings' : 'ios-settings'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabBarOptions: {
|
||||
showLabel: false,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export default StacksInTabs;
|
||||
@@ -1,159 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ScrollView, StatusBar } from 'react-native';
|
||||
import { Ionicons } from '@expo/vector-icons';
|
||||
import {
|
||||
getActiveChildNavigationOptions,
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { createBottomTabNavigator } from 'react-navigation-tabs';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({
|
||||
navigation,
|
||||
banner,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
banner: string;
|
||||
}) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always', vertical: 'never' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
||||
title="Open profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('NotifSettings')}
|
||||
title="Open notifications screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('SettingsTab')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.name}s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
const MyNotificationsSettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
|
||||
|
||||
const MySettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Settings Screen" navigation={navigation} />;
|
||||
|
||||
const TabNav = createBottomTabNavigator(
|
||||
{
|
||||
MainTab: {
|
||||
navigationOptions: {
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
focused,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-home' : 'ios-home'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
tabBarLabel: 'Home',
|
||||
title: 'Welcome',
|
||||
},
|
||||
path: '/',
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
SettingsTab: {
|
||||
navigationOptions: {
|
||||
tabBarIcon: ({
|
||||
tintColor,
|
||||
focused,
|
||||
}: {
|
||||
tintColor: string;
|
||||
focused: boolean;
|
||||
}) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-settings' : 'ios-settings'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
title: 'Settings',
|
||||
},
|
||||
path: '/settings',
|
||||
screen: MySettingsScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
animationEnabled: false,
|
||||
swipeEnabled: false,
|
||||
tabBarPosition: 'bottom',
|
||||
}
|
||||
);
|
||||
|
||||
TabNav.navigationOptions = ({
|
||||
navigation,
|
||||
screenProps,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
screenProps: { [key: string]: any };
|
||||
}) => {
|
||||
const childOptions = getActiveChildNavigationOptions(navigation, screenProps);
|
||||
return {
|
||||
title: childOptions.title,
|
||||
};
|
||||
};
|
||||
|
||||
const StacksOverTabs = createStackNavigator({
|
||||
NotifSettings: {
|
||||
navigationOptions: {
|
||||
title: 'Notifications',
|
||||
},
|
||||
screen: MyNotificationsSettingsScreen,
|
||||
},
|
||||
Profile: {
|
||||
navigationOptions: ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
title: `${navigation.state.params!.name}'s Profile!`,
|
||||
}),
|
||||
path: '/people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
Root: {
|
||||
screen: TabNav,
|
||||
},
|
||||
});
|
||||
|
||||
export default StacksOverTabs;
|
||||
@@ -1,178 +0,0 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
ScrollView,
|
||||
StatusBar,
|
||||
StatusBarStyle,
|
||||
StyleSheet,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import {
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import {
|
||||
createMaterialTopTabNavigator,
|
||||
MaterialTopTabBar,
|
||||
} from 'react-navigation-tabs';
|
||||
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const HEADER_HEIGHT = 64;
|
||||
|
||||
const MyNavScreen = ({
|
||||
navigation,
|
||||
banner,
|
||||
statusBarStyle,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
banner: string;
|
||||
statusBarStyle?: StatusBarStyle;
|
||||
}) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
||||
title="Open profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('NotifSettings')}
|
||||
title="Open notifications screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('SettingsTab')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
<StatusBar barStyle={statusBarStyle || 'default'} />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner="Home Screen"
|
||||
navigation={navigation}
|
||||
statusBarStyle="light-content"
|
||||
/>
|
||||
);
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.name}s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
const MyNotificationsSettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
|
||||
|
||||
const MySettingsScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
<MyNavScreen
|
||||
banner="Settings Screen"
|
||||
navigation={navigation}
|
||||
statusBarStyle="light-content"
|
||||
/>
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
stackHeader: {
|
||||
height: HEADER_HEIGHT,
|
||||
},
|
||||
tab: {
|
||||
height: HEADER_HEIGHT,
|
||||
},
|
||||
});
|
||||
|
||||
function MaterialTopTabBarWithStatusBar(props: any) {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
paddingTop: 20,
|
||||
backgroundColor: '#2196f3',
|
||||
}}
|
||||
>
|
||||
<MaterialTopTabBar
|
||||
{...props}
|
||||
jumpToIndex={() => {
|
||||
//
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const TabNavigator = createMaterialTopTabNavigator(
|
||||
{
|
||||
MainTab: {
|
||||
screen: MyHomeScreen,
|
||||
navigationOptions: {
|
||||
title: 'Welcome',
|
||||
},
|
||||
},
|
||||
SettingsTab: {
|
||||
screen: MySettingsScreen,
|
||||
navigationOptions: {
|
||||
title: 'Settings',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabBarComponent: MaterialTopTabBarWithStatusBar,
|
||||
tabBarOptions: {
|
||||
tabStyle: styles.tab,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const StackNavigator = createStackNavigator(
|
||||
{
|
||||
Root: {
|
||||
screen: TabNavigator,
|
||||
navigationOptions: {
|
||||
header: null,
|
||||
},
|
||||
},
|
||||
NotifSettings: {
|
||||
screen: MyNotificationsSettingsScreen,
|
||||
navigationOptions: {
|
||||
title: 'Notifications',
|
||||
},
|
||||
},
|
||||
Profile: {
|
||||
screen: MyProfileScreen,
|
||||
navigationOptions: ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
title: `${navigation.state.params!.name}'s Profile!`,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: {
|
||||
headerStyle: styles.stackHeader,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export default StackNavigator;
|
||||
@@ -1,128 +0,0 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
AsyncStorage,
|
||||
StyleSheet,
|
||||
View,
|
||||
Platform,
|
||||
} from 'react-native';
|
||||
import { Themed, createSwitchNavigator } from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
|
||||
class SignInScreen extends React.Component<any, any> {
|
||||
static navigationOptions = {
|
||||
title: 'Please sign in',
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Button title="Sign in!" onPress={this.signInAsync} />
|
||||
<Button
|
||||
title="Go back to other examples"
|
||||
onPress={() => this.props.navigation.goBack(null)}
|
||||
/>
|
||||
<Themed.StatusBar />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
signInAsync = async () => {
|
||||
await AsyncStorage.setItem('userToken', 'abc');
|
||||
this.props.navigation.navigate('Home');
|
||||
};
|
||||
}
|
||||
|
||||
class HomeScreen extends React.Component<any, any> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome to the app!',
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Button title="Show me more of the app" onPress={this.showMoreApp} />
|
||||
<Button title="Actually, sign me out :)" onPress={this.signOutAsync} />
|
||||
<Themed.StatusBar />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
showMoreApp = () => {
|
||||
this.props.navigation.navigate('Other');
|
||||
};
|
||||
|
||||
signOutAsync = async () => {
|
||||
if (Platform.OS === 'ios') {
|
||||
await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove);
|
||||
} else {
|
||||
await AsyncStorage.clear();
|
||||
}
|
||||
|
||||
this.props.navigation.navigate('Auth');
|
||||
};
|
||||
}
|
||||
|
||||
class OtherScreen extends React.Component<any, any> {
|
||||
static navigationOptions = {
|
||||
title: 'Lots of features here',
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Button title="I'm done, sign me out" onPress={this.signOutAsync} />
|
||||
<Themed.StatusBar />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
signOutAsync = async () => {
|
||||
if (Platform.OS === 'ios') {
|
||||
await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove);
|
||||
} else {
|
||||
await AsyncStorage.clear();
|
||||
}
|
||||
|
||||
this.props.navigation.navigate('Auth');
|
||||
};
|
||||
}
|
||||
|
||||
class LoadingScreen extends React.Component<any, any> {
|
||||
componentDidMount() {
|
||||
this.bootstrapAsync();
|
||||
}
|
||||
|
||||
bootstrapAsync = async () => {
|
||||
const userToken = await AsyncStorage.getItem('userToken');
|
||||
const initialRouteName = userToken ? 'App' : 'Auth';
|
||||
this.props.navigation.navigate(initialRouteName);
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<ActivityIndicator />
|
||||
<Themed.StatusBar />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
alignItems: 'center',
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
},
|
||||
});
|
||||
|
||||
const AppStack = createStackNavigator({ Home: HomeScreen, Other: OtherScreen });
|
||||
const AuthStack = createStackNavigator({ SignIn: SignInScreen });
|
||||
|
||||
export default createSwitchNavigator({
|
||||
App: AppStack,
|
||||
Auth: AuthStack,
|
||||
Loading: LoadingScreen,
|
||||
});
|
||||
@@ -1,28 +0,0 @@
|
||||
import React from 'react';
|
||||
import { MaterialIcons } from '@expo/vector-icons';
|
||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||
import SimpleTabs from './SimpleTabs';
|
||||
import StacksOverTabs from './StacksOverTabs';
|
||||
|
||||
const TabsInDrawer = createDrawerNavigator({
|
||||
SimpleTabs: {
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }: { tintColor: string }) => (
|
||||
<MaterialIcons name="filter-1" size={24} style={{ color: tintColor }} />
|
||||
),
|
||||
drawerLabel: 'Simple tabs',
|
||||
},
|
||||
screen: SimpleTabs,
|
||||
},
|
||||
StacksOverTabs: {
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }: { tintColor: string }) => (
|
||||
<MaterialIcons name="filter-2" size={24} style={{ color: tintColor }} />
|
||||
),
|
||||
drawerLabel: 'Stacks Over Tabs',
|
||||
},
|
||||
screen: StacksOverTabs,
|
||||
},
|
||||
});
|
||||
|
||||
export default TabsInDrawer;
|
||||
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 939 B |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 133 KiB |
@@ -1,156 +0,0 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
AccessibilityStates,
|
||||
Platform,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
|
||||
export interface ButtonProps {
|
||||
/**
|
||||
* Text to display inside the button
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* Handler to be called when the user taps the button
|
||||
*/
|
||||
onPress: (event?: any) => void;
|
||||
|
||||
/**
|
||||
* Color of the text (iOS), or background color of the button (Android)
|
||||
*/
|
||||
color?: string;
|
||||
|
||||
/**
|
||||
* TV preferred focus (see documentation for the View component).
|
||||
*/
|
||||
hasTVPreferredFocus?: boolean;
|
||||
|
||||
/**
|
||||
* Text to display for blindness accessibility features
|
||||
*/
|
||||
accessibilityLabel?: string;
|
||||
|
||||
/**
|
||||
* If true, disable all interactions for this component.
|
||||
*/
|
||||
disabled?: boolean;
|
||||
|
||||
/**
|
||||
* Used to locate this view in end-to-end tests.
|
||||
*/
|
||||
testID?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A basic button component that should render nicely on any platform. Supports
|
||||
* a minimal level of customization.
|
||||
*
|
||||
* <center><img src="img/buttonExample.png"></img></center>
|
||||
*
|
||||
* This button is built using TouchableOpacity
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```
|
||||
* import { Button } from 'react-native';
|
||||
* ...
|
||||
*
|
||||
* <Button
|
||||
* onPress={onPressLearnMore}
|
||||
* title="Learn More"
|
||||
* color="#841584"
|
||||
* accessibilityLabel="Learn more about this purple button"
|
||||
* />
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
|
||||
export default class Button extends React.Component<ButtonProps> {
|
||||
render() {
|
||||
const {
|
||||
accessibilityLabel,
|
||||
color,
|
||||
onPress,
|
||||
title,
|
||||
disabled,
|
||||
testID,
|
||||
} = this.props;
|
||||
const buttonStyles: any = [styles.button];
|
||||
const textStyles: any = [styles.text];
|
||||
if (color) {
|
||||
if (Platform.OS === 'ios') {
|
||||
textStyles.push({ color });
|
||||
} else {
|
||||
buttonStyles.push({ backgroundColor: color });
|
||||
}
|
||||
}
|
||||
const accessibilityStates: AccessibilityStates[] = [];
|
||||
if (disabled) {
|
||||
buttonStyles.push(styles.buttonDisabled);
|
||||
textStyles.push(styles.textDisabled);
|
||||
accessibilityStates.push('disabled');
|
||||
}
|
||||
const formattedTitle =
|
||||
Platform.OS === 'android' ? title.toUpperCase() : title;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
accessibilityRole="button"
|
||||
accessibilityStates={accessibilityStates}
|
||||
testID={testID}
|
||||
disabled={disabled}
|
||||
onPress={onPress}
|
||||
>
|
||||
<View style={buttonStyles}>
|
||||
<Text style={textStyles}>{formattedTitle}</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: Platform.select({
|
||||
android: {
|
||||
backgroundColor: '#2196F3',
|
||||
borderRadius: 2,
|
||||
elevation: 4,
|
||||
// Material design blue from https://material.google.com/style/color.html#color-color-palette
|
||||
},
|
||||
ios: {},
|
||||
}),
|
||||
buttonDisabled: Platform.select({
|
||||
android: {
|
||||
backgroundColor: '#dfdfdf',
|
||||
elevation: 0,
|
||||
},
|
||||
ios: {},
|
||||
}),
|
||||
text: {
|
||||
padding: 8,
|
||||
textAlign: 'center',
|
||||
...Platform.select({
|
||||
android: {
|
||||
color: 'white',
|
||||
fontWeight: '500',
|
||||
},
|
||||
ios: {
|
||||
// iOS blue from https://developer.apple.com/ios/human-interface-guidelines/visual-design/color/
|
||||
color: '#007AFF',
|
||||
fontSize: 18,
|
||||
},
|
||||
}),
|
||||
},
|
||||
textDisabled: Platform.select({
|
||||
android: {
|
||||
color: '#a1a1a1',
|
||||
},
|
||||
ios: {
|
||||
color: '#cdcdcd',
|
||||
},
|
||||
}),
|
||||
});
|
||||
@@ -1,19 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Platform, StyleSheet, View } from 'react-native';
|
||||
import BaseButton, { ButtonProps } from './Button';
|
||||
|
||||
export const Button = (props: ButtonProps) => (
|
||||
<View style={styles.margin}>
|
||||
<BaseButton {...props} />
|
||||
</View>
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
margin: {
|
||||
...Platform.select({
|
||||
android: {
|
||||
margin: 10,
|
||||
},
|
||||
}),
|
||||
},
|
||||
});
|
||||
@@ -1,18 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
HeaderButtons as DefaultHeaderButtons,
|
||||
Item,
|
||||
} from 'react-navigation-header-buttons';
|
||||
|
||||
export class HeaderButtons extends React.PureComponent {
|
||||
static Item = Item;
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DefaultHeaderButtons
|
||||
// color={Platform.OS === 'ios' ? '#037aff' : 'black'}
|
||||
{...this.props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
5957
example/yarn.lock
17
examples/NavigationPlayground/.babelrc
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"presets": [
|
||||
"babel-preset-expo"
|
||||
],
|
||||
"env": {
|
||||
"development": {
|
||||
"plugins": [
|
||||
"transform-react-jsx-source"
|
||||
],
|
||||
},
|
||||
"production": {
|
||||
"plugins": [
|
||||
"transform-remove-console"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
83
examples/NavigationPlayground/.flowconfig
Normal file
@@ -0,0 +1,83 @@
|
||||
[ignore]
|
||||
; We fork some components by platform
|
||||
.*/*[.]android.js
|
||||
|
||||
; Ignore "BUCK" generated dirs
|
||||
<PROJECT_ROOT>/\.buckd/
|
||||
|
||||
; Ignore unexpected extra "@providesModule"
|
||||
.*/node_modules/.*/node_modules/fbjs/.*
|
||||
|
||||
; Ignore duplicate module providers
|
||||
; For RN Apps installed via npm, "Libraries" folder is inside
|
||||
; "node_modules/react-native" but in the source repo it is in the root
|
||||
.*/Libraries/react-native/React.js
|
||||
|
||||
; Ignore polyfills
|
||||
.*/Libraries/polyfills/.*
|
||||
|
||||
.*/react-navigation/node_modules/.*
|
||||
|
||||
; Additional create-react-native-app ignores
|
||||
|
||||
; Ignore duplicate module providers
|
||||
.*/node_modules/fbemitter/lib/*
|
||||
|
||||
; Ignore misbehaving dev-dependencies
|
||||
.*/node_modules/xdl/build/*
|
||||
.*/node_modules/reqwest/tests/*
|
||||
|
||||
; Ignore missing expo-sdk dependencies (temporarily)
|
||||
; https://github.com/expo/expo/issues/162
|
||||
.*/node_modules/expo/src/*
|
||||
|
||||
; Ignore react-native-fbads dependency of the expo sdk
|
||||
.*/node_modules/react-native-fbads/*
|
||||
|
||||
.*/react-navigation/examples/ReduxExample/.*
|
||||
.*/react-navigation/website/.*
|
||||
|
||||
; This package is required by Expo and causes Flow errors
|
||||
.*/node_modules/react-native-gesture-handler/.*
|
||||
|
||||
.*/node_modules/metro/.*
|
||||
|
||||
[include]
|
||||
|
||||
[libs]
|
||||
node_modules/react-native/Libraries/react-native/react-native-interface.js
|
||||
node_modules/react-native/flow/
|
||||
node_modules/react-native/flow-github/
|
||||
../../flow/
|
||||
|
||||
[options]
|
||||
module.system=haste
|
||||
|
||||
emoji=true
|
||||
|
||||
experimental.strict_type_args=true
|
||||
|
||||
munge_underscores=true
|
||||
|
||||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
|
||||
module.file_ext=.js
|
||||
module.file_ext=.jsx
|
||||
module.file_ext=.json
|
||||
module.file_ext=.native.js
|
||||
|
||||
suppress_type=$FlowIgnore
|
||||
suppress_type=$FlowIssue
|
||||
suppress_type=$FlowFixMe
|
||||
suppress_type=$FlowFixMeProps
|
||||
suppress_type=$FlowFixMeState
|
||||
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIgnore\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
|
||||
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
|
||||
|
||||
unsafe.enable_getters_and_setters=true
|
||||
|
||||
[version]
|
||||
^0.61.0
|
||||
3
examples/NavigationPlayground/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
.expo/
|
||||
npm-debug.*
|
||||
1
examples/NavigationPlayground/.watchmanconfig
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
2
examples/NavigationPlayground/App.js
Normal file
@@ -0,0 +1,2 @@
|
||||
import App from './js/App';
|
||||
export default App;
|
||||
9
examples/NavigationPlayground/App.test.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import App from './App';
|
||||
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const rendered = renderer.create(<App />).toJSON();
|
||||
expect(rendered).toBeTruthy();
|
||||
});
|
||||
9
examples/NavigationPlayground/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Navigation Playground Example
|
||||
|
||||
A playground for experimenting with react-navigation in a pure-JS React Native app.
|
||||
|
||||
## Usage
|
||||
|
||||
Please see the [Contributors Guide](https://reactnavigation.org/docs/guides/contributors#Run-the-Example-App) for instructions on running these example apps.
|
||||
|
||||
You can view this example application directly on your phone by visiting [our expo demo](https://exp.host/@react-navigation/NavigationPlayground).
|
||||
26
examples/NavigationPlayground/app.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "NavigationPlayground",
|
||||
"description": "Try out react-navigation now with this awesome playground",
|
||||
"version": "1.0.0",
|
||||
"slug": "NavigationPlayground",
|
||||
"privacy": "public",
|
||||
"orientation": "portrait",
|
||||
"primaryColor": "#cccccc",
|
||||
"icon": "./assets/icons/icon.png",
|
||||
"splash": {
|
||||
"image": "./assets/icons/splash.png"
|
||||
},
|
||||
"sdkVersion": "25.0.0",
|
||||
"entryPoint": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
||||
"packagerOpts": {
|
||||
"assetExts": [
|
||||
"ttf",
|
||||
"mp4"
|
||||
]
|
||||
},
|
||||
"ios": {
|
||||
"supportsTablet": true
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
examples/NavigationPlayground/assets/icons/icon.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
examples/NavigationPlayground/assets/icons/splash.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
32
examples/NavigationPlayground/flow-typed/npm/babel-jest_vx.x.x.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
// flow-typed signature: ee7b4028012cfdcd83cc6541a39b2282
|
||||
// flow-typed version: <<STUB>>/babel-jest_v^21.0.0/flow_v0.61.0
|
||||
|
||||
/**
|
||||
* This is an autogenerated libdef stub for:
|
||||
*
|
||||
* 'babel-jest'
|
||||
*
|
||||
* Fill this stub out by replacing all the `any` types.
|
||||
*
|
||||
* Once filled out, we encourage you to share your work with the
|
||||
* community by sending a pull request to:
|
||||
* https://github.com/flowtype/flow-typed
|
||||
*/
|
||||
|
||||
declare module 'babel-jest' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* We include stubs for each file inside this npm package in case you need to
|
||||
* require those files directly. Feel free to delete any files that aren't
|
||||
* needed.
|
||||
*/
|
||||
declare module 'babel-jest/build/index' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
// Filename aliases
|
||||
declare module 'babel-jest/build/index.js' {
|
||||
declare module.exports: $Exports<'babel-jest/build/index'>;
|
||||
}
|
||||
823
examples/NavigationPlayground/flow-typed/npm/expo_vx.x.x.js
vendored
Normal file
@@ -0,0 +1,823 @@
|
||||
// flow-typed signature: c1ecfe71fbb86c3602b7da3d7c141df1
|
||||
// flow-typed version: <<STUB>>/expo_v^24.0.2/flow_v0.61.0
|
||||
|
||||
/**
|
||||
* This is an autogenerated libdef stub for:
|
||||
*
|
||||
* 'expo'
|
||||
*
|
||||
* Fill this stub out by replacing all the `any` types.
|
||||
*
|
||||
* Once filled out, we encourage you to share your work with the
|
||||
* community by sending a pull request to:
|
||||
* https://github.com/flowtype/flow-typed
|
||||
*/
|
||||
|
||||
declare module 'expo' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* We include stubs for each file inside this npm package in case you need to
|
||||
* require those files directly. Feel free to delete any files that aren't
|
||||
* needed.
|
||||
*/
|
||||
declare module 'expo/AppEntry' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/flow/metro-bundler' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/flow/react-native-gesture-handler' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__mocks__/Constants-development' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Amplitude-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/AuthSession-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Constants-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/ErrorRecovery-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Expo-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Facebook-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Font-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Location-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Notifications-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/SecureStore-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/Segment-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/__tests__/WebBrowser-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/admob/RNAdMobBanner' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/admob/RNAdMobInterstitial' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/admob/RNAdMobRewarded' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/admob/RNPublisherBanner' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Amplitude' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/apisAreAvailable' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Asset' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/AuthSession' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/av/Audio' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/av/Audio/Recording' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/av/Audio/Sound' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/av/AV' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/av/Video' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/BarCodeScanner.android' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/BarCodeScanner.ios' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Brightness' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Camera' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/CameraBasedBarCodeScanner' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Constants' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Contacts' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/DangerZone' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/DocumentPicker' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/effects/BlurView.android' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/effects/BlurView.ios' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/effects/LinearGradient.android' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/effects/LinearGradient.ios' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/environment/__tests__/validate-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/environment/logging' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/environment/validate' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/ErrorRecovery' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Expo' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/facebook-ads/AdSettings' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/facebook-ads/BannerViewManager' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/facebook-ads/index' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/facebook-ads/InterstitialAdManager' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/facebook-ads/NativeAdsManager' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/facebook-ads/withNativeAd' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Facebook' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/FaceDetector' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/FileSystem' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Fingerprint' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Font' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/GLView' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Google' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Icon' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/ImageManipulator' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/ImagePicker' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/IntentLauncherAndroid' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/KeepAwake' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/launch/AppLoading' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/launch/AppLoadingNativeWrapper.android' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/launch/AppLoadingNativeWrapper.ios' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/launch/registerRootComponent' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/launch/RootErrorBoundary' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/lib/Queue' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Location' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/__tests__/Logs-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/__tests__/LogSerialization-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/__tests__/RemoteConsole-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/__tests__/RemoteLogging-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/__tests__/RemoteLogs-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/Logs' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/LogSerialization' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/RemoteConsole' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/logs/RemoteLogging' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/modal/Modal' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/modal/ModalHost' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/modal/ModalImplementation' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/modal/PureContainer' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Notifications' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/OldBarCodeScanner' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Payments' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Pedometer' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Permissions' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/ScreenOrientation' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/SecureStore' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Segment' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/__tests__/Accelerometer-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/__tests__/DeviceMotion-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/__tests__/DeviceSensor-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/__tests__/Gyroscope-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/__tests__/Magnetometer-test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/Accelerometer' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/DeviceMotion' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/DeviceSensor' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/Gyroscope' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/Magnetometer' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/MagnetometerUncalibrated' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/sensor/ThreeAxisSensor' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Speech' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/SQLite' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Svg' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/takeSnapshotAsync' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/timer/polyfillNextTick' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/Util' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/src/WebBrowser' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/tools/hashAssetFiles' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'expo/tools/LogReporter' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
// Filename aliases
|
||||
declare module 'expo/AppEntry.js' {
|
||||
declare module.exports: $Exports<'expo/AppEntry'>;
|
||||
}
|
||||
declare module 'expo/flow/metro-bundler.js' {
|
||||
declare module.exports: $Exports<'expo/flow/metro-bundler'>;
|
||||
}
|
||||
declare module 'expo/flow/react-native-gesture-handler.js' {
|
||||
declare module.exports: $Exports<'expo/flow/react-native-gesture-handler'>;
|
||||
}
|
||||
declare module 'expo/src/__mocks__/Constants-development.js' {
|
||||
declare module.exports: $Exports<'expo/src/__mocks__/Constants-development'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Amplitude-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Amplitude-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/AuthSession-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/AuthSession-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Constants-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Constants-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/ErrorRecovery-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/ErrorRecovery-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Expo-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Expo-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Facebook-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Facebook-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Font-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Font-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Location-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Location-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Notifications-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Notifications-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/SecureStore-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/SecureStore-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/Segment-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/Segment-test'>;
|
||||
}
|
||||
declare module 'expo/src/__tests__/WebBrowser-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/__tests__/WebBrowser-test'>;
|
||||
}
|
||||
declare module 'expo/src/admob/RNAdMobBanner.js' {
|
||||
declare module.exports: $Exports<'expo/src/admob/RNAdMobBanner'>;
|
||||
}
|
||||
declare module 'expo/src/admob/RNAdMobInterstitial.js' {
|
||||
declare module.exports: $Exports<'expo/src/admob/RNAdMobInterstitial'>;
|
||||
}
|
||||
declare module 'expo/src/admob/RNAdMobRewarded.js' {
|
||||
declare module.exports: $Exports<'expo/src/admob/RNAdMobRewarded'>;
|
||||
}
|
||||
declare module 'expo/src/admob/RNPublisherBanner.js' {
|
||||
declare module.exports: $Exports<'expo/src/admob/RNPublisherBanner'>;
|
||||
}
|
||||
declare module 'expo/src/Amplitude.js' {
|
||||
declare module.exports: $Exports<'expo/src/Amplitude'>;
|
||||
}
|
||||
declare module 'expo/src/apisAreAvailable.js' {
|
||||
declare module.exports: $Exports<'expo/src/apisAreAvailable'>;
|
||||
}
|
||||
declare module 'expo/src/Asset.js' {
|
||||
declare module.exports: $Exports<'expo/src/Asset'>;
|
||||
}
|
||||
declare module 'expo/src/AuthSession.js' {
|
||||
declare module.exports: $Exports<'expo/src/AuthSession'>;
|
||||
}
|
||||
declare module 'expo/src/av/Audio.js' {
|
||||
declare module.exports: $Exports<'expo/src/av/Audio'>;
|
||||
}
|
||||
declare module 'expo/src/av/Audio/Recording.js' {
|
||||
declare module.exports: $Exports<'expo/src/av/Audio/Recording'>;
|
||||
}
|
||||
declare module 'expo/src/av/Audio/Sound.js' {
|
||||
declare module.exports: $Exports<'expo/src/av/Audio/Sound'>;
|
||||
}
|
||||
declare module 'expo/src/av/AV.js' {
|
||||
declare module.exports: $Exports<'expo/src/av/AV'>;
|
||||
}
|
||||
declare module 'expo/src/av/Video.js' {
|
||||
declare module.exports: $Exports<'expo/src/av/Video'>;
|
||||
}
|
||||
declare module 'expo/src/BarCodeScanner.android.js' {
|
||||
declare module.exports: $Exports<'expo/src/BarCodeScanner.android'>;
|
||||
}
|
||||
declare module 'expo/src/BarCodeScanner.ios.js' {
|
||||
declare module.exports: $Exports<'expo/src/BarCodeScanner.ios'>;
|
||||
}
|
||||
declare module 'expo/src/Brightness.js' {
|
||||
declare module.exports: $Exports<'expo/src/Brightness'>;
|
||||
}
|
||||
declare module 'expo/src/Camera.js' {
|
||||
declare module.exports: $Exports<'expo/src/Camera'>;
|
||||
}
|
||||
declare module 'expo/src/CameraBasedBarCodeScanner.js' {
|
||||
declare module.exports: $Exports<'expo/src/CameraBasedBarCodeScanner'>;
|
||||
}
|
||||
declare module 'expo/src/Constants.js' {
|
||||
declare module.exports: $Exports<'expo/src/Constants'>;
|
||||
}
|
||||
declare module 'expo/src/Contacts.js' {
|
||||
declare module.exports: $Exports<'expo/src/Contacts'>;
|
||||
}
|
||||
declare module 'expo/src/DangerZone.js' {
|
||||
declare module.exports: $Exports<'expo/src/DangerZone'>;
|
||||
}
|
||||
declare module 'expo/src/DocumentPicker.js' {
|
||||
declare module.exports: $Exports<'expo/src/DocumentPicker'>;
|
||||
}
|
||||
declare module 'expo/src/effects/BlurView.android.js' {
|
||||
declare module.exports: $Exports<'expo/src/effects/BlurView.android'>;
|
||||
}
|
||||
declare module 'expo/src/effects/BlurView.ios.js' {
|
||||
declare module.exports: $Exports<'expo/src/effects/BlurView.ios'>;
|
||||
}
|
||||
declare module 'expo/src/effects/LinearGradient.android.js' {
|
||||
declare module.exports: $Exports<'expo/src/effects/LinearGradient.android'>;
|
||||
}
|
||||
declare module 'expo/src/effects/LinearGradient.ios.js' {
|
||||
declare module.exports: $Exports<'expo/src/effects/LinearGradient.ios'>;
|
||||
}
|
||||
declare module 'expo/src/environment/__tests__/validate-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/environment/__tests__/validate-test'>;
|
||||
}
|
||||
declare module 'expo/src/environment/logging.js' {
|
||||
declare module.exports: $Exports<'expo/src/environment/logging'>;
|
||||
}
|
||||
declare module 'expo/src/environment/validate.js' {
|
||||
declare module.exports: $Exports<'expo/src/environment/validate'>;
|
||||
}
|
||||
declare module 'expo/src/ErrorRecovery.js' {
|
||||
declare module.exports: $Exports<'expo/src/ErrorRecovery'>;
|
||||
}
|
||||
declare module 'expo/src/Expo.js' {
|
||||
declare module.exports: $Exports<'expo/src/Expo'>;
|
||||
}
|
||||
declare module 'expo/src/facebook-ads/AdSettings.js' {
|
||||
declare module.exports: $Exports<'expo/src/facebook-ads/AdSettings'>;
|
||||
}
|
||||
declare module 'expo/src/facebook-ads/BannerViewManager.js' {
|
||||
declare module.exports: $Exports<'expo/src/facebook-ads/BannerViewManager'>;
|
||||
}
|
||||
declare module 'expo/src/facebook-ads/index.js' {
|
||||
declare module.exports: $Exports<'expo/src/facebook-ads/index'>;
|
||||
}
|
||||
declare module 'expo/src/facebook-ads/InterstitialAdManager.js' {
|
||||
declare module.exports: $Exports<'expo/src/facebook-ads/InterstitialAdManager'>;
|
||||
}
|
||||
declare module 'expo/src/facebook-ads/NativeAdsManager.js' {
|
||||
declare module.exports: $Exports<'expo/src/facebook-ads/NativeAdsManager'>;
|
||||
}
|
||||
declare module 'expo/src/facebook-ads/withNativeAd.js' {
|
||||
declare module.exports: $Exports<'expo/src/facebook-ads/withNativeAd'>;
|
||||
}
|
||||
declare module 'expo/src/Facebook.js' {
|
||||
declare module.exports: $Exports<'expo/src/Facebook'>;
|
||||
}
|
||||
declare module 'expo/src/FaceDetector.js' {
|
||||
declare module.exports: $Exports<'expo/src/FaceDetector'>;
|
||||
}
|
||||
declare module 'expo/src/FileSystem.js' {
|
||||
declare module.exports: $Exports<'expo/src/FileSystem'>;
|
||||
}
|
||||
declare module 'expo/src/Fingerprint.js' {
|
||||
declare module.exports: $Exports<'expo/src/Fingerprint'>;
|
||||
}
|
||||
declare module 'expo/src/Font.js' {
|
||||
declare module.exports: $Exports<'expo/src/Font'>;
|
||||
}
|
||||
declare module 'expo/src/GLView.js' {
|
||||
declare module.exports: $Exports<'expo/src/GLView'>;
|
||||
}
|
||||
declare module 'expo/src/Google.js' {
|
||||
declare module.exports: $Exports<'expo/src/Google'>;
|
||||
}
|
||||
declare module 'expo/src/Icon.js' {
|
||||
declare module.exports: $Exports<'expo/src/Icon'>;
|
||||
}
|
||||
declare module 'expo/src/ImageManipulator.js' {
|
||||
declare module.exports: $Exports<'expo/src/ImageManipulator'>;
|
||||
}
|
||||
declare module 'expo/src/ImagePicker.js' {
|
||||
declare module.exports: $Exports<'expo/src/ImagePicker'>;
|
||||
}
|
||||
declare module 'expo/src/IntentLauncherAndroid.js' {
|
||||
declare module.exports: $Exports<'expo/src/IntentLauncherAndroid'>;
|
||||
}
|
||||
declare module 'expo/src/KeepAwake.js' {
|
||||
declare module.exports: $Exports<'expo/src/KeepAwake'>;
|
||||
}
|
||||
declare module 'expo/src/launch/AppLoading.js' {
|
||||
declare module.exports: $Exports<'expo/src/launch/AppLoading'>;
|
||||
}
|
||||
declare module 'expo/src/launch/AppLoadingNativeWrapper.android.js' {
|
||||
declare module.exports: $Exports<'expo/src/launch/AppLoadingNativeWrapper.android'>;
|
||||
}
|
||||
declare module 'expo/src/launch/AppLoadingNativeWrapper.ios.js' {
|
||||
declare module.exports: $Exports<'expo/src/launch/AppLoadingNativeWrapper.ios'>;
|
||||
}
|
||||
declare module 'expo/src/launch/registerRootComponent.js' {
|
||||
declare module.exports: $Exports<'expo/src/launch/registerRootComponent'>;
|
||||
}
|
||||
declare module 'expo/src/launch/RootErrorBoundary.js' {
|
||||
declare module.exports: $Exports<'expo/src/launch/RootErrorBoundary'>;
|
||||
}
|
||||
declare module 'expo/src/lib/Queue.js' {
|
||||
declare module.exports: $Exports<'expo/src/lib/Queue'>;
|
||||
}
|
||||
declare module 'expo/src/Location.js' {
|
||||
declare module.exports: $Exports<'expo/src/Location'>;
|
||||
}
|
||||
declare module 'expo/src/logs/__tests__/Logs-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/__tests__/Logs-test'>;
|
||||
}
|
||||
declare module 'expo/src/logs/__tests__/LogSerialization-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/__tests__/LogSerialization-test'>;
|
||||
}
|
||||
declare module 'expo/src/logs/__tests__/RemoteConsole-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/__tests__/RemoteConsole-test'>;
|
||||
}
|
||||
declare module 'expo/src/logs/__tests__/RemoteLogging-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/__tests__/RemoteLogging-test'>;
|
||||
}
|
||||
declare module 'expo/src/logs/__tests__/RemoteLogs-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/__tests__/RemoteLogs-test'>;
|
||||
}
|
||||
declare module 'expo/src/logs/Logs.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/Logs'>;
|
||||
}
|
||||
declare module 'expo/src/logs/LogSerialization.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/LogSerialization'>;
|
||||
}
|
||||
declare module 'expo/src/logs/RemoteConsole.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/RemoteConsole'>;
|
||||
}
|
||||
declare module 'expo/src/logs/RemoteLogging.js' {
|
||||
declare module.exports: $Exports<'expo/src/logs/RemoteLogging'>;
|
||||
}
|
||||
declare module 'expo/src/modal/Modal.js' {
|
||||
declare module.exports: $Exports<'expo/src/modal/Modal'>;
|
||||
}
|
||||
declare module 'expo/src/modal/ModalHost.js' {
|
||||
declare module.exports: $Exports<'expo/src/modal/ModalHost'>;
|
||||
}
|
||||
declare module 'expo/src/modal/ModalImplementation.js' {
|
||||
declare module.exports: $Exports<'expo/src/modal/ModalImplementation'>;
|
||||
}
|
||||
declare module 'expo/src/modal/PureContainer.js' {
|
||||
declare module.exports: $Exports<'expo/src/modal/PureContainer'>;
|
||||
}
|
||||
declare module 'expo/src/Notifications.js' {
|
||||
declare module.exports: $Exports<'expo/src/Notifications'>;
|
||||
}
|
||||
declare module 'expo/src/OldBarCodeScanner.js' {
|
||||
declare module.exports: $Exports<'expo/src/OldBarCodeScanner'>;
|
||||
}
|
||||
declare module 'expo/src/Payments.js' {
|
||||
declare module.exports: $Exports<'expo/src/Payments'>;
|
||||
}
|
||||
declare module 'expo/src/Pedometer.js' {
|
||||
declare module.exports: $Exports<'expo/src/Pedometer'>;
|
||||
}
|
||||
declare module 'expo/src/Permissions.js' {
|
||||
declare module.exports: $Exports<'expo/src/Permissions'>;
|
||||
}
|
||||
declare module 'expo/src/ScreenOrientation.js' {
|
||||
declare module.exports: $Exports<'expo/src/ScreenOrientation'>;
|
||||
}
|
||||
declare module 'expo/src/SecureStore.js' {
|
||||
declare module.exports: $Exports<'expo/src/SecureStore'>;
|
||||
}
|
||||
declare module 'expo/src/Segment.js' {
|
||||
declare module.exports: $Exports<'expo/src/Segment'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/__tests__/Accelerometer-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/__tests__/Accelerometer-test'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/__tests__/DeviceMotion-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/__tests__/DeviceMotion-test'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/__tests__/DeviceSensor-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/__tests__/DeviceSensor-test'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/__tests__/Gyroscope-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/__tests__/Gyroscope-test'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/__tests__/Magnetometer-test.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/__tests__/Magnetometer-test'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/Accelerometer.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/Accelerometer'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/DeviceMotion.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/DeviceMotion'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/DeviceSensor.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/DeviceSensor'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/Gyroscope.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/Gyroscope'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/Magnetometer.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/Magnetometer'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/MagnetometerUncalibrated.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/MagnetometerUncalibrated'>;
|
||||
}
|
||||
declare module 'expo/src/sensor/ThreeAxisSensor.js' {
|
||||
declare module.exports: $Exports<'expo/src/sensor/ThreeAxisSensor'>;
|
||||
}
|
||||
declare module 'expo/src/Speech.js' {
|
||||
declare module.exports: $Exports<'expo/src/Speech'>;
|
||||
}
|
||||
declare module 'expo/src/SQLite.js' {
|
||||
declare module.exports: $Exports<'expo/src/SQLite'>;
|
||||
}
|
||||
declare module 'expo/src/Svg.js' {
|
||||
declare module.exports: $Exports<'expo/src/Svg'>;
|
||||
}
|
||||
declare module 'expo/src/takeSnapshotAsync.js' {
|
||||
declare module.exports: $Exports<'expo/src/takeSnapshotAsync'>;
|
||||
}
|
||||
declare module 'expo/src/timer/polyfillNextTick.js' {
|
||||
declare module.exports: $Exports<'expo/src/timer/polyfillNextTick'>;
|
||||
}
|
||||
declare module 'expo/src/Util.js' {
|
||||
declare module.exports: $Exports<'expo/src/Util'>;
|
||||
}
|
||||
declare module 'expo/src/WebBrowser.js' {
|
||||
declare module.exports: $Exports<'expo/src/WebBrowser'>;
|
||||
}
|
||||
declare module 'expo/tools/hashAssetFiles.js' {
|
||||
declare module.exports: $Exports<'expo/tools/hashAssetFiles'>;
|
||||
}
|
||||
declare module 'expo/tools/LogReporter.js' {
|
||||
declare module.exports: $Exports<'expo/tools/LogReporter'>;
|
||||
}
|
||||
6
examples/NavigationPlayground/flow-typed/npm/flow-bin_v0.x.x.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583
|
||||
// flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x
|
||||
|
||||
declare module "flow-bin" {
|
||||
declare module.exports: string;
|
||||
}
|
||||
46
examples/NavigationPlayground/flow-typed/npm/jest-expo_vx.x.x.js
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// flow-typed signature: b1e3826a494aecf4ff482336321b54bd
|
||||
// flow-typed version: <<STUB>>/jest-expo_v^24.0.0/flow_v0.61.0
|
||||
|
||||
/**
|
||||
* This is an autogenerated libdef stub for:
|
||||
*
|
||||
* 'jest-expo'
|
||||
*
|
||||
* Fill this stub out by replacing all the `any` types.
|
||||
*
|
||||
* Once filled out, we encourage you to share your work with the
|
||||
* community by sending a pull request to:
|
||||
* https://github.com/flowtype/flow-typed
|
||||
*/
|
||||
|
||||
declare module 'jest-expo' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* We include stubs for each file inside this npm package in case you need to
|
||||
* require those files directly. Feel free to delete any files that aren't
|
||||
* needed.
|
||||
*/
|
||||
declare module 'jest-expo/src/createMockConstants' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'jest-expo/src/expoModules' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'jest-expo/src/setup' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
// Filename aliases
|
||||
declare module 'jest-expo/src/createMockConstants.js' {
|
||||
declare module.exports: $Exports<'jest-expo/src/createMockConstants'>;
|
||||
}
|
||||
declare module 'jest-expo/src/expoModules.js' {
|
||||
declare module.exports: $Exports<'jest-expo/src/expoModules'>;
|
||||
}
|
||||
declare module 'jest-expo/src/setup.js' {
|
||||
declare module.exports: $Exports<'jest-expo/src/setup'>;
|
||||
}
|
||||
584
examples/NavigationPlayground/flow-typed/npm/jest_v21.x.x.js
vendored
Normal file
@@ -0,0 +1,584 @@
|
||||
// flow-typed signature: 107cf7068b8835594e97f938e8848244
|
||||
// flow-typed version: 8b4dd96654/jest_v21.x.x/flow_>=v0.39.x
|
||||
|
||||
type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
|
||||
(...args: TArguments): TReturn,
|
||||
/**
|
||||
* An object for introspecting mock calls
|
||||
*/
|
||||
mock: {
|
||||
/**
|
||||
* An array that represents all calls that have been made into this mock
|
||||
* function. Each call is represented by an array of arguments that were
|
||||
* passed during the call.
|
||||
*/
|
||||
calls: Array<TArguments>,
|
||||
/**
|
||||
* An array that contains all the object instances that have been
|
||||
* instantiated from this mock function.
|
||||
*/
|
||||
instances: Array<TReturn>
|
||||
},
|
||||
/**
|
||||
* Resets all information stored in the mockFn.mock.calls and
|
||||
* mockFn.mock.instances arrays. Often this is useful when you want to clean
|
||||
* up a mock's usage data between two assertions.
|
||||
*/
|
||||
mockClear(): void,
|
||||
/**
|
||||
* Resets all information stored in the mock. This is useful when you want to
|
||||
* completely restore a mock back to its initial state.
|
||||
*/
|
||||
mockReset(): void,
|
||||
/**
|
||||
* Removes the mock and restores the initial implementation. This is useful
|
||||
* when you want to mock functions in certain test cases and restore the
|
||||
* original implementation in others. Beware that mockFn.mockRestore only
|
||||
* works when mock was created with jest.spyOn. Thus you have to take care of
|
||||
* restoration yourself when manually assigning jest.fn().
|
||||
*/
|
||||
mockRestore(): void,
|
||||
/**
|
||||
* Accepts a function that should be used as the implementation of the mock.
|
||||
* The mock itself will still record all calls that go into and instances
|
||||
* that come from itself -- the only difference is that the implementation
|
||||
* will also be executed when the mock is called.
|
||||
*/
|
||||
mockImplementation(
|
||||
fn: (...args: TArguments) => TReturn
|
||||
): JestMockFn<TArguments, TReturn>,
|
||||
/**
|
||||
* Accepts a function that will be used as an implementation of the mock for
|
||||
* one call to the mocked function. Can be chained so that multiple function
|
||||
* calls produce different results.
|
||||
*/
|
||||
mockImplementationOnce(
|
||||
fn: (...args: TArguments) => TReturn
|
||||
): JestMockFn<TArguments, TReturn>,
|
||||
/**
|
||||
* Just a simple sugar function for returning `this`
|
||||
*/
|
||||
mockReturnThis(): void,
|
||||
/**
|
||||
* Deprecated: use jest.fn(() => value) instead
|
||||
*/
|
||||
mockReturnValue(value: TReturn): JestMockFn<TArguments, TReturn>,
|
||||
/**
|
||||
* Sugar for only returning a value once inside your mock
|
||||
*/
|
||||
mockReturnValueOnce(value: TReturn): JestMockFn<TArguments, TReturn>
|
||||
};
|
||||
|
||||
type JestAsymmetricEqualityType = {
|
||||
/**
|
||||
* A custom Jasmine equality tester
|
||||
*/
|
||||
asymmetricMatch(value: mixed): boolean
|
||||
};
|
||||
|
||||
type JestCallsType = {
|
||||
allArgs(): mixed,
|
||||
all(): mixed,
|
||||
any(): boolean,
|
||||
count(): number,
|
||||
first(): mixed,
|
||||
mostRecent(): mixed,
|
||||
reset(): void
|
||||
};
|
||||
|
||||
type JestClockType = {
|
||||
install(): void,
|
||||
mockDate(date: Date): void,
|
||||
tick(milliseconds?: number): void,
|
||||
uninstall(): void
|
||||
};
|
||||
|
||||
type JestMatcherResult = {
|
||||
message?: string | (() => string),
|
||||
pass: boolean
|
||||
};
|
||||
|
||||
type JestMatcher = (actual: any, expected: any) => JestMatcherResult;
|
||||
|
||||
type JestPromiseType = {
|
||||
/**
|
||||
* Use rejects to unwrap the reason of a rejected promise so any other
|
||||
* matcher can be chained. If the promise is fulfilled the assertion fails.
|
||||
*/
|
||||
rejects: JestExpectType,
|
||||
/**
|
||||
* Use resolves to unwrap the value of a fulfilled promise so any other
|
||||
* matcher can be chained. If the promise is rejected the assertion fails.
|
||||
*/
|
||||
resolves: JestExpectType
|
||||
};
|
||||
|
||||
/**
|
||||
* Plugin: jest-enzyme
|
||||
*/
|
||||
type EnzymeMatchersType = {
|
||||
toBeChecked(): void,
|
||||
toBeDisabled(): void,
|
||||
toBeEmpty(): void,
|
||||
toBePresent(): void,
|
||||
toContainReact(element: React$Element<any>): void,
|
||||
toHaveClassName(className: string): void,
|
||||
toHaveHTML(html: string): void,
|
||||
toHaveProp(propKey: string, propValue?: any): void,
|
||||
toHaveRef(refName: string): void,
|
||||
toHaveState(stateKey: string, stateValue?: any): void,
|
||||
toHaveStyle(styleKey: string, styleValue?: any): void,
|
||||
toHaveTagName(tagName: string): void,
|
||||
toHaveText(text: string): void,
|
||||
toIncludeText(text: string): void,
|
||||
toHaveValue(value: any): void,
|
||||
toMatchElement(element: React$Element<any>): void,
|
||||
toMatchSelector(selector: string): void
|
||||
};
|
||||
|
||||
type JestExpectType = {
|
||||
not: JestExpectType & EnzymeMatchersType,
|
||||
/**
|
||||
* If you have a mock function, you can use .lastCalledWith to test what
|
||||
* arguments it was last called with.
|
||||
*/
|
||||
lastCalledWith(...args: Array<any>): void,
|
||||
/**
|
||||
* toBe just checks that a value is what you expect. It uses === to check
|
||||
* strict equality.
|
||||
*/
|
||||
toBe(value: any): void,
|
||||
/**
|
||||
* Use .toHaveBeenCalled to ensure that a mock function got called.
|
||||
*/
|
||||
toBeCalled(): void,
|
||||
/**
|
||||
* Use .toBeCalledWith to ensure that a mock function was called with
|
||||
* specific arguments.
|
||||
*/
|
||||
toBeCalledWith(...args: Array<any>): void,
|
||||
/**
|
||||
* Using exact equality with floating point numbers is a bad idea. Rounding
|
||||
* means that intuitive things fail.
|
||||
*/
|
||||
toBeCloseTo(num: number, delta: any): void,
|
||||
/**
|
||||
* Use .toBeDefined to check that a variable is not undefined.
|
||||
*/
|
||||
toBeDefined(): void,
|
||||
/**
|
||||
* Use .toBeFalsy when you don't care what a value is, you just want to
|
||||
* ensure a value is false in a boolean context.
|
||||
*/
|
||||
toBeFalsy(): void,
|
||||
/**
|
||||
* To compare floating point numbers, you can use toBeGreaterThan.
|
||||
*/
|
||||
toBeGreaterThan(number: number): void,
|
||||
/**
|
||||
* To compare floating point numbers, you can use toBeGreaterThanOrEqual.
|
||||
*/
|
||||
toBeGreaterThanOrEqual(number: number): void,
|
||||
/**
|
||||
* To compare floating point numbers, you can use toBeLessThan.
|
||||
*/
|
||||
toBeLessThan(number: number): void,
|
||||
/**
|
||||
* To compare floating point numbers, you can use toBeLessThanOrEqual.
|
||||
*/
|
||||
toBeLessThanOrEqual(number: number): void,
|
||||
/**
|
||||
* Use .toBeInstanceOf(Class) to check that an object is an instance of a
|
||||
* class.
|
||||
*/
|
||||
toBeInstanceOf(cls: Class<*>): void,
|
||||
/**
|
||||
* .toBeNull() is the same as .toBe(null) but the error messages are a bit
|
||||
* nicer.
|
||||
*/
|
||||
toBeNull(): void,
|
||||
/**
|
||||
* Use .toBeTruthy when you don't care what a value is, you just want to
|
||||
* ensure a value is true in a boolean context.
|
||||
*/
|
||||
toBeTruthy(): void,
|
||||
/**
|
||||
* Use .toBeUndefined to check that a variable is undefined.
|
||||
*/
|
||||
toBeUndefined(): void,
|
||||
/**
|
||||
* Use .toContain when you want to check that an item is in a list. For
|
||||
* testing the items in the list, this uses ===, a strict equality check.
|
||||
*/
|
||||
toContain(item: any): void,
|
||||
/**
|
||||
* Use .toContainEqual when you want to check that an item is in a list. For
|
||||
* testing the items in the list, this matcher recursively checks the
|
||||
* equality of all fields, rather than checking for object identity.
|
||||
*/
|
||||
toContainEqual(item: any): void,
|
||||
/**
|
||||
* Use .toEqual when you want to check that two objects have the same value.
|
||||
* This matcher recursively checks the equality of all fields, rather than
|
||||
* checking for object identity.
|
||||
*/
|
||||
toEqual(value: any): void,
|
||||
/**
|
||||
* Use .toHaveBeenCalled to ensure that a mock function got called.
|
||||
*/
|
||||
toHaveBeenCalled(): void,
|
||||
/**
|
||||
* Use .toHaveBeenCalledTimes to ensure that a mock function got called exact
|
||||
* number of times.
|
||||
*/
|
||||
toHaveBeenCalledTimes(number: number): void,
|
||||
/**
|
||||
* Use .toHaveBeenCalledWith to ensure that a mock function was called with
|
||||
* specific arguments.
|
||||
*/
|
||||
toHaveBeenCalledWith(...args: Array<any>): void,
|
||||
/**
|
||||
* Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
|
||||
* with specific arguments.
|
||||
*/
|
||||
toHaveBeenLastCalledWith(...args: Array<any>): void,
|
||||
/**
|
||||
* Check that an object has a .length property and it is set to a certain
|
||||
* numeric value.
|
||||
*/
|
||||
toHaveLength(number: number): void,
|
||||
/**
|
||||
*
|
||||
*/
|
||||
toHaveProperty(propPath: string, value?: any): void,
|
||||
/**
|
||||
* Use .toMatch to check that a string matches a regular expression or string.
|
||||
*/
|
||||
toMatch(regexpOrString: RegExp | string): void,
|
||||
/**
|
||||
* Use .toMatchObject to check that a javascript object matches a subset of the properties of an object.
|
||||
*/
|
||||
toMatchObject(object: Object | Array<Object>): void,
|
||||
/**
|
||||
* This ensures that a React component matches the most recent snapshot.
|
||||
*/
|
||||
toMatchSnapshot(name?: string): void,
|
||||
/**
|
||||
* Use .toThrow to test that a function throws when it is called.
|
||||
* If you want to test that a specific error gets thrown, you can provide an
|
||||
* argument to toThrow. The argument can be a string for the error message,
|
||||
* a class for the error, or a regex that should match the error.
|
||||
*
|
||||
* Alias: .toThrowError
|
||||
*/
|
||||
toThrow(message?: string | Error | Class<Error> | RegExp): void,
|
||||
toThrowError(message?: string | Error | Class<Error> | RegExp): void,
|
||||
/**
|
||||
* Use .toThrowErrorMatchingSnapshot to test that a function throws a error
|
||||
* matching the most recent snapshot when it is called.
|
||||
*/
|
||||
toThrowErrorMatchingSnapshot(): void
|
||||
};
|
||||
|
||||
type JestObjectType = {
|
||||
/**
|
||||
* Disables automatic mocking in the module loader.
|
||||
*
|
||||
* After this method is called, all `require()`s will return the real
|
||||
* versions of each module (rather than a mocked version).
|
||||
*/
|
||||
disableAutomock(): JestObjectType,
|
||||
/**
|
||||
* An un-hoisted version of disableAutomock
|
||||
*/
|
||||
autoMockOff(): JestObjectType,
|
||||
/**
|
||||
* Enables automatic mocking in the module loader.
|
||||
*/
|
||||
enableAutomock(): JestObjectType,
|
||||
/**
|
||||
* An un-hoisted version of enableAutomock
|
||||
*/
|
||||
autoMockOn(): JestObjectType,
|
||||
/**
|
||||
* Clears the mock.calls and mock.instances properties of all mocks.
|
||||
* Equivalent to calling .mockClear() on every mocked function.
|
||||
*/
|
||||
clearAllMocks(): JestObjectType,
|
||||
/**
|
||||
* Resets the state of all mocks. Equivalent to calling .mockReset() on every
|
||||
* mocked function.
|
||||
*/
|
||||
resetAllMocks(): JestObjectType,
|
||||
/**
|
||||
* Removes any pending timers from the timer system.
|
||||
*/
|
||||
clearAllTimers(): void,
|
||||
/**
|
||||
* The same as `mock` but not moved to the top of the expectation by
|
||||
* babel-jest.
|
||||
*/
|
||||
doMock(moduleName: string, moduleFactory?: any): JestObjectType,
|
||||
/**
|
||||
* The same as `unmock` but not moved to the top of the expectation by
|
||||
* babel-jest.
|
||||
*/
|
||||
dontMock(moduleName: string): JestObjectType,
|
||||
/**
|
||||
* Returns a new, unused mock function. Optionally takes a mock
|
||||
* implementation.
|
||||
*/
|
||||
fn<TArguments: $ReadOnlyArray<*>, TReturn>(
|
||||
implementation?: (...args: TArguments) => TReturn
|
||||
): JestMockFn<TArguments, TReturn>,
|
||||
/**
|
||||
* Determines if the given function is a mocked function.
|
||||
*/
|
||||
isMockFunction(fn: Function): boolean,
|
||||
/**
|
||||
* Given the name of a module, use the automatic mocking system to generate a
|
||||
* mocked version of the module for you.
|
||||
*/
|
||||
genMockFromModule(moduleName: string): any,
|
||||
/**
|
||||
* Mocks a module with an auto-mocked version when it is being required.
|
||||
*
|
||||
* The second argument can be used to specify an explicit module factory that
|
||||
* is being run instead of using Jest's automocking feature.
|
||||
*
|
||||
* The third argument can be used to create virtual mocks -- mocks of modules
|
||||
* that don't exist anywhere in the system.
|
||||
*/
|
||||
mock(
|
||||
moduleName: string,
|
||||
moduleFactory?: any,
|
||||
options?: Object
|
||||
): JestObjectType,
|
||||
/**
|
||||
* Returns the actual module instead of a mock, bypassing all checks on
|
||||
* whether the module should receive a mock implementation or not.
|
||||
*/
|
||||
requireActual(moduleName: string): any,
|
||||
/**
|
||||
* Returns a mock module instead of the actual module, bypassing all checks
|
||||
* on whether the module should be required normally or not.
|
||||
*/
|
||||
requireMock(moduleName: string): any,
|
||||
/**
|
||||
* Resets the module registry - the cache of all required modules. This is
|
||||
* useful to isolate modules where local state might conflict between tests.
|
||||
*/
|
||||
resetModules(): JestObjectType,
|
||||
/**
|
||||
* Exhausts the micro-task queue (usually interfaced in node via
|
||||
* process.nextTick).
|
||||
*/
|
||||
runAllTicks(): void,
|
||||
/**
|
||||
* Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(),
|
||||
* setInterval(), and setImmediate()).
|
||||
*/
|
||||
runAllTimers(): void,
|
||||
/**
|
||||
* Exhausts all tasks queued by setImmediate().
|
||||
*/
|
||||
runAllImmediates(): void,
|
||||
/**
|
||||
* Executes only the macro task queue (i.e. all tasks queued by setTimeout()
|
||||
* or setInterval() and setImmediate()).
|
||||
*/
|
||||
runTimersToTime(msToRun: number): void,
|
||||
/**
|
||||
* Executes only the macro-tasks that are currently pending (i.e., only the
|
||||
* tasks that have been queued by setTimeout() or setInterval() up to this
|
||||
* point)
|
||||
*/
|
||||
runOnlyPendingTimers(): void,
|
||||
/**
|
||||
* Explicitly supplies the mock object that the module system should return
|
||||
* for the specified module. Note: It is recommended to use jest.mock()
|
||||
* instead.
|
||||
*/
|
||||
setMock(moduleName: string, moduleExports: any): JestObjectType,
|
||||
/**
|
||||
* Indicates that the module system should never return a mocked version of
|
||||
* the specified module from require() (e.g. that it should always return the
|
||||
* real module).
|
||||
*/
|
||||
unmock(moduleName: string): JestObjectType,
|
||||
/**
|
||||
* Instructs Jest to use fake versions of the standard timer functions
|
||||
* (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
|
||||
* setImmediate and clearImmediate).
|
||||
*/
|
||||
useFakeTimers(): JestObjectType,
|
||||
/**
|
||||
* Instructs Jest to use the real versions of the standard timer functions.
|
||||
*/
|
||||
useRealTimers(): JestObjectType,
|
||||
/**
|
||||
* Creates a mock function similar to jest.fn but also tracks calls to
|
||||
* object[methodName].
|
||||
*/
|
||||
spyOn(object: Object, methodName: string): JestMockFn<any, any>,
|
||||
/**
|
||||
* Set the default timeout interval for tests and before/after hooks in milliseconds.
|
||||
* Note: The default timeout interval is 5 seconds if this method is not called.
|
||||
*/
|
||||
setTimeout(timeout: number): JestObjectType
|
||||
};
|
||||
|
||||
type JestSpyType = {
|
||||
calls: JestCallsType
|
||||
};
|
||||
|
||||
/** Runs this function after every test inside this context */
|
||||
declare function afterEach(
|
||||
fn: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void;
|
||||
/** Runs this function before every test inside this context */
|
||||
declare function beforeEach(
|
||||
fn: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void;
|
||||
/** Runs this function after all tests have finished inside this context */
|
||||
declare function afterAll(
|
||||
fn: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void;
|
||||
/** Runs this function before any tests have started inside this context */
|
||||
declare function beforeAll(
|
||||
fn: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void;
|
||||
|
||||
/** A context for grouping tests together */
|
||||
declare var describe: {
|
||||
/**
|
||||
* Creates a block that groups together several related tests in one "test suite"
|
||||
*/
|
||||
(name: string, fn: () => void): void,
|
||||
|
||||
/**
|
||||
* Only run this describe block
|
||||
*/
|
||||
only(name: string, fn: () => void): void,
|
||||
|
||||
/**
|
||||
* Skip running this describe block
|
||||
*/
|
||||
skip(name: string, fn: () => void): void
|
||||
};
|
||||
|
||||
/** An individual test unit */
|
||||
declare var it: {
|
||||
/**
|
||||
* An individual test unit
|
||||
*
|
||||
* @param {string} Name of Test
|
||||
* @param {Function} Test
|
||||
* @param {number} Timeout for the test, in milliseconds.
|
||||
*/
|
||||
(
|
||||
name: string,
|
||||
fn?: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void,
|
||||
/**
|
||||
* Only run this test
|
||||
*
|
||||
* @param {string} Name of Test
|
||||
* @param {Function} Test
|
||||
* @param {number} Timeout for the test, in milliseconds.
|
||||
*/
|
||||
only(
|
||||
name: string,
|
||||
fn?: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void,
|
||||
/**
|
||||
* Skip running this test
|
||||
*
|
||||
* @param {string} Name of Test
|
||||
* @param {Function} Test
|
||||
* @param {number} Timeout for the test, in milliseconds.
|
||||
*/
|
||||
skip(
|
||||
name: string,
|
||||
fn?: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void,
|
||||
/**
|
||||
* Run the test concurrently
|
||||
*
|
||||
* @param {string} Name of Test
|
||||
* @param {Function} Test
|
||||
* @param {number} Timeout for the test, in milliseconds.
|
||||
*/
|
||||
concurrent(
|
||||
name: string,
|
||||
fn?: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void
|
||||
};
|
||||
declare function fit(
|
||||
name: string,
|
||||
fn: (done: () => void) => ?Promise<mixed>,
|
||||
timeout?: number
|
||||
): void;
|
||||
/** An individual test unit */
|
||||
declare var test: typeof it;
|
||||
/** A disabled group of tests */
|
||||
declare var xdescribe: typeof describe;
|
||||
/** A focused group of tests */
|
||||
declare var fdescribe: typeof describe;
|
||||
/** A disabled individual test */
|
||||
declare var xit: typeof it;
|
||||
/** A disabled individual test */
|
||||
declare var xtest: typeof it;
|
||||
|
||||
/** The expect function is used every time you want to test a value */
|
||||
declare var expect: {
|
||||
/** The object that you want to make assertions against */
|
||||
(value: any): JestExpectType & JestPromiseType & EnzymeMatchersType,
|
||||
/** Add additional Jasmine matchers to Jest's roster */
|
||||
extend(matchers: { [name: string]: JestMatcher }): void,
|
||||
/** Add a module that formats application-specific data structures. */
|
||||
addSnapshotSerializer(serializer: (input: Object) => string): void,
|
||||
assertions(expectedAssertions: number): void,
|
||||
hasAssertions(): void,
|
||||
any(value: mixed): JestAsymmetricEqualityType,
|
||||
anything(): void,
|
||||
arrayContaining(value: Array<mixed>): void,
|
||||
objectContaining(value: Object): void,
|
||||
/** Matches any received string that contains the exact expected string. */
|
||||
stringContaining(value: string): void,
|
||||
stringMatching(value: string | RegExp): void
|
||||
};
|
||||
|
||||
// TODO handle return type
|
||||
// http://jasmine.github.io/2.4/introduction.html#section-Spies
|
||||
declare function spyOn(value: mixed, method: string): Object;
|
||||
|
||||
/** Holds all functions related to manipulating test runner */
|
||||
declare var jest: JestObjectType;
|
||||
|
||||
/**
|
||||
* The global Jasmine object, this is generally not exposed as the public API,
|
||||
* using features inside here could break in later versions of Jest.
|
||||
*/
|
||||
declare var jasmine: {
|
||||
DEFAULT_TIMEOUT_INTERVAL: number,
|
||||
any(value: mixed): JestAsymmetricEqualityType,
|
||||
anything(): void,
|
||||
arrayContaining(value: Array<mixed>): void,
|
||||
clock(): JestClockType,
|
||||
createSpy(name: string): JestSpyType,
|
||||
createSpyObj(
|
||||
baseName: string,
|
||||
methodNames: Array<string>
|
||||
): { [methodName: string]: JestSpyType },
|
||||
objectContaining(value: Object): void,
|
||||
stringMatching(value: string): void
|
||||
};
|
||||
39
examples/NavigationPlayground/flow-typed/npm/jest_vx.x.x.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// flow-typed signature: 3ba80f288ae054d394dca2d025d14dd9
|
||||
// flow-typed version: <<STUB>>/jest_v^21.0.1/flow_v0.53.0
|
||||
|
||||
/**
|
||||
* This is an autogenerated libdef stub for:
|
||||
*
|
||||
* 'jest'
|
||||
*
|
||||
* Fill this stub out by replacing all the `any` types.
|
||||
*
|
||||
* Once filled out, we encourage you to share your work with the
|
||||
* community by sending a pull request to:
|
||||
* https://github.com/flowtype/flow-typed
|
||||
*/
|
||||
|
||||
declare module 'jest' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* We include stubs for each file inside this npm package in case you need to
|
||||
* require those files directly. Feel free to delete any files that aren't
|
||||
* needed.
|
||||
*/
|
||||
declare module 'jest/bin/jest' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'jest/build/jest' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
// Filename aliases
|
||||
declare module 'jest/bin/jest.js' {
|
||||
declare module.exports: $Exports<'jest/bin/jest'>;
|
||||
}
|
||||
declare module 'jest/build/jest.js' {
|
||||
declare module.exports: $Exports<'jest/build/jest'>;
|
||||
}
|
||||
33
examples/NavigationPlayground/flow-typed/npm/react-addons-test-utils_vx.x.x.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// flow-typed signature: fe3ce80849031f84c8c106122bef896a
|
||||
// flow-typed version: <<STUB>>/react-addons-test-utils_v16.0.0-alpha.3/flow_v0.53.0
|
||||
|
||||
/**
|
||||
* This is an autogenerated libdef stub for:
|
||||
*
|
||||
* 'react-addons-test-utils'
|
||||
*
|
||||
* Fill this stub out by replacing all the `any` types.
|
||||
*
|
||||
* Once filled out, we encourage you to share your work with the
|
||||
* community by sending a pull request to:
|
||||
* https://github.com/flowtype/flow-typed
|
||||
*/
|
||||
|
||||
declare module 'react-addons-test-utils' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* We include stubs for each file inside this npm package in case you need to
|
||||
* require those files directly. Feel free to delete any files that aren't
|
||||
* needed.
|
||||
*/
|
||||
|
||||
|
||||
// Filename aliases
|
||||
declare module 'react-addons-test-utils/index' {
|
||||
declare module.exports: $Exports<'react-addons-test-utils'>;
|
||||
}
|
||||
declare module 'react-addons-test-utils/index.js' {
|
||||
declare module.exports: $Exports<'react-addons-test-utils'>;
|
||||
}
|
||||
123
examples/NavigationPlayground/flow-typed/npm/react-native-scripts_vx.x.x.js
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
// flow-typed signature: 42d8cd2e84e894c09d28f891fef9f01d
|
||||
// flow-typed version: <<STUB>>/react-native-scripts_v^1.5.0/flow_v0.61.0
|
||||
|
||||
/**
|
||||
* This is an autogenerated libdef stub for:
|
||||
*
|
||||
* 'react-native-scripts'
|
||||
*
|
||||
* Fill this stub out by replacing all the `any` types.
|
||||
*
|
||||
* Once filled out, we encourage you to share your work with the
|
||||
* community by sending a pull request to:
|
||||
* https://github.com/flowtype/flow-typed
|
||||
*/
|
||||
|
||||
declare module 'react-native-scripts' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* We include stubs for each file inside this npm package in case you need to
|
||||
* require those files directly. Feel free to delete any files that aren't
|
||||
* needed.
|
||||
*/
|
||||
declare module 'react-native-scripts/build/bin/crna-entry' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/bin/react-native-scripts' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/scripts/android' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/scripts/eject' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/scripts/init' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/scripts/ios' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/scripts/start' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/util/clearConsole' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/util/expo' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/util/install' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/util/log' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/build/util/packager' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/template/App' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-native-scripts/template/App.test' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
// Filename aliases
|
||||
declare module 'react-native-scripts/build/bin/crna-entry.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/bin/crna-entry'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/bin/react-native-scripts.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/bin/react-native-scripts'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/scripts/android.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/scripts/android'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/scripts/eject.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/scripts/eject'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/scripts/init.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/scripts/init'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/scripts/ios.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/scripts/ios'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/scripts/start.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/scripts/start'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/util/clearConsole.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/util/clearConsole'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/util/expo.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/util/expo'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/util/install.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/util/install'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/util/log.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/util/log'>;
|
||||
}
|
||||
declare module 'react-native-scripts/build/util/packager.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/build/util/packager'>;
|
||||
}
|
||||
declare module 'react-native-scripts/template/App.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/template/App'>;
|
||||
}
|
||||
declare module 'react-native-scripts/template/App.test.js' {
|
||||
declare module.exports: $Exports<'react-native-scripts/template/App.test'>;
|
||||
}
|
||||
6283
examples/NavigationPlayground/flow-typed/npm/react-native_vx.x.x.js
vendored
Normal file
62
examples/NavigationPlayground/flow-typed/npm/react-test-renderer_v16.x.x.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
// flow-typed signature: 2d946f2ec4aba5210b19d053c411a59d
|
||||
// flow-typed version: 95b3e05165/react-test-renderer_v16.x.x/flow_>=v0.47.x
|
||||
|
||||
// Type definitions for react-test-renderer 16.x.x
|
||||
// Ported from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-test-renderer
|
||||
|
||||
type ReactTestRendererJSON = {
|
||||
type: string,
|
||||
props: { [propName: string]: any },
|
||||
children: null | ReactTestRendererJSON[]
|
||||
};
|
||||
|
||||
type ReactTestRendererTree = ReactTestRendererJSON & {
|
||||
nodeType: "component" | "host",
|
||||
instance: any,
|
||||
rendered: null | ReactTestRendererTree
|
||||
};
|
||||
|
||||
type ReactTestInstance = {
|
||||
instance: any,
|
||||
type: string,
|
||||
props: { [propName: string]: any },
|
||||
parent: null | ReactTestInstance,
|
||||
children: Array<ReactTestInstance | string>,
|
||||
|
||||
find(predicate: (node: ReactTestInstance) => boolean): ReactTestInstance,
|
||||
findByType(type: React$ElementType): ReactTestInstance,
|
||||
findByProps(props: { [propName: string]: any }): ReactTestInstance,
|
||||
|
||||
findAll(
|
||||
predicate: (node: ReactTestInstance) => boolean,
|
||||
options?: { deep: boolean }
|
||||
): ReactTestInstance[],
|
||||
findAllByType(
|
||||
type: React$ElementType,
|
||||
options?: { deep: boolean }
|
||||
): ReactTestInstance[],
|
||||
findAllByProps(
|
||||
props: { [propName: string]: any },
|
||||
options?: { deep: boolean }
|
||||
): ReactTestInstance[]
|
||||
};
|
||||
|
||||
type ReactTestRenderer = {
|
||||
toJSON(): null | ReactTestRendererJSON,
|
||||
toTree(): null | ReactTestRendererTree,
|
||||
unmount(nextElement?: React$Element<any>): void,
|
||||
update(nextElement: React$Element<any>): void,
|
||||
getInstance(): null | ReactTestInstance,
|
||||
root: ReactTestInstance
|
||||
};
|
||||
|
||||
type TestRendererOptions = {
|
||||
createNodeMock(element: React$Element<any>): any
|
||||
};
|
||||
|
||||
declare module "react-test-renderer" {
|
||||
declare function create(
|
||||
nextElement: React$Element<any>,
|
||||
options?: TestRendererOptions
|
||||
): ReactTestRenderer;
|
||||
}
|
||||
66
examples/NavigationPlayground/flow-typed/npm/react-test-renderer_vx.x.x.js
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
// flow-typed signature: bc77d9125cee5869fd1f9ffe55231e21
|
||||
// flow-typed version: <<STUB>>/react-test-renderer_v16.0.0-alpha.12/flow_v0.53.0
|
||||
|
||||
/**
|
||||
* This is an autogenerated libdef stub for:
|
||||
*
|
||||
* 'react-test-renderer'
|
||||
*
|
||||
* Fill this stub out by replacing all the `any` types.
|
||||
*
|
||||
* Once filled out, we encourage you to share your work with the
|
||||
* community by sending a pull request to:
|
||||
* https://github.com/flowtype/flow-typed
|
||||
*/
|
||||
|
||||
declare module 'react-test-renderer' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* We include stubs for each file inside this npm package in case you need to
|
||||
* require those files directly. Feel free to delete any files that aren't
|
||||
* needed.
|
||||
*/
|
||||
declare module 'react-test-renderer/cjs/react-test-renderer-shallow.development' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-test-renderer/cjs/react-test-renderer-stack.development' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-test-renderer/cjs/react-test-renderer.development' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-test-renderer/shallow' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
declare module 'react-test-renderer/stack' {
|
||||
declare module.exports: any;
|
||||
}
|
||||
|
||||
// Filename aliases
|
||||
declare module 'react-test-renderer/cjs/react-test-renderer-shallow.development.js' {
|
||||
declare module.exports: $Exports<'react-test-renderer/cjs/react-test-renderer-shallow.development'>;
|
||||
}
|
||||
declare module 'react-test-renderer/cjs/react-test-renderer-stack.development.js' {
|
||||
declare module.exports: $Exports<'react-test-renderer/cjs/react-test-renderer-stack.development'>;
|
||||
}
|
||||
declare module 'react-test-renderer/cjs/react-test-renderer.development.js' {
|
||||
declare module.exports: $Exports<'react-test-renderer/cjs/react-test-renderer.development'>;
|
||||
}
|
||||
declare module 'react-test-renderer/index' {
|
||||
declare module.exports: $Exports<'react-test-renderer'>;
|
||||
}
|
||||
declare module 'react-test-renderer/index.js' {
|
||||
declare module.exports: $Exports<'react-test-renderer'>;
|
||||
}
|
||||
declare module 'react-test-renderer/shallow.js' {
|
||||
declare module.exports: $Exports<'react-test-renderer/shallow'>;
|
||||
}
|
||||
declare module 'react-test-renderer/stack.js' {
|
||||
declare module.exports: $Exports<'react-test-renderer/stack'>;
|
||||
}
|
||||
376
examples/NavigationPlayground/js/App.js
Normal file
@@ -0,0 +1,376 @@
|
||||
/* @flow */
|
||||
|
||||
import React from 'react';
|
||||
import { Asset, Constants, ScreenOrientation } from 'expo';
|
||||
|
||||
ScreenOrientation.allow(ScreenOrientation.Orientation.ALL);
|
||||
|
||||
import {
|
||||
Animated,
|
||||
Image,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
Text,
|
||||
StatusBar,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { SafeAreaView, StackNavigator } from 'react-navigation';
|
||||
|
||||
import CustomTabs from './CustomTabs';
|
||||
import CustomTransitioner from './CustomTransitioner';
|
||||
import Drawer from './Drawer';
|
||||
import MultipleDrawer from './MultipleDrawer';
|
||||
import TabsInDrawer from './TabsInDrawer';
|
||||
import ModalStack from './ModalStack';
|
||||
import StacksInTabs from './StacksInTabs';
|
||||
import StacksOverTabs from './StacksOverTabs';
|
||||
import StacksWithKeys from './StacksWithKeys';
|
||||
import SimpleStack from './SimpleStack';
|
||||
import StackWithHeaderPreset from './StackWithHeaderPreset';
|
||||
import StackWithTranslucentHeader from './StackWithTranslucentHeader';
|
||||
import SimpleTabs from './SimpleTabs';
|
||||
import TabAnimations from './TabAnimations';
|
||||
import TabsWithNavigationFocus from './TabsWithNavigationFocus';
|
||||
|
||||
const ExampleInfo = {
|
||||
SimpleStack: {
|
||||
name: 'Stack Example',
|
||||
description: 'A card stack',
|
||||
},
|
||||
SimpleTabs: {
|
||||
name: 'Tabs Example',
|
||||
description: 'Tabs following platform conventions',
|
||||
},
|
||||
Drawer: {
|
||||
name: 'Drawer Example',
|
||||
description: 'Android-style drawer navigation',
|
||||
},
|
||||
StackWithHeaderPreset: {
|
||||
name: 'UIKit-style Header Transitions',
|
||||
description: 'Masked back button and sliding header items. iOS only.',
|
||||
},
|
||||
StackWithHeaderPreset: {
|
||||
name: 'UIKit-style Header Transitions',
|
||||
description: 'Masked back button and sliding header items. iOS only.',
|
||||
},
|
||||
StackWithTranslucentHeader: {
|
||||
name: 'Translucent Header',
|
||||
description: 'Render arbitrary translucent content in header background.',
|
||||
},
|
||||
// MultipleDrawer: {
|
||||
// name: 'Multiple Drawer Example',
|
||||
// description: 'Add any drawer you need',
|
||||
// },
|
||||
TabsInDrawer: {
|
||||
name: 'Drawer + Tabs Example',
|
||||
description: 'A drawer combined with tabs',
|
||||
},
|
||||
CustomTabs: {
|
||||
name: 'Custom Tabs',
|
||||
description: 'Custom tabs with tab router',
|
||||
},
|
||||
CustomTransitioner: {
|
||||
name: 'Custom Transitioner',
|
||||
description: 'Custom transitioner with stack router',
|
||||
},
|
||||
ModalStack: {
|
||||
name:
|
||||
Platform.OS === 'ios'
|
||||
? 'Modal Stack Example'
|
||||
: 'Stack with Dynamic Header',
|
||||
description:
|
||||
Platform.OS === 'ios'
|
||||
? 'Stack navigation with modals'
|
||||
: 'Dynamically showing and hiding the header',
|
||||
},
|
||||
StacksInTabs: {
|
||||
name: 'Stacks in Tabs',
|
||||
description: 'Nested stack navigation in tabs',
|
||||
},
|
||||
StacksOverTabs: {
|
||||
name: 'Stacks over Tabs',
|
||||
description: 'Nested stack navigation that pushes on top of tabs',
|
||||
},
|
||||
StacksWithKeys: {
|
||||
name: 'Link in Stack with keys',
|
||||
description: 'Use keys to link between screens',
|
||||
},
|
||||
LinkStack: {
|
||||
name: 'Link in Stack',
|
||||
description: 'Deep linking into a route in stack',
|
||||
},
|
||||
LinkTabs: {
|
||||
name: 'Link to Settings Tab',
|
||||
description: 'Deep linking into a route in tab',
|
||||
},
|
||||
TabAnimations: {
|
||||
name: 'Animated Tabs Example',
|
||||
description: 'Tab transitions have custom animations',
|
||||
},
|
||||
TabsWithNavigationFocus: {
|
||||
name: 'withNavigationFocus',
|
||||
description: 'Receive the focus prop to know when a screen is focused',
|
||||
},
|
||||
};
|
||||
|
||||
const ExampleRoutes = {
|
||||
SimpleStack: SimpleStack,
|
||||
SimpleTabs: SimpleTabs,
|
||||
Drawer: Drawer,
|
||||
// MultipleDrawer: {
|
||||
// screen: MultipleDrawer,
|
||||
// },
|
||||
StackWithHeaderPreset: StackWithHeaderPreset,
|
||||
StackWithTranslucentHeader: StackWithTranslucentHeader,
|
||||
TabsInDrawer: TabsInDrawer,
|
||||
CustomTabs: CustomTabs,
|
||||
CustomTransitioner: CustomTransitioner,
|
||||
ModalStack: ModalStack,
|
||||
StacksWithKeys: StacksWithKeys,
|
||||
StacksInTabs: StacksInTabs,
|
||||
StacksOverTabs: StacksOverTabs,
|
||||
LinkStack: {
|
||||
screen: SimpleStack,
|
||||
path: 'people/Jordan',
|
||||
},
|
||||
LinkTabs: {
|
||||
screen: SimpleTabs,
|
||||
path: 'settings',
|
||||
},
|
||||
TabAnimations,
|
||||
TabsWithNavigationFocus,
|
||||
};
|
||||
|
||||
type State = {
|
||||
scrollY: Animated.Value,
|
||||
};
|
||||
class MainScreen extends React.Component<any, State> {
|
||||
state = {
|
||||
scrollY: new Animated.Value(0),
|
||||
};
|
||||
|
||||
componentWillMount() {
|
||||
Asset.fromModule(
|
||||
require('react-navigation/src/views/assets/back-icon-mask.png')
|
||||
).downloadAsync();
|
||||
Asset.fromModule(
|
||||
require('react-navigation/src/views/assets/back-icon.png')
|
||||
).downloadAsync();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
const scale = this.state.scrollY.interpolate({
|
||||
inputRange: [-450, 0, 100],
|
||||
outputRange: [2, 1, 0.8],
|
||||
extrapolate: 'clamp',
|
||||
});
|
||||
|
||||
const translateY = this.state.scrollY.interpolate({
|
||||
inputRange: [-450, 0, 100],
|
||||
outputRange: [-150, 0, 40],
|
||||
});
|
||||
|
||||
const opacity = this.state.scrollY.interpolate({
|
||||
inputRange: [0, 50],
|
||||
outputRange: [1, 0],
|
||||
extrapolate: 'clamp',
|
||||
});
|
||||
|
||||
const underlayOpacity = this.state.scrollY.interpolate({
|
||||
inputRange: [0, 50],
|
||||
outputRange: [0, 1],
|
||||
extrapolate: 'clamp',
|
||||
});
|
||||
|
||||
const backgroundScale = this.state.scrollY.interpolate({
|
||||
inputRange: [-450, 0],
|
||||
outputRange: [3, 1],
|
||||
extrapolate: 'clamp',
|
||||
});
|
||||
|
||||
const backgroundTranslateY = this.state.scrollY.interpolate({
|
||||
inputRange: [-450, 0],
|
||||
outputRange: [0, 0],
|
||||
});
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Animated.ScrollView
|
||||
style={{ flex: 1 }}
|
||||
scrollEventThrottle={1}
|
||||
onScroll={Animated.event(
|
||||
[
|
||||
{
|
||||
nativeEvent: { contentOffset: { y: this.state.scrollY } },
|
||||
},
|
||||
],
|
||||
{ useNativeDriver: true }
|
||||
)}
|
||||
>
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.backgroundUnderlay,
|
||||
{
|
||||
transform: [
|
||||
{ scale: backgroundScale },
|
||||
{ translateY: backgroundTranslateY },
|
||||
],
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Animated.View
|
||||
style={{ opacity, transform: [{ scale }, { translateY }] }}
|
||||
>
|
||||
<SafeAreaView
|
||||
style={styles.bannerContainer}
|
||||
forceInset={{ top: 'always', bottom: 'never' }}
|
||||
>
|
||||
<View style={styles.banner}>
|
||||
<Image
|
||||
source={require('./assets/NavLogo.png')}
|
||||
style={styles.bannerImage}
|
||||
/>
|
||||
<Text style={styles.bannerTitle}>
|
||||
React Navigation Examples
|
||||
</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</Animated.View>
|
||||
|
||||
<SafeAreaView forceInset={{ bottom: 'always', horizontal: 'never' }}>
|
||||
<View style={{ backgroundColor: '#fff' }}>
|
||||
{Object.keys(ExampleRoutes).map((routeName: string) => (
|
||||
<TouchableOpacity
|
||||
key={routeName}
|
||||
onPress={() => {
|
||||
let route = ExampleRoutes[routeName];
|
||||
if (route.screen || route.path || route.params) {
|
||||
const { path, params, screen } = route;
|
||||
const { router } = screen;
|
||||
const action =
|
||||
path && router.getActionForPathAndParams(path, params);
|
||||
navigation.navigate(routeName, {}, action);
|
||||
} else {
|
||||
navigation.navigate(routeName);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SafeAreaView
|
||||
style={styles.itemContainer}
|
||||
forceInset={{ veritcal: 'never', bottom: 'never' }}
|
||||
>
|
||||
<View style={styles.item}>
|
||||
<Text style={styles.title}>
|
||||
{ExampleInfo[routeName].name}
|
||||
</Text>
|
||||
<Text style={styles.description}>
|
||||
{ExampleInfo[routeName].description}
|
||||
</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</Animated.ScrollView>
|
||||
<StatusBar barStyle="light-content" />
|
||||
<Animated.View
|
||||
style={[styles.statusBarUnderlay, { opacity: underlayOpacity }]}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const AppNavigator = StackNavigator(
|
||||
{
|
||||
...ExampleRoutes,
|
||||
Index: {
|
||||
screen: MainScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
initialRouteName: 'Index',
|
||||
headerMode: 'none',
|
||||
|
||||
/*
|
||||
* Use modal on iOS because the card mode comes from the right,
|
||||
* which conflicts with the drawer example gesture
|
||||
*/
|
||||
mode: Platform.OS === 'ios' ? 'modal' : 'card',
|
||||
}
|
||||
);
|
||||
|
||||
// export default () => <AppNavigator />;
|
||||
export default SimpleStack;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
item: {
|
||||
paddingHorizontal: 16,
|
||||
paddingVertical: 12,
|
||||
},
|
||||
itemContainer: {
|
||||
backgroundColor: '#fff',
|
||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||
borderBottomColor: '#ddd',
|
||||
},
|
||||
image: {
|
||||
width: 120,
|
||||
height: 120,
|
||||
alignSelf: 'center',
|
||||
marginBottom: 20,
|
||||
resizeMode: 'contain',
|
||||
},
|
||||
statusBarUnderlay: {
|
||||
backgroundColor: '#673ab7',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: Constants.statusBarHeight,
|
||||
},
|
||||
title: {
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
color: '#444',
|
||||
},
|
||||
description: {
|
||||
fontSize: 13,
|
||||
color: '#999',
|
||||
},
|
||||
backgroundUnderlay: {
|
||||
backgroundColor: '#673ab7',
|
||||
position: 'absolute',
|
||||
top: -100,
|
||||
height: 300,
|
||||
left: 0,
|
||||
right: 0,
|
||||
},
|
||||
bannerContainer: {
|
||||
// backgroundColor: '#673ab7',
|
||||
alignItems: 'center',
|
||||
},
|
||||
banner: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
padding: 16,
|
||||
},
|
||||
bannerImage: {
|
||||
width: 36,
|
||||
height: 36,
|
||||
resizeMode: 'contain',
|
||||
tintColor: '#fff',
|
||||
margin: 8,
|
||||
},
|
||||
bannerTitle: {
|
||||
fontSize: 18,
|
||||
fontWeight: '200',
|
||||
color: '#fff',
|
||||
marginVertical: 8,
|
||||
marginRight: 5,
|
||||
},
|
||||
});
|
||||
45
examples/NavigationPlayground/js/Banner.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/* @flow */
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { Image, Platform, StyleSheet, Text, View } from 'react-native';
|
||||
import { SafeAreaView } from 'react-navigation';
|
||||
|
||||
const Banner = () => (
|
||||
<SafeAreaView
|
||||
style={styles.bannerContainer}
|
||||
forceInset={{ top: 'always' }}
|
||||
>
|
||||
<View style={styles.banner}>
|
||||
<Image source={require('./assets/NavLogo.png')} style={styles.image} />
|
||||
<Text style={styles.title}>React Navigation Examples</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
||||
export default Banner;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
bannerContainer: {
|
||||
backgroundColor: '#673ab7',
|
||||
paddingTop: 20,
|
||||
},
|
||||
banner: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
padding: 16,
|
||||
},
|
||||
image: {
|
||||
width: 36,
|
||||
height: 36,
|
||||
resizeMode: 'contain',
|
||||
tintColor: '#fff',
|
||||
margin: 8,
|
||||
},
|
||||
title: {
|
||||
fontSize: 18,
|
||||
fontWeight: '200',
|
||||
color: '#fff',
|
||||
margin: 8,
|
||||
},
|
||||
});
|
||||
121
examples/NavigationPlayground/js/CustomTabs.js
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
StatusBar,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import {
|
||||
createNavigator,
|
||||
createNavigationContainer,
|
||||
SafeAreaView,
|
||||
TabRouter,
|
||||
} from 'react-navigation';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => {
|
||||
navigation.goBack(null);
|
||||
}}
|
||||
title="Go back"
|
||||
/>
|
||||
</SafeAreaView>
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MyNotificationsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MySettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Settings Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const CustomTabBar = ({ navigation }) => {
|
||||
const { routes } = navigation.state;
|
||||
return (
|
||||
<SafeAreaView style={styles.tabContainer}>
|
||||
{routes.map(route => (
|
||||
<TouchableOpacity
|
||||
onPress={() => navigation.navigate(route.routeName)}
|
||||
style={styles.tab}
|
||||
key={route.routeName}
|
||||
>
|
||||
<Text>{route.routeName}</Text>
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
|
||||
const CustomTabView = ({ descriptors, navigation }) => {
|
||||
const { routes, index } = navigation.state;
|
||||
const descriptor = descriptors[routes[index].key];
|
||||
const ActiveScreen = descriptor.getComponent();
|
||||
return (
|
||||
<SafeAreaView forceInset={{ top: 'always' }}>
|
||||
<CustomTabBar navigation={navigation} />
|
||||
<ActiveScreen navigation={descriptor.navigation} />
|
||||
</SafeAreaView>
|
||||
);
|
||||
};
|
||||
|
||||
const CustomTabRouter = TabRouter(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
path: '',
|
||||
},
|
||||
Notifications: {
|
||||
screen: MyNotificationsScreen,
|
||||
path: 'notifications',
|
||||
},
|
||||
Settings: {
|
||||
screen: MySettingsScreen,
|
||||
path: 'settings',
|
||||
},
|
||||
},
|
||||
{
|
||||
// Change this to start on a different tab
|
||||
initialRouteName: 'Home',
|
||||
}
|
||||
);
|
||||
|
||||
const CustomTabs = createNavigationContainer(
|
||||
createNavigator(CustomTabView, CustomTabRouter, {})
|
||||
);
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tabContainer: {
|
||||
flexDirection: 'row',
|
||||
height: 48,
|
||||
},
|
||||
tab: {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
margin: 4,
|
||||
borderWidth: 1,
|
||||
borderColor: '#ddd',
|
||||
borderRadius: 4,
|
||||
},
|
||||
});
|
||||
|
||||
export default CustomTabs;
|
||||
117
examples/NavigationPlayground/js/CustomTransitioner.js
Normal file
@@ -0,0 +1,117 @@
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import {
|
||||
Animated,
|
||||
Button,
|
||||
Easing,
|
||||
Image,
|
||||
Platform,
|
||||
StatusBar,
|
||||
StyleSheet,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import {
|
||||
Transitioner,
|
||||
SafeAreaView,
|
||||
StackRouter,
|
||||
createNavigationContainer,
|
||||
createNavigator,
|
||||
} from 'react-navigation';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<SafeAreaView forceInset={{ top: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
{navigation.state &&
|
||||
navigation.state.routeName !== 'Settings' && (
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Settings')}
|
||||
title="Go to a settings screen"
|
||||
/>
|
||||
)}
|
||||
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<StatusBar barStyle="default" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MySettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Settings Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
class CustomNavigationView extends Component {
|
||||
render() {
|
||||
const { navigation, router, descriptors } = this.props;
|
||||
|
||||
return (
|
||||
<Transitioner
|
||||
configureTransition={this._configureTransition}
|
||||
descriptors={descriptors}
|
||||
navigation={navigation}
|
||||
render={this._render}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
_configureTransition(transitionProps, prevTransitionProps) {
|
||||
return {
|
||||
duration: 200,
|
||||
easing: Easing.out(Easing.ease),
|
||||
};
|
||||
}
|
||||
|
||||
_render = (transitionProps, prevTransitionProps) => {
|
||||
const scenes = transitionProps.scenes.map(scene =>
|
||||
this._renderScene(transitionProps, scene)
|
||||
);
|
||||
return <View style={{ flex: 1 }}>{scenes}</View>;
|
||||
};
|
||||
|
||||
_renderScene = (transitionProps, scene) => {
|
||||
const { navigation, router } = this.props;
|
||||
const { routes } = navigation.state;
|
||||
const { position } = transitionProps;
|
||||
const { index } = scene;
|
||||
|
||||
const animatedValue = position.interpolate({
|
||||
inputRange: [index - 1, index, index + 1],
|
||||
outputRange: [0, 1, 0],
|
||||
});
|
||||
|
||||
const animation = {
|
||||
opacity: animatedValue,
|
||||
transform: [{ scale: animatedValue }],
|
||||
};
|
||||
|
||||
const Scene = scene.descriptor.getComponent();
|
||||
return (
|
||||
<Animated.View key={index} style={[styles.view, animation]}>
|
||||
<Scene navigation={scene.descriptor.navigation} />
|
||||
</Animated.View>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const CustomRouter = StackRouter({
|
||||
Home: { screen: MyHomeScreen },
|
||||
Settings: { screen: MySettingsScreen },
|
||||
});
|
||||
|
||||
const CustomTransitioner = createNavigationContainer(
|
||||
createNavigator(CustomNavigationView, CustomRouter, {})
|
||||
);
|
||||
|
||||
export default CustomTransitioner;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
view: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
},
|
||||
});
|
||||
87
examples/NavigationPlayground/js/Drawer.js
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Platform, ScrollView, StatusBar } from 'react-native';
|
||||
import {
|
||||
StackNavigator,
|
||||
DrawerNavigator,
|
||||
SafeAreaView,
|
||||
} from 'react-navigation';
|
||||
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ top: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button onPress={() => navigation.openDrawer()} title="Open drawer" />
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Email')}
|
||||
title="Open other screen"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const InboxScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner={'Inbox Screen'} navigation={navigation} />
|
||||
);
|
||||
InboxScreen.navigationOptions = {
|
||||
drawerLabel: 'Inbox',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons
|
||||
name="move-to-inbox"
|
||||
size={24}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
const EmailScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner={'Email Screen'} navigation={navigation} />
|
||||
);
|
||||
|
||||
const DraftsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner={'Drafts Screen'} navigation={navigation} />
|
||||
);
|
||||
DraftsScreen.navigationOptions = {
|
||||
drawerLabel: 'Drafts',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons name="drafts" size={24} style={{ color: tintColor }} />
|
||||
),
|
||||
};
|
||||
|
||||
const InboxStack = StackNavigator({
|
||||
Inbox: { screen: InboxScreen },
|
||||
Email: { screen: EmailScreen },
|
||||
});
|
||||
|
||||
const DraftsStack = StackNavigator({
|
||||
Drafts: { screen: DraftsScreen },
|
||||
Email: { screen: EmailScreen },
|
||||
});
|
||||
|
||||
const DrawerExample = DrawerNavigator(
|
||||
{
|
||||
Inbox: {
|
||||
path: '/',
|
||||
screen: InboxStack,
|
||||
},
|
||||
Drafts: {
|
||||
path: '/sent',
|
||||
screen: DraftsStack,
|
||||
},
|
||||
},
|
||||
{
|
||||
initialRouteName: 'Drafts',
|
||||
contentOptions: {
|
||||
activeTintColor: '#e91e63',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export default DrawerExample;
|
||||
@@ -1,22 +1,13 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { ScrollView } from 'react-native';
|
||||
import {
|
||||
NavigationScreenProp,
|
||||
Themed,
|
||||
SafeAreaView,
|
||||
NavigationState,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import { Button, ScrollView, StatusBar, Text } from 'react-native';
|
||||
import { SafeAreaView, StackNavigator } from 'react-navigation';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({
|
||||
navigation,
|
||||
banner,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState & any>;
|
||||
banner: string;
|
||||
}) => (
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView
|
||||
forceInset={{
|
||||
@@ -40,44 +31,33 @@ const MyNavScreen = ({
|
||||
headerVisible:
|
||||
!navigation.state.params ||
|
||||
!navigation.state.params.headerVisible,
|
||||
})
|
||||
}
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
<Themed.StatusBar />
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
const MyHomeScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
||||
);
|
||||
MyHomeScreen.navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
|
||||
const MyProfileScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => (
|
||||
const MyProfileScreen = ({ navigation }) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params!.name}'s Profile`}
|
||||
banner={`${navigation.state.params.name}'s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
MyProfileScreen.navigationOptions = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
title: `${navigation.state.params!.name}'s Profile!`,
|
||||
MyProfileScreen.navigationOptions = ({ navigation }) => ({
|
||||
title: `${navigation.state.params.name}'s Profile!`,
|
||||
});
|
||||
|
||||
const ProfileNavigator = createStackNavigator(
|
||||
const ProfileNavigator = StackNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
@@ -88,23 +68,17 @@ const ProfileNavigator = createStackNavigator(
|
||||
},
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: {
|
||||
navigationOptions: {
|
||||
headerLeft: null,
|
||||
},
|
||||
mode: 'modal',
|
||||
}
|
||||
);
|
||||
|
||||
const MyHeaderTestScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Full screen view" navigation={navigation} />;
|
||||
MyHeaderTestScreen.navigationOptions = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => {
|
||||
const MyHeaderTestScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner={`Full screen view`} navigation={navigation} />
|
||||
);
|
||||
MyHeaderTestScreen.navigationOptions = ({ navigation }) => {
|
||||
const headerVisible =
|
||||
navigation.state.params && navigation.state.params.headerVisible;
|
||||
return {
|
||||
@@ -113,15 +87,15 @@ MyHeaderTestScreen.navigationOptions = ({
|
||||
};
|
||||
};
|
||||
|
||||
const ModalStack = createStackNavigator(
|
||||
const ModalStack = StackNavigator(
|
||||
{
|
||||
HeaderTest: { screen: MyHeaderTestScreen },
|
||||
ProfileNavigator: {
|
||||
screen: ProfileNavigator,
|
||||
},
|
||||
HeaderTest: { screen: MyHeaderTestScreen },
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: {
|
||||
navigationOptions: {
|
||||
header: null,
|
||||
},
|
||||
mode: 'modal',
|
||||
74
examples/NavigationPlayground/js/MultipleDrawer.js
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Platform, ScrollView, StyleSheet } from 'react-native';
|
||||
import { DrawerNavigator } from 'react-navigation';
|
||||
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<ScrollView style={styles.container}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button onPress={() => navigation.openDrawer()} title="Open drawer" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const InboxScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner={'Inbox Screen'} navigation={navigation} />
|
||||
);
|
||||
InboxScreen.navigationOptions = {
|
||||
drawerLabel: 'Inbox',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons
|
||||
name="move-to-inbox"
|
||||
size={24}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
const DraftsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner={'Drafts Screen'} navigation={navigation} />
|
||||
);
|
||||
DraftsScreen.navigationOptions = {
|
||||
drawerLabel: 'Drafts',
|
||||
drawerIcon: ({ tintColor }) => (
|
||||
<MaterialIcons name="drafts" size={24} style={{ color: tintColor }} />
|
||||
),
|
||||
};
|
||||
|
||||
const DrawerExample = DrawerNavigator(
|
||||
{
|
||||
Inbox: {
|
||||
path: '/',
|
||||
screen: InboxScreen,
|
||||
},
|
||||
Drafts: {
|
||||
path: '/sent',
|
||||
screen: DraftsScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
initialRouteName: 'Drafts',
|
||||
contentOptions: {
|
||||
activeTintColor: '#e91e63',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const MainDrawerExample = DrawerNavigator({
|
||||
Drafts: {
|
||||
screen: DrawerExample,
|
||||
},
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
marginTop: Platform.OS === 'ios' ? 20 : 0,
|
||||
},
|
||||
});
|
||||
|
||||
export default MainDrawerExample;
|
||||
22
examples/NavigationPlayground/js/SampleText.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/* @flow */
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { StyleSheet, Text } from 'react-native';
|
||||
|
||||
/**
|
||||
* Used across examples as a screen placeholder.
|
||||
*/
|
||||
import type { ChildrenArray } from 'react';
|
||||
|
||||
const SampleText = ({ children }: { children?: ChildrenArray<*> }) => (
|
||||
<Text style={styles.sampleText}>{children}</Text>
|
||||
);
|
||||
|
||||
export default SampleText;
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
sampleText: {
|
||||
margin: 14,
|
||||
},
|
||||
});
|
||||
195
examples/NavigationPlayground/js/SimpleStack.js
Normal file
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type {
|
||||
NavigationScreenProp,
|
||||
NavigationEventSubscription,
|
||||
} from 'react-navigation';
|
||||
|
||||
import * as React from 'react';
|
||||
import { Button, ScrollView, StatusBar } from 'react-native';
|
||||
import { StackNavigator, SafeAreaView, withNavigation } from 'react-navigation';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
type MyNavScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
banner: React.Node,
|
||||
};
|
||||
|
||||
class MyBackButton extends React.Component<any, any> {
|
||||
render() {
|
||||
return <Button onPress={this._navigateBack} title="Custom Back" />;
|
||||
}
|
||||
|
||||
_navigateBack = () => {
|
||||
this.props.navigation.goBack(null);
|
||||
};
|
||||
}
|
||||
|
||||
const MyBackButtonWithNavigation = withNavigation(MyBackButton);
|
||||
|
||||
class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
render() {
|
||||
const { navigation, banner } = this.props;
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.push('Profile', { name: 'Jane' })}
|
||||
title="Push a profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
|
||||
title="Navigate to a photos screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.replace('Profile', { name: 'Lucy' })}
|
||||
title="Replace with profile"
|
||||
/>
|
||||
<Button onPress={() => navigation.popToTop()} title="Pop to top" />
|
||||
<Button onPress={() => navigation.pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<StatusBar barStyle="default" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
type MyHomeScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onWF);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onDF);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onWB);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onWF = a => {
|
||||
console.log('_willFocus HomeScreen', a);
|
||||
};
|
||||
_onDF = a => {
|
||||
console.log('_didFocus HomeScreen', a);
|
||||
};
|
||||
_onWB = a => {
|
||||
console.log('_willBlur HomeScreen', a);
|
||||
};
|
||||
_onDB = a => {
|
||||
console.log('_didBlur HomeScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
type MyPhotosScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Photos',
|
||||
headerLeft: <MyBackButtonWithNavigation />,
|
||||
};
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onWF);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onDF);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onWB);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onWF = a => {
|
||||
console.log('_willFocus PhotosScreen', a);
|
||||
};
|
||||
_onDF = a => {
|
||||
console.log('_didFocus PhotosScreen', a);
|
||||
};
|
||||
_onWB = a => {
|
||||
console.log('_willBlur PhotosScreen', a);
|
||||
};
|
||||
_onDB = a => {
|
||||
console.log('_didBlur PhotosScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params.name}'s Photos`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const MyProfileScreen = ({ navigation }) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params.mode === 'edit' ? 'Now Editing ' : ''}${
|
||||
navigation.state.params.name
|
||||
}'s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
MyProfileScreen.navigationOptions = props => {
|
||||
const { navigation } = props;
|
||||
const { state, setParams } = navigation;
|
||||
const { params } = state;
|
||||
return {
|
||||
headerBackImage: params.headerBackImage,
|
||||
headerTitle: `${params.name}'s Profile!`,
|
||||
// Render a button on the right side of the header.
|
||||
// When pressed switches the screen to edit mode.
|
||||
headerRight: (
|
||||
<Button
|
||||
title={params.mode === 'edit' ? 'Done' : 'Edit'}
|
||||
onPress={() =>
|
||||
setParams({ mode: params.mode === 'edit' ? '' : 'edit' })
|
||||
}
|
||||
/>
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
const SimpleStack = StackNavigator({
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
Profile: {
|
||||
path: 'people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
Photos: {
|
||||
path: 'photos/:name',
|
||||
screen: MyPhotosScreen,
|
||||
},
|
||||
});
|
||||
|
||||
export default SimpleStack;
|
||||
205
examples/NavigationPlayground/js/SimpleTabs.js
Normal file
@@ -0,0 +1,205 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type {
|
||||
NavigationScreenProp,
|
||||
NavigationEventSubscription,
|
||||
} from 'react-navigation';
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Platform, ScrollView, StatusBar, View } from 'react-native';
|
||||
import { SafeAreaView, TabNavigator } from 'react-navigation';
|
||||
import Ionicons from 'react-native-vector-icons/Ionicons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Home')}
|
||||
title="Go to home tab"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Settings')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<StatusBar barStyle="default" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Home Tab" navigation={navigation} />
|
||||
);
|
||||
|
||||
MyHomeScreen.navigationOptions = {
|
||||
tabBarTestIDProps: {
|
||||
testID: 'TEST_ID_HOME',
|
||||
accessibilityLabel: 'TEST_ID_HOME_ACLBL',
|
||||
},
|
||||
tabBarLabel: 'Home',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-home' : 'ios-home-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
type MyPeopleScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
class MyPeopleScreen extends React.Component<MyPeopleScreenProps> {
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
static navigationOptions = {
|
||||
tabBarLabel: 'People',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-people' : 'ios-people-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onEvent);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onEvent);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onEvent);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onEvent);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onEvent = a => {
|
||||
console.log('EVENT ON PEOPLE TAB', a.type, a);
|
||||
};
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="People Tab" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
type MyChatScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
class MyChatScreen extends React.Component<MyChatScreenProps> {
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
static navigationOptions = {
|
||||
tabBarLabel: 'Chat',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-chatboxes' : 'ios-chatboxes-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onEvent);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onEvent);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onEvent);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onEvent);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onEvent = a => {
|
||||
console.log('EVENT ON CHAT TAB', a.type, a);
|
||||
};
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="Chat Tab" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
const MySettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Settings Tab" navigation={navigation} />
|
||||
);
|
||||
|
||||
MySettingsScreen.navigationOptions = {
|
||||
tabBarLabel: 'Settings',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-settings' : 'ios-settings-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
const SimpleTabs = TabNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
path: '',
|
||||
},
|
||||
People: {
|
||||
screen: MyPeopleScreen,
|
||||
path: 'cart',
|
||||
},
|
||||
Chat: {
|
||||
screen: MyChatScreen,
|
||||
path: 'chat',
|
||||
},
|
||||
Settings: {
|
||||
screen: MySettingsScreen,
|
||||
path: 'settings',
|
||||
},
|
||||
},
|
||||
{
|
||||
lazy: true,
|
||||
removeClippedSubviews: true,
|
||||
tabBarOptions: {
|
||||
activeTintColor: Platform.OS === 'ios' ? '#e91e63' : '#fff',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
type SimpleTabsContainerProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
|
||||
class SimpleTabsContainer extends React.Component<SimpleTabsContainerProps> {
|
||||
static router = SimpleTabs.router;
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onAction);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onAction);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onAction);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onAction);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onAction = a => {
|
||||
console.log('TABS EVENT', a.type, a);
|
||||
};
|
||||
render() {
|
||||
return <SimpleTabs navigation={this.props.navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
export default SimpleTabsContainer;
|
||||
68
examples/NavigationPlayground/js/StackWithHeaderPreset.js
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
import type { NavigationScreenProp } from 'react-navigation';
|
||||
|
||||
import * as React from 'react';
|
||||
import { Button, ScrollView, StatusBar } from 'react-native';
|
||||
import { StackNavigator, SafeAreaView } from 'react-navigation';
|
||||
|
||||
type NavScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
|
||||
class HomeScreen extends React.Component<NavScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ paddingTop: 30 }}>
|
||||
<Button
|
||||
onPress={() => navigation.push('Other')}
|
||||
title="Push another screen"
|
||||
/>
|
||||
<Button onPress={() => navigation.pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<StatusBar barStyle="default" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OtherScreen extends React.Component<NavScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Your title here',
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return (
|
||||
<SafeAreaView style={{ paddingTop: 30 }}>
|
||||
<Button
|
||||
onPress={() => navigation.push('Other')}
|
||||
title="Push another screen"
|
||||
/>
|
||||
<Button onPress={() => navigation.pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<StatusBar barStyle="default" />
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const StackWithHeaderPreset = StackNavigator(
|
||||
{
|
||||
Home: HomeScreen,
|
||||
Other: OtherScreen,
|
||||
},
|
||||
{
|
||||
headerTransitionPreset: 'uikit',
|
||||
}
|
||||
);
|
||||
|
||||
export default StackWithHeaderPreset;
|
||||
234
examples/NavigationPlayground/js/StackWithTranslucentHeader.js
Normal file
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type {
|
||||
NavigationScreenProp,
|
||||
NavigationEventSubscription,
|
||||
} from 'react-navigation';
|
||||
|
||||
import { isIphoneX } from 'react-native-iphone-x-helper';
|
||||
|
||||
import * as React from 'react';
|
||||
import { BlurView, Constants } from 'expo';
|
||||
import {
|
||||
Button,
|
||||
Dimensions,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StatusBar,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { Header, StackNavigator } from 'react-navigation';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
type MyNavScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
banner: React.Node,
|
||||
};
|
||||
|
||||
class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
render() {
|
||||
const { navigation, banner } = this.props;
|
||||
return (
|
||||
<ScrollView style={{ flex: 1 }} {...this.getHeaderInset()}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.push('Profile', { name: 'Jane' })}
|
||||
title="Push a profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
|
||||
title="Navigate to a photos screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.replace('Profile', { name: 'Lucy' })}
|
||||
title="Replace with profile"
|
||||
/>
|
||||
<Button onPress={() => navigation.popToTop()} title="Pop to top" />
|
||||
<Button onPress={() => navigation.pop()} title="Pop" />
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
||||
// Inset to compensate for navigation bar being transparent.
|
||||
// And improved abstraction for this will be built in to react-navigation
|
||||
// at some point.
|
||||
|
||||
getHeaderInset() {
|
||||
const NOTCH_HEIGHT = isIphoneX() ? 25 : 0;
|
||||
|
||||
// $FlowIgnore: we will remove the HEIGHT static soon enough
|
||||
const BASE_HEADER_HEIGHT = Header.HEIGHT;
|
||||
|
||||
const HEADER_HEIGHT =
|
||||
Platform.OS === 'ios'
|
||||
? BASE_HEADER_HEIGHT + NOTCH_HEIGHT
|
||||
: BASE_HEADER_HEIGHT + Constants.statusBarHeight;
|
||||
|
||||
return Platform.select({
|
||||
ios: {
|
||||
contentInset: { top: HEADER_HEIGHT },
|
||||
contentOffset: { y: -HEADER_HEIGHT },
|
||||
},
|
||||
android: {
|
||||
contentContainerStyle: {
|
||||
paddingTop: HEADER_HEIGHT,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
type MyHomeScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onWF);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onDF);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onWB);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onWF = a => {
|
||||
console.log('_willFocus HomeScreen', a);
|
||||
};
|
||||
_onDF = a => {
|
||||
console.log('_didFocus HomeScreen', a);
|
||||
};
|
||||
_onWB = a => {
|
||||
console.log('_willBlur HomeScreen', a);
|
||||
};
|
||||
_onDB = a => {
|
||||
console.log('_didBlur HomeScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
type MyPhotosScreenProps = {
|
||||
navigation: NavigationScreenProp<*>,
|
||||
};
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Photos',
|
||||
};
|
||||
_s0: NavigationEventSubscription;
|
||||
_s1: NavigationEventSubscription;
|
||||
_s2: NavigationEventSubscription;
|
||||
_s3: NavigationEventSubscription;
|
||||
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onWF);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onDF);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onWB);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onWF = a => {
|
||||
console.log('_willFocus PhotosScreen', a);
|
||||
};
|
||||
_onDF = a => {
|
||||
console.log('_didFocus PhotosScreen', a);
|
||||
};
|
||||
_onWB = a => {
|
||||
console.log('_willBlur PhotosScreen', a);
|
||||
};
|
||||
_onDB = a => {
|
||||
console.log('_didBlur PhotosScreen', a);
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
return (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params.name}'s Photos`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const MyProfileScreen = ({ navigation }) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params.mode === 'edit' ? 'Now Editing ' : ''}${
|
||||
navigation.state.params.name
|
||||
}'s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
MyProfileScreen.navigationOptions = props => {
|
||||
const { navigation } = props;
|
||||
const { state, setParams } = navigation;
|
||||
const { params } = state;
|
||||
return {
|
||||
headerBackImage: params.headerBackImage,
|
||||
headerTitle: `${params.name}'s Profile!`,
|
||||
// Render a button on the right side of the header.
|
||||
// When pressed switches the screen to edit mode.
|
||||
headerRight: (
|
||||
<Button
|
||||
title={params.mode === 'edit' ? 'Done' : 'Edit'}
|
||||
onPress={() =>
|
||||
setParams({ mode: params.mode === 'edit' ? '' : 'edit' })
|
||||
}
|
||||
/>
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
const StackWithTranslucentHeader = StackNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
Profile: {
|
||||
path: 'people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
Photos: {
|
||||
path: 'photos/:name',
|
||||
screen: MyPhotosScreen,
|
||||
},
|
||||
},
|
||||
{
|
||||
headerTransitionPreset: 'uikit',
|
||||
navigationOptions: {
|
||||
headerTransparent: true,
|
||||
headerBackground: Platform.select({
|
||||
ios: <BlurView style={{ flex: 1 }} intensity={98} />,
|
||||
android: (
|
||||
<View style={{ flex: 1, backgroundColor: 'rgba(255,255,255,0.7)' }} />
|
||||
),
|
||||
}),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export default StackWithTranslucentHeader;
|
||||
125
examples/NavigationPlayground/js/StacksInTabs.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, ScrollView, StatusBar } from 'react-native';
|
||||
import { SafeAreaView, StackNavigator, TabNavigator } from 'react-navigation';
|
||||
|
||||
import Ionicons from 'react-native-vector-icons/Ionicons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
||||
title="Open profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('NotifSettings')}
|
||||
title="Open notifications screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('SettingsTab')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MyProfileScreen = ({ navigation }) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params.name}s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
const MyNotificationsSettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MySettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Settings Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MainTab = StackNavigator({
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
path: '/',
|
||||
navigationOptions: {
|
||||
title: 'Welcome',
|
||||
},
|
||||
},
|
||||
Profile: {
|
||||
screen: MyProfileScreen,
|
||||
path: '/people/:name',
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: `${navigation.state.params.name}'s Profile!`,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
const SettingsTab = StackNavigator({
|
||||
Settings: {
|
||||
screen: MySettingsScreen,
|
||||
path: '/',
|
||||
navigationOptions: () => ({
|
||||
title: 'Settings',
|
||||
}),
|
||||
},
|
||||
NotifSettings: {
|
||||
screen: MyNotificationsSettingsScreen,
|
||||
navigationOptions: {
|
||||
title: 'Notifications',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const StacksInTabs = TabNavigator(
|
||||
{
|
||||
MainTab: {
|
||||
screen: MainTab,
|
||||
path: '/',
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Home',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-home' : 'ios-home-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
},
|
||||
SettingsTab: {
|
||||
screen: SettingsTab,
|
||||
path: '/settings',
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Settings',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-settings' : 'ios-settings-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabBarPosition: 'bottom',
|
||||
animationEnabled: false,
|
||||
swipeEnabled: false,
|
||||
}
|
||||
);
|
||||
|
||||
export default StacksInTabs;
|
||||
111
examples/NavigationPlayground/js/StacksOverTabs.js
Normal file
@@ -0,0 +1,111 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, ScrollView, StatusBar } from 'react-native';
|
||||
import { SafeAreaView, StackNavigator, TabNavigator } from 'react-navigation';
|
||||
|
||||
import Ionicons from 'react-native-vector-icons/Ionicons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ horizontal: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
||||
title="Open profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('NotifSettings')}
|
||||
title="Open notifications screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('SettingsTab')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
</SafeAreaView>
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MyProfileScreen = ({ navigation }) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params.name}s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
const MyNotificationsSettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MySettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Settings Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const TabNav = TabNavigator(
|
||||
{
|
||||
MainTab: {
|
||||
screen: MyHomeScreen,
|
||||
path: '/',
|
||||
navigationOptions: {
|
||||
title: 'Welcome',
|
||||
tabBarLabel: 'Home',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-home' : 'ios-home-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
},
|
||||
SettingsTab: {
|
||||
screen: MySettingsScreen,
|
||||
path: '/settings',
|
||||
navigationOptions: {
|
||||
title: 'Settings',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-settings' : 'ios-settings-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabBarPosition: 'bottom',
|
||||
animationEnabled: false,
|
||||
swipeEnabled: false,
|
||||
}
|
||||
);
|
||||
|
||||
const StacksOverTabs = StackNavigator({
|
||||
Root: {
|
||||
screen: TabNav,
|
||||
},
|
||||
NotifSettings: {
|
||||
screen: MyNotificationsSettingsScreen,
|
||||
navigationOptions: {
|
||||
title: 'Notifications',
|
||||
},
|
||||
},
|
||||
Profile: {
|
||||
screen: MyProfileScreen,
|
||||
path: '/people/:name',
|
||||
navigationOptions: ({ navigation }) => {
|
||||
title: `${navigation.state.params.name}'s Profile!`;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default StacksOverTabs;
|
||||
@@ -1,18 +1,8 @@
|
||||
import React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
import {
|
||||
NavigationScreenProp,
|
||||
NavigationState,
|
||||
Themed,
|
||||
} from 'react-navigation';
|
||||
import { createStackNavigator } from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import { Button, StatusBar, Text, View } from 'react-native';
|
||||
import { StackNavigator } from 'react-navigation';
|
||||
|
||||
interface Props {
|
||||
navigation: NavigationScreenProp<NavigationState & any>;
|
||||
}
|
||||
|
||||
class HomeScreen extends React.Component<Props, any> {
|
||||
class HomeScreen extends React.Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||
@@ -21,9 +11,9 @@ class HomeScreen extends React.Component<Props, any> {
|
||||
title="Navigate to 'Profile' with key 'A'"
|
||||
onPress={() =>
|
||||
this.props.navigation.navigate({
|
||||
routeName: 'Profile',
|
||||
key: 'A',
|
||||
params: { homeKey: this.props.navigation.state.key },
|
||||
routeName: 'Profile',
|
||||
})
|
||||
}
|
||||
/>
|
||||
@@ -31,7 +21,7 @@ class HomeScreen extends React.Component<Props, any> {
|
||||
title="Go back to other examples"
|
||||
onPress={() => this.props.navigation.goBack(null)}
|
||||
/>
|
||||
<Themed.StatusBar />
|
||||
<StatusBar barStyle="default" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -47,9 +37,9 @@ class ProfileScreen extends React.Component<any, any> {
|
||||
title="Navigate to 'Settings' with key 'B'"
|
||||
onPress={() =>
|
||||
this.props.navigation.navigate({
|
||||
routeName: 'Settings',
|
||||
key: 'B',
|
||||
params: { homeKey },
|
||||
routeName: 'Settings',
|
||||
})
|
||||
}
|
||||
/>
|
||||
@@ -64,9 +54,9 @@ class ProfileScreen extends React.Component<any, any> {
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsScreen extends React.Component<Props, any> {
|
||||
class SettingsScreen extends React.Component<any, any> {
|
||||
render() {
|
||||
const { homeKey } = this.props.navigation.state.params!;
|
||||
const { homeKey } = this.props.navigation.state.params;
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||
@@ -81,8 +71,8 @@ class SettingsScreen extends React.Component<Props, any> {
|
||||
title="Navigate back to 'Profile' with key 'A'"
|
||||
onPress={() =>
|
||||
this.props.navigation.navigate({
|
||||
key: 'A',
|
||||
routeName: 'Profile',
|
||||
key: 'A',
|
||||
})
|
||||
}
|
||||
/>
|
||||
@@ -91,7 +81,7 @@ class SettingsScreen extends React.Component<Props, any> {
|
||||
}
|
||||
}
|
||||
|
||||
const Stack = createStackNavigator(
|
||||
const Stack = StackNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: HomeScreen,
|
||||
127
examples/NavigationPlayground/js/TabAnimations.js
Normal file
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Animated, Button, ScrollView, StatusBar } from 'react-native';
|
||||
import { StackNavigator, TabNavigator } from 'react-navigation';
|
||||
|
||||
import Ionicons from 'react-native-vector-icons/Ionicons';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
const MyNavScreen = ({ navigation, banner }) => (
|
||||
<ScrollView>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
|
||||
title="Open profile screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('NotifSettings')}
|
||||
title="Open notifications screen"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('SettingsTab')}
|
||||
title="Go to settings tab"
|
||||
/>
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
<StatusBar barStyle="default" />
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const MyHomeScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Home Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MyProfileScreen = ({ navigation }) => (
|
||||
<MyNavScreen
|
||||
banner={`${navigation.state.params.name}s Profile`}
|
||||
navigation={navigation}
|
||||
/>
|
||||
);
|
||||
|
||||
const MyNotificationsSettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MySettingsScreen = ({ navigation }) => (
|
||||
<MyNavScreen banner="Settings Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
const MainTab = StackNavigator({
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
path: '/',
|
||||
navigationOptions: {
|
||||
title: 'Welcome',
|
||||
},
|
||||
},
|
||||
Profile: {
|
||||
screen: MyProfileScreen,
|
||||
path: '/people/:name',
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: `${navigation.state.params.name}'s Profile!`,
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
const SettingsTab = StackNavigator({
|
||||
Settings: {
|
||||
screen: MySettingsScreen,
|
||||
path: '/',
|
||||
navigationOptions: () => ({
|
||||
title: 'Settings',
|
||||
}),
|
||||
},
|
||||
NotifSettings: {
|
||||
screen: MyNotificationsSettingsScreen,
|
||||
navigationOptions: {
|
||||
title: 'Notifications',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const TabAnimations = TabNavigator(
|
||||
{
|
||||
MainTab: {
|
||||
screen: MainTab,
|
||||
path: '/',
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Home',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-home' : 'ios-home-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
},
|
||||
SettingsTab: {
|
||||
screen: SettingsTab,
|
||||
path: '/settings',
|
||||
navigationOptions: {
|
||||
tabBarLabel: 'Settings',
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? 'ios-settings' : 'ios-settings-outline'}
|
||||
size={26}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
tabBarPosition: 'bottom',
|
||||
animationEnabled: true,
|
||||
configureTransition: (currentTransitionProps,nextTransitionProps) => ({
|
||||
timing: Animated.spring,
|
||||
tension: 1,
|
||||
friction: 35,
|
||||
}),
|
||||
swipeEnabled: false,
|
||||
}
|
||||
);
|
||||
|
||||
export default TabAnimations;
|
||||
45
examples/NavigationPlayground/js/TabsInDrawer.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Platform, ScrollView } from 'react-native';
|
||||
import { TabNavigator, DrawerNavigator } from 'react-navigation';
|
||||
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
||||
import SimpleTabs from './SimpleTabs';
|
||||
import StacksOverTabs from './StacksOverTabs';
|
||||
|
||||
const TabsInDrawer = DrawerNavigator({
|
||||
SimpleTabs: {
|
||||
screen: SimpleTabs,
|
||||
navigationOptions: {
|
||||
drawer: () => ({
|
||||
label: 'Simple Tabs',
|
||||
icon: ({ tintColor }) => (
|
||||
<MaterialIcons
|
||||
name="filter-1"
|
||||
size={24}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
},
|
||||
},
|
||||
StacksOverTabs: {
|
||||
screen: StacksOverTabs,
|
||||
navigationOptions: {
|
||||
drawer: () => ({
|
||||
label: 'Stacks Over Tabs',
|
||||
icon: ({ tintColor }) => (
|
||||
<MaterialIcons
|
||||
name="filter-2"
|
||||
size={24}
|
||||
style={{ color: tintColor }}
|
||||
/>
|
||||
),
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default TabsInDrawer;
|
||||
101
examples/NavigationPlayground/js/TabsWithNavigationFocus.js
Normal file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Button, SafeAreaView, Text } from 'react-native';
|
||||
import { TabNavigator, withNavigationFocus } from 'react-navigation';
|
||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
|
||||
import SampleText from './SampleText';
|
||||
|
||||
class Child extends React.Component<any, any> {
|
||||
render() {
|
||||
return (
|
||||
<Text style={{ color: this.props.isFocused ? 'green' : 'maroon' }}>
|
||||
{this.props.isFocused
|
||||
? 'I know that my parent is focused!'
|
||||
: 'My parent is not focused! :O'}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const ChildWithNavigationFocus = withNavigationFocus(Child);
|
||||
|
||||
const createTabScreen = (name, icon, focusedIcon, tintColor = '#673ab7') => {
|
||||
class TabScreen extends React.Component<any, any> {
|
||||
static navigationOptions = {
|
||||
tabBarLabel: name,
|
||||
tabBarIcon: ({ tintColor, focused }) => (
|
||||
<MaterialCommunityIcons
|
||||
name={focused ? focusedIcon : icon}
|
||||
size={26}
|
||||
style={{ color: focused ? tintColor : '#ccc' }}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
state = { showChild: false };
|
||||
|
||||
render() {
|
||||
const { isFocused } = this.props;
|
||||
|
||||
return (
|
||||
<SafeAreaView
|
||||
forceInset={{ horizontal: 'always', top: 'always' }}
|
||||
style={{
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontWeight: '700', fontSize: 16, marginBottom: 5 }}>
|
||||
{'Tab ' + name.toLowerCase()}
|
||||
</Text>
|
||||
<Text style={{ marginBottom: 20 }}>
|
||||
{'props.isFocused: ' + (isFocused ? ' true' : 'false')}
|
||||
</Text>
|
||||
{this.state.showChild ? (
|
||||
<ChildWithNavigationFocus />
|
||||
) : (
|
||||
<Button
|
||||
title="Press me"
|
||||
onPress={() => this.setState({ showChild: true })}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
onPress={() => this.props.navigation.goBack(null)}
|
||||
title="Back to other examples"
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
}
|
||||
return withNavigationFocus(TabScreen);
|
||||
};
|
||||
|
||||
const TabsWithNavigationFocus = TabNavigator(
|
||||
{
|
||||
One: {
|
||||
screen: createTabScreen('One', 'numeric-1-box-outline', 'numeric-1-box'),
|
||||
},
|
||||
Two: {
|
||||
screen: createTabScreen('Two', 'numeric-2-box-outline', 'numeric-2-box'),
|
||||
},
|
||||
Three: {
|
||||
screen: createTabScreen(
|
||||
'Three',
|
||||
'numeric-3-box-outline',
|
||||
'numeric-3-box'
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
tabBarPosition: 'bottom',
|
||||
animationEnabled: true,
|
||||
swipeEnabled: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default TabsWithNavigationFocus;
|
||||
BIN
examples/NavigationPlayground/js/assets/NavLogo.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
examples/NavigationPlayground/js/assets/dog-back.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
46
examples/NavigationPlayground/package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "NavigationPlayground",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
||||
"scripts": {
|
||||
"start": "react-native-scripts start",
|
||||
"eject": "react-native-scripts eject",
|
||||
"android": "react-native-scripts android",
|
||||
"ios": "react-native-scripts ios",
|
||||
"test": "node node_modules/jest/bin/jest.js && flow"
|
||||
},
|
||||
"dependencies": {
|
||||
"expo": "^25.0.0",
|
||||
"react": "16.2.0",
|
||||
"react-native": "^0.52.0",
|
||||
"react-native-iphone-x-helper": "^1.0.2",
|
||||
"react-navigation": "link:../.."
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-jest": "^21.0.0",
|
||||
"babel-plugin-transform-remove-console": "^6.9.0",
|
||||
"flow-bin": "^0.61.0",
|
||||
"jest": "^21.0.1",
|
||||
"jest-expo": "^25.1.0",
|
||||
"react-native-scripts": "^1.5.0",
|
||||
"react-test-renderer": "16.0.0"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "jest-expo",
|
||||
"moduleFileExtensions": [
|
||||
"web.js",
|
||||
"js",
|
||||
"json",
|
||||
"jsx",
|
||||
"node"
|
||||
],
|
||||
"modulePathIgnorePatterns": [
|
||||
"/node_modules/.*/react-native/",
|
||||
"/node_modules/.*/react/"
|
||||
],
|
||||
"transformIgnorePatterns": [
|
||||
"/node_modules/(?!react-native|react-navigation)/"
|
||||
]
|
||||
}
|
||||
}
|
||||
52
examples/NavigationPlayground/rn-cli.config.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @noflow
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const blacklist = require('metro/src/blacklist');
|
||||
|
||||
module.exports = {
|
||||
getBlacklistRE() {
|
||||
return blacklist([
|
||||
/react\-navigation\/examples\/(?!NavigationPlayground).*/,
|
||||
/react\-navigation\/node_modules\/react-native\/(.*)/,
|
||||
/react\-navigation\/node_modules\/react\/(.*)/
|
||||
]);
|
||||
},
|
||||
extraNodeModules: getNodeModulesForDirectory(path.resolve('.')),
|
||||
};
|
||||
|
||||
function getNodeModulesForDirectory(rootPath) {
|
||||
const nodeModulePath = path.join(rootPath, 'node_modules');
|
||||
const folders = fs.readdirSync(nodeModulePath);
|
||||
return folders.reduce((modules, folderName) => {
|
||||
const folderPath = path.join(nodeModulePath, folderName);
|
||||
if (folderName.startsWith('@')) {
|
||||
const scopedModuleFolders = fs.readdirSync(folderPath);
|
||||
const scopedModules = scopedModuleFolders.reduce(
|
||||
(scopedModules, scopedFolderName) => {
|
||||
scopedModules[
|
||||
`${folderName}/${scopedFolderName}`
|
||||
] = maybeResolveSymlink(path.join(folderPath, scopedFolderName));
|
||||
return scopedModules;
|
||||
},
|
||||
{}
|
||||
);
|
||||
return Object.assign({}, modules, scopedModules);
|
||||
}
|
||||
modules[folderName] = maybeResolveSymlink(folderPath);
|
||||
return modules;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function maybeResolveSymlink(maybeSymlinkPath) {
|
||||
if (fs.lstatSync(maybeSymlinkPath).isSymbolicLink()) {
|
||||
const resolved = path.resolve(
|
||||
path.dirname(maybeSymlinkPath),
|
||||
fs.readlinkSync(maybeSymlinkPath)
|
||||
);
|
||||
return resolved;
|
||||
}
|
||||
return maybeSymlinkPath;
|
||||
}
|
||||
6898
examples/NavigationPlayground/yarn.lock
Normal file
5
examples/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Examples
|
||||
|
||||
## Usage
|
||||
|
||||
Please see the [Contributors Guide](https://reactnavigation.org/docs/contributing.html#run-the-example-app) for instructions on running these example apps.
|
||||
8
examples/ReduxExample/.babelrc
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"presets": ["babel-preset-expo"],
|
||||
"env": {
|
||||
"development": {
|
||||
"plugins": ["transform-react-jsx-source"]
|
||||
}
|
||||
}
|
||||
}
|
||||
3
examples/ReduxExample/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules/
|
||||
.expo/
|
||||
npm-debug.*
|
||||
1
examples/ReduxExample/.watchmanconfig
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
27
examples/ReduxExample/App.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import React from 'react';
|
||||
import { AppRegistry } from 'react-native';
|
||||
import { Provider } from 'react-redux';
|
||||
import { createStore, applyMiddleware } from 'redux';
|
||||
|
||||
import AppReducer from './src/reducers';
|
||||
import AppWithNavigationState from './src/navigators/AppNavigator';
|
||||
import { middleware } from './src/utils/redux';
|
||||
|
||||
const store = createStore(
|
||||
AppReducer,
|
||||
applyMiddleware(middleware),
|
||||
);
|
||||
|
||||
class ReduxExampleApp extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<AppWithNavigationState />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AppRegistry.registerComponent('ReduxExample', () => ReduxExampleApp);
|
||||
|
||||
export default ReduxExampleApp;
|
||||
9
examples/ReduxExample/App.test.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import App from './App';
|
||||
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const rendered = renderer.create(<App />).toJSON();
|
||||
expect(rendered).toBeTruthy();
|
||||
});
|
||||
5
examples/ReduxExample/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Redux example
|
||||
|
||||
## Usage
|
||||
|
||||
Please see the [Contributors Guide](https://reactnavigation.org/docs/guides/contributors#Run-the-Example-App) for instructions on running these example apps.
|
||||
24
examples/ReduxExample/app.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "ReduxExample",
|
||||
"description": "Try out react-navigation with this awesome Redux example",
|
||||
"version": "1.0.0",
|
||||
"slug": "ReduxExample",
|
||||
"privacy": "public",
|
||||
"orientation": "portrait",
|
||||
"primaryColor": "#cccccc",
|
||||
"icon": "./assets/icons/react-navigation.png",
|
||||
"loading": {
|
||||
"icon": "./assets/icons/react-navigation.png",
|
||||
"hideExponentText": false
|
||||
},
|
||||
"sdkVersion": "25.0.0",
|
||||
"entryPoint": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
||||
"packagerOpts": {
|
||||
"assetExts": ["ttf", "mp4"]
|
||||
},
|
||||
"ios": {
|
||||
"supportsTablet": true
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
examples/ReduxExample/assets/icons/react-navigation.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
40
examples/ReduxExample/package.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "ReduxExample",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
|
||||
"scripts": {
|
||||
"start": "react-native-scripts start",
|
||||
"eject": "react-native-scripts eject",
|
||||
"android": "react-native-scripts android",
|
||||
"ios": "react-native-scripts ios",
|
||||
"test": "node node_modules/jest/bin/jest.js"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "jest-expo",
|
||||
"modulePathIgnorePatterns": [
|
||||
"/node_modules/.*/react-native/",
|
||||
"/node_modules/.*/react/"
|
||||
],
|
||||
"transformIgnorePatterns": [
|
||||
"/node_modules/(?!react-native|react-navigation)/"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"expo": "^25.0.0",
|
||||
"prop-types": "^15.5.10",
|
||||
"react": "16.2.0",
|
||||
"react-native": "^0.52.0",
|
||||
"react-navigation": "link:../..",
|
||||
"react-navigation-redux-helpers": "^1.0.0",
|
||||
"react-redux": "^5.0.6",
|
||||
"redux": "^3.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-jest": "^21.0.0",
|
||||
"jest": "^21.0.1",
|
||||
"jest-expo": "^25.1.0",
|
||||
"react-native-scripts": "^1.3.1",
|
||||
"react-test-renderer": "16.0.0"
|
||||
}
|
||||
}
|
||||
52
examples/ReduxExample/rn-cli.config.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @noflow
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const blacklist = require('metro/src/blacklist');
|
||||
|
||||
module.exports = {
|
||||
getBlacklistRE() {
|
||||
return blacklist([
|
||||
/react\-navigation\/examples\/(?!ReduxExample).*/,
|
||||
/react\-navigation\/node_modules\/react-native\/(.*)/,
|
||||
/react\-navigation\/node_modules\/react\/(.*)/
|
||||
]);
|
||||
},
|
||||
extraNodeModules: getNodeModulesForDirectory(path.resolve('.')),
|
||||
};
|
||||
|
||||
function getNodeModulesForDirectory(rootPath) {
|
||||
const nodeModulePath = path.join(rootPath, 'node_modules');
|
||||
const folders = fs.readdirSync(nodeModulePath);
|
||||
return folders.reduce((modules, folderName) => {
|
||||
const folderPath = path.join(nodeModulePath, folderName);
|
||||
if (folderName.startsWith('@')) {
|
||||
const scopedModuleFolders = fs.readdirSync(folderPath);
|
||||
const scopedModules = scopedModuleFolders.reduce(
|
||||
(scopedModules, scopedFolderName) => {
|
||||
scopedModules[
|
||||
`${folderName}/${scopedFolderName}`
|
||||
] = maybeResolveSymlink(path.join(folderPath, scopedFolderName));
|
||||
return scopedModules;
|
||||
},
|
||||
{}
|
||||
);
|
||||
return Object.assign({}, modules, scopedModules);
|
||||
}
|
||||
modules[folderName] = maybeResolveSymlink(folderPath);
|
||||
return modules;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function maybeResolveSymlink(maybeSymlinkPath) {
|
||||
if (fs.lstatSync(maybeSymlinkPath).isSymbolicLink()) {
|
||||
const resolved = path.resolve(
|
||||
path.dirname(maybeSymlinkPath),
|
||||
fs.readlinkSync(maybeSymlinkPath)
|
||||
);
|
||||
return resolved;
|
||||
}
|
||||
return maybeSymlinkPath;
|
||||
}
|
||||