mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-26 22:28:19 +08:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
848da3e2dd | ||
|
|
4cff366a0d | ||
|
|
0fb81cf926 | ||
|
|
e80c96a4eb | ||
|
|
c147129152 | ||
|
|
4b176d3581 | ||
|
|
475c390fea | ||
|
|
ef83e73a95 | ||
|
|
ccb1f612d8 | ||
|
|
2931badefc | ||
|
|
e31d63a6f4 | ||
|
|
43cc9a6874 | ||
|
|
9a3eb3a6ac | ||
|
|
683892e8ab | ||
|
|
4278291650 | ||
|
|
19470a1e02 | ||
|
|
5b60a2ee03 | ||
|
|
ace2cd0c6c | ||
|
|
f2d16abf75 | ||
|
|
2e34cb1e38 | ||
|
|
188bd33442 | ||
|
|
94d6ccada4 | ||
|
|
246f4b0e15 | ||
|
|
c828050ba1 |
@@ -2,7 +2,7 @@ version: 2
|
||||
|
||||
defaults: &defaults
|
||||
docker:
|
||||
- image: circleci/node:10.9.0
|
||||
- image: circleci/node:10
|
||||
working_directory: ~/project
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
coverage/
|
||||
flow/
|
||||
node_modules/
|
||||
lib/
|
||||
build/
|
||||
|
||||
39
.github/ISSUE_TEMPLATE.md
vendored
39
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,39 +0,0 @@
|
||||
## The issue tracker is reserved for bug reports only.
|
||||
|
||||
If you have a question, feature request, or an idea for improving the library or its related tools, please try one of the following resources:
|
||||
|
||||
- [Read the documentation](https://reactnavigation.org/)
|
||||
- [Post an issue to the website repository if you'd like to see a documentation change](http://github.com/react-navigation/website)
|
||||
- [Post a feature request to Canny](https://react-navigation.canny.io/feature-requests)
|
||||
- [Write a RFC if you have ideas for how to implement a feature request](https://github.com/react-navigation/rfcs)
|
||||
- [Get help on Discord chat (#react-navigation on Reactiflux)](https://discord.gg/4xEK3nD) or [on StackOverflow](https://stackoverflow.com/questions/tagged/react-navigation)
|
||||
- Search for your issue - it may have already been answered or even fixed in the development branch. However, if you find that an old, closed issue still persists in the latest version, you should open a new issue.
|
||||
|
||||
Bugs with react-navigation must be reproducible *without any external libraries that operate on it*. This means that if you are attempting to use Redux or MobX with it and you think you have found a bug, you must be able to reproduce it without Redux or MobX in this report. Redux related issues belong in [react-navigation-redux-helpers](https://github.com/react-navigation/react-navigation-redux-helpers), and we do not have any first-class integration with MobX at the moment.
|
||||
|
||||
---
|
||||
|
||||
### Current Behavior
|
||||
|
||||
- What code are you running and what is happening?
|
||||
- Include a screenshot if it makes sense.
|
||||
|
||||
### Expected Behavior
|
||||
|
||||
- What do you expect should be happening?
|
||||
- Include a screenshot if it makes sense.
|
||||
|
||||
### How to reproduce
|
||||
|
||||
- You must provide a way to reproduce the problem. If you are having an issue with your machine or build tools, the issue belongs on another repository as that is outside of the scope of React Navigation.
|
||||
- Either re-create the bug on [Snack](https://snack.expo.io) or link to a GitHub repository with code that reproduces the bug.
|
||||
- Explain how to run the example app and any steps that we need to take to reproduce the issue from the example app.
|
||||
|
||||
### Your Environment
|
||||
|
||||
| software | version
|
||||
| ---------------- | -------
|
||||
| react-navigation |
|
||||
| react-native |
|
||||
| node |
|
||||
| npm or yarn |
|
||||
36
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
36
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: Miscellaneous
|
||||
about: Report an issue which is regarding the core API of React Navigation.
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Current Behavior**
|
||||
|
||||
- What code are you running and what is happening?
|
||||
- Include a screenshot or video if it makes sense.
|
||||
|
||||
**Expected Behavior**
|
||||
|
||||
- What do you expect should be happening?
|
||||
- Include a screenshot or video if it makes sense.
|
||||
|
||||
**How to reproduce**
|
||||
|
||||
- You must provide a way to reproduce the problem. If you are having an issue with your machine or build tools, the issue belongs on another repository as that is outside of the scope of React Navigation.
|
||||
- Either re-create the bug on [Snack](https://snack.expo.io) or link to a GitHub repository with code that reproduces the bug.
|
||||
- Explain how to run the example app and any steps that we need to take to reproduce the issue from the example app.
|
||||
- Keep the repro code as simple as possible, with the minimum amount of code required to repro the issue.
|
||||
- Before reporting an issue, make sure you are on latest version of the package.
|
||||
|
||||
**Your Environment**
|
||||
|
||||
| software | version |
|
||||
| ---------------- | ------- |
|
||||
| iOS or Android |
|
||||
| react-navigation |
|
||||
| react-native |
|
||||
| expo |
|
||||
| node |
|
||||
| npm or yarn |
|
||||
38
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
38
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Stack Navigator
|
||||
url: https://github.com/react-navigation/stack/issues/new
|
||||
about: Submit a bug report for Stack Navigator (react-navigation-stack).
|
||||
- name: Drawer Navigator
|
||||
url: https://github.com/react-navigation/drawer/issues/new
|
||||
about: Submit a bug report for Drawer Navigator (react-navigation-drawer).
|
||||
- name: Tab Navigator
|
||||
url: https://github.com/react-navigation/tabs/issues/new
|
||||
about: Submit a bug report for Bottom Tab Navigator and Material Top Tab Navigator (react-navigation-tabs).
|
||||
- name: Material Bottom Tab Navigator
|
||||
url: https://github.com/react-navigation/material-bottom-tabs/issues/new
|
||||
about: Submit a bug report for Material Bottom Tab Navigator (react-navigation-material-bottom-tabs).
|
||||
- name: Animated Switch Navigator
|
||||
url: https://github.com/react-navigation/animated-switch/issues/new
|
||||
about: Submit a bug report for Animated Switch Navigator (react-navigation-animated-switch).
|
||||
- name: React Navigation 5
|
||||
url: https://github.com/react-navigation/navigation-ex/issues/new/choose
|
||||
about: Submit a bug report for React Navigation 5.
|
||||
- name: Common mistakes
|
||||
url: https://reactnavigation.org/docs/en/common-mistakes.html
|
||||
about: Read about common mistakes and how to fix them.
|
||||
- name: Documentation
|
||||
url: https://reactnavigation.org
|
||||
about: Read the official documentation.
|
||||
- name: Feature requests
|
||||
url: https://react-navigation.canny.io/feature-requests
|
||||
about: Post a feature request on Canny.
|
||||
- name: StackOverflow
|
||||
url: https://stackoverflow.com/questions/tagged/react-navigation
|
||||
about: Ask and answer questions using the react-navigation label.
|
||||
- name: Reactiflux
|
||||
url: https://www.reactiflux.com/
|
||||
about: Chat with other community members in the react-navigation channel.
|
||||
- name: Write an RFC
|
||||
url: https://github.com/react-navigation/rfcs
|
||||
about: Write a RFC if you have ideas for how to implement a feature request.
|
||||
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
8
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,10 +1,10 @@
|
||||
Please provide enough information so that others can review your pull request:
|
||||
|
||||
## Motivation
|
||||
**Motivation**
|
||||
|
||||
Explain the **motivation** for making this change. What existing problem does the pull request solve?
|
||||
|
||||
## Test plan
|
||||
**Test plan**
|
||||
|
||||
Demonstrate the code is solid. Example: the exact commands you ran and their output, screenshots / videos if the pull request changes UI.
|
||||
|
||||
@@ -12,6 +12,6 @@ Make sure you test on both platforms if your change affects both platforms.
|
||||
|
||||
The code must pass tests.
|
||||
|
||||
## Code formatting
|
||||
**Code formatting**
|
||||
|
||||
Look around. Match the style of the rest of the codebase. Run `yarn format` before committing.
|
||||
Look around. Match the style of the rest of the codebase. Run `yarn lint --fix` before committing.
|
||||
|
||||
16
.github/workflows/stale.yml
vendored
Normal file
16
.github/workflows/stale.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: "Close stale issues and pull requests"
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.'
|
||||
stale-pr-message: 'Hello 👋, this pull request has been open for more than 2 months with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days.'
|
||||
exempt-issue-label: 'Keep opened'
|
||||
exempt-pr-label: 'Keep opened'
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 React Native Community
|
||||
Copyright (c) 2017 React Navigation Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://badge.fury.io/js/react-navigation) [](https://circleci.com/gh/react-navigation/react-navigation/tree/master) [](https://reactnavigation.org/docs/contributing.html)
|
||||
|
||||
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution based on Javascript.
|
||||
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution based on JavaScript.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -19,7 +19,7 @@ See: https://reactnavigation.org/docs/en/getting-started.html
|
||||
|
||||
## Changelog
|
||||
|
||||
The changes for each release are outlined on [the Github releases page](https://github.com/react-navigation/react-navigation/releases).
|
||||
The changes for each release are outlined on [the GitHub releases page](https://github.com/react-navigation/react-navigation/releases).
|
||||
|
||||
## Try it out
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
module.exports = {
|
||||
presets: ['module:metro-react-native-babel-preset'],
|
||||
};
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
module.exports = {
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
};
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
"name": "React Navigation Stack Example",
|
||||
"description": "Demonstrates the various capabilities of react-navigation-stack",
|
||||
"slug": "react-navigation-stack-demo",
|
||||
"sdkVersion": "33.0.0",
|
||||
"sdkVersion": "36.0.0",
|
||||
"version": "1.0.0",
|
||||
"primaryColor": "#2196f3"
|
||||
"primaryColor": "#2196f3",
|
||||
"platforms": [
|
||||
"android",
|
||||
"ios"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,45 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies, import/no-commonjs */
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
|
||||
const path = require('path');
|
||||
const blacklist = require('metro-config/src/defaults/blacklist');
|
||||
const project = require('../package.json');
|
||||
const fs = require('fs');
|
||||
const escape = require('escape-string-regexp');
|
||||
const blacklist = require('metro-config/src/defaults/blacklist');
|
||||
|
||||
const projectDependencies = Object.keys({
|
||||
...project.dependencies,
|
||||
...project.peerDependencies,
|
||||
});
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const pak = JSON.parse(
|
||||
fs.readFileSync(path.join(root, 'package.json'), 'utf8')
|
||||
);
|
||||
|
||||
const modules = [
|
||||
'@babel/runtime',
|
||||
'@expo/vector-icons',
|
||||
...Object.keys({
|
||||
...pak.dependencies,
|
||||
...pak.peerDependencies,
|
||||
}),
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
projectRoot: __dirname,
|
||||
watchFolders: [path.resolve(__dirname, '..')],
|
||||
watchFolders: [root],
|
||||
|
||||
resolver: {
|
||||
blacklistRE: blacklist([
|
||||
new RegExp(
|
||||
`^${escape(
|
||||
path.resolve(__dirname, 'node_modules', project.name)
|
||||
)}\\/.*$`
|
||||
),
|
||||
new RegExp(
|
||||
`^${escape(path.resolve(__dirname, '..', 'node_modules'))}\\/.*$`
|
||||
),
|
||||
new RegExp(`^${escape(path.join(root, 'node_modules'))}\\/.*$`),
|
||||
]),
|
||||
|
||||
providesModuleNodeModules: [
|
||||
'@expo/vector-icons',
|
||||
'@babel/runtime',
|
||||
...projectDependencies,
|
||||
],
|
||||
extraNodeModules: modules.reduce((acc, name) => {
|
||||
acc[name] = path.join(__dirname, 'node_modules', name);
|
||||
return acc;
|
||||
}, {}),
|
||||
},
|
||||
|
||||
transformer: {
|
||||
getTransformOptions: async () => ({
|
||||
transform: {
|
||||
experimentalImportSupport: false,
|
||||
inlineRequires: true,
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -9,29 +9,30 @@
|
||||
"ios": "expo start --ios"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "^10.0.0",
|
||||
"@react-native-community/masked-view": "^0.1.1",
|
||||
"@expo/vector-icons": "^10.0.6",
|
||||
"@react-native-community/masked-view": "0.1.5",
|
||||
"@react-navigation/core": "^3.5.1",
|
||||
"@react-navigation/native": "^3.6.2",
|
||||
"expo": "^33.0.7",
|
||||
"expo-asset": "^5.0.1",
|
||||
"expo-blur": "~5.0.1",
|
||||
"expo-constants": "~5.0.1",
|
||||
"hoist-non-react-statics": "^3.3.0",
|
||||
"react": "16.8.3",
|
||||
"react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
|
||||
"expo": "^36.0.0",
|
||||
"expo-asset": "~8.0.0",
|
||||
"expo-blur": "~8.0.0",
|
||||
"expo-constants": "~8.0.0",
|
||||
"hoist-non-react-statics": "^3.3.1",
|
||||
"react": "16.9.0",
|
||||
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz",
|
||||
"react-native-gesture-handler": "~1.5.0",
|
||||
"react-native-iphone-x-helper": "^1.2.1",
|
||||
"react-native-paper": "^2.15.2",
|
||||
"react-navigation-drawer": "^2.0.1",
|
||||
"react-navigation-header-buttons": "^3.0.2",
|
||||
"react-navigation-stack": "^1.7.2",
|
||||
"react-navigation-tabs": "^1.2.0"
|
||||
"react-native-paper": "^3.4.0",
|
||||
"react-native-reanimated": "~1.4.0",
|
||||
"react-native-safe-area-context": "0.6.0",
|
||||
"react-native-screens": "2.0.0-alpha.12",
|
||||
"react-navigation-drawer": "^2.3.3",
|
||||
"react-navigation-header-buttons": "^3.0.4",
|
||||
"react-navigation-stack": "^2.0.4",
|
||||
"react-navigation-tabs": "^2.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-plugin-module-resolver": "^3.2.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"react-native-safe-area-view": "0.14.6",
|
||||
"react-native-screens": "1.0.0-alpha.23"
|
||||
"babel-plugin-module-resolver": "^4.0.0",
|
||||
"expo-cli": "^3.11.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
} from 'react-navigation-stack';
|
||||
import { createDrawerNavigator } from 'react-navigation-drawer';
|
||||
import {
|
||||
createDrawerNavigator,
|
||||
NavigationDrawerScreenProps,
|
||||
} from 'react-navigation-drawer';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import SampleText from './SampleText';
|
||||
|
||||
@@ -25,7 +28,13 @@ const MyNavScreen = ({
|
||||
<ScrollView>
|
||||
<SafeAreaView forceInset={{ top: 'always' }}>
|
||||
<SampleText>{banner}</SampleText>
|
||||
<Button onPress={() => navigation.openDrawer()} title="Open drawer" />
|
||||
<Button
|
||||
onPress={() => {
|
||||
// @ts-ignore
|
||||
navigation.openDrawer();
|
||||
}}
|
||||
title="Open drawer"
|
||||
/>
|
||||
<Button
|
||||
onPress={() => navigation.navigate('Email')}
|
||||
title="Open other screen"
|
||||
@@ -36,11 +45,10 @@ const MyNavScreen = ({
|
||||
</ScrollView>
|
||||
);
|
||||
|
||||
const InboxScreen = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => <MyNavScreen banner="Inbox Screen" navigation={navigation} />;
|
||||
const InboxScreen = ({ navigation }: NavigationDrawerScreenProps) => (
|
||||
<MyNavScreen banner="Inbox Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
InboxScreen.navigationOptions = {
|
||||
headerTitle: 'Inbox',
|
||||
};
|
||||
@@ -52,6 +60,7 @@ const EmailScreen = ({ navigation }: NavigationStackScreenProps) => (
|
||||
const DraftsScreen = ({ navigation }: NavigationStackScreenProps) => (
|
||||
<MyNavScreen banner="Drafts Screen" navigation={navigation} />
|
||||
);
|
||||
|
||||
DraftsScreen.navigationOptions = {
|
||||
headerTitle: 'Drafts',
|
||||
};
|
||||
|
||||
@@ -92,7 +92,7 @@ const ProfileNavigator = createStackNavigator(
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: {
|
||||
headerLeft: null,
|
||||
headerLeft: () => null,
|
||||
},
|
||||
mode: 'modal',
|
||||
}
|
||||
@@ -107,8 +107,9 @@ MyHeaderTestScreen.navigationOptions = ({
|
||||
}: NavigationStackScreenProps) => {
|
||||
const headerVisible =
|
||||
navigation.state.params && navigation.state.params.headerVisible;
|
||||
|
||||
return {
|
||||
header: headerVisible ? undefined : null,
|
||||
headerShown: headerVisible,
|
||||
title: 'Now you see me',
|
||||
};
|
||||
};
|
||||
@@ -122,7 +123,7 @@ const ModalStack = createStackNavigator(
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: {
|
||||
header: null,
|
||||
headerShown: false,
|
||||
},
|
||||
mode: 'modal',
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ MyProfileScreen.navigationOptions = (props: NavigationStackScreenProps) => {
|
||||
headerBackImage: params!.headerBackImage,
|
||||
// Render a button on the right side of the header.
|
||||
// When pressed switches the screen to edit mode.
|
||||
headerRight: (
|
||||
headerRight: () => (
|
||||
<HeaderButtons>
|
||||
<HeaderButtons.Item
|
||||
title={params!.mode === 'edit' ? 'Done' : 'Edit'}
|
||||
@@ -221,23 +221,18 @@ MyProfileScreen.navigationOptions = (props: NavigationStackScreenProps) => {
|
||||
};
|
||||
};
|
||||
|
||||
const SimpleStack = createStackNavigator(
|
||||
{
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
Photos: {
|
||||
path: 'photos/:name',
|
||||
screen: MyPhotosScreen,
|
||||
},
|
||||
Profile: {
|
||||
path: 'people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
const SimpleStack = createStackNavigator({
|
||||
Home: {
|
||||
screen: MyHomeScreen,
|
||||
},
|
||||
{
|
||||
// headerLayoutPreset: 'center',
|
||||
}
|
||||
);
|
||||
Photos: {
|
||||
path: 'photos/:name',
|
||||
screen: MyPhotosScreen,
|
||||
},
|
||||
Profile: {
|
||||
path: 'people/:name',
|
||||
screen: MyProfileScreen,
|
||||
},
|
||||
});
|
||||
|
||||
export default SimpleStack;
|
||||
|
||||
@@ -39,6 +39,7 @@ const MyNavScreen = ({
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
{TEXT.split('\n').map((p, n) => (
|
||||
<Themed.Text
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
key={n}
|
||||
style={{ marginVertical: 10, marginHorizontal: 8 }}
|
||||
>
|
||||
|
||||
@@ -52,7 +52,7 @@ interface MyHomeScreenProps {
|
||||
|
||||
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
static navigationOptions = {
|
||||
headerBackTitle: null,
|
||||
headerBackTitleVisible: false,
|
||||
title: 'Welcome',
|
||||
};
|
||||
|
||||
@@ -65,13 +65,14 @@ class MyHomeScreen extends React.Component<MyHomeScreenProps> {
|
||||
interface MyPhotosScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
static navigationOptions = ({
|
||||
navigation,
|
||||
}: {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}) => ({
|
||||
headerBackTitle: null,
|
||||
headerBackTitleVisible: false,
|
||||
title: `${navigation.state.params!.name}'s photos`,
|
||||
});
|
||||
|
||||
@@ -94,6 +95,7 @@ class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
|
||||
interface MyProfileScreenProps {
|
||||
navigation: NavigationScreenProp<NavigationState>;
|
||||
}
|
||||
|
||||
class MyProfileScreen extends React.Component<MyProfileScreenProps> {
|
||||
static navigationOptions = {
|
||||
title: 'Profile',
|
||||
|
||||
@@ -3,6 +3,8 @@ import { SafeAreaView, Themed } from 'react-navigation';
|
||||
import {
|
||||
createStackNavigator,
|
||||
NavigationStackScreenProps,
|
||||
TransitionPresets,
|
||||
HeaderStyleInterpolators,
|
||||
} from 'react-navigation-stack';
|
||||
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
@@ -78,7 +80,7 @@ class ScreenWithLongTitle extends React.Component<NavigationStackScreenProps> {
|
||||
|
||||
class ScreenWithNoHeader extends React.Component<NavigationStackScreenProps> {
|
||||
static navigationOptions = {
|
||||
header: null,
|
||||
headerShown: false,
|
||||
title: 'No Header',
|
||||
};
|
||||
|
||||
@@ -105,7 +107,10 @@ const StackWithHeaderPreset = createStackNavigator(
|
||||
ScreenWithNoHeader,
|
||||
},
|
||||
{
|
||||
headerTransitionPreset: 'uikit',
|
||||
defaultNavigationOptions: {
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
headerStyleInterpolator: HeaderStyleInterpolators.forUIKit,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import { Platform, ScrollView, StyleSheet, View } from 'react-native';
|
||||
import { BlurView } from 'expo-blur';
|
||||
import { isIphoneX } from 'react-native-iphone-x-helper';
|
||||
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
||||
import {
|
||||
NavigationEventPayload,
|
||||
NavigationEventSubscription,
|
||||
@@ -10,10 +10,10 @@ import {
|
||||
} from 'react-navigation';
|
||||
import {
|
||||
createStackNavigator,
|
||||
Header,
|
||||
HeaderStyleInterpolator,
|
||||
HeaderStyleInterpolators,
|
||||
NavigationStackScreenProps,
|
||||
NavigationStackProp,
|
||||
TransitionPresets,
|
||||
} from 'react-navigation-stack';
|
||||
import { Button } from './commonComponents/ButtonWithMargin';
|
||||
import { HeaderButtons } from './commonComponents/HeaderButtons';
|
||||
@@ -56,15 +56,8 @@ class MyNavScreen extends React.Component<MyNavScreenProps> {
|
||||
// at some point.
|
||||
|
||||
getHeaderInset(): any {
|
||||
const NOTCH_HEIGHT = isIphoneX() ? 25 : 0;
|
||||
|
||||
// $FlowIgnore: we will remove the HEIGHT static soon enough
|
||||
const BASE_HEADER_HEIGHT = Header.HEIGHT;
|
||||
|
||||
const HEADER_HEIGHT =
|
||||
Platform.OS === 'ios'
|
||||
? BASE_HEADER_HEIGHT + NOTCH_HEIGHT
|
||||
: BASE_HEADER_HEIGHT + 20;
|
||||
getStatusBarHeight() + Platform.select({ ios: 44, default: 56 });
|
||||
|
||||
return Platform.select({
|
||||
android: {
|
||||
@@ -193,10 +186,12 @@ MyProfileScreen.navigationOptions = (props: {
|
||||
const { state, setParams } = navigation;
|
||||
const { params } = state;
|
||||
return {
|
||||
headerBackImage: params!.headerBackImage,
|
||||
headerBackImage: params!.headerBackImage
|
||||
? () => params!.headerBackImage
|
||||
: undefined,
|
||||
// Render a button on the right side of the header.
|
||||
// When pressed switches the screen to edit mode.
|
||||
headerRight: (
|
||||
headerRight: () => (
|
||||
<HeaderButtons>
|
||||
<HeaderButtons.Item
|
||||
color={theme === 'light' ? '#000' : '#fff'}
|
||||
@@ -227,7 +222,8 @@ const StackWithTranslucentHeader = createStackNavigator(
|
||||
},
|
||||
{
|
||||
defaultNavigationOptions: ({ theme }: NavigationStackScreenProps) => ({
|
||||
headerBackground:
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
headerBackground: () =>
|
||||
Platform.OS === 'ios' ? (
|
||||
<BlurView
|
||||
style={{ flex: 1 }}
|
||||
@@ -241,13 +237,7 @@ const StackWithTranslucentHeader = createStackNavigator(
|
||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||
},
|
||||
headerTransparent: true,
|
||||
}),
|
||||
headerTransitionPreset: 'uikit',
|
||||
// You can leave this out if you don't want the card shadow to
|
||||
// be visible through the header
|
||||
transitionConfig: () => ({
|
||||
headerBackgroundInterpolator:
|
||||
HeaderStyleInterpolator.forBackgroundWithTranslation,
|
||||
headerStyleInterpolator: HeaderStyleInterpolators.forUIKit,
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -51,6 +51,7 @@ class MyNavScreen extends React.Component<Props> {
|
||||
<Button onPress={() => navigation.goBack(null)} title="Go back" />
|
||||
|
||||
{TEXT.split('\n').map((p, n) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<Text key={n} style={{ marginVertical: 10, marginHorizontal: 8 }}>
|
||||
{p}
|
||||
</Text>
|
||||
|
||||
@@ -147,7 +147,7 @@ const StackNavigator = createStackNavigator(
|
||||
Root: {
|
||||
screen: TabNavigator,
|
||||
navigationOptions: {
|
||||
header: null,
|
||||
headerShown: false,
|
||||
},
|
||||
},
|
||||
NotifSettings: {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 939 B After Width: | Height: | Size: 930 B |
Binary file not shown.
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 75 KiB |
10296
example/yarn.lock
10296
example/yarn.lock
File diff suppressed because it is too large
Load Diff
1310
flow/react-navigation.js
vendored
1310
flow/react-navigation.js
vendored
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-navigation",
|
||||
"version": "4.0.8",
|
||||
"version": "4.1.1",
|
||||
"description": "Routing and navigation for your React Native apps",
|
||||
"main": "src/react-navigation.js",
|
||||
"types": "typescript/react-navigation.d.ts",
|
||||
@@ -31,28 +31,28 @@
|
||||
"react-native": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-navigation/core": "^3.5.1",
|
||||
"@react-navigation/native": "^3.6.2"
|
||||
"@react-navigation/core": "^3.5.2",
|
||||
"@react-navigation/native": "^3.6.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/config-conventional": "^8.0.0",
|
||||
"@commitlint/config-conventional": "^8.3.4",
|
||||
"@release-it/conventional-changelog": "^1.1.0",
|
||||
"@types/jest": "^24.0.18",
|
||||
"@types/react": "^16.9.2",
|
||||
"@types/react-native": "^0.60.9",
|
||||
"codecov": "^3.5.0",
|
||||
"commitlint": "^8.0.0",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-satya164": "^2.4.1",
|
||||
"@types/jest": "^24.0.25",
|
||||
"@types/react": "^16.9.17",
|
||||
"@types/react-native": "^0.60.27",
|
||||
"codecov": "^3.6.1",
|
||||
"commitlint": "^8.3.4",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-satya164": "^3.1.5",
|
||||
"eslint-plugin-react-native-globals": "^0.1.0",
|
||||
"husky": "^3.0.0",
|
||||
"husky": "^3.1.0",
|
||||
"jest": "^24.9.0",
|
||||
"prettier": "^1.18.2",
|
||||
"prettier": "^1.19.1",
|
||||
"react": "16.8.3",
|
||||
"react-native": "~0.59.8",
|
||||
"react-test-renderer": "16.8.3",
|
||||
"release-it": "^12.3.6",
|
||||
"typescript": "^3.6.2"
|
||||
"release-it": "^12.4.3",
|
||||
"typescript": "^3.7.4"
|
||||
},
|
||||
"jest": {
|
||||
"notify": true,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
module.exports = {
|
||||
trailingComma: 'es5',
|
||||
singleQuote: true,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const throwError = (message, page) => {
|
||||
throw new Error(
|
||||
`${message}. See https://reactnavigation.org/docs/4.x/${page}.html for more details.`
|
||||
`${message}. See https://reactnavigation.org/docs/${page}.html for more details.`
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"react-navigation": ["../src/index"]
|
||||
"react-navigation": ["./typescript/react-navigation"]
|
||||
},
|
||||
"allowUnreachableCode": false,
|
||||
"allowUnusedLabels": false,
|
||||
|
||||
1953
typescript/react-navigation.d.ts
vendored
1953
typescript/react-navigation.d.ts
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user