Compare commits

..

2 Commits

Author SHA1 Message Date
satyajit.happy
04ab7a4043 chore: release 3.11.2 2019-09-20 14:09:37 +02:00
satyajit.happy
5f6dada0d8 fix: lock version of react-navigation-stack 2019-09-20 14:08:44 +02:00
76 changed files with 14956 additions and 17297 deletions

View File

@@ -1,65 +1,11 @@
version: 2
defaults: &defaults
docker:
- image: circleci/node:10.9.0
working_directory: ~/project
version: 3
jobs:
install-dependencies:
<<: *defaults
build:
docker:
- image: circleci/node:10
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
- 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
- run: yarn install --frozen-lockfile
- run: ./scripts/test.sh

View File

@@ -1,5 +1,8 @@
coverage/
node_modules/
lib/
build/
typescript/
coverage
flow
node_modules
lib*
build
## Temporary
examples

View File

@@ -1,21 +1,52 @@
{
"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/no-deprecated": "off",
"react/forbid-prop-types": "warn",
"react/prop-types": "off",
"react/require-default-props": "off",
"react/no-unused-prop-types": "off"
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"modules": true
}
}
}

39
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,39 @@
## The issue tracker is reserved for bug reports only.
If you have a question, feature request, or an idea for improving the library or its related tools, please try one of the following resources:
- [Read the documentation](https://reactnavigation.org/)
- [Post an issue to the website repository if you'd like to see a documentation change](http://github.com/react-navigation/website)
- [Post a feature request to Canny](https://react-navigation.canny.io/feature-requests)
- [Write a RFC if you have ideas for how to implement a feature request](https://github.com/react-navigation/rfcs)
- [Get help on Discord chat (#react-navigation on Reactiflux)](https://discord.gg/4xEK3nD) or [on StackOverflow](https://stackoverflow.com/questions/tagged/react-navigation)
- Search for your issue - it may have already been answered or even fixed in the development branch. However, if you find that an old, closed issue still persists in the latest version, you should open a new issue.
Bugs with react-navigation must be reproducible *without any external libraries that operate on it*. This means that if you are attempting to use Redux or MobX with it and you think you have found a bug, you must be able to reproduce it without Redux or MobX in this report. Redux related issues belong in [react-navigation-redux-helpers](https://github.com/react-navigation/react-navigation-redux-helpers), and we do not have any first-class integration with MobX at the moment.
---
### Current Behavior
- What code are you running and what is happening?
- Include a screenshot if it makes sense.
### Expected Behavior
- What do you expect should be happening?
- Include a screenshot if it makes sense.
### 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.
- 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.
### Your Environment
| software | version
| ---------------- | -------
| react-navigation |
| react-native |
| node |
| npm or yarn |

View File

@@ -1,36 +0,0 @@
---
name: Miscellaneous
about: Report an issue which is regarding the core API of React Navigation.
title: ''
labels: bug
assignees: ''
---
**Current Behavior**
- What code are you running and what is happening?
- Include a screenshot or video if it makes sense.
**Expected Behavior**
- What do you expect should be happening?
- Include a screenshot or video if it makes sense.
**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.
- 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.
- Keep the repro code as simple as possible, with the minimum amount of code required to repro the issue.
- Before reporting an issue, make sure you are on latest version of the package.
**Your Environment**
| software | version |
| ---------------- | ------- |
| iOS or Android |
| react-navigation |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -1,38 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Stack Navigator
url: https://github.com/react-navigation/stack/issues/new
about: Submit a bug report for Stack Navigator (react-navigation-stack).
- name: Drawer Navigator
url: https://github.com/react-navigation/drawer/issues/new
about: Submit a bug report for Drawer Navigator (react-navigation-drawer).
- name: Tab Navigator
url: https://github.com/react-navigation/tabs/issues/new
about: Submit a bug report for Bottom Tab Navigator and Material Top Tab Navigator (react-navigation-tabs).
- name: Material Bottom Tab Navigator
url: https://github.com/react-navigation/material-bottom-tabs/issues/new
about: Submit a bug report for Material Bottom Tab Navigator (react-navigation-material-bottom-tabs).
- name: Animated Switch Navigator
url: https://github.com/react-navigation/animated-switch/issues/new
about: Submit a bug report for Animated Switch Navigator (react-navigation-animated-switch).
- name: React Navigation 5
url: https://github.com/react-navigation/navigation-ex/issues/new/choose
about: Submit a bug report for React Navigation 5.
- name: Common mistakes
url: https://reactnavigation.org/docs/en/common-mistakes.html
about: Read about common mistakes and how to fix them.
- name: Documentation
url: https://reactnavigation.org
about: Read the official documentation.
- name: Feature requests
url: https://react-navigation.canny.io/feature-requests
about: Post a feature request on Canny.
- name: StackOverflow
url: https://stackoverflow.com/questions/tagged/react-navigation
about: Ask and answer questions using the react-navigation label.
- name: Reactiflux
url: https://www.reactiflux.com/
about: Chat with other community members in the react-navigation channel.
- name: Write an RFC
url: https://github.com/react-navigation/rfcs
about: Write a RFC if you have ideas for how to implement a feature request.

View File

@@ -1,10 +1,10 @@
Please provide enough information so that others can review your pull request:
**Motivation**
## Motivation
Explain the **motivation** for making this change. What existing problem does the pull request solve?
**Test plan**
## Test plan
Demonstrate the code is solid. Example: the exact commands you ran and their output, screenshots / videos if the pull request changes UI.
@@ -12,6 +12,10 @@ 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 lint --fix` before committing.
Look around. Match the style of the rest of the codebase. Run `yarn format` before committing.
## Changelog
Add an entry under the "Unreleased" heading in [CHANGELOG.md](https://github.com/react-navigation/react-navigation/blob/master/CHANGELOG.md#unreleased) which explains your change.

View File

@@ -1,16 +0,0 @@
name: "Close stale issues and pull requests"
on:
schedule:
- cron: "0 0 * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.'
stale-pr-message: 'Hello 👋, this pull request has been open for more than 2 months with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days.'
exempt-issue-label: 'Keep opened'
exempt-pr-label: 'Keep opened'

View File

@@ -1,5 +1,8 @@
{
"git": {
"increment": "conventional:angular",
"changelogCommand": "conventional-changelog -p angular | tail -n +3",
"safeBump": false,
"src": {
"commitMessage": "chore: release %s",
"tagName": "v%s"
},
@@ -8,10 +11,5 @@
},
"github": {
"release": true
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "angular"
}
}
}

336
CHANGELOG.md Normal file
View File

@@ -0,0 +1,336 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased
- Add missing Flow type exports for `ScrollView` and `NavigationContext`
## [3.11.1]
## Fixes
- Fix `navigationOptions` type from `NavigationScreenProp<NavigationRoute>` to `NavigationScreenConfig<Options>`.
- Fix missing `isFirstRouteInParent` type in typescript and flow.
- Add missing `backTitleVisible` for typescript, `disabled` and `backTitleVisible` for flow definitions in type `HeaderBackButtonProps`
- Add missing `keyboardHidesTabBar` for TypeScript to `TabViewConfig.tabBarOptions`
- Add missing `unmountInactiveRoutes` for TypeScript to `DrawerNavigatorConfig`
## [3.11.0]
## New Features
- Export `SwitchActions`
## [3.10.2]
## Fixes
- Update Flow types - Add `cardShadowEnabled` and `cardOverlayEnabled` to NavigationStackViewConfig
- Upgrade react-navigation-tabs [#5914](https://github.com/react-navigation/react-navigation/issues/5914)
## [3.10.0] - [2019-05-16](https://github.com/react-navigation/react-navigation/releases/tag/3.10.0)
## Removed
- `persistenceKey` no longer automatically saves and restores navigation state using AsyncStorage. Typically this would be a breaking change that would require a major version bump, but because this has always been marked as experimental in the documentation and it is unlikely to impact production apps, we are rolling it in a minor release. `persistenceKey` has been replaced with `persistNavigationState` and `loadNavigationState`. See the diff in docs: https://github.com/react-navigation/react-navigation.github.io/pull/425/files?short_path=b668b1a#diff-b668b1a4201e40b1378036dc012100fe
## Changed
- Removed animations from stack on web
- Ensure that headerMode is float by default on web
## Fixes
- Prevent transitionConfig's useNativeDriver value being overwritten. (https://github.com/react-navigation/stack/commit/8b2af7d94209d4658abd8d799bc78744a1004b4e)
- Update typescript with headerLeftContainerStyle and headerRightContainerStyle
- Update typescript - Add `safeAreaInset` to `BottomTabBarProps`
- Update typescript - `TabBarTop` is now `MaterialTopTabBar`
- Update typescript - Remove `SwitchNavigator`, `TabNavigator` and `StackNavigator`. Added exports for `SceneView` and `SwitchRouter`
- Update typescript - `getLabel` is now `getLabelText` in BottomTabProps and TopTabProps
- Silence deprecated lifecycle warning in Stack Transitioner
## [3.9.0] - [2019-04-23](https://github.com/react-navigation/react-navigation/releases/tag/3.9.0)
## Fixes
- Remove `createTabNavigator` from type definitions
- Add missing types for `DrawerNavigatorConfig`
- Use `preserveFocus` action param rather than matching on specific action types to determine if index needs to be updated if child router changes (https://github.com/react-navigation/react-navigation-core/pull/56)
## [3.8.1] - [2019-04-12](https://github.com/react-navigation/react-navigation/releases/tag/3.8.1)
## Changed
- Add missing type for `enableURLHandling` to TypeScript definition (#5803)
- Update Flow types (#5806)
## [3.8.0] - [2019-04-12](https://github.com/react-navigation/react-navigation/releases/tag/3.8.0)
## Fixes
- `onRefresh` on exported lists `FlatList` and `SectionList` works as expected now (no need to add `refreshControl` prop explicitly)
- On Android, the exported `ScrollView` is now same as the React Native ScrollView (but with scroll-to-top behavior added), whereas on iOS we still use react-native-gesture-handler ScrollView. We can change Android back to react-native-gesture-handler ScrollView when https://github.com/kmagiera/react-native-gesture-handler/issues/560 is resolved.
- Look for `scrollResponderScrollTo` function in our ScrollView, in react-native 0.59 the interface appears to have changed for FlatList such that this is needed. (react-navigation-native#20)
## Changed
- Stack header style improvements for web (react-navigation-stack#104)
## [3.7.1] - [2019-04-10](https://github.com/react-navigation/react-navigation/releases/tag/3.7.1)
## Fixes
- Update Flow types (#5800 and #5801)
- More open `navigationOptions` types for bottom tab navigator config (#5796)
- Fix hit slop for bottom tab bar (react-navigation-tabs#110)
## Added
- Add accessibility role and state to bottom bar (react-navigation-tabs#90)
- Hide tab bar when keyboard is shown (react-navigation-tabs#112)
- Specify default values for getAccessibilityX on tabs (react-navigation-tabs##116)
- Add a isFirstRouteInParent method to navigation object (react-navigation-core#51)
## [3.6.1] - [2019-04-02](https://github.com/react-navigation/react-navigation/releases/tag/3.6.1)
## Fixed
- Move event subscriptions to constructor in `withNavigationFocus` to ensure initial `didFocus` event is received.
## [3.6.0] - [2019-03-31](https://github.com/react-navigation/react-navigation/releases/tag/3.6.0)
## Added
- Export TabBarIconProps, TabBarLabelProps, DrawerIconProps, DrawerLabelProps, ScreenProps and InitialLayout.
- Add `disabled` prop to HeaderBackButton
- Add `StackViewTransitionConfigs.NoAnimation`
- Add `drawerContainerStyle` to navigator config for drawer navigator
## [3.5.1] - [2019-03-19](https://github.com/react-navigation/react-navigation/releases/tag/3.5.1)
## Added
- Export StackGestureContext and DrawerGestureContext
- Add missing type for withOrientation
## Fixed
- Fix header HeaderBackButton title TypeScript type
## [3.5.0] - [2019-03-19](https://github.com/react-navigation/react-navigation/releases/tag/3.5.0)
## Fixed
- Fixed types for `BottomTabBar`
- export `NavigationContext` type
## Changed
- Make 'react-native-gesture-handler' a peer dependency rather than a hard dependency
## [3.4.1] - [2019-03-16](https://github.com/react-navigation/react-navigation/releases/tag/3.4.1)
## Fixed
- Fix missing TypeScript definitions file in release package
## [3.4.0] - [2019-03-15](https://github.com/react-navigation/react-navigation/releases/tag/3.4.0)
## Added
- TypeScript type definition now included in the project.
- Better support for react-native-web in core and stack.
## Fixed
- Default key to null in stack reset action (https://github.com/react-navigation/react-navigation-core/commit/59238160d86284a3353d53af10688fcf3f36004f)
- Fix header back button label and title label scaling. Defaults to false. (https://github.com/react-navigation/react-navigation-stack/commit/c1f1dff465e9eebe274a08e274cf10570045fa23)
## Changed
- Remove react-lifecycles-compat from @react-navigation/core
- NavigationPlayground uses TypeScript
## [3.3.2] - [2019-02-25](https://github.com/react-navigation/react-navigation/releases/tag/3.3.2)
## Fixed
- Updated Flow types (https://github.com/react-navigation/react-navigation/commit/d3040e52b39bc8e91ffc1354d9c5f8c096baf597)
## [3.3.1] - [2019-02-25](https://github.com/react-navigation/react-navigation/releases/tag/3.3.1)
## Fixed
- SafeAreaView bottom inset on iPhone XR and XS fixed. (https://github.com/react-navigation/react-navigation/issues/5625)
## [3.3.0] - [2019-02-16](https://github.com/react-navigation/react-navigation/releases/tag/3.3.0)
## Added
- Pass through `drawerOpenProgress` to drawer content component (https://github.com/react-navigation/react-navigation-drawer/pull/40)
## [3.2.3] - [2019-02-09](https://github.com/react-navigation/react-navigation/releases/tag/3.2.3)
## Fixed
- `await` the result of `onTransitionStart` before starting the transition (https://github.com/react-navigation/react-navigation-stack/pull/79)
## [3.2.2]
- Oops, I skipped it. Nothing here.
## [3.2.1] - [2019-02-09](https://github.com/react-navigation/react-navigation/releases/tag/3.2.1)
## Fixed
- Remove accidental console.log
## [3.2.0] - [2019-02-08](https://github.com/react-navigation/react-navigation/releases/tag/3.2.0)
## Added
- Add support for `backBehavior: history'` and `backBehavior: 'order'` to any navigator based on SwitchRouter (eg: tab navigators). (https://github.com/react-navigation/react-navigation-core/pull/31)
## [3.1.5] - [2019-02-06](https://github.com/react-navigation/react-navigation/releases/tag/3.1.5)
## Fixed
- Revert "Transparent header measurement fix (https://github.com/react-navigation/react-navigation-stack/pull/71)"
## [3.1.4] - [2019-02-05](https://github.com/react-navigation/react-navigation/releases/tag/3.1.4)
## Fixed
- Fix references to onGestureFinish in StackViewLayout, should be onGestureEnd
## [3.1.3] - [2019-02-04](https://github.com/react-navigation/react-navigation/releases/tag/3.1.3)
## Fixed
- Stack navigator properly dismisses and restores keyboard when gesture starts and is cancelled
- Transparent header measurement fix (https://github.com/react-navigation/react-navigation-stack/pull/71)
## [3.1.2] - [2019-02-01](https://github.com/react-navigation/react-navigation/releases/tag/3.1.2)
## Fixed
- Update flow definition for `withNavigation` and `withNavigationFocus` to support `defaultProps`
- Prevent onRef callback be called twice on withNavigationFocus components (https://github.com/react-navigation/react-navigation-core/pull/30)
- Bump react-navigation-drawer version to improve performance - if you use Expo, you will need expo@^32.0.3 to update!
## [3.0.9] - [2018-12-19](https://github.com/react-navigation/react-navigation/releases/tag/3.0.9)
## Fixed
- Intermittent flicker when changing tabs while using react-native-screens fixed by not changing opacity (https://github.com/react-navigation/react-navigation-tabs/pull/80)
- Prevent fading the previous screen on push/pop on Android (https://github.com/react-navigation/react-navigation-stack/pull/73)
## [3.0.8] - [2018-12-08](https://github.com/react-navigation/react-navigation/releases/tag/3.0.8)
## Changed
- Lock create-react-context to 0.2.2
## [3.0.7] - [2018-12-08](https://github.com/react-navigation/react-navigation/releases/tag/3.0.7)
## Changed
- Optimize stack gesture to avoid a setState and reduce unnecessary Animated node creation (https://github.com/react-navigation/react-navigation-stack/pull/70)
## [3.0.6] - [2018-12-06](https://github.com/react-navigation/react-navigation/releases/tag/3.0.6)
## Fixes
- Fix drawer accessibility label when drawer label is not a string
## [3.0.5] - [2018-12-03](https://github.com/react-navigation/react-navigation/releases/tag/3.0.5)
## Fixes
- Fix crash in rare case where onNavigationStateChange on container leads to setState and container has screenProps (https://github.com/react-navigation/react-navigation/issues/5301)
- Expose underlaying ScrollView methods to NavigationAwareScrollable (https://github.com/react-navigation/react-navigation-native/pull/8)
## [3.0.4] - [2018-11-30](https://github.com/react-navigation/react-navigation/releases/tag/3.0.4)
## Changed
- Lock dependencies to exact versions
## Fixes
- Fix crash when screenInterpolator is null (https://github.com/react-navigation/react-navigation-stack/issues/64)
- Fix renderPager override (https://github.com/react-navigation/react-navigation-tabs/pull/70)
## Added
- Accessibility labels on drawer items (https://github.com/react-navigation/react-navigation-drawer/pull/30)
## [3.0.3] - [2018-11-30](https://github.com/react-navigation/react-navigation/releases/tag/3.0.3)
## Fixes
- Fix bug where if you navigate immediately when the navigator is first mounted the stack could get in an invalid state.
- Transparent stack card factors in header height now, even though you probably won't want to use this.
- Fix bug where shadow was still rendered on transparent stack
- Fix gestureResponseDistance custom values being ignored for modal stack
## [3.0.2] - [2018-11-27](https://github.com/react-navigation/react-navigation/releases/tag/3.0.2)
## Fixes
- Fix `drawerLockMode` on drawer navigator
- Fix RTL support in drawer navigator
## [3.0.1] - [2018-11-26](https://github.com/react-navigation/react-navigation/releases/tag/3.0.1)
## Fixes
- fix NavigationTestUtils.js deprecated file import.
- Update `getParam` flow typings to check `key` and `fallback` arguments, as well as return the correct type automatically.
- Fix regression in backgroundColor on cardStyle for stack navigator.
## [3.0.0] - [2018-11-17](https://github.com/react-navigation/react-navigation/releases/tag/3.0.0)
- Changes between the latest 2.x release and 3.0.0 are listed on the blog at https://reactnavigation.org/blog/2018/11/17/react-navigation-3.0.html
# [Previous major versions]
- [2.x](https://github.com/react-navigation/react-navigation/blob/2.x/CHANGELOG.md)
[Unreleased]: Fixed NavigationStackScreenOptions types by adding headerTitleContainerStyle
[Unreleased]: https://github.com/react-navigation/react-navigation/compare/3.10.0...HEAD
[3.10.0]: https://github.com/react-navigation/react-navigation/compare/3.10.0...3.9.0
[3.9.0]: https://github.com/react-navigation/react-navigation/compare/3.8.1...3.9.0
[3.8.1]: https://github.com/react-navigation/react-navigation/compare/3.8.0...3.8.1
[3.8.0]: https://github.com/react-navigation/react-navigation/compare/3.7.1...3.8.0
[3.7.1]: https://github.com/react-navigation/react-navigation/compare/3.6.1...3.7.1
[3.6.1]: https://github.com/react-navigation/react-navigation/compare/3.6.0...3.6.1
[3.6.0]: https://github.com/react-navigation/react-navigation/compare/3.5.1...3.6.0
[3.5.1]: https://github.com/react-navigation/react-navigation/compare/3.5.0...3.5.1
[3.5.0]: https://github.com/react-navigation/react-navigation/compare/3.4.1...3.5.0
[3.4.1]: https://github.com/react-navigation/react-navigation/compare/3.4.0...3.4.1
[3.4.0]: https://github.com/react-navigation/react-navigation/compare/3.3.2...3.4.0
[3.3.2]: https://github.com/react-navigation/react-navigation/compare/3.3.1...3.3.2
[3.3.1]: https://github.com/react-navigation/react-navigation/compare/3.3.0...3.3.1
[3.3.0]: https://github.com/react-navigation/react-navigation/compare/3.2.3...3.3.0
[3.2.3]: https://github.com/react-navigation/react-navigation/compare/3.2.1...3.2.3
[3.2.1]: https://github.com/react-navigation/react-navigation/compare/3.2.0...3.2.1
[3.2.0]: https://github.com/react-navigation/react-navigation/compare/3.1.5...3.2.0
[3.1.5]: https://github.com/react-navigation/react-navigation/compare/3.1.4...3.1.5
[3.1.4]: https://github.com/react-navigation/react-navigation/compare/3.1.3...3.1.4
[3.1.3]: https://github.com/react-navigation/react-navigation/compare/3.1.2...3.1.3
[3.1.2]: https://github.com/react-navigation/react-navigation/compare/3.0.9...3.1.2
[3.0.9]: https://github.com/react-navigation/react-navigation/compare/3.0.8...3.0.9
[3.0.8]: https://github.com/react-navigation/react-navigation/compare/3.0.7...3.0.8
[3.0.7]: https://github.com/react-navigation/react-navigation/compare/3.0.6...3.0.7
[3.0.6]: https://github.com/react-navigation/react-navigation/compare/3.0.5...3.0.6
[3.0.5]: https://github.com/react-navigation/react-navigation/compare/3.0.4...3.0.5
[3.0.4]: https://github.com/react-navigation/react-navigation/compare/3.0.3...3.0.4
[3.0.3]: https://github.com/react-navigation/react-navigation/compare/3.0.2...3.0.3
[3.0.2]: https://github.com/react-navigation/react-navigation/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/react-navigation/react-navigation/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/react-navigation/react-navigation/compare/2.x...3.0.0

39
LICENSE
View File

@@ -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.

View File

@@ -2,7 +2,7 @@
[![npm version](https://badge.fury.io/js/react-navigation.svg)](https://badge.fury.io/js/react-navigation) [![CircleCI badge](https://circleci.com/gh/react-navigation/react-navigation/tree/master.svg?style=shield)](https://circleci.com/gh/react-navigation/react-navigation/tree/master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://reactnavigation.org/docs/contributing.html)
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution based on JavaScript.
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution based on Javascript.
## Installation
@@ -17,10 +17,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.
@@ -49,4 +45,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).

View File

@@ -1,4 +1,3 @@
/* 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.
@@ -7,7 +6,7 @@
const path = require('path');
module.exports = {
process(src, filename) {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};

View File

@@ -1,3 +0,0 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};

View File

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

View File

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

View File

@@ -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": "36.0.0",
"version": "1.0.0",
"primaryColor": "#2196f3",
"platforms": [
"android",
"ios"
]
}
}

View File

@@ -1,45 +0,0 @@
/* eslint-disable import/no-extraneous-dependencies */
const path = require('path');
const fs = require('fs');
const escape = require('escape-string-regexp');
const blacklist = require('metro-config/src/defaults/blacklist');
const root = path.resolve(__dirname, '..');
const pak = JSON.parse(
fs.readFileSync(path.join(root, 'package.json'), 'utf8')
);
const modules = [
'@babel/runtime',
'@expo/vector-icons',
...Object.keys({
...pak.dependencies,
...pak.peerDependencies,
}),
];
module.exports = {
projectRoot: __dirname,
watchFolders: [root],
resolver: {
blacklistRE: blacklist([
new RegExp(`^${escape(path.join(root, 'node_modules'))}\\/.*$`),
]),
extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {}),
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};

View File

@@ -1,38 +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.6",
"@react-native-community/masked-view": "0.1.5",
"@react-navigation/core": "^3.5.1",
"@react-navigation/native": "^3.6.2",
"expo": "^36.0.0",
"expo-asset": "~8.0.0",
"expo-blur": "~8.0.0",
"expo-constants": "~8.0.0",
"hoist-non-react-statics": "^3.3.1",
"react": "16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
"react-native-gesture-handler": "~1.5.0",
"react-native-iphone-x-helper": "^1.2.1",
"react-native-paper": "^3.4.0",
"react-native-reanimated": "~1.4.0",
"react-native-safe-area-context": "0.6.0",
"react-native-screens": "2.0.0-alpha.12",
"react-navigation-drawer": "^2.3.3",
"react-navigation-header-buttons": "^3.0.4",
"react-navigation-stack": "^2.0.4",
"react-navigation-tabs": "^2.6.2"
},
"devDependencies": {
"babel-plugin-module-resolver": "^4.0.0",
"expo-cli": "^3.11.3"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
{
"2597acb02c2c2a7cf6627e6e3570f99612cb9e87847e685e6a60b5668e2799a0": true,
"5e5a970a20c69dd6ecd2e5c3db621effc6e7eba78c972a63dacd69e9e6734616": true,
"69ef6f9ec53cb7b1657de525c6c77f03fcecbe3607d4b6086995c73024a013fe": true,
"33e0eb31a7feec0d570d18432ac02c90520557ee17f021652be26b0a51fb9dcc": true,
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
}

View File

@@ -0,0 +1 @@
*.pbxproj -text

View File

@@ -0,0 +1,63 @@
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
# Visual Studio Code
#
.vscode/
# node.js
#
node_modules/
npm-debug.log
yarn-error.log
# BUCK
buck-out/
\.buckd/
*.keystore
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
# Bundle artifact
*.jsbundle
# Exponent
.expo/*

View File

@@ -19,9 +19,9 @@ import {
ThemeContext,
Themed,
createAppContainer,
createStackNavigator,
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';
@@ -428,6 +428,13 @@ const styles = StyleSheet.create({
color: '#999',
fontSize: 13,
},
image: {
alignSelf: 'center',
height: 120,
marginBottom: 20,
resizeMode: 'contain',
width: 120,
},
item: {
borderBottomWidth: StyleSheet.hairlineWidth,
paddingHorizontal: 16,

View File

@@ -5,8 +5,10 @@ The NavigationPlayground example app includes a variety of patterns and is used
## Usage
```bash
yarn bootstrap # in the react-navigation root directory
yarn example start
yarn # in the react-navigation root directory
cd examples/NavigationPlayground
yarn
yarn start
```
You can view this example application directly on Android phones by visiting scanning the QR code on [this site](https://exp.host/@react-navigation/NavigationPlayground) with the [Expo app](https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en).

View File

@@ -0,0 +1,31 @@
{
"expo": {
"name": "React Navigation Playground",
"description": "Explore various patterns for navigation",
"slug": "NavigationPlayground",
"privacy": "public",
"sdkVersion": "33.0.0",
"platforms": [
"ios",
"android"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./src/assets/icon.png",
"splash": {
"image": "./src/assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "org.reactnavigation.playground"
}
}
}

View File

@@ -0,0 +1,6 @@
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};

View File

@@ -0,0 +1,74 @@
{
"name": "NavigationPlayground",
"version": "0.1.0",
"private": true,
"main": "./node_modules/expo/AppEntry.js",
"scripts": {
"postinstall": "patch-package && rm -rf node_modules/react-navigation/node_modules/react-native && rm -rf node_modules/react-navigation/node_modules/@types && rm -rf node_modules/react-navigation/node_modules/examples && rm -rf node_modules/react-navigation/node_modules/react-native-gesture-handler && rm -rf node_modules/react-navigation/node_modules/react && rm -rf node_modules/react-navigation/examples",
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "jest && tsc",
"tsc": "tsc",
"release": "release-it"
},
"dependencies": {
"expo": "^33.0.7",
"expo-blur": "~5.0.1",
"patch-package": "^6.0.5",
"postinstall-postinstall": "^2.0.0",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
"react-native-gesture-handler": "^1.1.0",
"react-native-iphone-x-helper": "^1.2.0",
"react-native-vector-icons": "^6.1.0",
"react-navigation": "file:../..",
"react-navigation-header-buttons": "^2.1.1"
},
"devDependencies": {
"@types/jest": "23.3.10",
"@types/react-native": "~0.57.38",
"@types/react-native-vector-icons": "^4.6.4",
"@types/react-test-renderer": "16.0.3",
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.50.0",
"react-test-renderer": "16.6.1",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.16.0",
"tslint-react": "^3.6.0",
"typescript": "3.2.1"
},
"jest": {
"preset": "react-native",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
"^.+\\.tsx?$": "ts-jest"
},
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|react-navigation|@react-navigation/.*))"
],
"globals": {
"ts-jest": {
"tsConfig": "tsconfig.jest.json"
}
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"setupFiles": [
"./tests/setup.js"
]
},
"resolutions": {
"react-native-gesture-handler": "^1.1.0"
}
}

View File

@@ -0,0 +1,4 @@
module.exports = {
trailingComma: 'es5',
singleQuote: true,
};

View File

@@ -8,18 +8,16 @@ import {
Text,
View,
} from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import Ionicons from 'react-native-vector-icons/Ionicons';
import {
MaterialTopTabBar,
Themed,
createMaterialTopTabNavigator,
ThemeContext,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import {
createMaterialTopTabNavigator,
MaterialTopTabBar,
} from 'react-navigation-tabs';
import { Button } from './commonComponents/ButtonWithMargin';
interface Props {
@@ -110,7 +108,11 @@ class MaterialTopTabBarWrapper extends React.Component<MaterialTopTabBarProps> {
}
class FeaturedScreen extends React.Component<Props> {
static navigationOptions = {
static navigationOptions = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
tabBarLabel: 'Featured',
tabBarIcon: ({
tintColor,
@@ -127,8 +129,7 @@ class FeaturedScreen extends React.Component<Props> {
style={{ color: tintColor }}
/>
),
};
});
render() {
const { navigation } = this.props;
return (

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { ScrollView, StyleSheet } from 'react-native';
import { ScrollView, StatusBar, StyleSheet, Text } from 'react-native';
import { BorderlessButton } from 'react-native-gesture-handler';
import {
createNavigator,

View File

@@ -1,20 +1,13 @@
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,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import {
createDrawerNavigator,
NavigationDrawerScreenProps,
} from 'react-navigation-drawer';
createStackNavigator,
Themed,
SafeAreaView,
} from 'react-navigation';
import { NavigationScreenProp, NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
@@ -28,13 +21,7 @@ const MyNavScreen = ({
<ScrollView>
<SafeAreaView forceInset={{ top: 'always' }}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => {
// @ts-ignore
navigation.openDrawer();
}}
title="Open drawer"
/>
<Button onPress={() => navigation.openDrawer()} title="Open drawer" />
<Button
onPress={() => navigation.navigate('Email')}
title="Open other screen"
@@ -45,22 +32,26 @@ const MyNavScreen = ({
</ScrollView>
);
const InboxScreen = ({ navigation }: NavigationDrawerScreenProps) => (
<MyNavScreen banner="Inbox Screen" navigation={navigation} />
);
const InboxScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner={'Inbox Screen'} navigation={navigation} />;
InboxScreen.navigationOptions = {
headerTitle: 'Inbox',
};
const EmailScreen = ({ navigation }: NavigationStackScreenProps) => (
<MyNavScreen banner="Email Screen" navigation={navigation} />
);
const DraftsScreen = ({ navigation }: NavigationStackScreenProps) => (
<MyNavScreen banner="Drafts Screen" navigation={navigation} />
);
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',
};
@@ -72,7 +63,7 @@ const InboxStack = createStackNavigator(
},
{
navigationOptions: {
drawerIcon: ({ tintColor }: { tintColor: string }) => (
drawerIcon: ({ tintColor }) => (
<MaterialIcons
name="move-to-inbox"
size={24}
@@ -91,7 +82,7 @@ const DraftsStack = createStackNavigator(
},
{
navigationOptions: {
drawerIcon: ({ tintColor }: { tintColor: string }) => (
drawerIcon: ({ tintColor }) => (
<MaterialIcons
name="drafts"
size={24}

View File

@@ -1,15 +1,12 @@
import React from 'react';
import { ScrollView } from 'react-native';
import {
createStackNavigator,
NavigationScreenProp,
Themed,
SafeAreaView,
NavigationState,
} from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import { NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
@@ -92,24 +89,26 @@ const ProfileNavigator = createStackNavigator(
},
{
defaultNavigationOptions: {
headerLeft: () => null,
headerLeft: null,
},
mode: 'modal',
}
);
const MyHeaderTestScreen = ({ navigation }: NavigationStackScreenProps) => (
<MyNavScreen banner="Full screen view" navigation={navigation} />
);
const MyHeaderTestScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner={`Full screen view`} navigation={navigation} />;
MyHeaderTestScreen.navigationOptions = ({
navigation,
}: NavigationStackScreenProps) => {
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => {
const headerVisible =
navigation.state.params && navigation.state.params.headerVisible;
return {
headerShown: headerVisible,
header: headerVisible ? undefined : null,
title: 'Now you see me',
};
};
@@ -123,7 +122,7 @@ const ModalStack = createStackNavigator(
},
{
defaultNavigationOptions: {
headerShown: false,
header: null,
},
mode: 'modal',
}

View File

@@ -1,5 +1,5 @@
import React, { ReactNode } from 'react';
import { StyleSheet } from 'react-native';
import { StyleSheet, Text } from 'react-native';
import { Themed } from 'react-navigation';
/**

View File

@@ -2,19 +2,18 @@
import * as React from 'react';
import {
createStackNavigator,
NavigationActions,
NavigationEventPayload,
NavigationEventSubscription,
NavigationScreenProp,
NavigationState,
NavigationStateRoute,
SafeAreaView,
StackActions,
Themed,
withNavigation,
} from 'react-navigation';
import {
createStackNavigator,
NavigationStackProp,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import { Button } from './commonComponents/ButtonWithMargin';
import { HeaderButtons } from './commonComponents/HeaderButtons';
import SampleText from './SampleText';
@@ -22,12 +21,12 @@ import SampleText from './SampleText';
const DEBUG = false;
interface MyNavScreenProps {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
banner: React.ReactNode;
}
interface BackButtonProps {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationStateRoute<any>>;
}
class MyBackButton extends React.Component<BackButtonProps, any> {
@@ -100,7 +99,11 @@ class MyNavScreen extends React.Component<MyNavScreenProps> {
}
}
class MyHomeScreen extends React.Component<NavigationStackScreenProps> {
interface MyHomeScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
static navigationOptions = {
title: 'Welcome',
};
@@ -140,9 +143,12 @@ class MyHomeScreen extends React.Component<NavigationStackScreenProps> {
}
}
class MyPhotosScreen extends React.Component<NavigationStackScreenProps> {
interface MyPhotosScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
static navigationOptions = {
headerLeft: () => <MyBackButtonWithNavigation />,
headerLeft: <MyBackButtonWithNavigation />,
title: 'Photos',
};
s0: NavigationEventSubscription | null = null;
@@ -189,7 +195,7 @@ class MyPhotosScreen extends React.Component<NavigationStackScreenProps> {
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${
@@ -199,7 +205,7 @@ const MyProfileScreen = ({
/>
);
MyProfileScreen.navigationOptions = (props: NavigationStackScreenProps) => {
MyProfileScreen.navigationOptions = (props: MyHomeScreenProps) => {
const { navigation } = props;
const { state, setParams } = navigation;
const { params } = state;
@@ -207,7 +213,7 @@ MyProfileScreen.navigationOptions = (props: NavigationStackScreenProps) => {
headerBackImage: params!.headerBackImage,
// Render a button on the right side of the header.
// When pressed switches the screen to edit mode.
headerRight: () => (
headerRight: (
<HeaderButtons>
<HeaderButtons.Item
title={params!.mode === 'edit' ? 'Done' : 'Edit'}
@@ -221,18 +227,23 @@ MyProfileScreen.navigationOptions = (props: NavigationStackScreenProps) => {
};
};
const SimpleStack = createStackNavigator({
Home: {
screen: MyHomeScreen,
const SimpleStack = createStackNavigator(
{
Home: {
screen: MyHomeScreen,
},
Photos: {
path: 'photos/:name',
screen: MyPhotosScreen,
},
Profile: {
path: 'people/:name',
screen: MyProfileScreen,
},
},
Photos: {
path: 'photos/:name',
screen: MyPhotosScreen,
},
Profile: {
path: 'people/:name',
screen: MyProfileScreen,
},
});
{
// headerLayoutPreset: 'center',
}
);
export default SimpleStack;

View File

@@ -1,16 +1,15 @@
import React from 'react';
import { Ionicons } from '@expo/vector-icons';
import Ionicons from 'react-native-vector-icons/Ionicons';
import {
createBottomTabNavigator,
FlatList,
NavigationEventSubscription,
NavigationScreenProp,
SafeAreaView,
Themed,
ScrollView,
NavigationEventPayload,
NavigationState,
} from 'react-navigation';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import { NavigationEventPayload, NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
@@ -38,11 +37,7 @@ const MyNavScreen = ({
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
{TEXT.split('\n').map((p, n) => (
<Themed.Text
// eslint-disable-next-line react/no-array-index-key
key={n}
style={{ marginVertical: 10, marginHorizontal: 8 }}
>
<Themed.Text key={n} style={{ marginVertical: 10, marginHorizontal: 8 }}>
{p}
</Themed.Text>
))}
@@ -51,15 +46,17 @@ const MyNavScreen = ({
</ScrollView>
);
const MyListScreen = () => (
const MyListScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<FlatList
data={TEXT.split('\n')}
style={{ paddingTop: 10 }}
keyExtractor={(_, index) => index.toString()}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item }) => (
<Themed.Text
style={{ fontSize: 16, marginVertical: 10, marginHorizontal: 8 }}
>
<Themed.Text style={{ fontSize: 16, marginVertical: 10, marginHorizontal: 8 }}>
{item}
</Themed.Text>
)}
@@ -75,6 +72,7 @@ const MyHomeScreen = ({
MyHomeScreen.navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
@@ -82,7 +80,7 @@ MyHomeScreen.navigationOptions = {
horizontal: boolean;
}) => (
<Ionicons
name="ios-home"
name={'ios-home'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
@@ -102,6 +100,7 @@ class MyPeopleScreen extends React.Component<MyPeopleScreenProps> {
static navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
@@ -109,7 +108,7 @@ class MyPeopleScreen extends React.Component<MyPeopleScreenProps> {
horizontal: boolean;
}) => (
<Ionicons
name="ios-people"
name={'ios-people'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
@@ -148,6 +147,7 @@ class MyChatScreen extends React.Component<MyChatScreenProps> {
static navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
@@ -155,7 +155,7 @@ class MyChatScreen extends React.Component<MyChatScreenProps> {
horizontal: boolean;
}) => (
<Ionicons
name="ios-chatboxes"
name={'ios-chatboxes'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
@@ -196,6 +196,7 @@ const MySettingsScreen = ({
MySettingsScreen.navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
@@ -203,7 +204,7 @@ MySettingsScreen.navigationOptions = {
horizontal: boolean;
}) => (
<Ionicons
name="ios-settings"
name={'ios-settings'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>

View File

@@ -1,15 +1,13 @@
import * as React from 'react';
import { Button, Image, StyleSheet } from 'react-native';
import {
createStackNavigator,
NavigationScreenProp,
NavigationState,
NavigationScreenConfigProps,
Themed,
SafeAreaView,
} from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import SampleText from './SampleText';
interface MyNavScreenProps {
@@ -52,7 +50,7 @@ interface MyHomeScreenProps {
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
static navigationOptions = {
headerBackTitleVisible: false,
headerBackTitle: null,
title: 'Welcome',
};
@@ -65,14 +63,13 @@ class MyHomeScreen extends React.Component<MyHomeScreenProps> {
interface MyPhotosScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
static navigationOptions = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
headerBackTitleVisible: false,
headerBackTitle: null,
title: `${navigation.state.params!.name}'s photos`,
});
@@ -95,7 +92,6 @@ class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
interface MyProfileScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyProfileScreen extends React.Component<MyProfileScreenProps> {
static navigationOptions = {
title: 'Profile',
@@ -128,8 +124,8 @@ const StackWithCustomHeaderBackImage = createStackNavigator(
},
},
{
defaultNavigationOptions: ({ theme }: NavigationStackScreenProps) => ({
headerBackImage: () => (
defaultNavigationOptions: ({ theme }: NavigationScreenConfigProps) => ({
headerBackImage: (
<MyCustomHeaderBackImage
style={[
styles.myCustomHeaderBackImageAlt,

View File

@@ -1,15 +1,19 @@
import * as React from 'react';
import { SafeAreaView, Themed } from 'react-navigation';
import { StatusBar } from 'react-native';
import {
createStackNavigator,
NavigationStackScreenProps,
TransitionPresets,
HeaderStyleInterpolators,
} from 'react-navigation-stack';
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
class HomeScreen extends React.Component<NavigationStackScreenProps> {
interface NavScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class HomeScreen extends React.Component<NavScreenProps> {
static navigationOptions = {
title: 'Welcome',
};
@@ -26,13 +30,13 @@ class HomeScreen extends React.Component<NavigationStackScreenProps> {
title="Push screen with no header"
/>
<Button onPress={() => navigation.goBack(null)} title="Go Home" />
<Themed.StatusBar />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
class OtherScreen extends React.Component<NavigationStackScreenProps> {
class OtherScreen extends React.Component<NavScreenProps> {
static navigationOptions = {
title: 'Your title here',
};
@@ -53,13 +57,13 @@ class OtherScreen extends React.Component<NavigationStackScreenProps> {
/>
<Button onPress={() => pop()} title="Pop" />
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<Themed.StatusBar />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
class ScreenWithLongTitle extends React.Component<NavigationStackScreenProps> {
class ScreenWithLongTitle extends React.Component<NavScreenProps> {
static navigationOptions = {
title: "Another title that's kind of long",
};
@@ -72,15 +76,15 @@ class ScreenWithLongTitle extends React.Component<NavigationStackScreenProps> {
<SafeAreaView style={{ paddingTop: 30 }}>
<Button onPress={() => pop()} title="Pop" />
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<Themed.StatusBar />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
class ScreenWithNoHeader extends React.Component<NavigationStackScreenProps> {
class ScreenWithNoHeader extends React.Component<NavScreenProps> {
static navigationOptions = {
headerShown: false,
header: null,
title: 'No Header',
};
@@ -93,7 +97,7 @@ class ScreenWithNoHeader extends React.Component<NavigationStackScreenProps> {
<Button onPress={() => push('Other')} title="Push another screen" />
<Button onPress={() => pop()} title="Pop" />
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<Themed.StatusBar />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
@@ -107,10 +111,7 @@ const StackWithHeaderPreset = createStackNavigator(
ScreenWithNoHeader,
},
{
defaultNavigationOptions: {
...TransitionPresets.SlideFromRightIOS,
headerStyleInterpolator: HeaderStyleInterpolators.forUIKit,
},
headerTransitionPreset: 'uikit',
}
);

View File

@@ -1,26 +1,26 @@
import * as React from 'react';
import { Platform, ScrollView, StyleSheet, View } from 'react-native';
import { BlurView } from 'expo-blur';
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
import {
NavigationEventPayload,
NavigationEventSubscription,
Themed,
SupportedThemes,
} from 'react-navigation';
import { isIphoneX } from 'react-native-iphone-x-helper';
import {
createStackNavigator,
HeaderStyleInterpolators,
NavigationStackScreenProps,
NavigationStackProp,
TransitionPresets,
} from 'react-navigation-stack';
Header,
HeaderStyleInterpolator,
NavigationEventPayload,
NavigationScreenConfigProps,
NavigationEventSubscription,
NavigationScreenProp,
NavigationState,
Themed,
SupportedThemes,
TransitionConfig,
} from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import { HeaderButtons } from './commonComponents/HeaderButtons';
import SampleText from './SampleText';
interface MyNavScreenProps {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
banner: React.ReactNode;
}
@@ -56,8 +56,15 @@ class MyNavScreen extends React.Component<MyNavScreenProps> {
// 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 =
getStatusBarHeight() + Platform.select({ ios: 44, default: 56 });
Platform.OS === 'ios'
? BASE_HEADER_HEIGHT + NOTCH_HEIGHT
: BASE_HEADER_HEIGHT + 20;
return Platform.select({
android: {
@@ -74,7 +81,7 @@ class MyNavScreen extends React.Component<MyNavScreenProps> {
}
interface MyHomeScreenProps {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
}
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
@@ -118,7 +125,7 @@ class MyHomeScreen extends React.Component<MyHomeScreenProps> {
}
interface MyPhotosScreenProps {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
}
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
static navigationOptions = {
@@ -168,7 +175,7 @@ class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params!.mode === 'edit' ? 'Now Editing ' : ''}${
@@ -179,19 +186,17 @@ const MyProfileScreen = ({
);
MyProfileScreen.navigationOptions = (props: {
navigation: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
theme: SupportedThemes;
}) => {
const { navigation, theme } = props;
const { state, setParams } = navigation;
const { params } = state;
return {
headerBackImage: params!.headerBackImage
? () => params!.headerBackImage
: undefined,
headerBackImage: params!.headerBackImage,
// Render a button on the right side of the header.
// When pressed switches the screen to edit mode.
headerRight: () => (
headerRight: (
<HeaderButtons>
<HeaderButtons.Item
color={theme === 'light' ? '#000' : '#fff'}
@@ -221,9 +226,8 @@ const StackWithTranslucentHeader = createStackNavigator(
},
},
{
defaultNavigationOptions: ({ theme }: NavigationStackScreenProps) => ({
...TransitionPresets.SlideFromRightIOS,
headerBackground: () =>
defaultNavigationOptions: ({ theme }: NavigationScreenConfigProps) => ({
headerBackground:
Platform.OS === 'ios' ? (
<BlurView
style={{ flex: 1 }}
@@ -237,8 +241,15 @@ const StackWithTranslucentHeader = createStackNavigator(
borderBottomWidth: StyleSheet.hairlineWidth,
},
headerTransparent: true,
headerStyleInterpolator: HeaderStyleInterpolators.forUIKit,
}),
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,
} as TransitionConfig),
}
);

View File

@@ -1,13 +1,14 @@
import React from 'react';
import { Text, View } from 'react-native';
import { Themed } from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import { StatusBar, Text, View } from 'react-native';
import { createStackNavigator, NavigationScreenProp } from 'react-navigation';
import { NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
class HomeScreen extends React.Component<NavigationStackScreenProps> {
interface Props {
navigation: NavigationScreenProp<NavigationState & any>;
}
class HomeScreen extends React.Component<Props, any> {
render() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
@@ -26,18 +27,15 @@ class HomeScreen extends React.Component<NavigationStackScreenProps> {
title="Go back to other examples"
onPress={() => this.props.navigation.goBack(null)}
/>
<Themed.StatusBar />
<StatusBar barStyle="default" />
</View>
);
}
}
class ProfileScreen extends React.Component<
NavigationStackScreenProps<{ homeKey: string }>
> {
class ProfileScreen extends React.Component<any, any> {
render() {
const homeKey = this.props.navigation.getParam('homeKey');
const { homeKey } = this.props.navigation.state.params;
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Profile</Text>
@@ -62,7 +60,7 @@ class ProfileScreen extends React.Component<
}
}
class SettingsScreen extends React.Component<NavigationStackScreenProps> {
class SettingsScreen extends React.Component<Props, any> {
render() {
const { homeKey } = this.props.navigation.state.params!;

View File

@@ -1,19 +1,15 @@
import React from 'react';
import { Text } from 'react-native';
import { StatusBar, Text } from 'react-native';
import {
Themed,
createBottomTabNavigator,
createStackNavigator,
NavigationScreenProp,
NavigationState,
SafeAreaView,
ScrollView,
} from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenProps,
NavigationStackProp,
} from 'react-navigation-stack';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import { Ionicons } from '@expo/vector-icons';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
@@ -23,7 +19,7 @@ Nulla convallis pulvinar hendrerit. Nulla mattis sem et aliquam ultrices. Nam eg
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: NavigationStackProp;
navigation: NavigationScreenProp<NavigationState>;
banner: string;
}
@@ -51,20 +47,23 @@ class MyNavScreen extends React.Component<Props> {
<Button onPress={() => navigation.goBack(null)} title="Go back" />
{TEXT.split('\n').map((p, n) => (
// eslint-disable-next-line react/no-array-index-key
<Text key={n} style={{ marginVertical: 10, marginHorizontal: 8 }}>
{p}
</Text>
))}
</SafeAreaView>
<Themed.StatusBar />
<StatusBar barStyle="default" />
</ScrollView>
);
}
}
const MyProfileScreen = ({ navigation }: NavigationStackScreenProps) => (
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params!.name}s Profile`}
navigation={navigation}

View File

@@ -1,17 +1,14 @@
import React from 'react';
import { ScrollView, StatusBar } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import Ionicons from 'react-native-vector-icons/Ionicons';
import {
createBottomTabNavigator,
createStackNavigator,
getActiveChildNavigationOptions,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import { createBottomTabNavigator } from 'react-navigation-tabs';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
@@ -62,9 +59,9 @@ const MyProfileScreen = ({
const MyNotificationsSettingsScreen = ({
navigation,
}: NavigationStackScreenProps) => (
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
);
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
const MySettingsScreen = ({
navigation,
@@ -144,7 +141,11 @@ const StacksOverTabs = createStackNavigator({
screen: MyNotificationsSettingsScreen,
},
Profile: {
navigationOptions: ({ navigation }: NavigationStackScreenProps) => ({
navigationOptions: ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
title: `${navigation.state.params!.name}'s Profile!`,
}),
path: '/people/:name',

View File

@@ -7,18 +7,13 @@ import {
View,
} from 'react-native';
import {
createMaterialTopTabNavigator,
createStackNavigator,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import {
createMaterialTopTabNavigator,
MaterialTopTabBar,
} from 'react-navigation-tabs';
import { MaterialTopTabBar } from 'react-navigation-tabs';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
@@ -67,7 +62,11 @@ const MyHomeScreen = ({
/>
);
const MyProfileScreen = ({ navigation }: NavigationStackScreenProps) => (
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params!.name}s Profile`}
navigation={navigation}
@@ -76,9 +75,9 @@ const MyProfileScreen = ({ navigation }: NavigationStackScreenProps) => (
const MyNotificationsSettingsScreen = ({
navigation,
}: NavigationStackScreenProps) => (
<MyNavScreen banner="Notifications Screen" navigation={navigation} />
);
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
const MySettingsScreen = ({
navigation,
@@ -147,7 +146,7 @@ const StackNavigator = createStackNavigator(
Root: {
screen: TabNavigator,
navigationOptions: {
headerShown: false,
header: null,
},
},
NotifSettings: {
@@ -158,7 +157,11 @@ const StackNavigator = createStackNavigator(
},
Profile: {
screen: MyProfileScreen,
navigationOptions: ({ navigation }: NavigationStackScreenProps) => ({
navigationOptions: ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
title: `${navigation.state.params!.name}'s Profile!`,
}),
},

View File

@@ -2,18 +2,15 @@ import React from 'react';
import {
ActivityIndicator,
AsyncStorage,
StatusBar,
StyleSheet,
View,
Platform,
} from 'react-native';
import { Themed, createSwitchNavigator } from 'react-navigation';
import {
createStackNavigator,
NavigationStackScreenProps,
} from 'react-navigation-stack';
import { createStackNavigator, createSwitchNavigator } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
class SignInScreen extends React.Component<NavigationStackScreenProps> {
class SignInScreen extends React.Component<any, any> {
static navigationOptions = {
title: 'Please sign in',
};
@@ -26,7 +23,7 @@ class SignInScreen extends React.Component<NavigationStackScreenProps> {
title="Go back to other examples"
onPress={() => this.props.navigation.goBack(null)}
/>
<Themed.StatusBar />
<StatusBar barStyle="default" />
</View>
);
}
@@ -37,7 +34,7 @@ class SignInScreen extends React.Component<NavigationStackScreenProps> {
};
}
class HomeScreen extends React.Component<NavigationStackScreenProps> {
class HomeScreen extends React.Component<any, any> {
static navigationOptions = {
title: 'Welcome to the app!',
};
@@ -47,7 +44,7 @@ class HomeScreen extends React.Component<NavigationStackScreenProps> {
<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 />
<StatusBar barStyle="default" />
</View>
);
}
@@ -57,17 +54,12 @@ class HomeScreen extends React.Component<NavigationStackScreenProps> {
};
signOutAsync = async () => {
if (Platform.OS === 'ios') {
await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove);
} else {
await AsyncStorage.clear();
}
Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
this.props.navigation.navigate('Auth');
};
}
class OtherScreen extends React.Component<NavigationStackScreenProps> {
class OtherScreen extends React.Component<any, any> {
static navigationOptions = {
title: 'Lots of features here',
};
@@ -76,18 +68,13 @@ class OtherScreen extends React.Component<NavigationStackScreenProps> {
return (
<View style={styles.container}>
<Button title="I'm done, sign me out" onPress={this.signOutAsync} />
<Themed.StatusBar />
<StatusBar barStyle="default" />
</View>
);
}
signOutAsync = async () => {
if (Platform.OS === 'ios') {
await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove);
} else {
await AsyncStorage.clear();
}
Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
this.props.navigation.navigate('Auth');
};
}
@@ -107,7 +94,7 @@ class LoadingScreen extends React.Component<any, any> {
return (
<View style={styles.container}>
<ActivityIndicator />
<Themed.StatusBar />
<StatusBar barStyle="default" />
</View>
);
}

View File

@@ -1,6 +1,7 @@
import React from 'react';
import { MaterialIcons } from '@expo/vector-icons';
import { createDrawerNavigator } from 'react-navigation-drawer';
import { Platform, ScrollView } from 'react-native';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import { createDrawerNavigator } from 'react-navigation';
import SimpleTabs from './SimpleTabs';
import StacksOverTabs from './StacksOverTabs';

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 939 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

View File

@@ -1,49 +1,42 @@
import React from 'react';
import {
AccessibilityStates,
Platform,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import { AccessibilityState, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
export interface ButtonProps {
/**
* Text to display inside the button
*/
title: string;
title: string,
/**
* Handler to be called when the user taps the button
*/
onPress: (event?: any) => void;
onPress: (event?: any) => void,
/**
* Color of the text (iOS), or background color of the button (Android)
*/
color?: string;
color?: string,
/**
* TV preferred focus (see documentation for the View component).
*/
hasTVPreferredFocus?: boolean;
hasTVPreferredFocus?: boolean,
/**
* Text to display for blindness accessibility features
*/
accessibilityLabel?: string;
accessibilityLabel?: string,
/**
* If true, disable all interactions for this component.
*/
disabled?: boolean;
disabled?: boolean,
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string;
}
testID?: string,
};
/**
* A basic button component that should render nicely on any platform. Supports
@@ -88,7 +81,7 @@ export default class Button extends React.Component<ButtonProps> {
buttonStyles.push({ backgroundColor: color });
}
}
const accessibilityStates: AccessibilityStates[] = [];
const accessibilityStates: AccessibilityState[] = [];
if (disabled) {
buttonStyles.push(styles.buttonDisabled);
textStyles.push(styles.textDisabled);
@@ -106,7 +99,9 @@ export default class Button extends React.Component<ButtonProps> {
onPress={onPress}
>
<View style={buttonStyles}>
<Text style={textStyles}>{formattedTitle}</Text>
<Text style={textStyles}>
{formattedTitle}
</Text>
</View>
</TouchableOpacity>
);

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import { Platform, StyleSheet, View } from 'react-native';
import BaseButton, { ButtonProps } from './Button';
export const Button = (props: ButtonProps) => (

View File

@@ -1,11 +1,9 @@
import DefaultHeaderButtons from 'react-navigation-header-buttons';
import * as React from 'react';
import {
HeaderButtons as DefaultHeaderButtons,
Item,
} from 'react-navigation-header-buttons';
import { Platform } from 'react-native';
export class HeaderButtons extends React.PureComponent {
static Item = Item;
static Item = DefaultHeaderButtons.Item;
render() {
return (

View File

@@ -0,0 +1,46 @@
import { NativeModules } from 'react-native';
NativeModules.ReactLocalization = {
language: 'en',
};
// TODO: remove these mocks!
jest.mock('react-native-gesture-handler', () => {
const View = require('react-native/Libraries/Components/View/View');
return {
Swipeable: View,
DrawerLayout: View,
State: {},
ScrollView: View,
Slider: View,
Switch: View,
TextInput: View,
ToolbarAndroid: View,
ViewPagerAndroid: View,
DrawerLayoutAndroid: View,
WebView: View,
NativeViewGestureHandler: View,
TapGestureHandler: View,
FlingGestureHandler: View,
ForceTouchGestureHandler: View,
LongPressGestureHandler: View,
PanGestureHandler: View,
PinchGestureHandler: View,
RotationGestureHandler: View,
/* Buttons */
RawButton: View,
BaseButton: View,
RectButton: View,
BorderlessButton: View,
/* Other */
FlatList: View,
gestureHandlerRootHOC: jest.fn(),
Directions: {},
};
});
jest.mock('react-native-gesture-handler/DrawerLayout', () => {
return {
Directions: null,
};
});

View File

@@ -0,0 +1,7 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"jsx": "react",
"module": "commonjs"
}
}

View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-native",
"lib": ["es6"],
"moduleResolution": "node",
"noEmit": true,
"strict": true,
"target": "esnext"
},
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,11 @@
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"rules": {
"jsx-no-lambda": false,
"member-access": false,
"interface-name": false,
"max-classes-per-file": false,
"no-console": false,
"object-literal-sort-keys": false
}
}

View File

@@ -0,0 +1,9 @@
declare module 'react-navigation-tabs' {
import * as React from 'react';
interface MaterialTopbarProperties {
// it actually has some properties but yolo
}
export class MaterialTopTabBar extends React.Component<MaterialTopbarProperties> {}
}

File diff suppressed because it is too large Load Diff

1310
flow/react-navigation.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,7 @@
/* eslint-env jest */
/**
* @flow
* eslint-env jest
*/
import React from 'react';
@@ -8,7 +11,9 @@ jest.mock('Linking', () => ({
removeEventListener: jest.fn(),
openURL: jest.fn(),
canOpenURL: jest.fn(),
getInitialURL: jest.fn().mockImplementation(value => Promise.resolve(value)),
getInitialURL: jest
.fn()
.mockImplementation((value: string) => Promise.resolve(value)),
}));
// See https://github.com/facebook/react-native/issues/11659

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation",
"version": "4.1.0",
"version": "3.11.2",
"description": "Routing and navigation for your React Native apps",
"main": "src/react-navigation.js",
"types": "typescript/react-navigation.d.ts",
@@ -8,14 +8,19 @@
"url": "git@github.com:react-navigation/react-navigation.git",
"type": "git"
},
"author": "Adam Miskiewicz <adam@sk3vy.com>, Eric Vicenti <ericvicenti@gmail.com>, Brent Vatne <brent@expo.io>, Satyajit Sahoo <satyajit.happy@gmail.com>",
"license": "MIT",
"author": "Adam Miskiewicz <adam@sk3vy.com>, Eric Vicenti <ericvicenti@gmail.com>, Brent Vatne <brent@expo.io>",
"license": "BSD-2-Clause",
"scripts": {
"bootstrap": "yarn example && yarn",
"example": "yarn --cwd example",
"test": "jest",
"lint": "eslint . --ext '.js,.ts,.tsx'",
"typescript": "tsc --noEmit",
"start": "npm run ios",
"ios": "cd examples/NavigationPlayground && yarn && yarn ios",
"android": "cd examples/NavigationPlayground && yarn && yarn android",
"test": "npm run lint && npm run jest",
"codecov": "codecov",
"jest": "jest",
"test-update-snapshot": "jest --updateSnapshot",
"lint": "eslint .",
"format": "eslint --fix .",
"precommit": "lint-staged",
"release": "release-it"
},
"publishConfig": {
@@ -31,28 +36,37 @@
"react-native": "*"
},
"dependencies": {
"@react-navigation/core": "^3.5.2",
"@react-navigation/native": "^3.6.3"
"@react-navigation/core": "~3.5.1",
"@react-navigation/native": "~3.6.2",
"react-navigation-drawer": "~1.4.0",
"react-navigation-stack": "1.5.3",
"react-navigation-tabs": "~1.2.0"
},
"devDependencies": {
"@commitlint/config-conventional": "^8.3.4",
"@release-it/conventional-changelog": "^1.1.0",
"@types/jest": "^24.0.25",
"@types/react": "^16.9.17",
"@types/react-native": "^0.60.27",
"codecov": "^3.6.1",
"commitlint": "^8.3.4",
"eslint": "^6.8.0",
"eslint-config-satya164": "^3.1.5",
"eslint-plugin-react-native-globals": "^0.1.0",
"husky": "^3.1.0",
"jest": "^24.9.0",
"prettier": "^1.19.1",
"react": "16.8.3",
"react-native": "~0.59.8",
"react-test-renderer": "16.8.3",
"release-it": "^12.4.3",
"typescript": "^3.7.4"
"@types/react-native": "~0.57.38",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-eslint": "^7.2.3",
"babel-jest": "^22.4.1",
"babel-preset-react-native": "^2.1.0",
"codecov": "^2.2.0",
"eslint": "^4.2.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.1.0",
"husky": "^0.14.3",
"jest": "^24.5.0",
"jest-expo": "^25.1.0",
"lint-staged": "^4.2.1",
"prettier": "^1.12.1",
"prettier-eslint": "^8.8.1",
"react": "16.6.1",
"react-native": "~0.57.7",
"react-native-vector-icons": "^4.2.0",
"react-test-renderer": "^16.0.0",
"release-it": "^7.6.1"
},
"jest": {
"notify": true,
@@ -76,20 +90,17 @@
"\\.png$": "<rootDir>/assetsTransformer.js"
},
"modulePathIgnorePatterns": [
"<rootDir>/example/"
"<rootDir>/examples/"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|react-navigation-stack|@react-navigation/core|@react-navigation/native)"
"node_modules/(?!(jest-)?react-native|react-clone-referenced-element|react-navigation-deprecated-tab-navigator|react-navigation-stack|@react-navigation/core|@react-navigation/native)"
]
},
"prettier": {
"trailingComma": "es5",
"singleQuote": true
},
"husky": {
"hooks": {
"pre-commit": "yarn typescript && yarn lint && yarn test",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
"lint-staged": {
"*.js": [
"eslint --fix",
"prettier --write flow/react-navigation.js",
"git add"
]
}
}

6
scripts/build-push-docker.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
set -eo pipefail
docker build -t reactcommunity/node-ci:8.4.0-0 -f ./ci.Dockerfile .
docker push reactcommunity/node-ci:8.4.0-0

19
scripts/ci.Dockerfile Normal file
View File

@@ -0,0 +1,19 @@
FROM node:8.4.0
RUN apt-get update -y && \
apt-get install -y ocaml libelf1 && \
rm -rf /var/lib/apt/lists/* && \
curl -o- -L https://yarnpkg.com/install.sh | bash && \
yarn global add exp
RUN git clone https://github.com/facebook/watchman.git \
&& cd watchman \
&& git checkout v4.7.0 \
&& apt-get update -y \
&& apt-get install -y autoconf automake build-essential python-dev \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install \
&& apt-get remove --purge -y autoconf automake build-essential python-dev \
&& rm -rf /var/lib/apt/lists/*

7
scripts/test.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -eo pipefail
case $CIRCLE_NODE_INDEX in
0) yarn test && yarn codecov ;;
esac

View File

@@ -1,158 +0,0 @@
/* eslint-disable getter-return, import/no-commonjs */
const throwError = (message, page) => {
throw new Error(
`${message}. See https://reactnavigation.org/docs/${page}.html for more details.`
);
};
module.exports = {
get createNavigationContainer() {
throw new Error(
'`createNavigationContainer()` has been removed. Use `createAppContainer()` instead. You can also import createAppContainer directly from `@react-navigation/native`.'
);
},
get createStackNavigator() {
throwError(
'`createStackNavigator()` has been moved to `react-navigation-stack`',
'stack-navigator'
);
},
get createBottomTabNavigator() {
throwError(
'`createBottomTabNavigator()` has been moved to `react-navigation-tabs`',
'bottom-tab-navigator'
);
},
get createMaterialTopTabNavigator() {
throwError(
'`createMaterialTopTabNavigator()` has been moved to `react-navigation-tabs`',
'material-top-tab-navigator'
);
},
get createDrawerNavigator() {
throwError(
'`createDrawerNavigator()` has been moved to `react-navigation-drawer`',
'drawer-navigator'
);
},
// Gesture contexts
get StackGestureContext() {
throwError(
'`StackGestureContext` has been moved to `react-navigation-stack`',
'stack-navigator'
);
},
get DrawerGestureContext() {
throwError(
'`DrawerGestureContext` has been moved to `react-navigation-drawer`',
'stack-navigator'
);
},
// Routers and Actions
get DrawerRouter() {
throwError(
'`DrawerRouter` has been moved to `react-navigation-drawer`',
'drawer-navigator'
);
},
get DrawerActions() {
throwError(
'`DrawerActions` has been moved to `react-navigation-drawer`',
'drawer-navigator'
);
},
// Views
get Transitioner() {
throwError('`Transitioner` has been removed.', 'stack-navigator');
},
get StackView() {
throwError('`StackView` has been removed', 'stack-navigator');
},
get StackViewCard() {
throwError('`StackViewCard` has been removed', 'stack-navigator');
},
get StackViewTransitionConfigs() {
throwError(
'`StackViewTransitionConfigs` has been removed',
'stack-navigator'
);
},
// Header
get Header() {
throwError(
'`Header` has been moved to `react-navigation-stack`',
'stack-navigator'
);
},
get HeaderTitle() {
throwError(
'`HeaderTitle` has been moved to `react-navigation-stack`',
'stack-navigator'
);
},
get HeaderBackButton() {
throwError(
'`HeaderBackButton` has been moved to `react-navigation-stack`',
'stack-navigator'
);
},
get HeaderStyleInterpolator() {
throwError('`HeaderStyleInterpolator` has been removed', 'stack-navigator');
},
// DrawerView
get DrawerView() {
throwError(
'`createStackNavigator()` has been moved to `react-navigation-drawer`',
'stack-navigator'
);
},
get DrawerItems() {
throwError(
'`DrawerItems` has been moved to `react-navigation-drawer`',
'drawer-navigator'
);
},
get DrawerSidebar() {
throwError(
'`DrawerSidebar` has been moved to `react-navigation-drawer`',
'drawer-navigator'
);
},
// Tabs
get BottomTabBar() {
throwError(
'`BottomTabBar` has been moved to `react-navigation-tabs`',
'bottom-tab-navigator'
);
},
get MaterialTopTabBar() {
throwError(
'`MaterialTopTabBar` has been moved to `react-navigation-tabs`',
'material-top-tab-navigator'
);
},
};

View File

@@ -1,29 +1,208 @@
export * from '@react-navigation/core';
export * from '@react-navigation/native';
/* eslint global-require: 0 */
// Export each item individually so that they can be evaluated lazily
// https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#lazy
export {
createNavigationContainer,
createStackNavigator,
createBottomTabNavigator,
createMaterialTopTabNavigator,
createDrawerNavigator,
StackGestureContext,
DrawerGestureContext,
DrawerRouter,
DrawerActions,
Transitioner,
StackView,
StackViewCard,
StackViewTransitionConfigs,
Header,
HeaderTitle,
HeaderBackButton,
HeaderStyleInterpolator,
DrawerView,
DrawerItems,
DrawerSidebar,
BottomTabBar,
MaterialTopTabBar,
} from './deprecations';
module.exports = {
// Themes
get useTheme() {
return require('@react-navigation/core').useTheme;
},
get ThemeContext() {
return require('@react-navigation/core').ThemeContext;
},
get ThemeColors() {
return require('@react-navigation/core').ThemeColors;
},
get Themed() {
return require('@react-navigation/native').Themed;
},
// Native
get createAppContainer() {
return require('@react-navigation/native').createAppContainer;
},
get createNavigationContainer() {
console.warn(
'`createNavigationContainer()` has been deprecated, please use `createAppContainer()` instead. You can also import createAppContainer directly from @react-navigation/native'
);
return require('@react-navigation/native').createAppContainer;
},
get createKeyboardAwareNavigator() {
return require('@react-navigation/native').createKeyboardAwareNavigator;
},
get createNavigationAwareScrollable() {
return require('@react-navigation/native').createNavigationAwareScrollable;
},
get ScrollView() {
return require('@react-navigation/native').ScrollView;
},
get FlatList() {
return require('@react-navigation/native').FlatList;
},
get SectionList() {
return require('@react-navigation/native').SectionList;
},
get ResourceSavingSceneView() {
return require('@react-navigation/native').ResourceSavingSceneView;
},
get SafeAreaView() {
return require('@react-navigation/native').SafeAreaView;
},
get withOrientation() {
return require('@react-navigation/native').withOrientation;
},
// Core
get createNavigator() {
return require('@react-navigation/core').createNavigator;
},
get StateUtils() {
return require('@react-navigation/core').StateUtils;
},
get getNavigation() {
return require('@react-navigation/core').getNavigation;
},
get NavigationContext() {
return require('@react-navigation/core').NavigationContext;
},
get NavigationProvider() {
return require('@react-navigation/core').NavigationProvider;
},
get NavigationConsumer() {
return require('@react-navigation/core').NavigationConsumer;
},
get NavigationActions() {
return require('@react-navigation/core').NavigationActions;
},
get StackActions() {
return require('@react-navigation/core').StackActions;
},
get StackRouter() {
return require('@react-navigation/core').StackRouter;
},
get TabRouter() {
return require('@react-navigation/core').TabRouter;
},
get SwitchRouter() {
return require('@react-navigation/core').SwitchRouter;
},
get SwitchActions() {
return require('@react-navigation/core').SwitchActions;
},
get createConfigGetter() {
return require('@react-navigation/core').StackAcreateConfigGetterctions;
},
get getScreenForRouteName() {
return require('@react-navigation/core').getScreenForRouteName;
},
get validateRouteConfigMap() {
return require('@react-navigation/core').validateRouteConfigMap;
},
get getActiveChildNavigationOptions() {
return require('@react-navigation/core').getActiveChildNavigationOptions;
},
get pathUtils() {
return require('@react-navigation/core').pathUtils;
},
get SceneView() {
return require('@react-navigation/core').SceneView;
},
get SwitchView() {
return require('@react-navigation/core').SwitchView;
},
get NavigationEvents() {
return require('@react-navigation/core').NavigationEvents;
},
get withNavigation() {
return require('@react-navigation/core').withNavigation;
},
get withNavigationFocus() {
return require('@react-navigation/core').withNavigationFocus;
},
// Navigators
get createStackNavigator() {
return require('react-navigation-stack').createStackNavigator;
},
get createSwitchNavigator() {
return require('@react-navigation/core').createSwitchNavigator;
},
get createBottomTabNavigator() {
return require('react-navigation-tabs').createBottomTabNavigator;
},
get createMaterialTopTabNavigator() {
return require('react-navigation-tabs').createMaterialTopTabNavigator;
},
get createDrawerNavigator() {
return require('react-navigation-drawer').createDrawerNavigator;
},
// Gesture contexts
get StackGestureContext() {
return require('react-navigation-stack').StackGestureContext;
},
get DrawerGestureContext() {
return require('react-navigation-drawer').DrawerGestureContext;
},
// Routers and Actions
get DrawerRouter() {
return require('react-navigation-drawer').DrawerRouter;
},
get DrawerActions() {
return require('react-navigation-drawer').DrawerActions;
},
// Views
get Transitioner() {
console.warn(
'Importing the stack Transitioner directly from react-navigation is now deprecated. Instead, import { Transitioner } from "react-navigation-stack";'
);
return require('react-navigation-stack').Transitioner;
},
get StackView() {
return require('react-navigation-stack').StackView;
},
get StackViewCard() {
return require('react-navigation-stack').StackViewCard;
},
get StackViewTransitionConfigs() {
return require('react-navigation-stack').StackViewTransitionConfigs;
},
// Header
get Header() {
return require('react-navigation-stack').Header;
},
get HeaderTitle() {
return require('react-navigation-stack').HeaderTitle;
},
get HeaderBackButton() {
return require('react-navigation-stack').HeaderBackButton;
},
get HeaderStyleInterpolator() {
return require('react-navigation-stack').HeaderStyleInterpolator;
},
// DrawerView
get DrawerView() {
return require('react-navigation-drawer').DrawerView;
},
get DrawerItems() {
return require('react-navigation-drawer').DrawerNavigatorItems;
},
get DrawerSidebar() {
return require('react-navigation-drawer').DrawerSidebar;
},
// Tabs
get BottomTabBar() {
return require('react-navigation-tabs').BottomTabBar;
},
get MaterialTopTabBar() {
return require('react-navigation-tabs').MaterialTopTabBar;
},
};

View File

@@ -1,26 +0,0 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"react-navigation": ["../src/index"]
},
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": ["esnext"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
"noStrictGenericChecks": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
declare module 'react-navigation-tabs';

6399
yarn.lock

File diff suppressed because it is too large Load Diff