Compare commits

..

1 Commits

Author SHA1 Message Date
Zhigang Fang
fbfed01098 fix: import animated from react-native-reanimated 2021-06-25 20:36:10 +08:00
93 changed files with 971 additions and 1990 deletions

View File

@@ -0,0 +1,38 @@
---
name: Bottom Tab Navigator
about: Report an issue with Bottom Tab Navigator (@react-navigation/bottom-tabs)
title: ''
labels: bug, package:bottom-tabs
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/native |
| @react-navigation/bottom-tabs |
| react-native-screens |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -0,0 +1,41 @@
---
name: Drawer Navigator
about: Report an issue with Drawer Navigator (@react-navigation/drawer)
title: ''
labels: bug, package:drawer
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/native |
| @react-navigation/drawer |
| react-native-reanimated |
| react-native-gesture-handler |
| react-native-safe-area-context |
| react-native-screens |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -0,0 +1,38 @@
---
name: Material Bottom Tab Navigator
about: Report an issue with Material Bottom Tab Navigator (@react-navigation/material-bottom-tabs)
title: ''
labels: bug, package:material-bottom-tabs
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/native |
| @react-navigation/material-bottom-tabs |
| react-native-paper |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -0,0 +1,38 @@
---
name: Material Top Tab Navigator
about: Report an issue with Material Top Tab Navigator (@react-navigation/material-top-tabs)
title: ''
labels: bug, package:material-top-tabs
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/native |
| @react-navigation/material-top-tabs |
| react-native-tab-view |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -0,0 +1,40 @@
---
name: Stack Navigator
about: Report an issue with Stack Navigator (@react-navigation/stack)
title: ''
labels: bug, package:stack
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/native |
| @react-navigation/stack |
| react-native-gesture-handler |
| react-native-safe-area-context |
| react-native-screens |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -0,0 +1,43 @@
---
name: React Navigation 4
about: Report an issue with React Navigation 4
title: ''
labels: bug, version-4
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-navigation-stack |
| react-navigation-tabs |
| react-navigation-drawer |
| react-native-reanimated |
| react-native-gesture-handler |
| react-native-safe-area-context |
| react-native-screens |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -1,92 +0,0 @@
name: React Navigation 4
description: Report an issue with React Navigation 4
labels: [bug, version-4]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
If this is not a bug report, please use other relevant channels:
- [Post a feature request on Canny](https://react-navigation.canny.io/feature-requests)
- [Ask questions on StackOverflow using the react-navigation label](https://stackoverflow.com/questions/tagged/react-navigation)
- [Chat with others in the #help-react-native channel on Discord](https://www.reactiflux.com/)
- type: textarea
attributes:
label: Current behavior
description: |
What code are you running and what is happening? Include a screenshot or video if it's an UI related issue.
placeholder: Current behavior
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: |
What do you expect to happen instead?
placeholder: Expected behavior
validations:
required: true
- type: input
attributes:
label: Reproduction
description: |
You must provide a way to reproduce the problem. If you don't provide a repro, the issue will be closed automatically after a specific period.
- Either re-create the bug on [Snack](https://snack.expo.dev) 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.
- 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.
placeholder: Link to repro
validations:
required: true
- type: checkboxes
attributes:
label: Platform
description: |
What are the platforms where you see the issue?
options:
- label: Android
- label: iOS
- label: Web
validations:
required: true
- type: checkboxes
attributes:
label: Packages
description: |
Which packages are affected by the issue?
options:
- label: 'react-navigation-drawer'
- label: 'react-navigation-stack'
- label: 'react-navigation-tabs'
validations:
required: true
- type: textarea
attributes:
label: Environment
description: |
What are the exact versions of packages that you are using?
When filling the table below, remove the packages that you're not using.
value: |
| package | version |
| -------------------------------------- | ------- |
| react-navigation |
| react-navigation-tabs |
| react-navigation-drawer |
| react-navigation-stack |
| react-native-safe-area-context |
| react-native-screens |
| react-native-gesture-handler |
| react-native-reanimated |
| react-native-tab-view |
| react-native |
| expo |
| node |
| npm or yarn |
validations:
required: true

36
.github/ISSUE_TEMPLATE/bug-report.md vendored Normal file
View File

@@ -0,0 +1,36 @@
---
name: Other bugs
about: Report an issue which is not about a specific navigator.
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/native |
| react-native |
| expo |
| node |
| npm or yarn |

View File

@@ -1,99 +0,0 @@
name: React Navigation 5
description: Report an issue with React Navigation 5
labels: [bug]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
If this is not a bug report, please use other relevant channels:
- [Post a feature request on Canny](https://react-navigation.canny.io/feature-requests)
- [Ask questions on StackOverflow using the react-navigation label](https://stackoverflow.com/questions/tagged/react-navigation)
- [Chat with others in the #help-react-native channel on Discord](https://www.reactiflux.com/)
- type: textarea
attributes:
label: Current behavior
description: |
What code are you running and what is happening? Include a screenshot or video if it's an UI related issue.
placeholder: Current behavior
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: |
What do you expect to happen instead?
placeholder: Expected behavior
validations:
required: true
- type: input
attributes:
label: Reproduction
description: |
You must provide a way to reproduce the problem. If you don't provide a repro, the issue will be closed automatically after a specific period.
- Either re-create the bug on [Snack](https://snack.expo.dev) 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.
- 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.
placeholder: Link to repro
validations:
required: true
- type: checkboxes
attributes:
label: Platform
description: |
What are the platforms where you see the issue?
options:
- label: Android
- label: iOS
- label: Web
- label: Windows
- label: MacOS
validations:
required: true
- type: checkboxes
attributes:
label: Packages
description: |
Which packages are affected by the issue?
options:
- label: '@react-navigation/bottom-tabs'
- label: '@react-navigation/drawer'
- label: '@react-navigation/material-bottom-tabs'
- label: '@react-navigation/material-top-tabs'
- label: '@react-navigation/stack'
validations:
required: true
- type: textarea
attributes:
label: Environment
description: |
What are the exact versions of packages that you are using?
When filling the table below, remove the packages that you're not using.
value: |
| package | version |
| -------------------------------------- | ------- |
| @react-navigation/native |
| @react-navigation/bottom-tabs |
| @react-navigation/drawer |
| @react-navigation/material-bottom-tabs |
| @react-navigation/material-top-tabs |
| @react-navigation/stack |
| react-native-safe-area-context |
| react-native-screens |
| react-native-gesture-handler |
| react-native-reanimated |
| react-native-tab-view |
| react-native-pager-view |
| react-native |
| expo |
| node |
| npm or yarn |
validations:
required: true

View File

@@ -1,44 +0,0 @@
name: Check for labels
on:
issues:
types: [opened, edited]
jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const body = context.payload.issue.body;
const packages = Array.from(
body.matchAll(/- \[x\] @react-navigation\/([\S]+)/gim)
)
.map((match) => match[1])
.filter((name) =>
[
'bottom-tabs',
'drawer',
'material-bottom-tabs',
'material-top-tabs',
'stack',
].includes(name)
)
.map((name) => `package:${name}`);
const platforms = Array.from(
body.matchAll(/- \[x\] (Android|iOS|Web|Windows|MacOS)/gim)
).map((matches) => `platform:${matches[1].toLowerCase()}`);
const labels = [...packages, ...platforms];
if (labels.length) {
await github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels,
});
}

View File

@@ -19,7 +19,7 @@ jobs:
: context.payload.issue.body;
const regex = new RegExp(
`https?:\\/\\/((github\\.com\\/${user}\\/[^/]+\\/?[\\s\\n]+)|(snack\\.expo\\.dev\\/.+))`,
`https?:\\/\\/((github\\.com\\/${user}\\/[^/]+\\/?[\\s\\n]+)|(snack\\.expo\\.io\\/.+))`,
'gm'
);
@@ -48,7 +48,7 @@ jobs:
return;
}
const body = "Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a [snack.expo.dev](https://snack.expo.dev) link or link to a GitHub repo under your username).\n\nCan you provide a [minimal repro](https://stackoverflow.com/help/minimal-reproducible-example) which demonstrates the issue? A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.";
const body = "Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a [snack.expo.io](https://snack.expo.io) link or link to a GitHub repo under your username).\n\nCan you provide a [minimal repro](https://stackoverflow.com/help/minimal-reproducible-example) which demonstrates the issue? A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.";
const comments = await github.issues.listComments({
issue_number: context.issue.number,

View File

@@ -46,7 +46,7 @@ jobs:
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const body = 'The Expo app for the example from this branch is ready!\n\n[expo.dev/${{ steps.expo.outputs.path }}](https://expo.dev/${{ steps.expo.outputs.path }})\n\n<a href="https://exp.host/${{ steps.expo.outputs.path }}"><img src="https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=exp://exp.host/${{ steps.expo.outputs.path }}" height="200px" width="200px"></a>';
const body = 'The Expo app for the example from this branch is ready!\n\n[expo.io/${{ steps.expo.outputs.path }}](https://expo.io/${{ steps.expo.outputs.path }})\n\n<a href="https://exp.host/${{ steps.expo.outputs.path }}"><img src="https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=exp://exp.host/${{ steps.expo.outputs.path }}" height="200px" width="200px"></a>';
const comments = await github.issues.listComments({
issue_number: context.issue.number,

View File

@@ -16,7 +16,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Hey! Thanks for opening the issue. Can you provide more information about the issue? Please fill the issue template when opening the issue without deleting any section. We need all the information we can to be able to help.\n\nMake sure to at least provide - Current behaviour, Expected behaviour, A way to [reproduce the issue with minimal code](https://stackoverflow.com/help/minimal-reproducible-example) (link to [snack.expo.dev](https://snack.expo.dev)) or a repo on GitHub, and the information about your environment (such as the platform of the device, exact versions of all the packages mentioned in the template etc.). In addition, if you can provide a video or GIF demonstrating the issue, it will also be very helpful."
body: "Hey! Thanks for opening the issue. Can you provide more information about the issue? Please fill the issue template when opening the issue without deleting any section. We need all the information we can to be able to help.\n\nMake sure to at least provide - Current behaviour, Expected behaviour, A way to [reproduce the issue with minimal code](https://stackoverflow.com/help/minimal-reproducible-example) (link to [snack.expo.io](https://snack.expo.io)) or a repo on GitHub, and the information about your environment (such as the platform of the device, exact versions of all the packages mentioned in the template etc.). In addition, if you can provide a video or GIF demonstrating the issue, it will also be very helpful."
})
needs-repro:
@@ -31,7 +31,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Hey! Thanks for opening the issue. Can you provide a [minimal repro](https://stackoverflow.com/help/minimal-reproducible-example) which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.\n\nThe easiest way to provide a repro is on [snack.expo.dev](https://snack.expo.dev). If it's not possible to repro it on [snack.expo.dev](https://snack.expo.dev), then please provide the repro in a GitHub repository."
body: "Hey! Thanks for opening the issue. Can you provide a [minimal repro](https://stackoverflow.com/help/minimal-reproducible-example) which demonstrates the issue? Posting a snippet of your code in the issue is useful, but it's not usually straightforward to run. A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.\n\nThe easiest way to provide a repro is on [snack.expo.io](https://snack.expo.io). If it's not possible to repro it on [snack.expo.io](https://snack.expo.io), then please provide the repro in a GitHub repository."
})
question:

View File

@@ -3,7 +3,7 @@
This library is a community effort: it can only be great if we all help out in one way or another! If you feel like you aren't experienced enough using React Navigation to contribute, you can still make an impact by:
- Responding to one of the open [issues](https://github.com/react-navigation/react-navigation/issues). Even if you can't resolve or fully answer a question, asking for more information or clarity on an issue is extremely beneficial for someone to come after you to resolve the issue.
- Creating public example repositories or [Snacks](https://snack.expo.dev/) of navigation problems you have solved and sharing the links.
- Creating public example repositories or [Snacks](https://snack.expo.io/) of navigation problems you have solved and sharing the links.
- Answering questions on [Stack Overflow](https://stackoverflow.com/search?q=react-navigation).
- Answering questions in our [Reactiflux](https://www.reactiflux.com/) channel.
- Providing feedback on the open [PRs](https://github.com/react-navigation/react-navigation/pulls).
@@ -20,7 +20,7 @@ The project uses a monorepo structure for the packages managed by [yarn workspac
yarn
```
While developing, you can run the [example app](/example/) with [Expo](https://expo.dev/) to test your changes:
While developing, you can run the [example app](/example/) with [Expo](https://expo.io/) to test your changes:
```sh
yarn example start

View File

@@ -4,6 +4,6 @@ If you want to run the example from the repo,
- Clone the repository and run `yarn` in the project root
- Run `yarn example start` to start the packager
- Follow the instructions to open it with the [Expo app](https://expo.dev/)
- Follow the instructions to open it with the [Expo app](https://expo.io/)
You can also run the currently published [app on Expo](https://expo.dev/@react-navigation/react-navigation-example) on your Android device or iOS simulator or the [web app](https://react-navigation-example.netlify.com/) in your browser.
You can also run the currently published [app on Expo](https://expo.io/@react-navigation/react-navigation-example) on your Android device or iOS simulator or the [web app](https://react-navigation-example.netlify.com/) in your browser.

View File

@@ -36,7 +36,7 @@
"react-native-reanimated": "~2.2.0",
"react-native-safe-area-context": "~3.2.0",
"react-native-screens": "~3.3.0",
"react-native-tab-view": "^3.1.1",
"react-native-tab-view": "^3.0.1",
"react-native-unimodules": "~0.13.3",
"react-native-vector-icons": "^8.1.0",
"react-native-web": "~0.16.3"

View File

@@ -1,5 +1,6 @@
import {
CommonActions,
NavigationAction,
ParamListBase,
useTheme,
} from '@react-navigation/native';
@@ -68,7 +69,10 @@ const InputScreen = ({
React.useEffect(
() =>
navigation.addListener('beforeRemove', (e) => {
if (!hasUnsavedChanges) {
const action: NavigationAction & { payload?: { confirmed?: boolean } } =
e.data.action;
if (!hasUnsavedChanges || action.payload?.confirmed) {
return;
}
@@ -80,7 +84,7 @@ const InputScreen = ({
);
if (discard) {
navigation.dispatch(e.data.action);
navigation.dispatch(action);
}
} else {
Alert.alert(
@@ -91,7 +95,7 @@ const InputScreen = ({
{
text: 'Discard',
style: 'destructive',
onPress: () => navigation.dispatch(e.data.action),
onPress: () => navigation.dispatch(action),
},
]
);

View File

@@ -11,6 +11,7 @@
"allowBranch": "main",
"conventionalCommits": true,
"createRelease": "github",
"distTag": "next",
"message": "chore: publish",
"ignoreChanges": [
"**/__fixtures__/**",

View File

@@ -3,41 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.22...@react-navigation/bottom-tabs@6.0.0) (2021-08-01)
### Bug Fixes
* remove tabBarAdapative option ([5f4e124](https://github.com/react-navigation/react-navigation/commit/5f4e12403265d22a2e4d03f11a11746b01184116))
# [6.0.0-next.22](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.21...@react-navigation/bottom-tabs@6.0.0-next.22) (2021-07-16)
**Note:** Version bump only for package @react-navigation/bottom-tabs
# [6.0.0-next.21](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.20...@react-navigation/bottom-tabs@6.0.0-next.21) (2021-07-16)
**Note:** Version bump only for package @react-navigation/bottom-tabs
# [6.0.0-next.20](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.18...@react-navigation/bottom-tabs@6.0.0-next.20) (2021-07-01)
**Note:** Version bump only for package @react-navigation/bottom-tabs
# [6.0.0-next.19](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@6.0.0-next.18...@react-navigation/bottom-tabs@6.0.0-next.19) (2021-06-10)
**Note:** Version bump only for package @react-navigation/bottom-tabs

View File

@@ -2,4 +2,4 @@
Bottom tab navigator for React Navigation following iOS design guidelines.
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/bottom-tab-navigator/).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/bottom-tab-navigator/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/bottom-tabs",
"description": "Bottom tab navigator following iOS design guidelines",
"version": "6.0.0",
"version": "6.0.0-next.19",
"keywords": [
"react-native-component",
"react-component",
@@ -36,12 +36,12 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/elements": "^1.0.0",
"@react-navigation/elements": "^1.0.0-next.18",
"color": "^3.1.3",
"warn-once": "^0.1.0"
},
"devDependencies": {
"@react-navigation/native": "^6.0.0",
"@react-navigation/native": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/color": "^3.0.1",
"@types/react": "^17.0.9",

View File

@@ -54,22 +54,8 @@ function BottomTabNavigator({
tabBarLabelStyle: tabBarOptions.labelStyle,
tabBarIconStyle: tabBarOptions.iconStyle,
tabBarItemStyle: tabBarOptions.tabStyle,
tabBarLabelPosition:
tabBarOptions.labelPosition ??
(tabBarOptions.adaptive === false ? 'below-icon' : undefined),
tabBarStyle: [
{ display: tabBarOptions.tabBarVisible ? 'none' : 'flex' },
defaultScreenOptions.tabBarStyle,
],
});
(
Object.keys(defaultScreenOptions) as (keyof BottomTabNavigationOptions)[]
).forEach((key) => {
if (defaultScreenOptions[key] === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete defaultScreenOptions[key];
}
tabBarLabelPosition: tabBarOptions.labelPosition,
tabBarAdaptive: tabBarOptions.adaptive,
});
warnOnce(
@@ -78,7 +64,7 @@ function BottomTabNavigator({
defaultScreenOptions,
null,
2
)}\n\nSee https://reactnavigation.org/docs/bottom-tab-navigator#options for more details.`
)}\n\nSee https://reactnavigation.org/docs/6.x/bottom-tab-navigator#options for more details.`
);
}
@@ -87,7 +73,7 @@ function BottomTabNavigator({
warnOnce(
true,
`Bottom Tab Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/bottom-tab-navigator/#lazy for more details.`
`Bottom Tab Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.`
);
}

View File

@@ -86,6 +86,23 @@ export type BottomTabNavigationOptions = HeaderOptions & {
*/
title?: string;
/**
* Whether this screens should render the first time it's accessed. Defaults to `true`.
* Set it to `false` if you want to render the screen on initial render.
*/
lazy?: boolean;
/**
* Function that given returns a React Element to display as a header.
*/
header?: (props: BottomTabHeaderProps) => React.ReactNode;
/**
* Whether to show the header. Setting this to `false` hides the header.
* Defaults to `true`.
*/
headerShown?: boolean;
/**
* Title string of a tab displayed in the tab bar
* or a function that given { focused: boolean, color: string, position: 'below-icon' | 'beside-icon' } returns a React.Node to display in tab bar.
@@ -100,31 +117,6 @@ export type BottomTabNavigationOptions = HeaderOptions & {
position: LabelPosition;
}) => React.ReactNode);
/**
* Whether the tab label should be visible. Defaults to `true`.
*/
tabBarShowLabel?: boolean;
/**
* Whether the label is shown below the icon or beside the icon.
*
* - `below-icon`: the label is shown below the icon (typical for iPhones)
* - `beside-icon` the label is shown next to the icon (typical for iPad)
*
* By default, the position is chosen automatically based on device width.
*/
tabBarLabelPosition?: LabelPosition;
/**
* Style object for the tab label.
*/
tabBarLabelStyle?: StyleProp<TextStyle>;
/**
* Whether label font should scale to respect Text Size accessibility settings.
*/
tabBarAllowFontScaling?: boolean;
/**
* A function that given { focused: boolean, color: string } returns a React.Node to display in the tab bar.
*/
@@ -134,11 +126,6 @@ export type BottomTabNavigationOptions = HeaderOptions & {
size: number;
}) => React.ReactNode;
/**
* Style object for the tab icon.
*/
tabBarIconStyle?: StyleProp<TextStyle>;
/**
* Text to show in a badge on the tab icon.
*/
@@ -161,9 +148,17 @@ export type BottomTabNavigationOptions = HeaderOptions & {
*/
tabBarTestID?: string;
/**
* Animation config for showing and hiding the tab bar.
*/
tabBarVisibilityAnimationConfig?: {
show?: TabBarVisibilityAnimationConfig;
hide?: TabBarVisibilityAnimationConfig;
};
/**
* Function which returns a React element to render as the tab bar button.
* Renders `Pressable` by default.
* Renders `TouchableWithoutFeedback` by default.
*/
tabBarButton?: (props: BottomTabBarButtonProps) => React.ReactNode;
@@ -183,35 +178,59 @@ export type BottomTabNavigationOptions = HeaderOptions & {
tabBarActiveBackgroundColor?: string;
/**
* Background color for the inactive tabs.
* background color for the inactive tabs.
*/
tabBarInactiveBackgroundColor?: string;
/**
* Whether label font should scale to respect Text Size accessibility settings.
*/
tabBarAllowFontScaling?: boolean;
/**
* Whether the tab label should be visible. Defaults to `true`.
*/
tabBarShowLabel?: boolean;
/**
* Style object for the tab label.
*/
tabBarLabelStyle?: StyleProp<TextStyle>;
/**
* Style object for the tab icon.
*/
tabBarIconStyle?: StyleProp<TextStyle>;
/**
* Style object for the tab item container.
*/
tabBarItemStyle?: StyleProp<ViewStyle>;
/**
* Whether the label is rendered below the icon or beside the icon.
* By default, the position is chosen automatically based on device width.
* In `below-icon` orientation (typical for iPhones), the label is rendered below and in `beside-icon` orientation, it's rendered beside (typical for iPad).
*/
tabBarLabelPosition?: LabelPosition;
/**
* Whether the label position should adapt to the orientation.
*/
tabBarAdaptive?: boolean;
/**
* Whether the tab bar gets hidden when the keyboard is shown. Defaults to `false`.
*/
tabBarHideOnKeyboard?: boolean;
/**
* Animation config for showing and hiding the tab bar when the keyboard is shown/hidden.
*/
tabBarVisibilityAnimationConfig?: {
show?: TabBarVisibilityAnimationConfig;
hide?: TabBarVisibilityAnimationConfig;
};
/**
* Style object for the tab bar container.
*/
tabBarStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
/**
* Function which returns a React Element to use as background for the tab bar.
* Component to use as background for the tab bar.
* You could render an image, a gradient, blur view etc.
*
* When using `BlurView`, make sure to set `position: 'absolute'` in `tabBarStyle` as well.
@@ -219,23 +238,6 @@ export type BottomTabNavigationOptions = HeaderOptions & {
*/
tabBarBackground?: () => React.ReactNode;
/**
* Whether this screens should render the first time it's accessed. Defaults to `true`.
* Set it to `false` if you want to render the screen on initial render.
*/
lazy?: boolean;
/**
* Function that given returns a React Element to display as a header.
*/
header?: (props: BottomTabHeaderProps) => React.ReactNode;
/**
* Whether to show the header. Setting this to `false` hides the header.
* Defaults to `true`.
*/
headerShown?: boolean;
/**
* Whether this screen should be unmounted when navigating away from it.
* Defaults to `false`.

View File

@@ -48,16 +48,15 @@ const shouldUseHorizontalLabels = ({
layout,
dimensions,
}: Options) => {
const { tabBarLabelPosition } =
const { tabBarLabelPosition, tabBarAdaptive = true } =
descriptors[state.routes[state.index].key].options;
if (tabBarLabelPosition) {
switch (tabBarLabelPosition) {
case 'beside-icon':
return true;
case 'below-icon':
return false;
}
return tabBarLabelPosition === 'beside-icon';
}
if (!tabBarAdaptive) {
return false;
}
if (layout.width >= 768) {

View File

@@ -3,56 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.17...@react-navigation/core@6.0.0) (2021-08-01)
### Bug Fixes
* clear options set from a screen when it unmounts. closes [#9756](https://github.com/react-navigation/react-navigation/issues/9756) ([d2d7f8d](https://github.com/react-navigation/react-navigation/commit/d2d7f8d95e84e8d45b6807f59afcf4d0e64c3828))
# [6.0.0-next.17](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.16...@react-navigation/core@6.0.0-next.17) (2021-07-16)
### Bug Fixes
* use nested params for initial state only ([577d79e](https://github.com/react-navigation/react-navigation/commit/577d79e98c6d6f1c78e0f3232225b2b6b331340b))
# [6.0.0-next.16](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.15...@react-navigation/core@6.0.0-next.16) (2021-07-16)
### Bug Fixes
* prevent navigation state updates after state cleanup ([#9688](https://github.com/react-navigation/react-navigation/issues/9688)) ([16f0e11](https://github.com/react-navigation/react-navigation/commit/16f0e11822b14aa5b1ba4b288fb38fcf15088419))
* sort wildcard and :params ([#9672](https://github.com/react-navigation/react-navigation/issues/9672)) ([4135d09](https://github.com/react-navigation/react-navigation/commit/4135d09c6f14030257b2da47658e102b083c7727))
# [6.0.0-next.15](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.13...@react-navigation/core@6.0.0-next.15) (2021-07-01)
### Bug Fixes
* fix typechecking in linking config ([b1134c8](https://github.com/react-navigation/react-navigation/commit/b1134c8a34f96be2817cb780c4bd23b2025b4c35))
### Features
* show stack trace in the flipper plugin ([97772af](https://github.com/react-navigation/react-navigation/commit/97772affa3c8f26489f0bdbfb6872ef4377b8ed1))
# [6.0.0-next.14](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@6.0.0-next.13...@react-navigation/core@6.0.0-next.14) (2021-06-10)

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/core",
"description": "Core utilities for building navigators",
"version": "6.0.0",
"version": "6.0.0-next.14",
"keywords": [
"react",
"react-native",
@@ -35,7 +35,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/routers": "^6.0.0",
"@react-navigation/routers": "^6.0.0-next.5",
"escape-string-regexp": "^4.0.0",
"nanoid": "^3.1.23",
"query-string": "^7.0.0",

View File

@@ -20,7 +20,6 @@ type Props<State extends NavigationState, ScreenOptions extends {}> = {
getState: () => State;
setState: (state: State) => void;
options: object;
clearOptions: () => void;
};
/**
@@ -38,7 +37,6 @@ export default function SceneView<
getState,
setState,
options,
clearOptions,
}: Props<State, ScreenOptions>) {
const navigatorKeyRef = React.useRef<string | undefined>();
const getKey = React.useCallback(() => navigatorKeyRef.current, []);
@@ -80,12 +78,6 @@ export default function SceneView<
isInitialRef.current = false;
});
// Clear options set by this screen when it is unmounted
React.useEffect(() => {
return clearOptions;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const getIsInitial = React.useCallback(() => isInitialRef.current, []);
const context = React.useMemo(

View File

@@ -2196,7 +2196,6 @@ it('tries to match wildcard patterns at the end', () => {
path: '/bar/:id/',
screens: {
404: '*',
UserProfile: ':userSlug',
Test: 'test',
},
},

View File

@@ -143,31 +143,27 @@ export default function getStateFromPath<ParamList extends {}>(
const aParts = a.pattern.split('/');
const bParts = b.pattern.split('/');
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
// if b is longer, b get higher priority
if (aParts[i] == null) {
return 1;
}
// if a is longer, a get higher priority
if (bParts[i] == null) {
return -1;
}
const aWildCard = aParts[i] === '*' || aParts[i].startsWith(':');
const bWildCard = bParts[i] === '*' || bParts[i].startsWith(':');
// if both are wildcard we compare next component
if (aWildCard && bWildCard) {
continue;
}
// if only a is wild card, b get higher priority
if (aWildCard) {
return 1;
}
// if only b is wild card, a get higher priority
if (bWildCard) {
return -1;
}
const aWildcardIndex = aParts.indexOf('*');
const bWildcardIndex = bParts.indexOf('*');
// If only one of the patterns has a wildcard, move it down in the list
if (aWildcardIndex === -1 && bWildcardIndex !== -1) {
return -1;
}
return bParts.length - aParts.length;
if (aWildcardIndex !== -1 && bWildcardIndex === -1) {
return 1;
}
if (aWildcardIndex === bWildcardIndex) {
// If `b` has more `/`, it's more exhaustive
// So we move it up in the list
return bParts.length - aParts.length;
}
// If the wildcard appears later in the pattern (has higher index), it's more specific
// So we move it up in the list
return bWildcardIndex - aWildcardIndex;
});
// Check for duplicate patterns in the config

View File

@@ -200,13 +200,8 @@ type NavigationHelpersCommon<
*/
navigate<RouteName extends keyof ParamList>(
options:
| { key: string; params?: ParamList[RouteName]; merge?: boolean }
| {
name: RouteName;
key?: string;
params: ParamList[RouteName];
merge?: boolean;
}
| { key: string; params?: ParamList[RouteName] }
| { name: RouteName; key?: string; params: ParamList[RouteName] }
): void;
/**
@@ -637,9 +632,10 @@ export type PathConfig<ParamList extends {}> = {
};
export type PathConfigMap<ParamList extends {}> = {
[RouteName in keyof ParamList]?: NonNullable<
ParamList[RouteName]
> extends NavigatorScreenParams<infer T, any>
[RouteName in keyof ParamList]?: ParamList[RouteName] extends NavigatorScreenParams<
infer T,
any
>
? string | PathConfig<T>
: string | Omit<PathConfig<{}>, 'screens' | 'initialRouteName'>;
};

View File

@@ -186,17 +186,6 @@ export default function useDescriptors<
...customOptions,
};
const clearOptions = () =>
setOptions((o) => {
if (route.key in o) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { [route.key]: _, ...rest } = o;
return rest;
}
return o;
});
acc[route.key] = {
route,
// @ts-expect-error: it's missing action helpers, fix later
@@ -214,7 +203,6 @@ export default function useDescriptors<
getState={getState}
setState={setState}
options={mergedOptions}
clearOptions={clearOptions}
/>
</NavigationRouteContext.Provider>
</NavigationContext.Provider>

View File

@@ -250,7 +250,21 @@ export default function useNavigationBuilder<
const routeParamList = routeNames.reduce<Record<string, object | undefined>>(
(acc, curr) => {
const { initialParams } = screens[curr][1];
acc[curr] = initialParams;
const initialParamsFromParams =
route?.params?.state == null &&
route?.params?.initial !== false &&
route?.params?.screen === curr
? route.params.params
: undefined;
acc[curr] =
initialParams !== undefined || initialParamsFromParams !== undefined
? {
...initialParams,
...initialParamsFromParams,
}
: undefined;
return acc;
},
{}
@@ -285,55 +299,13 @@ export default function useNavigationBuilder<
const {
state: currentState,
getState: getCurrentState,
setState: setCurrentState,
setState,
setKey,
getKey,
getIsInitial,
} = React.useContext(NavigationStateContext);
const stateCleanedUp = React.useRef(false);
const cleanUpState = React.useCallback(() => {
setCurrentState(undefined);
stateCleanedUp.current = true;
}, [setCurrentState]);
const setState = React.useCallback(
(state: NavigationState | PartialState<NavigationState> | undefined) => {
if (stateCleanedUp.current) {
// State might have been already cleaned up due to unmount
// We do not want to expose API allowing to override this
// This would lead to old data preservation on main navigator unmount
return;
}
setCurrentState(state);
},
[setCurrentState]
);
const [initializedState, isFirstStateInitialization] = React.useMemo(() => {
const initialRouteParamList = routeNames.reduce<
Record<string, object | undefined>
>((acc, curr) => {
const { initialParams } = screens[curr][1];
const initialParamsFromParams =
route?.params?.state == null &&
route?.params?.initial !== false &&
route?.params?.screen === curr
? route.params.params
: undefined;
acc[curr] =
initialParams !== undefined || initialParamsFromParams !== undefined
? {
...initialParams,
...initialParamsFromParams,
}
: undefined;
return acc;
}, {});
// If the current state isn't initialized on first render, we initialize it
// We also need to re-initialize it if the state passed from parent was changed (maybe due to reset)
// Otherwise assume that the state was provided as initial state
@@ -345,7 +317,7 @@ export default function useNavigationBuilder<
return [
router.getInitialState({
routeNames,
routeParamList: initialRouteParamList,
routeParamList,
routeGetIdList,
}),
true,
@@ -356,15 +328,16 @@ export default function useNavigationBuilder<
route?.params?.state ?? (currentState as PartialState<State>),
{
routeNames,
routeParamList: initialRouteParamList,
routeParamList,
routeGetIdList,
}
),
false,
];
}
// We explicitly don't include routeNames, route.params etc. in the dep list
// below. We want to avoid forcing a new state to be calculated in those cases
// We explicitly don't include routeNames/routeParamList in the dep list
// below. We want to avoid forcing a new state to be calculated in cases
// where routeConfigs change without affecting routeNames/routeParamList.
// Instead, we handle changes to these in the nextState code below. Note
// that some changes to routeConfigs are explicitly ignored, such as changes
// to initialParams
@@ -471,7 +444,7 @@ export default function useNavigationBuilder<
// Otherwise, our cleanup step will cleanup state for the other navigator and re-initialize it
setTimeout(() => {
if (getCurrentState() !== undefined && getKey() === navigatorKey) {
cleanUpState();
setState(undefined);
}
}, 0);
};

View File

@@ -83,7 +83,7 @@ export default function useNavigationHelpers<
);
},
getParent: () => parentNavigationHelpers as any,
getState,
getState: getState,
} as NavigationHelpers<ParamListBase, EventMap> &
(NavigationProp<ParamListBase, string, any, any, any> | undefined) &
ActionHelpers;

View File

@@ -3,55 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.19...@react-navigation/devtools@6.0.0) (2021-08-01)
**Note:** Version bump only for package @react-navigation/devtools
# [6.0.0-next.19](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.18...@react-navigation/devtools@6.0.0-next.19) (2021-07-19)
### Bug Fixes
* ignore errors from symbolication in devtools ([f666059](https://github.com/react-navigation/react-navigation/commit/f666059d80e7888e50071b888e6f9a4afd00a71e))
# [6.0.0-next.18](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.17...@react-navigation/devtools@6.0.0-next.18) (2021-07-16)
**Note:** Version bump only for package @react-navigation/devtools
# [6.0.0-next.17](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.16...@react-navigation/devtools@6.0.0-next.17) (2021-07-16)
### Bug Fixes
* fix devtools not sending new events if an error occured ([c333f40](https://github.com/react-navigation/react-navigation/commit/c333f4086ea04c879fdd46ccc206d3faf84fabca))
# [6.0.0-next.16](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.14...@react-navigation/devtools@6.0.0-next.16) (2021-07-01)
### Features
* show stack trace in the flipper plugin ([97772af](https://github.com/react-navigation/react-navigation/commit/97772affa3c8f26489f0bdbfb6872ef4377b8ed1))
# [6.0.0-next.15](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@6.0.0-next.14...@react-navigation/devtools@6.0.0-next.15) (2021-06-10)

View File

@@ -2,4 +2,4 @@
Developer tools for React Navigation.
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/devtools).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/devtools).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/devtools",
"description": "Developer tools for React Navigation",
"version": "6.0.0",
"version": "6.0.0-next.15",
"keywords": [
"react",
"react-native",
@@ -40,7 +40,7 @@
"nanoid": "^3.1.23"
},
"devDependencies": {
"@react-navigation/core": "^6.0.0",
"@react-navigation/core": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/deep-equal": "^1.0.1",
"@types/react": "^17.0.9",

View File

@@ -75,7 +75,7 @@ export default function useDevToolsBase(
})
.filter(Boolean) as StackFrame[];
const urlMatch = frames[0]?.file?.match(/^https?:\/\/.+(:\d+)?\//);
const urlMatch = frames[0].file?.match(/^https?:\/\/.+(:\d+)?\//);
if (!urlMatch) {
return stack;
@@ -103,26 +103,15 @@ export default function useDevToolsBase(
const send = React.useCallback((data: ActionData) => {
// We need to make sure that our callbacks executed in the same order
// So we add check if the last promise is settled before sending the next one
pendingPromiseRef.current = pendingPromiseRef.current
.catch(() => {
// Ignore any errors from the last promise
})
.then(async () => {
if (data.stack) {
let stack: string | undefined;
pendingPromiseRef.current = pendingPromiseRef.current.then(async () => {
if (data.stack) {
const stack = await symbolicate(data.stack);
try {
stack = await symbolicate(data.stack);
} catch (err) {
// Ignore errors from symbolicate
}
callbackRef.current({ ...data, stack });
} else {
callbackRef.current(data);
}
});
callbackRef.current({ ...data, stack });
} else {
callbackRef.current(data);
}
});
}, []);
React.useEffect(() => {

View File

@@ -3,41 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.21...@react-navigation/drawer@6.0.0) (2021-08-01)
### Bug Fixes
* add deprecation warning for openByDefault ([9506ad1](https://github.com/react-navigation/react-navigation/commit/9506ad1f001b3ed295a36c6744ed17459fa193e4))
# [6.0.0-next.21](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.20...@react-navigation/drawer@6.0.0-next.21) (2021-07-16)
**Note:** Version bump only for package @react-navigation/drawer
# [6.0.0-next.20](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.19...@react-navigation/drawer@6.0.0-next.20) (2021-07-16)
**Note:** Version bump only for package @react-navigation/drawer
# [6.0.0-next.19](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.17...@react-navigation/drawer@6.0.0-next.19) (2021-07-01)
**Note:** Version bump only for package @react-navigation/drawer
# [6.0.0-next.18](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@6.0.0-next.17...@react-navigation/drawer@6.0.0-next.18) (2021-06-10)
**Note:** Version bump only for package @react-navigation/drawer

View File

@@ -2,4 +2,4 @@
Drawer navigator for React Navigation following Material Design guidelines.
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/drawer-navigator/).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/drawer-navigator/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/drawer",
"description": "Drawer navigator component with animated transitions and gesturess",
"version": "6.0.0",
"version": "6.0.0-next.18",
"keywords": [
"react-native-component",
"react-component",
@@ -41,12 +41,12 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/elements": "^1.0.0",
"@react-navigation/elements": "^1.0.0-next.18",
"color": "^3.1.3",
"warn-once": "^0.1.0"
},
"devDependencies": {
"@react-navigation/native": "^6.0.0",
"@react-navigation/native": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/react": "^17.0.9",
"@types/react-native": "~0.64.9",

View File

@@ -34,8 +34,6 @@ function DrawerNavigator({
children,
screenListeners,
screenOptions,
// @ts-expect-error: openByDefault is deprecated
openByDefault,
// @ts-expect-error: lazy is deprecated
lazy,
// @ts-expect-error: drawerContentOptions is deprecated
@@ -57,22 +55,13 @@ function DrawerNavigator({
gestureHandlerProps: drawerContentOptions.gestureHandlerProps,
});
(
Object.keys(defaultScreenOptions) as (keyof DrawerNavigationOptions)[]
).forEach((key) => {
if (defaultScreenOptions[key] === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete defaultScreenOptions[key];
}
});
warnOnce(
drawerContentOptions,
`Drawer Navigator: 'drawerContentOptions' is deprecated. Migrate the options to 'screenOptions' instead.\n\nPlace the following in 'screenOptions' in your code to keep current behavior:\n\n${JSON.stringify(
defaultScreenOptions,
null,
2
)}\n\nSee https://reactnavigation.org/docs/drawer-navigator#options for more details.`
)}\n\nSee https://reactnavigation.org/docs/6.x/drawer-navigator#options for more details.`
);
}
@@ -81,14 +70,7 @@ function DrawerNavigator({
warnOnce(
true,
`Drawer Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/drawer-navigator/#lazy for more details.`
);
}
if (typeof openByDefault === 'boolean') {
warnOnce(
true,
`Drawer Navigator: 'openByDefault' is deprecated. Use 'defaultStatus' and set it to 'open' or 'closed' instead.\n\nSee https://reactnavigation.org/docs/drawer-navigator/#defaultstatus for more details.`
`Drawer Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.`
);
}
@@ -101,12 +83,7 @@ function DrawerNavigator({
DrawerNavigationEventMap
>(DrawerRouter, {
initialRouteName,
defaultStatus:
defaultStatus !== undefined
? defaultStatus
: openByDefault
? 'open'
: 'closed',
defaultStatus,
backBehavior,
children,
screenListeners,

View File

@@ -3,47 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.21...@react-navigation/elements@1.0.0) (2021-08-01)
### Bug Fixes
* match native iOS header height in stack ([51b636d](https://github.com/react-navigation/react-navigation/commit/51b636d7268fc05a8a9aca9e6aad0161674f238e))
### Features
* basic web implementation for native stack ([de84458](https://github.com/react-navigation/react-navigation/commit/de8445896021da4865089ba44e95afffbcee0919))
* expose header height in native-stack ([#9774](https://github.com/react-navigation/react-navigation/issues/9774)) ([20abccd](https://github.com/react-navigation/react-navigation/commit/20abccda0d5074f61b2beb555b881a2087d27bb0))
# [1.0.0-next.21](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.20...@react-navigation/elements@1.0.0-next.21) (2021-07-16)
**Note:** Version bump only for package @react-navigation/elements
# [1.0.0-next.20](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.19...@react-navigation/elements@1.0.0-next.20) (2021-07-16)
**Note:** Version bump only for package @react-navigation/elements
# [1.0.0-next.19](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.17...@react-navigation/elements@1.0.0-next.19) (2021-07-01)
**Note:** Version bump only for package @react-navigation/elements
# [1.0.0-next.18](https://github.com/react-navigation/react-navigation/compare/@react-navigation/elements@1.0.0-next.17...@react-navigation/elements@1.0.0-next.18) (2021-06-10)
**Note:** Version bump only for package @react-navigation/elements

View File

@@ -2,4 +2,4 @@
UI Components for React Navigation.
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/elements/).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/elements/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/elements",
"description": "UI Components for React Navigation",
"version": "1.0.0",
"version": "1.0.0-next.18",
"keywords": [
"react-native",
"react-navigation",
@@ -38,7 +38,7 @@
},
"devDependencies": {
"@react-native-masked-view/masked-view": "^0.2.4",
"@react-navigation/native": "^6.0.0",
"@react-navigation/native": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/react": "^17.0.9",
"@types/react-native": "~0.64.9",

View File

@@ -12,10 +12,6 @@ import HeaderShownContext from './HeaderShownContext';
import HeaderTitle from './HeaderTitle';
type Props = HeaderOptions & {
/**
* Whether the header is in a modal
*/
modal?: boolean;
/**
* Layout of the screen.
*/
@@ -50,7 +46,6 @@ export default function Header(props: Props) {
const {
layout = frame,
modal = false,
title,
headerTitle: customTitle,
headerTitleAlign = Platform.select({
@@ -74,11 +69,7 @@ export default function Header(props: Props) {
headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
} = props;
const defaultHeight = getDefaultHeaderHeight(
layout,
modal,
headerStatusBarHeight
);
const defaultHeight = getDefaultHeaderHeight(layout, headerStatusBarHeight);
const {
height = defaultHeight,

View File

@@ -4,30 +4,17 @@ import type { Layout } from '../types';
export default function getDefaultHeaderHeight(
layout: Layout,
modalPresentation: boolean,
statusBarHeight: number
): number {
let headerHeight;
const isLandscape = layout.width > layout.height;
let headerHeight;
if (Platform.OS === 'ios') {
if (Platform.isPad) {
if (modalPresentation) {
headerHeight = 56;
} else {
headerHeight = 50;
}
if (isLandscape && !Platform.isPad) {
headerHeight = 32;
} else {
if (isLandscape) {
headerHeight = 32;
} else {
if (modalPresentation) {
headerHeight = 56;
} else {
headerHeight = 44;
}
}
headerHeight = 44;
}
} else if (Platform.OS === 'android') {
headerHeight = 56;

View File

@@ -1,7 +1,7 @@
import type { HeaderOptions } from '../types';
export default function getHeaderTitle(
options: { title?: string; headerTitle?: HeaderOptions['headerTitle'] },
options: HeaderOptions & { title?: string },
fallback: string
): string {
return typeof options.headerTitle === 'string'

View File

@@ -19,7 +19,6 @@ import HeaderShownContext from './Header/HeaderShownContext';
type Props = {
focused: boolean;
modal?: boolean;
navigation: NavigationProp<ParamListBase>;
route: RouteProp<ParamListBase>;
header: React.ReactNode;
@@ -38,7 +37,6 @@ export default function Screen(props: Props) {
const {
focused,
modal = false,
header,
headerShown = true,
headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
@@ -49,7 +47,7 @@ export default function Screen(props: Props) {
} = props;
const [headerHeight, setHeaderHeight] = React.useState(() =>
getDefaultHeaderHeight(dimensions, modal, headerStatusBarHeight)
getDefaultHeaderHeight(dimensions, headerStatusBarHeight)
);
return (
@@ -63,7 +61,7 @@ export default function Screen(props: Props) {
value={isParentHeaderShown || headerShown !== false}
>
<HeaderHeightContext.Provider
value={headerShown ? headerHeight : parentHeaderHeight ?? 0}
value={headerShown ? headerHeight : parentHeaderHeight}
>
{children}
</HeaderHeightContext.Provider>

View File

@@ -3,41 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.3](https://github.com/react-navigation/react-navigation/compare/flipper-plugin-react-navigation@1.3.2...flipper-plugin-react-navigation@1.3.3) (2021-08-01)
**Note:** Version bump only for package flipper-plugin-react-navigation
## [1.3.2](https://github.com/react-navigation/react-navigation/compare/flipper-plugin-react-navigation@1.3.1...flipper-plugin-react-navigation@1.3.2) (2021-07-16)
**Note:** Version bump only for package flipper-plugin-react-navigation
## [1.3.1](https://github.com/react-navigation/react-navigation/compare/flipper-plugin-react-navigation@1.3.0...flipper-plugin-react-navigation@1.3.1) (2021-07-16)
**Note:** Version bump only for package flipper-plugin-react-navigation
# [1.3.0](https://github.com/react-navigation/react-navigation/compare/flipper-plugin-react-navigation@1.1.4...flipper-plugin-react-navigation@1.3.0) (2021-07-01)
### Features
* show stack trace in the flipper plugin ([97772af](https://github.com/react-navigation/react-navigation/commit/97772affa3c8f26489f0bdbfb6872ef4377b8ed1))
# [1.2.0](https://github.com/react-navigation/react-navigation/compare/flipper-plugin-react-navigation@1.1.4...flipper-plugin-react-navigation@1.2.0) (2021-06-10)

View File

@@ -2,4 +2,4 @@
Flipper plugin with developer tools for React Navigation.
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/devtools).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/devtools).

View File

@@ -2,7 +2,7 @@
"$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
"name": "flipper-plugin-react-navigation",
"description": "Developer tools for React Navigation",
"version": "1.3.3",
"version": "1.2.0",
"main": "dist/bundle.js",
"license": "MIT",
"keywords": [
@@ -34,7 +34,7 @@
"@ant-design/icons": "^4.6.2",
"@babel/preset-react": "^7.12.13",
"@babel/preset-typescript": "^7.13.0",
"@react-navigation/core": "^6.0.0",
"@react-navigation/core": "^6.0.0-next.14",
"@types/react": "^17.0.9",
"@types/react-dom": "^17.0.6",
"antd": "^4.16.1",

View File

@@ -3,38 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.18...@react-navigation/material-bottom-tabs@6.0.0) (2021-08-01)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
# [6.0.0-next.18](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.17...@react-navigation/material-bottom-tabs@6.0.0-next.18) (2021-07-16)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
# [6.0.0-next.17](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.16...@react-navigation/material-bottom-tabs@6.0.0-next.17) (2021-07-16)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
# [6.0.0-next.16](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.14...@react-navigation/material-bottom-tabs@6.0.0-next.16) (2021-07-01)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
# [6.0.0-next.15](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@6.0.0-next.14...@react-navigation/material-bottom-tabs@6.0.0-next.15) (2021-06-10)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs

View File

@@ -2,4 +2,4 @@
React Navigation integration for [bottom navigation](https://material.io/components/bottom-navigation) component from [`react-native-paper`](https://callstack.github.io/react-native-paper/bottom-navigation.html).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/material-bottom-tab-navigator/).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/material-bottom-tab-navigator/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/material-bottom-tabs",
"description": "Integration for bottom navigation component from react-native-paper",
"version": "6.0.0",
"version": "6.0.0-next.15",
"keywords": [
"react-native-component",
"react-component",
@@ -41,10 +41,10 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/elements": "^1.0.0"
"@react-navigation/elements": "^1.0.0-next.18"
},
"devDependencies": {
"@react-navigation/native": "^6.0.0",
"@react-navigation/native": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/react": "^17.0.9",
"@types/react-native": "~0.64.9",

View File

@@ -3,42 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.18...@react-navigation/material-top-tabs@6.0.0) (2021-08-01)
### Features
* add tabBarBadge and tabBarIndicator options for material top tabs ([fdb3ede](https://github.com/react-navigation/react-navigation/commit/fdb3ede3e0eb1e43c4be30c810663880e2f5467c))
* move some props to screenOptions in material top tabs ([5bfc396](https://github.com/react-navigation/react-navigation/commit/5bfc39668bb5dce8bd872e5ff87f4b3fd683cf62))
# [6.0.0-next.18](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.17...@react-navigation/material-top-tabs@6.0.0-next.18) (2021-07-16)
**Note:** Version bump only for package @react-navigation/material-top-tabs
# [6.0.0-next.17](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.16...@react-navigation/material-top-tabs@6.0.0-next.17) (2021-07-16)
**Note:** Version bump only for package @react-navigation/material-top-tabs
# [6.0.0-next.16](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.14...@react-navigation/material-top-tabs@6.0.0-next.16) (2021-07-01)
**Note:** Version bump only for package @react-navigation/material-top-tabs
# [6.0.0-next.15](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@6.0.0-next.14...@react-navigation/material-top-tabs@6.0.0-next.15) (2021-06-10)
**Note:** Version bump only for package @react-navigation/material-top-tabs

View File

@@ -2,4 +2,4 @@
React Navigation integration for animated tab view component from [`react-native-tab-view`](https://github.com/satya164/react-native-tab-view).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/material-top-tab-navigator/).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/material-top-tab-navigator/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/material-top-tabs",
"description": "Integration for the animated tab view component from react-native-tab-view",
"version": "6.0.0",
"version": "6.0.0-next.15",
"keywords": [
"react-native-component",
"react-component",
@@ -45,7 +45,7 @@
"warn-once": "^0.1.0"
},
"devDependencies": {
"@react-navigation/native": "^6.0.0",
"@react-navigation/native": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/react": "^17.0.9",
"@types/react-native": "~0.64.9",
@@ -54,7 +54,7 @@
"react-native": "~0.63.4",
"react-native-builder-bob": "^0.18.1",
"react-native-pager-view": "^5.1.10",
"react-native-tab-view": "^3.1.1",
"react-native-tab-view": "^3.0.1",
"typescript": "^4.3.2"
},
"peerDependencies": {

View File

@@ -33,15 +33,7 @@ function MaterialTopTabNavigator({
children,
screenListeners,
screenOptions,
// @ts-expect-error: swipeEnabled is deprecated
swipeEnabled,
// @ts-expect-error: lazy is deprecated
lazy,
// @ts-expect-error: lazyPlaceholder is deprecated
lazyPlaceholder,
// @ts-expect-error: lazyPreloadDistance is deprecated
lazyPreloadDistance,
// @ts-expect-error: tabBarOptions is deprecated
tabBarOptions,
...rest
}: Props) {
@@ -61,53 +53,30 @@ function MaterialTopTabNavigator({
tabBarIconStyle: tabBarOptions.iconStyle,
tabBarLabelStyle: tabBarOptions.labelStyle,
tabBarItemStyle: tabBarOptions.tabStyle,
tabBarBadge: tabBarOptions.renderBadge,
tabBarIndicator: tabBarOptions.renderIndicator,
tabBarIndicatorStyle: tabBarOptions.indicatorStyle,
tabBarIndicatorContainerStyle: tabBarOptions.indicatorContainerStyle,
tabBarContentContainerStyle: tabBarOptions.contentContainerStyle,
tabBarStyle: tabBarOptions.style,
});
(
Object.keys(
defaultScreenOptions
) as (keyof MaterialTopTabNavigationOptions)[]
).forEach((key) => {
if (defaultScreenOptions[key] === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete defaultScreenOptions[key];
}
});
warnOnce(
tabBarOptions,
`Material Top Tab Navigator: 'tabBarOptions' is deprecated. Migrate the options to 'screenOptions' instead.\n\nPlace the following in 'screenOptions' in your code to keep current behavior:\n\n${JSON.stringify(
defaultScreenOptions,
null,
2
)}\n\nSee https://reactnavigation.org/docs/material-top-tab-navigator#options for more details.`
)}\n\nSee https://reactnavigation.org/docs/6.x/material-top-tab-navigator#options for more details.`
);
}
const deprecatedProps = {
swipeEnabled,
lazy,
lazyPlaceholder,
lazyPreloadDistance,
} as const;
if (typeof lazy === 'boolean') {
defaultScreenOptions.lazy = lazy;
Object.entries(deprecatedProps).forEach(([propName, propValue]) => {
if (propValue !== undefined) {
// @ts-expect-error: Object.entries doesn't return strict types
defaultScreenOptions[propName] = propValue;
warnOnce(
true,
`Material Top Tab Navigator: '${propName}' in props is deprecated. Move it to 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/material-top-tab-navigator#${propName.toLowerCase()} for more details.`
);
}
});
warnOnce(
true,
`Material Top Tab Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.`
);
}
const { state, descriptors, navigation, NavigationContent } =
useNavigationBuilder<
@@ -122,7 +91,6 @@ function MaterialTopTabNavigator({
children,
screenListeners,
screenOptions,
defaultScreenOptions,
});
return (

View File

@@ -8,13 +8,8 @@ import type {
TabActionHelpers,
TabNavigationState,
} from '@react-navigation/native';
import type React from 'react';
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
import type {
SceneRendererProps,
TabBar,
TabViewProps,
} from 'react-native-tab-view';
import type { SceneRendererProps, TabViewProps } from 'react-native-tab-view';
export type MaterialTopTabNavigationEventMap = {
/**
@@ -67,6 +62,21 @@ export type MaterialTopTabNavigationOptions = {
*/
title?: string;
/**
* Whether this screens should render the first time it's accessed. Defaults to `false`.
*/
lazy?: boolean;
/**
* Function that returns a React element to render if this screen hasn't been rendered yet.
* The `lazy` option also needs to be enabled for this to work.
*
* This view is usually only shown for a split second. Keep it lightweight.
*
* By default, this renders null.
*/
lazyPlaceholder?: () => React.ReactNode;
/**
* Title string of a tab displayed in the tab bar
* or a function that given { focused: boolean, color: string } returns a React.Node, to display in tab bar.
@@ -77,56 +87,16 @@ export type MaterialTopTabNavigationOptions = {
| string
| ((props: { focused: boolean; color: string }) => React.ReactNode);
/**
* Accessibility label for the tab button. This is read by the screen reader when the user taps the tab.
* It's recommended to set this if you don't have a label for the tab.
*/
tabBarAccessibilityLabel?: string;
/**
* Whether label font should scale to respect Text Size accessibility settings.
*/
tabBarAllowFontScaling?: boolean;
/**
* Whether the tab label should be visible. Defaults to `true`.
*/
tabBarShowLabel?: boolean;
/**
* A function that given { focused: boolean, color: string } returns a React.Node to display in the tab bar.
*/
tabBarIcon?: (props: { focused: boolean; color: string }) => React.ReactNode;
/**
* Whether the tab icon should be visible. Defaults to `false`.
* Accessibility label for the tab button. This is read by the screen reader when the user taps the tab.
* It's recommended to set this if you don't have a label for the tab.
*/
tabBarShowIcon?: boolean;
/**
* Function that returns a React element to use as a badge for the tab.
*/
tabBarBadge?: () => React.ReactNode;
/**
* Function that returns a React element as the tab bar indicator.
*/
tabBarIndicator?: (
props: Omit<
Parameters<React.ComponentProps<typeof TabBar>['renderIndicator']>[0],
'navigationState'
> & { state: TabNavigationState<ParamListBase> }
) => React.ReactNode;
/**
* Style object for the tab bar indicator.
*/
tabBarIndicatorStyle?: StyleProp<ViewStyle>;
/**
* Style object for the view containing the tab bar indicator.
*/
tabBarIndicatorContainerStyle?: StyleProp<ViewStyle>;
tabBarAccessibilityLabel?: string;
/**
* ID to locate this tab button in tests.
@@ -153,6 +123,21 @@ export type MaterialTopTabNavigationOptions = {
*/
tabBarPressOpacity?: number;
/**
* Whether the tab label should be visible. Defaults to `true`.
*/
tabBarShowLabel?: boolean;
/**
* Whether the tab icon should be visible. Defaults to `false`.
*/
tabBarShowIcon?: boolean;
/**
* Whether label font should scale to respect Text Size accessibility settings.
*/
tabBarAllowFontScaling?: boolean;
/**
* Boolean indicating whether the tab bar bounces when overscrolling.
*/
@@ -180,6 +165,16 @@ export type MaterialTopTabNavigationOptions = {
*/
tabBarItemStyle?: StyleProp<ViewStyle>;
/**
* Style object for the tab bar indicator.
*/
tabBarIndicatorStyle?: StyleProp<ViewStyle>;
/**
* Style object for the view containing the tab bar indicator.
*/
tabBarIndicatorContainerStyle?: StyleProp<ViewStyle>;
/**
* Style object for the view containing the tab items.
*/
@@ -189,42 +184,6 @@ export type MaterialTopTabNavigationOptions = {
* Style object for the the tab bar.
*/
tabBarStyle?: StyleProp<ViewStyle>;
/**
* Whether to enable swipe gestures when this screen is focused.
* Swipe gestures are enabled by default. Passing `false` will disable swipe gestures,
* but the user can still switch tabs by pressing the tab bar.
*/
swipeEnabled?: boolean;
/**
* Whether this screen should be lazily rendered. When this is set to `true`,
* the screen will be rendered as it comes into the viewport.
* By default all screens are rendered to provide a smoother swipe experience.
* But you might want to defer the rendering of screens out of the viewport until the user sees them.
* To enable lazy rendering for this screen, set `lazy` to `true`.
*
* When you enable `lazy`, the lazy loaded screens will usually take some time to render
* when they come into the viewport. You can use the `lazyPlaceholder` prop to customize
* what the user sees during this short period.
*/
lazy?: boolean;
/**
* When `lazy` is enabled, you can specify how many adjacent screens should be preloaded in advance with this prop.
* This value defaults to `0` which means lazy pages are loaded as they come into the viewport.
*/
lazyPreloadDistance?: number;
/**
* Function that returns a React element to render if this screen hasn't been rendered yet.
* The `lazy` option also needs to be enabled for this to work.
*
* This view is usually only shown for a split second. Keep it lightweight.
*
* By default, this renders `null`.
*/
lazyPlaceholder?: () => React.ReactNode;
};
export type MaterialTopTabDescriptor = Descriptor<
@@ -247,10 +206,7 @@ export type MaterialTopTabNavigationConfig = Omit<
| 'renderScene'
| 'renderTabBar'
| 'renderLazyPlaceholder'
| 'swipeEnabled'
| 'lazy'
| 'lazyPreloadDistance'
| 'lazyPlaceholder'
> & {
/**
* Function that returns a React element to display as the tab bar.

View File

@@ -1,13 +1,8 @@
import {
ParamListBase,
Route,
TabNavigationState,
useTheme,
} from '@react-navigation/native';
import { Route, useTheme } from '@react-navigation/native';
import Color from 'color';
import * as React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { TabBar, TabBarIndicator } from 'react-native-tab-view';
import { TabBar } from 'react-native-tab-view';
import type { MaterialTopTabBarProps } from '../types';
@@ -109,21 +104,6 @@ export default function TabBarTop({
return label({ focused, color });
}}
renderBadge={({ route }) => {
const { tabBarBadge } = descriptors[route.key].options;
return tabBarBadge?.() ?? null;
}}
renderIndicator={({ navigationState: state, ...rest }) => {
return focusedOptions.tabBarIndicator ? (
focusedOptions.tabBarIndicator({
state: state as TabNavigationState<ParamListBase>,
...rest,
})
) : (
<TabBarIndicator navigationState={state} {...rest} />
);
}}
/>
);
}

View File

@@ -41,8 +41,6 @@ export default function MaterialTopTabView({
});
};
const focusedOptions = descriptors[state.routes[state.index].key].options;
return (
<TabView<Route<string>>
{...rest}
@@ -59,8 +57,6 @@ export default function MaterialTopTabView({
descriptors[route.key].options.lazyPlaceholder?.() ?? null
}
lazy={({ route }) => descriptors[route.key].options.lazy === true}
lazyPreloadDistance={focusedOptions.lazyPreloadDistance}
swipeEnabled={focusedOptions.swipeEnabled}
onSwipeStart={() => navigation.emit({ type: 'swipeStart' })}
onSwipeEnd={() => navigation.emit({ type: 'swipeEnd' })}
sceneContainerStyle={[

View File

@@ -3,48 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native-stack@6.0.0-next.11...@react-navigation/native-stack@6.0.0) (2021-08-01)
### Bug Fixes
* show error when beforeRemove is used to prevent action in naive stack ([6d518a4](https://github.com/react-navigation/react-navigation/commit/6d518a46b89496f4a3bfd2da24245fe344f97290))
### Features
* add custom header option to native-stack ([1a39632](https://github.com/react-navigation/react-navigation/commit/1a3963265648e6f0672a2f49f3d647f9acfa6597))
* basic web implementation for native stack ([de84458](https://github.com/react-navigation/react-navigation/commit/de8445896021da4865089ba44e95afffbcee0919))
* expose header height in native-stack ([#9774](https://github.com/react-navigation/react-navigation/issues/9774)) ([20abccd](https://github.com/react-navigation/react-navigation/commit/20abccda0d5074f61b2beb555b881a2087d27bb0))
# [6.0.0-next.11](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native-stack@6.0.0-next.10...@react-navigation/native-stack@6.0.0-next.11) (2021-07-16)
**Note:** Version bump only for package @react-navigation/native-stack
# [6.0.0-next.10](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native-stack@6.0.0-next.9...@react-navigation/native-stack@6.0.0-next.10) (2021-07-16)
**Note:** Version bump only for package @react-navigation/native-stack
# [6.0.0-next.9](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native-stack@6.0.0-next.7...@react-navigation/native-stack@6.0.0-next.9) (2021-07-01)
**Note:** Version bump only for package @react-navigation/native-stack
# [6.0.0-next.8](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native-stack@6.0.0-next.7...@react-navigation/native-stack@6.0.0-next.8) (2021-06-10)
**Note:** Version bump only for package @react-navigation/native-stack

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/native-stack",
"description": "Native stack navigator using react-native-screens",
"version": "6.0.0",
"version": "6.0.0-next.8",
"keywords": [
"react-native-component",
"react-component",
@@ -41,11 +41,11 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/elements": "^1.0.0",
"@react-navigation/elements": "^1.0.0-next.18",
"warn-once": "^0.1.0"
},
"devDependencies": {
"@react-navigation/native": "^6.0.0",
"@react-navigation/native": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/react": "^17.0.9",
"@types/react-native": "~0.64.9",

View File

@@ -4,18 +4,12 @@ import type {
NavigationHelpers,
NavigationProp,
ParamListBase,
Route,
RouteProp,
StackActionHelpers,
StackNavigationState,
StackRouterOptions,
} from '@react-navigation/native';
import type {
ImageSourcePropType,
StyleProp,
TextStyle,
ViewStyle,
} from 'react-native';
import type { ImageSourcePropType, StyleProp, ViewStyle } from 'react-native';
import type {
ScreenProps,
ScreenStackHeaderConfigProps,
@@ -61,48 +55,16 @@ export type NativeStackNavigationHelpers = NavigationHelpers<
// We want it to be an empty object because navigator does not have any additional props
export type NativeStackNavigationConfig = {};
export type NativeStackHeaderProps = {
/**
* Options for the back button.
*/
back?: {
/**
* Title of the previous screen.
*/
title: string;
};
/**
* Options for the current screen.
*/
options: NativeStackNavigationOptions;
/**
* Route object for the current screen.
*/
route: Route<string>;
/**
* Navigation prop for the header.
*/
navigation: NativeStackNavigationProp<ParamListBase>;
};
export type NativeStackNavigationOptions = {
/**
* String that can be displayed in the header as a fallback for `headerTitle`.
*/
title?: string;
/**
* Function that given `HeaderProps` returns a React Element to display as a header.
*/
header?: (props: NativeStackHeaderProps) => React.ReactNode;
/**
* Whether the back button is visible in the header.
* You can use it to show a back button alongside `headerLeft` if you have specified it.
*
* This will have no effect on the first screen in the stack.
*
* Only supported on iOS.
*
* @platform ios
*/
headerBackVisible?: boolean;
/**
@@ -171,10 +133,6 @@ export type NativeStackNavigationOptions = {
headerLargeTitle?: boolean;
/**
* Whether drop shadow of header is visible when a large title is shown.
*
* Only supported on iOS.
*
* @platform ios
*/
headerLargeTitleShadowVisible?: boolean;
/**
@@ -265,11 +223,12 @@ export type NativeStackNavigationOptions = {
* - fontWeight
* - color
*/
headerTitleStyle?: StyleProp<
Pick<TextStyle, 'fontFamily' | 'fontSize' | 'fontWeight'> & {
color?: string;
}
>;
headerTitleStyle?: StyleProp<{
fontFamily?: string;
fontSize?: number;
fontWeight?: string;
color?: string;
}>;
/**
* Options to render a native search bar on iOS.
*
@@ -320,8 +279,6 @@ export type NativeStackNavigationOptions = {
* Supported values:
* - "push": the new screen will perform push animation.
* - "pop": the new screen will perform pop animation.
*
* Only supported on iOS and Android.
*/
animationTypeForReplace?: ScreenProps['replaceAnimation'];
/**
@@ -334,8 +291,6 @@ export type NativeStackNavigationOptions = {
* - "slide_from_right": slide in the new screen from right (Android only, uses default animation on iOS)
* - "slide_from_left": slide in the new screen from left (Android only, uses default animation on iOS)
* - "none": don't animate the screen
*
* Only supported on iOS and Android.
*/
animation?: ScreenProps['stackAnimation'];
/**
@@ -349,8 +304,6 @@ export type NativeStackNavigationOptions = {
* - "containedTransparentModal": will use "UIModalPresentationOverCurrentContext" modal style on iOS and will fallback to "transparentModal" on Android.
* - "fullScreenModal": will use "UIModalPresentationFullScreen" modal style on iOS and will fallback to "modal" on Android.
* - "formSheet": will use "UIModalPresentationFormSheet" modal style on iOS and will fallback to "modal" on Android.
*
* Only supported on iOS and Android.
*/
presentation?: Exclude<ScreenProps['stackPresentation'], 'push'> | 'card';
/**
@@ -365,8 +318,6 @@ export type NativeStackNavigationOptions = {
* - "landscape": landscape orientations are permitted.
* - "landscape_left": landscape-left orientation is permitted.
* - "landscape_right": landscape-right orientation is permitted.
*
* Only supported on iOS and Android.
*/
orientation?: ScreenProps['screenOrientation'];
};

View File

@@ -1,330 +0,0 @@
import {
getDefaultHeaderHeight,
getHeaderTitle,
HeaderHeightContext,
HeaderShownContext,
SafeAreaProviderCompat,
} from '@react-navigation/elements';
import {
ParamListBase,
Route,
StackActions,
StackNavigationState,
useTheme,
} from '@react-navigation/native';
import * as React from 'react';
import { Platform, PlatformIOSStatic, StyleSheet } from 'react-native';
import {
useSafeAreaFrame,
useSafeAreaInsets,
} from 'react-native-safe-area-context';
import {
Screen,
ScreenStack,
StackPresentationTypes,
} from 'react-native-screens';
import warnOnce from 'warn-once';
import type {
NativeStackDescriptor,
NativeStackDescriptorMap,
NativeStackNavigationHelpers,
NativeStackNavigationOptions,
} from '../types';
import DebugContainer from './DebugContainer';
import HeaderConfig from './HeaderConfig';
const isAndroid = Platform.OS === 'android';
const MaybeNestedStack = ({
options,
route,
presentation,
children,
}: {
options: NativeStackNavigationOptions;
route: Route<string>;
presentation: Exclude<StackPresentationTypes, 'push'> | 'card';
children: React.ReactNode;
}) => {
const { colors } = useTheme();
const { header, headerShown = true, contentStyle } = options;
const isHeaderInModal = isAndroid
? false
: presentation !== 'card' && headerShown === true && header === undefined;
const headerShownPreviousRef = React.useRef(headerShown);
React.useEffect(() => {
warnOnce(
!isAndroid &&
presentation !== 'card' &&
headerShownPreviousRef.current !== headerShown,
`Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`
);
headerShownPreviousRef.current = headerShown;
}, [headerShown, presentation, route.name]);
const content = (
<DebugContainer
style={[
styles.container,
presentation !== 'transparentModal' &&
presentation !== 'containedTransparentModal' && {
backgroundColor: colors.background,
},
contentStyle,
]}
stackPresentation={presentation === 'card' ? 'push' : presentation}
>
{children}
</DebugContainer>
);
const insets = useSafeAreaInsets();
const dimensions = useSafeAreaFrame();
// landscape is meaningful only for iPhone
const isLandscape =
dimensions.width > dimensions.height &&
!(Platform as PlatformIOSStatic).isPad &&
!(Platform as PlatformIOSStatic).isTVOS;
// `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.
const isFullScreenModal =
presentation !== 'modal' && presentation !== 'formSheet';
const topInset = isFullScreenModal && !isLandscape ? insets.top : 0;
const headerHeight = getDefaultHeaderHeight(
dimensions,
!isFullScreenModal,
topInset
);
if (isHeaderInModal) {
return (
<ScreenStack style={styles.container}>
<Screen enabled style={StyleSheet.absoluteFill}>
<HeaderShownContext.Provider value>
<HeaderHeightContext.Provider value={headerHeight}>
<HeaderConfig {...options} route={route} />
{content}
</HeaderHeightContext.Provider>
</HeaderShownContext.Provider>
</Screen>
</ScreenStack>
);
}
return content;
};
type SceneViewProps = {
index: number;
descriptor: NativeStackDescriptor;
previousDescriptor?: NativeStackDescriptor;
onWillDisappear: () => void;
onAppear: () => void;
onDisappear: () => void;
onDismissed: () => void;
};
const SceneView = ({
descriptor,
previousDescriptor,
index,
onWillDisappear,
onAppear,
onDisappear,
onDismissed,
}: SceneViewProps) => {
const { route, navigation, options, render } = descriptor;
const {
gestureEnabled,
header,
headerShown,
animationTypeForReplace = 'pop',
animation,
orientation,
statusBarAnimation,
statusBarHidden,
statusBarStyle,
} = options;
let { presentation = 'card' } = options;
if (index === 0) {
// first screen should always be treated as `card`, it resolves problems with no header animation
// for navigator with first screen as `modal` and the next as `card`
presentation = 'card';
}
const isHeaderInPush = isAndroid
? headerShown
: presentation === 'card' && headerShown !== false;
const isParentHeaderShown = React.useContext(HeaderShownContext);
const insets = useSafeAreaInsets();
const parentHeaderHeight = React.useContext(HeaderHeightContext);
const headerHeight = getDefaultHeaderHeight(
useSafeAreaFrame(),
false,
insets.top
);
return (
<Screen
key={route.key}
enabled
style={StyleSheet.absoluteFill}
gestureEnabled={
isAndroid
? // This prop enables handling of system back gestures on Android
// Since we handle them in JS side, we disable this
false
: gestureEnabled
}
replaceAnimation={animationTypeForReplace}
stackPresentation={presentation === 'card' ? 'push' : presentation}
stackAnimation={animation}
screenOrientation={orientation}
statusBarAnimation={statusBarAnimation}
statusBarHidden={statusBarHidden}
statusBarStyle={statusBarStyle}
onWillDisappear={onWillDisappear}
onAppear={onAppear}
onDisappear={onDisappear}
onDismissed={onDismissed}
>
<HeaderShownContext.Provider
value={isParentHeaderShown || isHeaderInPush !== false}
>
<HeaderHeightContext.Provider
value={
isHeaderInPush !== false ? headerHeight : parentHeaderHeight ?? 0
}
>
{header !== undefined && headerShown !== false ? (
// TODO: expose custom header height
header({
back: previousDescriptor
? {
title: getHeaderTitle(
previousDescriptor.options,
previousDescriptor.route.name
),
}
: undefined,
options,
route,
navigation,
})
) : (
<HeaderConfig
{...options}
route={route}
headerShown={isHeaderInPush}
/>
)}
<MaybeNestedStack
options={options}
route={route}
presentation={presentation}
>
{render()}
</MaybeNestedStack>
</HeaderHeightContext.Provider>
</HeaderShownContext.Provider>
</Screen>
);
};
type Props = {
state: StackNavigationState<ParamListBase>;
navigation: NativeStackNavigationHelpers;
descriptors: NativeStackDescriptorMap;
};
function NativeStackViewInner({ state, navigation, descriptors }: Props) {
const [nextDismissedKey, setNextDismissedKey] =
React.useState<string | null>(null);
const dismissedRouteName = nextDismissedKey
? state.routes.find((route) => route.key === nextDismissedKey)?.name
: null;
React.useEffect(() => {
if (dismissedRouteName) {
const message =
`The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +
`This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\n\n` +
`Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;
console.error(message);
}
}, [dismissedRouteName]);
return (
<ScreenStack style={styles.container}>
{state.routes.map((route, index) => {
const descriptor = descriptors[route.key];
const previousKey = state.routes[index - 1]?.key;
const previousDescriptor = previousKey
? descriptors[previousKey]
: undefined;
return (
<SceneView
key={route.key}
index={index}
descriptor={descriptor}
previousDescriptor={previousDescriptor}
onWillDisappear={() => {
navigation.emit({
type: 'transitionStart',
data: { closing: true },
target: route.key,
});
}}
onAppear={() => {
navigation.emit({
type: 'transitionEnd',
data: { closing: false },
target: route.key,
});
}}
onDisappear={() => {
navigation.emit({
type: 'transitionEnd',
data: { closing: true },
target: route.key,
});
}}
onDismissed={() => {
navigation.dispatch({
...StackActions.pop(),
source: route.key,
target: state.key,
});
setNextDismissedKey(route.key);
}}
/>
);
})}
</ScreenStack>
);
}
export default function NativeStackView(props: Props) {
return (
<SafeAreaProviderCompat>
<NativeStackViewInner {...props} />
</SafeAreaProviderCompat>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});

View File

@@ -1,147 +1,203 @@
import { SafeAreaProviderCompat } from '@react-navigation/elements';
import {
getHeaderTitle,
Header,
HeaderBackButton,
SafeAreaProviderCompat,
Screen,
} from '@react-navigation/elements';
import type {
ParamListBase,
Route,
StackActions,
StackNavigationState,
useTheme,
} from '@react-navigation/native';
import * as React from 'react';
import { Image, StyleSheet, View } from 'react-native';
import { Platform, StyleSheet } from 'react-native';
import {
Screen,
ScreenStack,
StackPresentationTypes,
} from 'react-native-screens';
import warnOnce from 'warn-once';
import type {
NativeStackDescriptorMap,
NativeStackNavigationHelpers,
NativeStackNavigationOptions,
} from '../types';
import DebugContainer from './DebugContainer';
import HeaderConfig from './HeaderConfig';
const isAndroid = Platform.OS === 'android';
const MaybeNestedStack = ({
options,
route,
presentation,
children,
}: {
options: NativeStackNavigationOptions;
route: Route<string>;
presentation: Exclude<StackPresentationTypes, 'push'> | 'card';
children: React.ReactNode;
}) => {
const { colors } = useTheme();
const { headerShown = true, contentStyle } = options;
const isHeaderInModal = isAndroid
? false
: presentation !== 'card' && headerShown === true;
const headerShownPreviousRef = React.useRef(headerShown);
React.useEffect(() => {
warnOnce(
!isAndroid &&
presentation !== 'card' &&
headerShownPreviousRef.current !== headerShown,
`Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`
);
headerShownPreviousRef.current = headerShown;
}, [headerShown, presentation, route.name]);
const content = (
<DebugContainer
style={[
styles.container,
presentation !== 'transparentModal' &&
presentation !== 'containedTransparentModal' && {
backgroundColor: colors.background,
},
contentStyle,
]}
stackPresentation={presentation === 'card' ? 'push' : presentation}
>
{children}
</DebugContainer>
);
if (isHeaderInModal) {
return (
<ScreenStack style={styles.container}>
<Screen enabled style={StyleSheet.absoluteFill}>
<HeaderConfig {...options} route={route} />
{content}
</Screen>
</ScreenStack>
);
}
return content;
};
type Props = {
state: StackNavigationState<ParamListBase>;
// This is used for the native implementation of the stack.
// eslint-disable-next-line react/no-unused-prop-types
navigation: NativeStackNavigationHelpers;
descriptors: NativeStackDescriptorMap;
};
export default function NativeStackView({ state, descriptors }: Props) {
function NativeStackViewInner({ state, navigation, descriptors }: Props) {
return (
<ScreenStack style={styles.container}>
{state.routes.map((route, index) => {
const { options, render: renderScene } = descriptors[route.key];
const {
gestureEnabled,
headerShown,
animationTypeForReplace = 'pop',
animation,
orientation,
statusBarAnimation,
statusBarHidden,
statusBarStyle,
} = options;
let { presentation = 'card' } = options;
if (index === 0) {
// first screen should always be treated as `card`, it resolves problems with no header animation
// for navigator with first screen as `modal` and the next as `card`
presentation = 'card';
}
const isHeaderInPush = isAndroid
? headerShown
: presentation === 'card' && headerShown !== false;
return (
<Screen
key={route.key}
enabled
style={StyleSheet.absoluteFill}
gestureEnabled={
isAndroid
? // This prop enables handling of system back gestures on Android
// Since we handle them in JS side, we disable this
false
: gestureEnabled
}
replaceAnimation={animationTypeForReplace}
stackPresentation={presentation === 'card' ? 'push' : presentation}
stackAnimation={animation}
screenOrientation={orientation}
statusBarAnimation={statusBarAnimation}
statusBarHidden={statusBarHidden}
statusBarStyle={statusBarStyle}
onWillAppear={() => {
navigation.emit({
type: 'transitionStart',
data: { closing: false },
target: route.key,
});
}}
onWillDisappear={() => {
navigation.emit({
type: 'transitionStart',
data: { closing: true },
target: route.key,
});
}}
onAppear={() => {
navigation.emit({
type: 'transitionEnd',
data: { closing: false },
target: route.key,
});
}}
onDisappear={() => {
navigation.emit({
type: 'transitionEnd',
data: { closing: true },
target: route.key,
});
}}
onDismissed={() => {
navigation.dispatch({
...StackActions.pop(),
source: route.key,
target: state.key,
});
}}
>
<HeaderConfig
{...options}
route={route}
headerShown={isHeaderInPush}
/>
<MaybeNestedStack
options={options}
route={route}
presentation={presentation}
>
{renderScene()}
</MaybeNestedStack>
</Screen>
);
})}
</ScreenStack>
);
}
export default function NativeStackView(props: Props) {
return (
<SafeAreaProviderCompat>
<View style={styles.container}>
{state.routes.map((route, i) => {
const isFocused = state.index === i;
const canGoBack = i !== 0;
const previousKey = state.routes[i - 1]?.key;
const previousDescriptor = previousKey
? descriptors[previousKey]
: undefined;
const { options, navigation, render } = descriptors[route.key];
const {
header,
headerShown,
headerTintColor,
headerBackImageSource,
headerLeft,
headerRight,
headerTitle,
headerTitleStyle,
headerStyle,
headerShadowVisible,
headerTranslucent,
contentStyle,
} = options;
return (
<Screen
key={route.key}
focused={isFocused}
route={route}
navigation={navigation}
headerShown={headerShown}
header={
header !== undefined ? (
header({
back: previousDescriptor
? {
title: getHeaderTitle(
previousDescriptor.options,
previousDescriptor.route.name
),
}
: undefined,
options,
route,
navigation,
})
) : (
<Header
title={getHeaderTitle(options, route.name)}
headerTintColor={headerTintColor}
headerLeft={
typeof headerLeft === 'function'
? ({ tintColor }) => headerLeft({ tintColor })
: headerLeft === undefined && canGoBack
? ({ tintColor }) => (
<HeaderBackButton
tintColor={tintColor}
backImage={
headerBackImageSource !== undefined
? () => (
<Image
source={headerBackImageSource}
style={[
styles.backImage,
{ tintColor },
]}
/>
)
: undefined
}
onPress={navigation.goBack}
canGoBack={canGoBack}
/>
)
: headerLeft
}
headerRight={
typeof headerRight === 'function'
? ({ tintColor }) => headerRight({ tintColor })
: headerRight
}
headerTitle={
typeof headerTitle === 'function'
? ({ children, tintColor }) =>
headerTitle({ children, tintColor })
: headerTitle
}
headerTitleStyle={headerTitleStyle}
headerStyle={[
headerTranslucent
? {
position: 'absolute',
backgroundColor: 'transparent',
}
: null,
headerStyle,
headerShadowVisible === false
? { shadowOpacity: 0, borderBottomWidth: 0 }
: null,
]}
/>
)
}
style={[
StyleSheet.absoluteFill,
{ display: isFocused ? 'flex' : 'none' },
]}
>
<View style={contentStyle}>{render()}</View>
</Screen>
);
})}
</View>
<NativeStackViewInner {...props} />
</SafeAreaProviderCompat>
);
}
@@ -150,10 +206,4 @@ const styles = StyleSheet.create({
container: {
flex: 1,
},
backImage: {
height: 24,
width: 24,
margin: 3,
resizeMode: 'contain',
},
});

View File

@@ -3,44 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.17...@react-navigation/native@6.0.0) (2021-08-01)
### Features
* add a way to filter out deep links from being handled ([c322b05](https://github.com/react-navigation/react-navigation/commit/c322b0501c6a9941a033471aed9e5b486b3ace7e))
# [6.0.0-next.17](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.16...@react-navigation/native@6.0.0-next.17) (2021-07-16)
**Note:** Version bump only for package @react-navigation/native
# [6.0.0-next.16](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.15...@react-navigation/native@6.0.0-next.16) (2021-07-16)
**Note:** Version bump only for package @react-navigation/native
# [6.0.0-next.15](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.13...@react-navigation/native@6.0.0-next.15) (2021-07-01)
### Bug Fixes
* disable duplicate linking check for independent containers ([20b8ebd](https://github.com/react-navigation/react-navigation/commit/20b8ebd40547d93ccf626fcd9dad327fe1807b52))
# [6.0.0-next.14](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@6.0.0-next.13...@react-navigation/native@6.0.0-next.14) (2021-06-10)
**Note:** Version bump only for package @react-navigation/native

View File

@@ -2,4 +2,4 @@
React Native integration for React Navigation.
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/getting-started/).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/getting-started/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/native",
"description": "React Native integration for React Navigation",
"version": "6.0.0",
"version": "6.0.0-next.14",
"keywords": [
"react-native",
"react-navigation",
@@ -37,7 +37,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/core": "^6.0.0",
"@react-navigation/core": "^6.0.0-next.14",
"escape-string-regexp": "^4.0.0",
"nanoid": "^3.1.23"
},

View File

@@ -74,7 +74,6 @@ function NavigationContainerInner(
useDocumentTitle(refContainer, documentTitle);
const { getInitialState } = useLinking(refContainer, {
independent: rest.independent,
enabled: isLinkingEnabled,
prefixes: [],
...linking,

View File

@@ -27,8 +27,7 @@ export type LinkingOptions<ParamList extends {}> = {
/**
* The prefixes are stripped from the URL before parsing them.
* Usually they are the `scheme` + `host` (e.g. `myapp://chat?user=jane`)
*
* This is not supported on Web.
* Only applicable on Android and iOS.
*
* @example
* ```js
@@ -42,24 +41,6 @@ export type LinkingOptions<ParamList extends {}> = {
* ```
*/
prefixes: string[];
/**
* Optional function which takes an incoming URL returns a boolean
* indicating whether React Navigation should handle it.
*
* This can be used to disable deep linking for specific URLs.
* e.g. URLs used for authentication, and not for deep linking to screens.
*
* This is not supported on Web.
*
* @example
* ```js
* {
* // Filter out URLs used by expo-auth-session
* filter: (url) => !url.includes('+expo-auth-session')
* }
* ```
*/
filter?: (url: string) => boolean;
/**
* Config to fine-tune how to parse the path.
*
@@ -80,8 +61,7 @@ export type LinkingOptions<ParamList extends {}> = {
/**
* Custom function to get the initial URL used for linking.
* Uses `Linking.getInitialURL()` by default.
*
* This is not supported on Web.
* Not supported on Web.
*
* @example
* ```js
@@ -98,8 +78,7 @@ export type LinkingOptions<ParamList extends {}> = {
/**
* Custom function to get subscribe to URL updates.
* Uses `Linking.addEventListener('url', callback)` by default.
*
* This is not supported on Web.
* Not supported on Web.
*
* @example
* ```js

View File

@@ -12,19 +12,13 @@ import type { LinkingOptions } from './types';
type ResultState = ReturnType<typeof getStateFromPathDefault>;
type Options = LinkingOptions<ParamListBase> & {
independent?: boolean;
};
let isUsingLinking = false;
export default function useLinking(
ref: React.RefObject<NavigationContainerRef<ParamListBase>>,
{
independent,
enabled = true,
prefixes,
filter,
config,
getInitialURL = () =>
Promise.race([
@@ -53,13 +47,9 @@ export default function useLinking(
},
getStateFromPath = getStateFromPathDefault,
getActionFromState = getActionFromStateDefault,
}: Options
}: LinkingOptions<ParamListBase>
) {
React.useEffect(() => {
if (independent) {
return undefined;
}
if (enabled !== false && isUsingLinking) {
throw new Error(
[
@@ -87,7 +77,6 @@ export default function useLinking(
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
const enabledRef = React.useRef(enabled);
const prefixesRef = React.useRef(prefixes);
const filterRef = React.useRef(filter);
const configRef = React.useRef(config);
const getInitialURLRef = React.useRef(getInitialURL);
const getStateFromPathRef = React.useRef(getStateFromPath);
@@ -96,28 +85,12 @@ export default function useLinking(
React.useEffect(() => {
enabledRef.current = enabled;
prefixesRef.current = prefixes;
filterRef.current = filter;
configRef.current = config;
getInitialURLRef.current = getInitialURL;
getStateFromPathRef.current = getStateFromPath;
getActionFromStateRef.current = getActionFromState;
});
const getStateFromURL = React.useCallback(
(url: string | null | undefined) => {
if (!url || (filterRef.current && !filterRef.current(url))) {
return undefined;
}
const path = extractPathFromURL(prefixesRef.current, url);
return path
? getStateFromPathRef.current(path, configRef.current)
: undefined;
},
[]
);
const getInitialState = React.useCallback(() => {
let state: ResultState | undefined;
@@ -126,13 +99,21 @@ export default function useLinking(
if (url != null && typeof url !== 'string') {
return url.then((url) => {
const state = getStateFromURL(url);
const path = url
? extractPathFromURL(prefixesRef.current, url)
: null;
return state;
return path
? getStateFromPathRef.current(path, configRef.current)
: undefined;
});
}
state = getStateFromURL(url);
const path = url ? extractPathFromURL(prefixesRef.current, url) : null;
state = path
? getStateFromPathRef.current(path, configRef.current)
: undefined;
}
const thenable = {
@@ -145,7 +126,7 @@ export default function useLinking(
};
return thenable as PromiseLike<ResultState | undefined>;
}, [getStateFromURL]);
}, []);
React.useEffect(() => {
const listener = (url: string) => {
@@ -153,41 +134,50 @@ export default function useLinking(
return;
}
const path = extractPathFromURL(prefixesRef.current, url);
const navigation = ref.current;
const state = navigation ? getStateFromURL(url) : undefined;
if (navigation && state) {
// Make sure that the routes in the state exist in the root navigator
// Otherwise there's an error in the linking configuration
const rootState = navigation.getRootState();
if (navigation && path) {
const state = getStateFromPathRef.current(path, configRef.current);
if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {
console.warn(
"The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration."
);
return;
}
if (state) {
// Make sure that the routes in the state exist in the root navigator
// Otherwise there's an error in the linking configuration
const rootState = navigation.getRootState();
const action = getActionFromStateRef.current(state, configRef.current);
if (action !== undefined) {
try {
navigation.dispatch(action);
} catch (e) {
// Ignore any errors from deep linking.
// This could happen in case of malformed links, navigation object not being initialized etc.
if (
state.routes.some((r) => !rootState?.routeNames.includes(r.name))
) {
console.warn(
`An error occurred when trying to handle the link '${url}': ${e.message}`
"The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration."
);
return;
}
const action = getActionFromStateRef.current(
state,
configRef.current
);
if (action !== undefined) {
try {
navigation.dispatch(action);
} catch (e) {
// Ignore any errors from deep linking.
// This could happen in case of malformed links, navigation object not being initialized etc.
console.warn(
`An error occurred when trying to handle the link '${path}': ${e.message}`
);
}
} else {
navigation.resetRoot(state);
}
} else {
navigation.resetRoot(state);
}
}
};
return subscribe(listener);
}, [enabled, getStateFromURL, ref, subscribe]);
}, [enabled, ref, subscribe]);
return {
getInitialState,

View File

@@ -289,26 +289,17 @@ const series = (cb: () => Promise<void>) => {
let isUsingLinking = false;
type Options = LinkingOptions<ParamListBase> & {
independent?: boolean;
};
export default function useLinking(
ref: React.RefObject<NavigationContainerRef<ParamListBase>>,
{
independent,
enabled = true,
config,
getStateFromPath = getStateFromPathDefault,
getPathFromState = getPathFromStateDefault,
getActionFromState = getActionFromStateDefault,
}: Options
}: LinkingOptions<ParamListBase>
) {
React.useEffect(() => {
if (independent) {
return undefined;
}
if (enabled !== false && isUsingLinking) {
throw new Error(
[

View File

@@ -3,25 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/routers@6.0.0-next.6...@react-navigation/routers@6.0.0) (2021-08-01)
### Bug Fixes
* don't merge initial params when merge !== true ([54b215b](https://github.com/react-navigation/react-navigation/commit/54b215b9d3192d11c4c28bd469dd217d90d6c5c5))
# [6.0.0-next.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/routers@6.0.0-next.4...@react-navigation/routers@6.0.0-next.6) (2021-07-01)
**Note:** Version bump only for package @react-navigation/routers
# [6.0.0-next.5](https://github.com/react-navigation/react-navigation/compare/@react-navigation/routers@6.0.0-next.4...@react-navigation/routers@6.0.0-next.5) (2021-06-10)
**Note:** Version bump only for package @react-navigation/routers

View File

@@ -14,4 +14,4 @@ yarn add @react-navigation/routers
## Usage
Documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/custom-routers/).
Documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/custom-routers/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/routers",
"description": "Routers to help build custom navigators",
"version": "6.0.0",
"version": "6.0.0-next.5",
"keywords": [
"react",
"react-native",

View File

@@ -434,7 +434,13 @@ export default function StackRouter(options: StackRouterOptions) {
}
: route.params;
} else {
params = action.payload.params;
params =
routeParamList[route.name] !== undefined
? {
...routeParamList[route.name],
...action.payload.params,
}
: action.payload.params;
}
return {

View File

@@ -326,7 +326,13 @@ export default function TabRouter({
}
: route.params;
} else {
params = action.payload.params;
params =
routeParamList[route.name] !== undefined
? {
...routeParamList[route.name],
...action.payload.params,
}
: action.payload.params;
}
const path =

View File

@@ -1487,7 +1487,7 @@ it("doesn't merge params on navigate to an existing screen", () => {
routeNames: ['baz', 'bar', 'qux'],
routes: [
{ key: 'baz', name: 'baz' },
{ key: 'bar', name: 'bar' },
{ key: 'bar', name: 'bar', params: { color: 'test' } },
],
});
@@ -1515,7 +1515,7 @@ it("doesn't merge params on navigate to an existing screen", () => {
routeNames: ['baz', 'bar', 'qux'],
routes: [
{ key: 'baz', name: 'baz' },
{ key: 'bar', name: 'bar', params: { fruit: 'orange' } },
{ key: 'bar', name: 'bar', params: { color: 'test', fruit: 'orange' } },
],
});
});

View File

@@ -1510,7 +1510,7 @@ it("doesn't merge params on navigate to an existing screen", () => {
routes: [
{ key: 'baz', name: 'baz' },
{ key: 'bar', name: 'bar' },
{ key: 'qux', name: 'qux', params: { test: 12 } },
{ key: 'qux', name: 'qux', params: { color: 'indigo', test: 12 } },
],
history: [
{ type: 'route', key: 'baz' },

View File

@@ -3,50 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [6.0.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.29...@react-navigation/stack@6.0.0) (2021-08-01)
### Bug Fixes
* match native iOS header height in stack ([51b636d](https://github.com/react-navigation/react-navigation/commit/51b636d7268fc05a8a9aca9e6aad0161674f238e))
* remove dep on react-native-iphonex-helper ([8a95fb5](https://github.com/react-navigation/react-navigation/commit/8a95fb588bd1f8a72fc4ef4e847f06e103ed55fe))
### Features
* expose header height in native-stack ([#9774](https://github.com/react-navigation/react-navigation/issues/9774)) ([20abccd](https://github.com/react-navigation/react-navigation/commit/20abccda0d5074f61b2beb555b881a2087d27bb0))
# [6.0.0-next.29](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.28...@react-navigation/stack@6.0.0-next.29) (2021-07-16)
**Note:** Version bump only for package @react-navigation/stack
# [6.0.0-next.28](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.27...@react-navigation/stack@6.0.0-next.28) (2021-07-16)
### Bug Fixes
* update isClosing in stack card ([#9738](https://github.com/react-navigation/react-navigation/issues/9738)) ([ee12690](https://github.com/react-navigation/react-navigation/commit/ee12690a823694fa19a3216f97676870f2999719))
# [6.0.0-next.27](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.25...@react-navigation/stack@6.0.0-next.27) (2021-07-01)
**Note:** Version bump only for package @react-navigation/stack
# [6.0.0-next.26](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@6.0.0-next.25...@react-navigation/stack@6.0.0-next.26) (2021-06-10)
**Note:** Version bump only for package @react-navigation/stack

View File

@@ -2,4 +2,4 @@
Stack navigator for React Navigation.
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/stack-navigator/).
Installation instructions and documentation can be found on the [React Navigation website](https://reactnavigation.org/docs/6.x/stack-navigator/).

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/stack",
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
"version": "6.0.0",
"version": "6.0.0-next.26",
"keywords": [
"react-native-component",
"react-component",
@@ -40,12 +40,13 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/elements": "^1.0.0",
"@react-navigation/elements": "^1.0.0-next.18",
"color": "^3.1.3",
"react-native-iphone-x-helper": "^1.3.0",
"warn-once": "^0.1.0"
},
"devDependencies": {
"@react-navigation/native": "^6.0.0",
"@react-navigation/native": "^6.0.0-next.14",
"@testing-library/react-native": "^7.2.0",
"@types/color": "^3.0.1",
"@types/react": "^17.0.9",

View File

@@ -1,4 +1,5 @@
import { Animated, Platform } from 'react-native';
import { Animated } from 'react-native';
import { isIphoneX } from 'react-native-iphone-x-helper';
import type {
StackCardInterpolatedStyle,
@@ -98,11 +99,6 @@ export function forModalPresentationIOS({
layouts: { screen },
insets,
}: StackCardInterpolationProps): StackCardInterpolatedStyle {
const hasNotchIos =
Platform.OS === 'ios' &&
!Platform.isPad &&
!Platform.isTVOS &&
insets.top > 20;
const isLandscape = screen.width > screen.height;
const topOffset = isLandscape ? 0 : 10;
const statusBarHeight = insets.top;
@@ -158,7 +154,7 @@ export function forModalPresentationIOS({
: isFirst
? progress.interpolate({
inputRange: [0, 1, 1.0001, 2],
outputRange: [0, 0, hasNotchIos ? 38 : 0, 10],
outputRange: [0, 0, isIphoneX() ? 38 : 0, 10],
})
: 10;
@@ -169,8 +165,8 @@ export function forModalPresentationIOS({
borderTopRightRadius: borderRadius,
// We don't need these for the animation
// But different border radius for corners improves animation perf
borderBottomLeftRadius: hasNotchIos ? borderRadius : 0,
borderBottomRightRadius: hasNotchIos ? borderRadius : 0,
borderBottomLeftRadius: isIphoneX() ? borderRadius : 0,
borderBottomRightRadius: isIphoneX() ? borderRadius : 0,
marginTop: isFirst ? 0 : statusBarHeight,
marginBottom: isFirst ? 0 : topOffset,
transform: [{ translateY }, { scale }],

View File

@@ -45,17 +45,17 @@ function StackNavigator({
warnOnce(
mode != null,
`Stack Navigator: 'mode="${mode}"' is deprecated. Use 'presentation: "${mode}"' in 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/stack-navigator#presentation for more details.`
`Stack Navigator: 'mode="${mode}"' is deprecated. Use 'presentation: "${mode}"' in 'screenOptions' instead.`
);
warnOnce(
headerMode === 'none',
`Stack Navigator: 'headerMode="none"' is deprecated. Use 'headerShown: false' in 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/stack-navigator/#headershown for more details.`
`Stack Navigator: 'headerMode="none"' is deprecated. Use 'headerShown: false' in 'screenOptions' instead.`
);
warnOnce(
headerMode != null && headerMode !== 'none',
`Stack Navigator: 'headerMode' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.\n\nSee https://reactnavigation.org/docs/stack-navigator/#headermode for more details.`
`Stack Navigator: 'headerMode' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.`
);
const { state, descriptors, navigation, NavigationContent } =

View File

@@ -13,7 +13,8 @@ import type {
StackNavigationState,
} from '@react-navigation/native';
import type * as React from 'react';
import type { Animated, StyleProp, TextStyle, ViewStyle } from 'react-native';
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
import type * as Animated from 'react-native-reanimated';
export type StackNavigationEventMap = {
/**
@@ -80,10 +81,6 @@ type SceneOptionsDefaults = TransitionPreset & {
};
export type Scene = {
/**
* Route object for the current screen.
*/
route: Route<string>;
/**
* Descriptor object for the screen.
*/

View File

@@ -62,7 +62,6 @@ export default React.memo(function Header({
progress={progress}
insets={insets}
layout={layout}
modal={isModal}
headerBackTitle={
options.headerBackTitle !== undefined
? options.headerBackTitle

View File

@@ -26,7 +26,6 @@ type Props = StackHeaderOptions & {
layout: Layout;
title: string;
insets: EdgeInsets;
modal: boolean;
onGoBack?: () => void;
progress: SceneProgress;
styleInterpolator: StackHeaderStyleInterpolator;
@@ -100,7 +99,6 @@ export default function HeaderSegment(props: Props) {
progress,
insets,
layout,
modal,
onGoBack,
headerTitle: title,
headerLeft: left,
@@ -122,11 +120,7 @@ export default function HeaderSegment(props: Props) {
...rest
} = props;
const defaultHeight = getDefaultHeaderHeight(
layout,
modal,
headerStatusBarHeight
);
const defaultHeight = getDefaultHeaderHeight(layout, headerStatusBarHeight);
const { height = defaultHeight } = StyleSheet.flatten(
customHeaderStyle || {}
@@ -178,7 +172,6 @@ export default function HeaderSegment(props: Props) {
return (
<Header
modal={modal}
layout={layout}
headerTitle={headerTitle}
headerLeft={headerLeft}

View File

@@ -21,6 +21,7 @@ export default function ModalStatusBarManager({
const { dark: darkTheme } = useTheme();
const [overlapping, setOverlapping] = React.useState(true);
const enabled = layout.width && layout.height > layout.width;
const scale = 1 - 20 / layout.width;
const offset = (insets.top - 34) * scale;
@@ -30,6 +31,10 @@ export default function ModalStatusBarManager({
)?.translateY;
React.useEffect(() => {
if (!enabled) {
return;
}
const listener = ({ value }: { value: number }) => {
setOverlapping(value < offset);
};
@@ -37,7 +42,11 @@ export default function ModalStatusBarManager({
const sub = translateY?.addListener(listener);
return () => translateY?.removeListener(sub);
}, [offset, translateY]);
}, [enabled, offset, translateY]);
if (!enabled) {
return null;
}
const darkContent = dark ?? !darkTheme;

View File

@@ -184,8 +184,6 @@ export default class Card extends React.Component<Props> {
this.lastToValue = toValue;
this.isClosing.setValue(closing ? TRUE : FALSE);
const spec = closing ? transitionSpec.close : transitionSpec.open;
const animation =

View File

@@ -282,7 +282,7 @@ function CardContainer({
value={isParentHeaderShown || headerShown !== false}
>
<HeaderHeightContext.Provider
value={headerShown ? headerHeight : parentHeaderHeight ?? 0}
value={headerShown ? headerHeight : parentHeaderHeight}
>
{renderScene({ route: scene.descriptor.route })}
</HeaderHeightContext.Provider>

View File

@@ -87,56 +87,28 @@ const STATE_ON_TOP = 2;
const FALLBACK_DESCRIPTOR = Object.freeze({ options: {} });
const getInterpolationIndex = (scenes: Scene[], index: number) => {
const { cardStyleInterpolator } = scenes[index].descriptor.options;
// Start from current card and count backwards the number of cards with same interpolation
let interpolationIndex = 0;
for (let i = index - 1; i >= 0; i--) {
const cardStyleInterpolatorCurrent =
scenes[i]?.descriptor.options.cardStyleInterpolator;
if (cardStyleInterpolatorCurrent !== cardStyleInterpolator) {
break;
}
interpolationIndex++;
}
return interpolationIndex;
};
const getHeaderHeights = (
scenes: Scene[],
routes: Route<string>[],
insets: EdgeInsets,
isParentHeaderShown: boolean,
descriptors: StackDescriptorMap,
layout: Layout,
previous: Record<string, number>
) => {
return scenes.reduce<Record<string, number>>((acc, curr, index) => {
const {
headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
cardStyleInterpolator,
headerStyle,
} = curr.descriptor.options;
const style = StyleSheet.flatten(headerStyle || {});
return routes.reduce<Record<string, number>>((acc, curr) => {
const { options = {} } = descriptors[curr.key] || {};
const style: any = StyleSheet.flatten(options.headerStyle || {});
const height =
typeof style.height === 'number'
? style.height
: previous[curr.route.key];
typeof style.height === 'number' ? style.height : previous[curr.key];
const interpolationIndex = getInterpolationIndex(scenes, index);
const isModalPresentation =
cardStyleInterpolator === forModalPresentationIOS;
const isModal = isModalPresentation && interpolationIndex !== 0;
const { headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top } =
options;
acc[curr.route.key] =
acc[curr.key] =
typeof height === 'number'
? height
: getDefaultHeaderHeight(layout, isModal, headerStatusBarHeight);
: getDefaultHeaderHeight(layout, headerStatusBarHeight);
return acc;
}, {});
@@ -212,152 +184,152 @@ export default class CardStack extends React.Component<Props, State> {
return acc;
}, {});
const scenes = props.routes.map((route, index, self) => {
const previousRoute = self[index - 1];
const nextRoute = self[index + 1];
const oldScene = state.scenes[index];
const currentGesture = gestures[route.key];
const previousGesture = previousRoute
? gestures[previousRoute.key]
: undefined;
const nextGesture = nextRoute ? gestures[nextRoute.key] : undefined;
const descriptor =
props.descriptors[route.key] ||
state.descriptors[route.key] ||
(oldScene ? oldScene.descriptor : FALLBACK_DESCRIPTOR);
const nextDescriptor =
props.descriptors[nextRoute?.key] || state.descriptors[nextRoute?.key];
const previousDescriptor =
props.descriptors[previousRoute?.key] ||
state.descriptors[previousRoute?.key];
// When a screen is not the last, it should use next screen's transition config
// Many transitions also animate the previous screen, so using 2 different transitions doesn't look right
// For example combining a slide and a modal transition would look wrong otherwise
// With this approach, combining different transition styles in the same navigator mostly looks right
// This will still be broken when 2 transitions have different idle state (e.g. modal presentation),
// but majority of the transitions look alright
const optionsForTransitionConfig =
index !== self.length - 1 &&
nextDescriptor &&
nextDescriptor.options.presentation !== 'transparentModal'
? nextDescriptor.options
: descriptor.options;
let defaultTransitionPreset =
optionsForTransitionConfig.presentation === 'modal'
? ModalTransition
: optionsForTransitionConfig.presentation === 'transparentModal'
? ModalFadeTransition
: DefaultTransition;
const {
animationEnabled = Platform.OS !== 'web' &&
Platform.OS !== 'windows' &&
Platform.OS !== 'macos',
gestureEnabled = Platform.OS === 'ios' && animationEnabled,
gestureDirection = defaultTransitionPreset.gestureDirection,
transitionSpec = defaultTransitionPreset.transitionSpec,
cardStyleInterpolator = animationEnabled === false
? forNoAnimationCard
: defaultTransitionPreset.cardStyleInterpolator,
headerStyleInterpolator = defaultTransitionPreset.headerStyleInterpolator,
cardOverlayEnabled = (Platform.OS !== 'ios' &&
optionsForTransitionConfig.presentation !== 'transparentModal') ||
cardStyleInterpolator === forModalPresentationIOS,
} = optionsForTransitionConfig;
const headerMode: StackHeaderMode =
descriptor.options.headerMode ??
(!(
optionsForTransitionConfig.presentation === 'modal' ||
optionsForTransitionConfig.presentation === 'transparentModal' ||
nextDescriptor?.options.presentation === 'modal' ||
nextDescriptor?.options.presentation === 'transparentModal' ||
cardStyleInterpolator === forModalPresentationIOS
) &&
Platform.OS === 'ios' &&
descriptor.options.header === undefined
? 'float'
: 'screen');
const scene = {
route,
descriptor: {
...descriptor,
options: {
...descriptor.options,
animationEnabled,
cardOverlayEnabled,
cardStyleInterpolator,
gestureDirection,
gestureEnabled,
headerStyleInterpolator,
transitionSpec,
headerMode,
},
},
progress: {
current: getProgressFromGesture(
currentGesture,
state.layout,
descriptor
),
next:
nextGesture &&
nextDescriptor.options.presentation !== 'transparentModal'
? getProgressFromGesture(
nextGesture,
state.layout,
nextDescriptor
)
: undefined,
previous: previousGesture
? getProgressFromGesture(
previousGesture,
state.layout,
previousDescriptor
)
: undefined,
},
__memo: [
state.layout,
descriptor,
nextDescriptor,
previousDescriptor,
currentGesture,
nextGesture,
previousGesture,
],
};
if (
oldScene &&
scene.__memo.every((it, i) => {
// @ts-expect-error: we haven't added __memo to the annotation to prevent usage elsewhere
return oldScene.__memo[i] === it;
})
) {
return oldScene;
}
return scene;
});
return {
routes: props.routes,
scenes,
scenes: props.routes.map((route, index, self) => {
const previousRoute = self[index - 1];
const nextRoute = self[index + 1];
const oldScene = state.scenes[index];
const currentGesture = gestures[route.key];
const previousGesture = previousRoute
? gestures[previousRoute.key]
: undefined;
const nextGesture = nextRoute ? gestures[nextRoute.key] : undefined;
const descriptor =
props.descriptors[route.key] ||
state.descriptors[route.key] ||
(oldScene ? oldScene.descriptor : FALLBACK_DESCRIPTOR);
const nextDescriptor =
props.descriptors[nextRoute?.key] ||
state.descriptors[nextRoute?.key];
const previousDescriptor =
props.descriptors[previousRoute?.key] ||
state.descriptors[previousRoute?.key];
// When a screen is not the last, it should use next screen's transition config
// Many transitions also animate the previous screen, so using 2 different transitions doesn't look right
// For example combining a slide and a modal transition would look wrong otherwise
// With this approach, combining different transition styles in the same navigator mostly looks right
// This will still be broken when 2 transitions have different idle state (e.g. modal presentation),
// but majority of the transitions look alright
const optionsForTransitionConfig =
index !== self.length - 1 &&
nextDescriptor &&
nextDescriptor.options.presentation !== 'transparentModal'
? nextDescriptor.options
: descriptor.options;
let defaultTransitionPreset =
optionsForTransitionConfig.presentation === 'modal'
? ModalTransition
: optionsForTransitionConfig.presentation === 'transparentModal'
? ModalFadeTransition
: DefaultTransition;
const {
animationEnabled = Platform.OS !== 'web' &&
Platform.OS !== 'windows' &&
Platform.OS !== 'macos',
gestureEnabled = Platform.OS === 'ios' && animationEnabled,
gestureDirection = defaultTransitionPreset.gestureDirection,
transitionSpec = defaultTransitionPreset.transitionSpec,
cardStyleInterpolator = animationEnabled === false
? forNoAnimationCard
: defaultTransitionPreset.cardStyleInterpolator,
headerStyleInterpolator = defaultTransitionPreset.headerStyleInterpolator,
cardOverlayEnabled = (Platform.OS !== 'ios' &&
optionsForTransitionConfig.presentation !== 'transparentModal') ||
cardStyleInterpolator === forModalPresentationIOS,
} = optionsForTransitionConfig;
const headerMode: StackHeaderMode =
descriptor.options.headerMode ??
(!(
optionsForTransitionConfig.presentation === 'modal' ||
optionsForTransitionConfig.presentation === 'transparentModal' ||
nextDescriptor?.options.presentation === 'modal' ||
nextDescriptor?.options.presentation === 'transparentModal' ||
cardStyleInterpolator === forModalPresentationIOS
) &&
Platform.OS === 'ios' &&
descriptor.options.header === undefined
? 'float'
: 'screen');
const scene = {
route,
descriptor: {
...descriptor,
options: {
...descriptor.options,
animationEnabled,
cardOverlayEnabled,
cardStyleInterpolator,
gestureDirection,
gestureEnabled,
headerStyleInterpolator,
transitionSpec,
headerMode,
},
},
progress: {
current: getProgressFromGesture(
currentGesture,
state.layout,
descriptor
),
next:
nextGesture &&
nextDescriptor.options.presentation !== 'transparentModal'
? getProgressFromGesture(
nextGesture,
state.layout,
nextDescriptor
)
: undefined,
previous: previousGesture
? getProgressFromGesture(
previousGesture,
state.layout,
previousDescriptor
)
: undefined,
},
__memo: [
state.layout,
descriptor,
nextDescriptor,
previousDescriptor,
currentGesture,
nextGesture,
previousGesture,
],
};
if (
oldScene &&
scene.__memo.every((it, i) => {
// @ts-expect-error: we haven't added __memo to the annotation to prevent usage elsewhere
return oldScene.__memo[i] === it;
})
) {
return oldScene;
}
return scene;
}),
gestures,
descriptors: props.descriptors,
headerHeights: getHeaderHeights(
scenes,
props.routes,
props.insets,
props.isParentHeaderShown,
state.descriptors,
state.layout,
state.headerHeights
),
@@ -395,9 +367,10 @@ export default class CardStack extends React.Component<Props, State> {
return {
layout,
headerHeights: getHeaderHeights(
state.scenes,
props.routes,
props.insets,
props.isParentHeaderShown,
state.descriptors,
layout,
state.headerHeights
),
@@ -576,6 +549,7 @@ export default class CardStack extends React.Component<Props, State> {
}
const {
cardStyleInterpolator,
headerShown = true,
headerTransparent,
headerStyle,
@@ -604,7 +578,18 @@ export default class CardStack extends React.Component<Props, State> {
}
// Start from current card and count backwards the number of cards with same interpolation
const interpolationIndex = getInterpolationIndex(scenes, index);
let interpolationIndex = 0;
for (let i = index - 1; i >= 0; i--) {
const cardStyleInterpolatorCurrent =
scenes[i]?.descriptor.options.cardStyleInterpolator;
if (cardStyleInterpolatorCurrent !== cardStyleInterpolator) {
break;
}
interpolationIndex++;
}
const isNextScreenTransparent =
scenes[index + 1]?.descriptor.options.presentation ===

View File

@@ -17744,7 +17744,7 @@ react-native-gesture-handler@~1.10.2:
invariant "^2.2.4"
prop-types "^15.7.2"
react-native-iphone-x-helper@^1.3.1:
react-native-iphone-x-helper@^1.3.0, react-native-iphone-x-helper@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010"
integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg==
@@ -17783,10 +17783,10 @@ react-native-screens@^3.3.0, react-native-screens@~3.3.0:
resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.3.0.tgz#d4464a96620b85d09e46bd6865b5f48456c244f0"
integrity sha512-ni11jC6I9cFVXdLIDwkgafDHw/STXUNzkR5Fx3w8Wikdzi8gfTEan2kiOm7aS42d2F/LXddZ6i74Z2em0L6LPQ==
react-native-tab-view@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-3.1.1.tgz#1f8d7a835ab4f5b1b1407ec8dddc1053b53fa3c6"
integrity sha512-M5pRN6utQfytKWoKlKVzg5NbkYu308qNoW1khGTtEOTs1k14p2dHJ/BWOJoJYHKbPVUyZldbG9MFT7gUl4YHnw==
react-native-tab-view@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-3.0.1.tgz#7ed8c5c4a0bb48fa8895e612d26e6d545ed03447"
integrity sha512-L7qXtYz5Z+NdWyu38zaJrlHA/8H6rNFRZXe3ydym12UEEPPoefbVZ71b9YK2O6QP0u4pUlzMpMVM/Lsz2DJ4jg==
react-native-unimodules@~0.13.3:
version "0.13.3"