mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-13 22:42:25 +08:00
Compare commits
23 Commits
@react-nav
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b7bbbdfd9 | ||
|
|
c5fefc6ee9 | ||
|
|
aaf01e01e7 | ||
|
|
ac242fd281 | ||
|
|
c5fcfbd427 | ||
|
|
424c9469e4 | ||
|
|
8f40a98086 | ||
|
|
f964200b0d | ||
|
|
bd2f008a83 | ||
|
|
e37d6598ca | ||
|
|
c8ac5fab61 | ||
|
|
b6accd03f6 | ||
|
|
0cca1309ec | ||
|
|
6c9447a38c | ||
|
|
030c63c89f | ||
|
|
2bf0958502 | ||
|
|
94cff2380a | ||
|
|
359ae1bfac | ||
|
|
031136f7c8 | ||
|
|
b6e7e08b9a | ||
|
|
6c6102b459 | ||
|
|
0c59ef7328 | ||
|
|
297eabb90e |
2
.github/workflows/triage.yml
vendored
2
.github/workflows/triage.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
args: comment "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. Make sure to at least provide - Current behaviour, Expected behaviour, A way to reproduce the issue with minimal code (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.)."
|
||||
args: comment "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. Make sure to at least provide - Current behaviour, Expected behaviour, A way to reproduce the issue with minimal code (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.)."
|
||||
|
||||
needs-repro:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -161,32 +161,33 @@
|
||||
<orderEntry type="library" name="Gradle: com.facebook.fresco:imagepipeline-okhttp3:2.0.0@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: io.nlopez.smartlocation:library:3.2.11@aar" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.webkit:android-jsc:r245459@aar" level="project" />
|
||||
<orderEntry type="module" module-name="android-expo-permissions" />
|
||||
<orderEntry type="module" module-name="android-expo-constants" />
|
||||
<orderEntry type="module" module-name="android-unimodules-image-loader-interface" />
|
||||
<orderEntry type="module" module-name="android-expo-web-browser" />
|
||||
<orderEntry type="module" module-name="android-unimodules-react-native-adapter" />
|
||||
<orderEntry type="module" module-name="android-expo-file-system" />
|
||||
<orderEntry type="module" module-name="android-expo-location" />
|
||||
<orderEntry type="module" module-name="android-expo-error-recovery" />
|
||||
<orderEntry type="module" module-name="android-unimodules-permissions-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-core" />
|
||||
<orderEntry type="module" module-name="android-expo-app-loader-provider" />
|
||||
<orderEntry type="module" module-name="android-expo-font" />
|
||||
<orderEntry type="module" module-name="android-expo-keep-awake" />
|
||||
<orderEntry type="module" module-name="android-expo-linear-gradient" />
|
||||
<orderEntry type="module" module-name="android-expo-sqlite" />
|
||||
<orderEntry type="module" module-name="android-unimodules-barcode-scanner-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-camera-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-constants-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-face-detector-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-file-system-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-font-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-sensors-interface" />
|
||||
<orderEntry type="module" module-name="android-unimodules-task-manager-interface" />
|
||||
<orderEntry type="module" module-name="android-@react-native-community_masked-view" />
|
||||
<orderEntry type="module" module-name="android-react-native-gesture-handler" />
|
||||
<orderEntry type="module" module-name="android-react-native-reanimated" />
|
||||
<orderEntry type="module" module-name="expo-permissions" />
|
||||
<orderEntry type="module" module-name="expo-constants" />
|
||||
<orderEntry type="module" module-name="unimodules-image-loader-interface" />
|
||||
<orderEntry type="module" module-name="expo-web-browser" />
|
||||
<orderEntry type="module" module-name="unimodules-react-native-adapter" />
|
||||
<orderEntry type="module" module-name="expo-file-system" />
|
||||
<orderEntry type="module" module-name="expo-location" />
|
||||
<orderEntry type="module" module-name="expo-error-recovery" />
|
||||
<orderEntry type="module" module-name="unimodules-permissions-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-core" />
|
||||
<orderEntry type="module" module-name="expo-app-loader-provider" />
|
||||
<orderEntry type="module" module-name="expo-font" />
|
||||
<orderEntry type="module" module-name="expo-keep-awake" />
|
||||
<orderEntry type="module" module-name="expo-linear-gradient" />
|
||||
<orderEntry type="module" module-name="expo-sqlite" />
|
||||
<orderEntry type="module" module-name="unimodules-barcode-scanner-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-camera-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-constants-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-face-detector-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-file-system-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-font-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-sensors-interface" />
|
||||
<orderEntry type="module" module-name="unimodules-task-manager-interface" />
|
||||
<orderEntry type="module" module-name="@react-native-community_masked-view" />
|
||||
<orderEntry type="module" module-name="react-native-gesture-handler" />
|
||||
<orderEntry type="module" module-name="react-native-reanimated" />
|
||||
<orderEntry type="module" module-name="react-native-restart" />
|
||||
<orderEntry type="module" module-name="react-native-safe-area-context" />
|
||||
<orderEntry type="module" module-name="react-native-screens" />
|
||||
</component>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"expo": {
|
||||
"name": "@react-navigation/example",
|
||||
"owner": "react-navigation",
|
||||
"slug": "react-react-navigationample",
|
||||
"slug": "react-navigation-example",
|
||||
"description": "Demo app to showcase various functionality of React Navigation",
|
||||
"privacy": "public",
|
||||
"sdkVersion": "36.0.0",
|
||||
|
||||
@@ -124,7 +124,8 @@ export default function App() {
|
||||
prefixes: LinkingPrefixes,
|
||||
config: {
|
||||
Root: {
|
||||
path: 'root',
|
||||
path: '',
|
||||
initialRouteName: 'Home',
|
||||
screens: Object.keys(SCREENS).reduce<{ [key: string]: string }>(
|
||||
(acc, name) => {
|
||||
// Convert screen names such as SimpleStack to kebab case (simple-stack)
|
||||
@@ -135,7 +136,7 @@ export default function App() {
|
||||
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
{ Home: '' }
|
||||
),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,6 +3,42 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.4...@react-navigation/bottom-tabs@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.3...@react-navigation/bottom-tabs@5.0.4) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.2...@react-navigation/bottom-tabs@5.0.3) (2020-02-12)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.1...@react-navigation/bottom-tabs@5.0.2) (2020-02-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* initialize keyboard-hiding tabBar to visible=true ([#6740](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/issues/6740), [#6799](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/issues/6799)) ([0c59ef7](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/commit/0c59ef7328c63108a2a2c04e927794d73cead63a))
|
||||
* provide route context to header and bottom tabs ([b6e7e08](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/commit/b6e7e08b9a05be6c04ed21e938b9580876239116))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.0.0-alpha.45...@react-navigation/bottom-tabs@5.0.1) (2020-02-10)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"android",
|
||||
"tab"
|
||||
],
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs",
|
||||
"main": "lib/commonjs/index.js",
|
||||
@@ -35,7 +35,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
"@react-navigation/native": "^5.0.1",
|
||||
"@react-navigation/native": "^5.0.4",
|
||||
"@types/color": "^3.0.1",
|
||||
"@types/react": "^16.9.19",
|
||||
"@types/react-native": "^0.60.30",
|
||||
@@ -49,7 +49,7 @@
|
||||
"@react-navigation/native": "^5.0.0",
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-safe-area-context": "^0.6.0"
|
||||
"react-native-safe-area-context": ">= 0.6.0"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -176,8 +176,8 @@ export type BottomTabBarOptions = {
|
||||
*/
|
||||
tabStyle?: StyleProp<ViewStyle>;
|
||||
/**
|
||||
* Whether the label is renderd below the icon or beside the icon.
|
||||
* By default, in `vertical` orinetation, label is rendered below and in `horizontal` orientation, it's renderd beside.
|
||||
* Whether the label is rendered below the icon or beside the icon.
|
||||
* By default, in `vertical` orinetation, label is rendered below and in `horizontal` orientation, it's rendered beside.
|
||||
*/
|
||||
labelPosition?: LabelPosition;
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
} from 'react-native';
|
||||
import {
|
||||
NavigationContext,
|
||||
NavigationRouteContext,
|
||||
CommonActions,
|
||||
useTheme,
|
||||
} from '@react-navigation/native';
|
||||
@@ -56,7 +57,7 @@ export default function BottomTabBar({
|
||||
});
|
||||
const [keyboardShown, setKeyboardShown] = React.useState(false);
|
||||
|
||||
const [visible] = React.useState(() => new Animated.Value(0));
|
||||
const [visible] = React.useState(() => new Animated.Value(1));
|
||||
|
||||
const { routes } = state;
|
||||
|
||||
@@ -237,27 +238,29 @@ export default function BottomTabBar({
|
||||
key={route.key}
|
||||
value={descriptors[route.key].navigation}
|
||||
>
|
||||
<BottomTabItem
|
||||
route={route}
|
||||
focused={focused}
|
||||
horizontal={shouldUseHorizontalLabels()}
|
||||
onPress={onPress}
|
||||
onLongPress={onLongPress}
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
testID={options.tabBarTestID}
|
||||
allowFontScaling={allowFontScaling}
|
||||
activeTintColor={activeTintColor}
|
||||
inactiveTintColor={inactiveTintColor}
|
||||
activeBackgroundColor={activeBackgroundColor}
|
||||
inactiveBackgroundColor={inactiveBackgroundColor}
|
||||
button={options.tabBarButton}
|
||||
icon={options.tabBarIcon}
|
||||
label={label}
|
||||
showIcon={showIcon}
|
||||
showLabel={showLabel}
|
||||
labelStyle={labelStyle}
|
||||
style={tabStyle}
|
||||
/>
|
||||
<NavigationRouteContext.Provider value={route}>
|
||||
<BottomTabItem
|
||||
route={route}
|
||||
focused={focused}
|
||||
horizontal={shouldUseHorizontalLabels()}
|
||||
onPress={onPress}
|
||||
onLongPress={onLongPress}
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
testID={options.tabBarTestID}
|
||||
allowFontScaling={allowFontScaling}
|
||||
activeTintColor={activeTintColor}
|
||||
inactiveTintColor={inactiveTintColor}
|
||||
activeBackgroundColor={activeBackgroundColor}
|
||||
inactiveBackgroundColor={inactiveBackgroundColor}
|
||||
button={options.tabBarButton}
|
||||
icon={options.tabBarIcon}
|
||||
label={label}
|
||||
showIcon={showIcon}
|
||||
showLabel={showLabel}
|
||||
labelStyle={labelStyle}
|
||||
style={tabStyle}
|
||||
/>
|
||||
</NavigationRouteContext.Provider>
|
||||
</NavigationContext.Provider>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -3,6 +3,38 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.4...@react-navigation/compat@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/compat
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.3...@react-navigation/compat@5.0.4) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/compat
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.2...@react-navigation/compat@5.0.3) (2020-02-12)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/compat
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.1...@react-navigation/compat@5.0.2) (2020-02-11)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/compat
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.0.0-alpha.34...@react-navigation/compat@5.0.1) (2020-02-10)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/compat
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/compat",
|
||||
"description": "Compatibility layer to write navigator definitions in static configuration format",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/compat",
|
||||
"bugs": {
|
||||
@@ -26,14 +26,14 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
"@react-navigation/native": "^5.0.1",
|
||||
"@react-navigation/native": "^5.0.4",
|
||||
"@types/react": "^16.9.19",
|
||||
"react": "~16.9.0",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@react-navigation/native": "^5.0.0",
|
||||
"react": "~16.9.0"
|
||||
"react": "*"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -3,6 +3,54 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.1.4](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.1.3...@react-navigation/core@5.1.4) (2020-02-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* link to migration guide on invalid usage ([c5fcfbd](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/c5fcfbd4277541e131acbaa7602a5d7e636afebb))
|
||||
* return '/' for empty paths ([aaf01e0](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/aaf01e01e7b47b375f68aebe6d0effe82878d060))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.1.3](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.1.2...@react-navigation/core@5.1.3) (2020-02-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* return false for canGoBack if navigator hasn't finished mounting ([c8ac5fa](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/c8ac5fab61cf127985431075a3c59c1f3dfa42da))
|
||||
* throw a descriptive error if navigation object hasn't initialized ([b6accd0](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/b6accd03f69dd438e595094d8bf8599cc12e71ac))
|
||||
* update links in error messages ([f964200](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/f964200b0dcbc19d5f88ad2dd1eb8e5576973497))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.1.1...@react-navigation/core@5.1.2) (2020-02-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix false positives for circular object check ([030c63c](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/030c63c89fe447aa484b767831c8f8e26e90431c)), closes [#6827](https://github.com/react-navigation/react-navigation/tree/master/packages/core/issues/6827)
|
||||
* static container memo check ([#6825](https://github.com/react-navigation/react-navigation/tree/master/packages/core/issues/6825)) ([2bf0958](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/2bf09585021470f500d967e9242836840efe970f))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.1.0...@react-navigation/core@5.1.1) (2020-02-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* don't cleanup state on switching navigator ([359ae1b](https://github.com/react-navigation/react-navigation/tree/master/packages/core/commit/359ae1bfacec5ef880b3944f465c881aedb16767))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [5.1.0](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.0.0-alpha.43...@react-navigation/core@5.1.0) (2020-02-10)
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/core",
|
||||
"description": "Core utilities for building navigators",
|
||||
"version": "5.1.0",
|
||||
"version": "5.1.3",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-native",
|
||||
@@ -49,7 +49,7 @@
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "~16.9.0"
|
||||
"react": "*"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -22,18 +22,28 @@ type State = NavigationState | PartialState<NavigationState> | undefined;
|
||||
const MISSING_CONTEXT_ERROR =
|
||||
"We couldn't find a navigation context. Have you wrapped your app with 'NavigationContainer'? See https://reactnavigation.org/docs/en/getting-started.html for setup instructions.";
|
||||
|
||||
const NOT_INITIALIZED_ERROR =
|
||||
"The 'navigation' object hasn't been initialized yet. This might happen if you don't have a navigator mounted, or if the navigator hasn't finished mounting. You can ensure that all navigators have mounted after the callback to 'useEffect' is called in your root component. See https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html#handling-initialization for more details.";
|
||||
|
||||
export const NavigationStateContext = React.createContext<{
|
||||
isDefault?: true;
|
||||
state?: NavigationState | PartialState<NavigationState>;
|
||||
getKey: () => string | undefined;
|
||||
setKey: (key: string) => void;
|
||||
getState: () => NavigationState | PartialState<NavigationState> | undefined;
|
||||
setState: (
|
||||
state: NavigationState | PartialState<NavigationState> | undefined
|
||||
) => void;
|
||||
key?: string;
|
||||
performTransaction: (action: () => void) => void;
|
||||
}>({
|
||||
isDefault: true,
|
||||
|
||||
get getKey(): any {
|
||||
throw new Error(MISSING_CONTEXT_ERROR);
|
||||
},
|
||||
get setKey(): any {
|
||||
throw new Error(MISSING_CONTEXT_ERROR);
|
||||
},
|
||||
get getState(): any {
|
||||
throw new Error(MISSING_CONTEXT_ERROR);
|
||||
},
|
||||
@@ -115,6 +125,14 @@ const BaseNavigationContainer = React.forwardRef(
|
||||
const isFirstMountRef = React.useRef<boolean>(true);
|
||||
const skipTrackingRef = React.useRef<boolean>(false);
|
||||
|
||||
const navigatorKeyRef = React.useRef<string | undefined>();
|
||||
|
||||
const getKey = React.useCallback(() => navigatorKeyRef.current, []);
|
||||
|
||||
const setKey = React.useCallback((key: string) => {
|
||||
navigatorKeyRef.current = key;
|
||||
}, []);
|
||||
|
||||
const performTransaction = React.useCallback((callback: () => void) => {
|
||||
if (isTransactionActiveRef.current) {
|
||||
throw new Error(
|
||||
@@ -180,10 +198,18 @@ const BaseNavigationContainer = React.forwardRef(
|
||||
const dispatch = (
|
||||
action: NavigationAction | ((state: NavigationState) => NavigationAction)
|
||||
) => {
|
||||
if (listeners[0] == null) {
|
||||
throw new Error(NOT_INITIALIZED_ERROR);
|
||||
}
|
||||
|
||||
listeners[0](navigation => navigation.dispatch(action));
|
||||
};
|
||||
|
||||
const canGoBack = () => {
|
||||
if (listeners[0] == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { result, handled } = listeners[0](navigation =>
|
||||
navigation.canGoBack()
|
||||
);
|
||||
@@ -246,8 +272,10 @@ const BaseNavigationContainer = React.forwardRef(
|
||||
performTransaction,
|
||||
getState,
|
||||
setState,
|
||||
getKey,
|
||||
setKey,
|
||||
}),
|
||||
[getState, performTransaction, setState, state]
|
||||
[getKey, getState, performTransaction, setKey, setState, state]
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -260,7 +288,7 @@ const BaseNavigationContainer = React.forwardRef(
|
||||
hasWarnedForSerialization = true;
|
||||
|
||||
console.warn(
|
||||
"We found non-serializable values in the navigation state, which can break usage such as persisting and restoring state. This might happen if you passed non-serializable values such as function, class instances etc. in params. If you need to use components with callbacks in your options, you can use 'navigation.setOptions' instead. See https://reactnavigation.org/docs/en/header-buttons.html#header-interaction-with-its-screen-component for docs."
|
||||
"We found non-serializable values in the navigation state, which can break usage such as persisting and restoring state. This might happen if you passed non-serializable values such as function, class instances etc. in params. If you need to use components with callbacks in your options, you can use 'navigation.setOptions' instead. See https://reactnavigation.org/docs/en/troubleshooting.html#i-get-the-warning-we-found-non-serializable-values-in-the-navigation-state for more details."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,14 @@ export default function SceneView<
|
||||
}: Props<State, ScreenOptions>) {
|
||||
const { performTransaction } = React.useContext(NavigationStateContext);
|
||||
|
||||
const navigatorKeyRef = React.useRef<string | undefined>();
|
||||
|
||||
const getKey = React.useCallback(() => navigatorKeyRef.current, []);
|
||||
|
||||
const setKey = React.useCallback((key: string) => {
|
||||
navigatorKeyRef.current = key;
|
||||
}, []);
|
||||
|
||||
const getCurrentState = React.useCallback(() => {
|
||||
const state = getState();
|
||||
const currentRoute = state.routes.find(r => r.key === route.key);
|
||||
@@ -65,14 +73,16 @@ export default function SceneView<
|
||||
getState: getCurrentState,
|
||||
setState: setCurrentState,
|
||||
performTransaction,
|
||||
key: route.key,
|
||||
getKey,
|
||||
setKey,
|
||||
}),
|
||||
[
|
||||
getCurrentState,
|
||||
getKey,
|
||||
performTransaction,
|
||||
route.key,
|
||||
route.state,
|
||||
setCurrentState,
|
||||
setKey,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
@@ -8,12 +8,19 @@ function StaticContainer(props: any) {
|
||||
}
|
||||
|
||||
export default React.memo(StaticContainer, (prevProps: any, nextProps: any) => {
|
||||
for (const prop in prevProps) {
|
||||
if (prop === 'children') {
|
||||
const prevPropKeys = Object.keys(prevProps);
|
||||
const nextPropKeys = Object.keys(nextProps);
|
||||
|
||||
if (prevPropKeys.length !== nextPropKeys.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const key of prevPropKeys) {
|
||||
if (key === 'children') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prevProps[prop] !== nextProps[prop]) {
|
||||
if (prevProps[key] !== nextProps[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,3 +501,51 @@ it('emits state events when the state changes', () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('throws if there is no navigator rendered', () => {
|
||||
expect.assertions(1);
|
||||
|
||||
const ref = React.createRef<NavigationContainerRef>();
|
||||
|
||||
const element = <BaseNavigationContainer ref={ref} children={null} />;
|
||||
|
||||
render(element);
|
||||
|
||||
act(() => {
|
||||
expect(() => ref.current?.dispatch({ type: 'WHATEVER' })).toThrow(
|
||||
"The 'navigation' object hasn't been initialized yet."
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("throws if the ref hasn't finished initializing", () => {
|
||||
expect.assertions(1);
|
||||
|
||||
const ref = React.createRef<NavigationContainerRef>();
|
||||
|
||||
const TestNavigator = (props: any) => {
|
||||
const { state, descriptors } = useNavigationBuilder(MockRouter, props);
|
||||
|
||||
return descriptors[state.routes[state.index].key].render();
|
||||
};
|
||||
|
||||
const TestScreen = () => {
|
||||
React.useEffect(() => {
|
||||
expect(() => ref.current?.dispatch({ type: 'WHATEVER' })).toThrow(
|
||||
"The 'navigation' object hasn't been initialized yet."
|
||||
);
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const element = (
|
||||
<BaseNavigationContainer ref={ref}>
|
||||
<TestNavigator>
|
||||
<Screen name="foo" component={TestScreen} />
|
||||
</TestNavigator>
|
||||
</BaseNavigationContainer>
|
||||
);
|
||||
|
||||
render(element);
|
||||
});
|
||||
|
||||
@@ -49,3 +49,27 @@ it('updates element if any props changed', () => {
|
||||
|
||||
expect(root).toMatchInlineSnapshot(`"second"`);
|
||||
});
|
||||
|
||||
it('updates element if any props are added', () => {
|
||||
expect.assertions(2);
|
||||
|
||||
const Test = ({ label }: any) => {
|
||||
return label;
|
||||
};
|
||||
|
||||
const root = render(
|
||||
<StaticContainer count={42}>
|
||||
<Test label="first" />
|
||||
</StaticContainer>
|
||||
);
|
||||
|
||||
expect(root).toMatchInlineSnapshot(`"first"`);
|
||||
|
||||
root.update(
|
||||
<StaticContainer count={42} moreCounts={12}>
|
||||
<Test label="second" />
|
||||
</StaticContainer>
|
||||
);
|
||||
|
||||
expect(root).toMatchInlineSnapshot(`"second"`);
|
||||
});
|
||||
|
||||
@@ -41,6 +41,43 @@ it('gets navigate action from state', () => {
|
||||
},
|
||||
type: 'NAVIGATE',
|
||||
});
|
||||
|
||||
expect(
|
||||
getActionFromState({
|
||||
routes: [
|
||||
{
|
||||
name: 'foo',
|
||||
state: {
|
||||
routes: [
|
||||
{
|
||||
name: 'bar',
|
||||
state: {
|
||||
routes: [
|
||||
{
|
||||
name: 'qux',
|
||||
params: { author: 'jane' },
|
||||
},
|
||||
{ name: 'quz' },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
).toEqual({
|
||||
payload: {
|
||||
name: 'foo',
|
||||
params: {
|
||||
screen: 'bar',
|
||||
params: {
|
||||
screen: 'quz',
|
||||
},
|
||||
},
|
||||
},
|
||||
type: 'NAVIGATE',
|
||||
});
|
||||
});
|
||||
|
||||
it('gets reset action from state', () => {
|
||||
@@ -53,13 +90,7 @@ it('gets reset action from state', () => {
|
||||
{
|
||||
name: 'bar',
|
||||
state: {
|
||||
routes: [
|
||||
{
|
||||
name: 'qux',
|
||||
params: { author: 'jane' },
|
||||
},
|
||||
{ name: 'quz' },
|
||||
],
|
||||
routes: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -68,8 +99,6 @@ it('gets reset action from state', () => {
|
||||
],
|
||||
};
|
||||
|
||||
expect(getActionFromState(state)).toEqual({
|
||||
payload: state,
|
||||
type: 'RESET_ROOT',
|
||||
});
|
||||
expect(getActionFromState(state)).toBe(undefined);
|
||||
expect(getActionFromState({ routes: [] })).toBe(undefined);
|
||||
});
|
||||
|
||||
@@ -489,3 +489,31 @@ it('handles empty path at the end', () => {
|
||||
expect(getPathFromState(state, config)).toBe(path);
|
||||
expect(getPathFromState(getStateFromPath(path, config), config)).toBe(path);
|
||||
});
|
||||
|
||||
it('returns "/" for empty path', () => {
|
||||
const config = {
|
||||
Foo: {
|
||||
path: '',
|
||||
screens: {
|
||||
Bar: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const state = {
|
||||
routes: [
|
||||
{
|
||||
name: 'Foo',
|
||||
state: {
|
||||
routes: [
|
||||
{
|
||||
name: 'Bar',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(getPathFromState(state, config)).toBe('/');
|
||||
});
|
||||
|
||||
@@ -51,20 +51,55 @@ it('returns false for non-serializable object', () => {
|
||||
});
|
||||
|
||||
it('returns false for circular references', () => {
|
||||
const o = {
|
||||
index: 0,
|
||||
key: '7',
|
||||
routeNames: ['foo', 'bar'],
|
||||
routes: [
|
||||
{
|
||||
key: 'foo',
|
||||
name: 'foo',
|
||||
},
|
||||
],
|
||||
const x = {
|
||||
a: 1,
|
||||
b: { b1: 1 },
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
o.routes[0].state = o;
|
||||
x.b.b2 = x;
|
||||
// @ts-ignore
|
||||
x.c = x.b;
|
||||
|
||||
expect(isSerializable(o)).toBe(false);
|
||||
expect(isSerializable(x)).toBe(false);
|
||||
|
||||
const y = [
|
||||
{
|
||||
label: 'home',
|
||||
children: [{ label: 'product' }],
|
||||
},
|
||||
{ label: 'about', extend: {} },
|
||||
];
|
||||
|
||||
// @ts-ignore
|
||||
y[0].children[0].parent = y[0];
|
||||
// @ts-ignore
|
||||
y[1].extend.home = y[0].children[0];
|
||||
|
||||
expect(isSerializable(y)).toBe(false);
|
||||
|
||||
const z = {
|
||||
name: 'sun',
|
||||
child: [{ name: 'flower' }],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
z.child[0].parent = z;
|
||||
|
||||
expect(isSerializable(z)).toBe(false);
|
||||
});
|
||||
|
||||
it("doesn't fail if same object used multiple times", () => {
|
||||
const o = { foo: 'bar' };
|
||||
|
||||
expect(
|
||||
isSerializable({
|
||||
baz: 'bax',
|
||||
first: o,
|
||||
second: o,
|
||||
stuff: {
|
||||
b: o,
|
||||
},
|
||||
})
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ export default function createNavigatorFactory<
|
||||
> {
|
||||
if (arguments[0] !== undefined) {
|
||||
throw new Error(
|
||||
"Creating a navigator doesn't take an argument. Maybe you are trying to use React Navigation 4 API with React Navigation 5? See https://reactnavigation.org/docs/en/hello-react-navigation.html for usage guide."
|
||||
"Creating a navigator doesn't take an argument. Maybe you are trying to use React Navigation 4 API with React Navigation 5? See https://reactnavigation.org/docs/en/upgrading-from-4.x.html for migration guide."
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,63 +5,50 @@ type NavigateParams = {
|
||||
params?: NavigateParams;
|
||||
};
|
||||
|
||||
type Action =
|
||||
| {
|
||||
type: 'NAVIGATE';
|
||||
payload: { name: string; params: NavigateParams };
|
||||
}
|
||||
| {
|
||||
type: 'RESET_ROOT';
|
||||
payload: PartialState<NavigationState>;
|
||||
};
|
||||
type NavigateAction = {
|
||||
type: 'NAVIGATE';
|
||||
payload: { name: string; params: NavigateParams };
|
||||
};
|
||||
|
||||
export default function getActionFromState(
|
||||
state: PartialState<NavigationState>
|
||||
): Action {
|
||||
let payload: { name: string; params: NavigateParams } | undefined;
|
||||
|
||||
if (state.routes.length === 1) {
|
||||
// Try to construct payload for a `NAVIGATE` action from the state
|
||||
// This lets us preserve the navigation state and not lose it
|
||||
let route = state.routes[0];
|
||||
|
||||
payload = {
|
||||
name: route.name,
|
||||
params: { ...route.params },
|
||||
};
|
||||
|
||||
let current = state.routes[0].state;
|
||||
let params = payload.params;
|
||||
|
||||
while (current) {
|
||||
if (current.routes.length === 1) {
|
||||
route = current.routes[0];
|
||||
params.screen = route.name;
|
||||
|
||||
if (route.state) {
|
||||
params.params = { ...route.params };
|
||||
params = params.params;
|
||||
} else {
|
||||
params.params = route.params;
|
||||
}
|
||||
|
||||
current = route.state;
|
||||
} else {
|
||||
payload = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
): NavigateAction | undefined {
|
||||
if (state.routes.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (payload) {
|
||||
return {
|
||||
type: 'NAVIGATE',
|
||||
payload,
|
||||
};
|
||||
// Try to construct payload for a `NAVIGATE` action from the state
|
||||
// This lets us preserve the navigation state and not lose it
|
||||
let route = state.routes[state.routes.length - 1];
|
||||
|
||||
let payload: { name: string; params: NavigateParams } = {
|
||||
name: route.name,
|
||||
params: { ...route.params },
|
||||
};
|
||||
|
||||
let current = route.state;
|
||||
let params = payload.params;
|
||||
|
||||
while (current) {
|
||||
if (current.routes.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
route = current.routes[current.routes.length - 1];
|
||||
params.screen = route.name;
|
||||
|
||||
if (route.state) {
|
||||
params.params = { ...route.params };
|
||||
params = params.params;
|
||||
} else {
|
||||
params.params = route.params;
|
||||
}
|
||||
|
||||
current = route.state;
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'RESET_ROOT',
|
||||
payload: state,
|
||||
type: 'NAVIGATE',
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -158,6 +158,10 @@ export default function getPathFromState(
|
||||
current = route.state;
|
||||
}
|
||||
|
||||
path = path.slice(path.length - 1) === '/' ? path.slice(0, -1) : path;
|
||||
path =
|
||||
path !== '/' && path.slice(path.length - 1) === '/'
|
||||
? path.slice(0, -1)
|
||||
: path;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const isSerializableWithoutCircularReference = (
|
||||
o: { [key: string]: any },
|
||||
seen = new Set<any>()
|
||||
seen: Set<any>
|
||||
): boolean => {
|
||||
if (
|
||||
o === undefined ||
|
||||
@@ -27,13 +27,13 @@ const isSerializableWithoutCircularReference = (
|
||||
|
||||
if (Array.isArray(o)) {
|
||||
for (const it of o) {
|
||||
if (!isSerializableWithoutCircularReference(it, seen)) {
|
||||
if (!isSerializableWithoutCircularReference(it, new Set<any>(seen))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const key in o) {
|
||||
if (!isSerializableWithoutCircularReference(o[key], seen)) {
|
||||
if (!isSerializableWithoutCircularReference(o[key], new Set<any>(seen))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -43,5 +43,5 @@ const isSerializableWithoutCircularReference = (
|
||||
};
|
||||
|
||||
export default function isSerializable(o: { [key: string]: any }) {
|
||||
return isSerializableWithoutCircularReference(o);
|
||||
return isSerializableWithoutCircularReference(o, new Set<any>());
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import useOnGetState from './useOnGetState';
|
||||
PrivateValueStore;
|
||||
|
||||
type NavigatorRoute = {
|
||||
key: string;
|
||||
params?: {
|
||||
screen?: string;
|
||||
params?: object;
|
||||
@@ -154,7 +155,7 @@ export default function useNavigationBuilder<
|
||||
createRouter: RouterFactory<State, any, RouterOptions>,
|
||||
options: DefaultNavigatorOptions<ScreenOptions> & RouterOptions
|
||||
) {
|
||||
useRegisterNavigator();
|
||||
const navigatorKey = useRegisterNavigator();
|
||||
|
||||
const route = React.useContext(NavigationRouteContext) as
|
||||
| NavigatorRoute
|
||||
@@ -232,7 +233,8 @@ export default function useNavigationBuilder<
|
||||
state: currentState,
|
||||
getState: getCurrentState,
|
||||
setState,
|
||||
key,
|
||||
setKey,
|
||||
getKey,
|
||||
performTransaction,
|
||||
} = React.useContext(NavigationStateContext);
|
||||
|
||||
@@ -325,11 +327,15 @@ export default function useNavigationBuilder<
|
||||
state = nextState;
|
||||
|
||||
React.useEffect(() => {
|
||||
setKey(navigatorKey);
|
||||
|
||||
return () => {
|
||||
// We need to clean up state for this navigator on unmount
|
||||
performTransaction(
|
||||
() => getCurrentState() !== undefined && setState(undefined)
|
||||
);
|
||||
performTransaction(() => {
|
||||
if (getCurrentState() !== undefined && getKey() === navigatorKey) {
|
||||
setState(undefined);
|
||||
}
|
||||
});
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
@@ -366,7 +372,7 @@ export default function useNavigationBuilder<
|
||||
router,
|
||||
getState,
|
||||
setState,
|
||||
key,
|
||||
key: route?.key,
|
||||
listeners: actionListeners,
|
||||
routerConfigOptions: {
|
||||
routeNames,
|
||||
@@ -376,7 +382,7 @@ export default function useNavigationBuilder<
|
||||
|
||||
const onRouteFocus = useOnRouteFocus({
|
||||
router,
|
||||
key,
|
||||
key: route?.key,
|
||||
getState,
|
||||
setState,
|
||||
});
|
||||
|
||||
@@ -23,4 +23,6 @@ export default function useRegisterNavigator() {
|
||||
|
||||
return () => unregister(key);
|
||||
}, [container, key]);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,41 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.4...@react-navigation/drawer@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/drawer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.3...@react-navigation/drawer@5.0.4) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/drawer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.2...@react-navigation/drawer@5.0.3) (2020-02-12)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/drawer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.1...@react-navigation/drawer@5.0.2) (2020-02-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove unnecessary borderless from drawer item ([031136f](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/commit/031136f7c86eff3c9139d1baa243da9f19bc61d4)), closes [#6801](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/issues/6801)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.0.0-alpha.47...@react-navigation/drawer@5.0.1) (2020-02-10)
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/drawer",
|
||||
"description": "Drawer navigator component with animated transitions and gesturess",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
"@react-navigation/native": "^5.0.1",
|
||||
"@react-navigation/native": "^5.0.4",
|
||||
"@types/react": "^16.9.19",
|
||||
"@types/react-native": "^0.60.30",
|
||||
"del-cli": "^3.0.0",
|
||||
@@ -56,10 +56,10 @@
|
||||
"@react-navigation/native": "^5.0.0",
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-gesture-handler": "^1.0.0",
|
||||
"react-native-reanimated": "^1.0.0",
|
||||
"react-native-safe-area-context": "^0.6.0",
|
||||
"react-native-screens": "^2.0.0-alpha.33"
|
||||
"react-native-gesture-handler": ">= 1.0.0",
|
||||
"react-native-reanimated": ">= 1.0.0",
|
||||
"react-native-safe-area-context": ">= 0.6.0",
|
||||
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -101,7 +101,6 @@ export default function DrawerItem(props: Props) {
|
||||
style={[styles.container, { borderRadius, backgroundColor }, style]}
|
||||
>
|
||||
<TouchableItem
|
||||
borderless
|
||||
delayPressIn={0}
|
||||
onPress={onPress}
|
||||
style={[styles.wrapper, { borderRadius }]}
|
||||
|
||||
@@ -3,6 +3,38 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.4...@react-navigation/material-bottom-tabs@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.3...@react-navigation/material-bottom-tabs@5.0.4) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.2...@react-navigation/material-bottom-tabs@5.0.3) (2020-02-12)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.1...@react-navigation/material-bottom-tabs@5.0.2) (2020-02-11)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.0.0-alpha.42...@react-navigation/material-bottom-tabs@5.0.1) (2020-02-10)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/material-bottom-tabs",
|
||||
"description": "Integration for bottom navigation component from react-native-paper",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -36,7 +36,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
"@react-navigation/native": "^5.0.1",
|
||||
"@react-navigation/native": "^5.0.4",
|
||||
"@types/react": "^16.9.19",
|
||||
"@types/react-native": "^0.60.30",
|
||||
"@types/react-native-vector-icons": "^6.4.5",
|
||||
@@ -51,8 +51,8 @@
|
||||
"@react-navigation/native": "^5.0.0",
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-paper": "^3.5.0",
|
||||
"react-native-vector-icons": "^6.0.0"
|
||||
"react-native-paper": ">= 3.0.0",
|
||||
"react-native-vector-icons": ">= 6.0.0"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -3,6 +3,38 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.4...@react-navigation/material-top-tabs@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.3...@react-navigation/material-top-tabs@5.0.4) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.2...@react-navigation/material-top-tabs@5.0.3) (2020-02-12)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.1...@react-navigation/material-top-tabs@5.0.2) (2020-02-11)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.0.0-alpha.41...@react-navigation/material-top-tabs@5.0.1) (2020-02-10)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/material-top-tabs",
|
||||
"description": "Integration for the animated tab view component from react-native-tab-view",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -39,7 +39,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
"@react-navigation/native": "^5.0.1",
|
||||
"@react-navigation/native": "^5.0.4",
|
||||
"@types/react": "^16.9.19",
|
||||
"@types/react-native": "^0.60.30",
|
||||
"del-cli": "^3.0.0",
|
||||
@@ -54,9 +54,9 @@
|
||||
"@react-navigation/native": "^5.0.0",
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-gesture-handler": "^1.0.0",
|
||||
"react-native-reanimated": "^1.0.0",
|
||||
"react-native-tab-view": "^2.13.0"
|
||||
"react-native-gesture-handler": ">= 1.0.0",
|
||||
"react-native-reanimated": ">= 1.0.0",
|
||||
"react-native-tab-view": ">= 2.0.0"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -3,6 +3,38 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/native-stack/compare/@react-navigation/native-stack@5.0.4...@react-navigation/native-stack@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/native-stack/compare/@react-navigation/native-stack@5.0.3...@react-navigation/native-stack@5.0.4) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/native-stack/compare/@react-navigation/native-stack@5.0.2...@react-navigation/native-stack@5.0.3) (2020-02-12)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/native-stack/compare/@react-navigation/native-stack@5.0.1...@react-navigation/native-stack@5.0.2) (2020-02-11)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native-stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/native-stack/compare/@react-navigation/native-stack@5.0.0-alpha.35...@react-navigation/native-stack@5.0.1) (2020-02-10)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native-stack
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/native-stack",
|
||||
"description": "Native stack navigator component for iOS and Android",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-native",
|
||||
@@ -31,16 +31,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
"@react-navigation/native": "^5.0.1",
|
||||
"@react-navigation/native": "^5.0.4",
|
||||
"del-cli": "^3.0.0",
|
||||
"react-native-screens": "^2.0.0-beta.2",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@react-navigation/native": "^5.0.0",
|
||||
"@react-navigation/native": ">= 5.0.0",
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-screens": "^2.0.0-alpha.33"
|
||||
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -3,6 +3,41 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.4...@react-navigation/native@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.3...@react-navigation/native@5.0.4) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.2...@react-navigation/native@5.0.3) (2020-02-12)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.1...@react-navigation/native@5.0.2) (2020-02-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* make getInitialState async on web ([6c6102b](https://github.com/react-navigation/react-navigation/tree/master/packages/native/commit/6c6102b4597b5f0e3eada9e802bc5c171ee988d0))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.0-alpha.35...@react-navigation/native@5.0.1) (2020-02-10)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/native
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/native",
|
||||
"description": "React Native integration for React Navigation",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"keywords": [
|
||||
"react-native",
|
||||
"react-navigation",
|
||||
@@ -31,7 +31,7 @@
|
||||
"clean": "del lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-navigation/core": "^5.1.0"
|
||||
"@react-navigation/core": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
|
||||
@@ -18,6 +18,7 @@ export type LinkingOptions = {
|
||||
/**
|
||||
* The prefixes are stripped from the URL before parsing them.
|
||||
* Usually they are the `scheme` + `host` (e.g. `myapp://chat?user=jane`)
|
||||
* Only applicable on Android and iOS.
|
||||
*/
|
||||
prefixes: string[];
|
||||
/**
|
||||
@@ -36,6 +37,7 @@ export type LinkingOptions = {
|
||||
config?: Parameters<typeof getStateFromPathDefault>[1];
|
||||
/**
|
||||
* Custom function to parse the URL to a valid navigation state (advanced).
|
||||
* Only applicable on Web.
|
||||
*/
|
||||
getStateFromPath?: typeof getStateFromPathDefault;
|
||||
/**
|
||||
|
||||
@@ -76,10 +76,10 @@ export default function useLinking(
|
||||
if (state) {
|
||||
const action = getActionFromState(state);
|
||||
|
||||
if (action.type === 'RESET_ROOT') {
|
||||
navigation.resetRoot(action.payload);
|
||||
} else {
|
||||
if (action !== undefined) {
|
||||
navigation.dispatch(action);
|
||||
} else {
|
||||
navigation.resetRoot(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ let isUsingLinking = false;
|
||||
export default function useLinking(
|
||||
ref: React.RefObject<NavigationContainerRef>,
|
||||
{
|
||||
prefixes,
|
||||
config,
|
||||
getStateFromPath = getStateFromPathDefault,
|
||||
getPathFromState = getPathFromStateDefault,
|
||||
@@ -55,19 +54,18 @@ export default function useLinking(
|
||||
// We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
|
||||
// This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
|
||||
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
|
||||
const prefixesRef = React.useRef(prefixes);
|
||||
const configRef = React.useRef(config);
|
||||
const getStateFromPathRef = React.useRef(getStateFromPath);
|
||||
const getPathFromStateRef = React.useRef(getPathFromState);
|
||||
|
||||
React.useEffect(() => {
|
||||
prefixesRef.current = prefixes;
|
||||
configRef.current = config;
|
||||
getStateFromPathRef.current = getStateFromPath;
|
||||
getPathFromStateRef.current = getPathFromState;
|
||||
}, [config, getPathFromState, getStateFromPath, prefixes]);
|
||||
}, [config, getPathFromState, getStateFromPath]);
|
||||
|
||||
const getInitialState = React.useCallback(() => {
|
||||
// Make it an async function to keep consistent with the native impl
|
||||
const getInitialState = React.useCallback(async () => {
|
||||
const path = location.pathname + location.search;
|
||||
|
||||
if (path) {
|
||||
@@ -164,10 +162,10 @@ export default function useLinking(
|
||||
|
||||
pendingStateUpdateRef.current = true;
|
||||
|
||||
if (action.type === 'RESET_ROOT') {
|
||||
navigation.resetRoot(action.payload);
|
||||
} else {
|
||||
if (action !== undefined) {
|
||||
navigation.dispatch(action);
|
||||
} else {
|
||||
navigation.resetRoot(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,47 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [5.0.5](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.4...@react-navigation/stack@5.0.5) (2020-02-14)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/stack
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.4](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.3...@react-navigation/stack@5.0.4) (2020-02-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* hard code header height for animation ([8f40a98](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/8f40a980862a182a9e86dbb1e4764a39d824cd70)), closes [#6818](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/issues/6818)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.3](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.2...@react-navigation/stack@5.0.3) (2020-02-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* check if we can go baack before dispatching pop ([6c9447a](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/6c9447a38c74ca029fc9def8aca0a2d2cca9639c))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.2](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.1...@react-navigation/stack@5.0.2) (2020-02-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* provide route context to header and bottom tabs ([b6e7e08](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/b6e7e08b9a05be6c04ed21e938b9580876239116))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## [5.0.1](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.0.0-alpha.71...@react-navigation/stack@5.0.1) (2020-02-10)
|
||||
|
||||
**Note:** Version bump only for package @react-navigation/stack
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@react-navigation/stack",
|
||||
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
||||
"version": "5.0.1",
|
||||
"version": "5.0.4",
|
||||
"keywords": [
|
||||
"react-native-component",
|
||||
"react-component",
|
||||
@@ -40,7 +40,7 @@
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.3",
|
||||
"@react-native-community/masked-view": "^0.1.6",
|
||||
"@react-navigation/native": "^5.0.1",
|
||||
"@react-navigation/native": "^5.0.4",
|
||||
"@types/color": "^3.0.1",
|
||||
"@types/react": "^16.9.19",
|
||||
"@types/react-native": "^0.60.30",
|
||||
@@ -53,13 +53,13 @@
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@react-native-community/masked-view": "^0.1.1",
|
||||
"@react-native-community/masked-view": ">= 0.1.0",
|
||||
"@react-navigation/native": "^5.0.0",
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-gesture-handler": "^1.0.0",
|
||||
"react-native-safe-area-context": "^0.6.0",
|
||||
"react-native-screens": "^2.0.0-alpha.33"
|
||||
"react-native-gesture-handler": ">= 1.0.0",
|
||||
"react-native-safe-area-context": ">= 0.6.0",
|
||||
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0"
|
||||
},
|
||||
"@react-native-community/bob": {
|
||||
"source": "src",
|
||||
|
||||
@@ -230,6 +230,7 @@ export function forSlideRight({
|
||||
export function forSlideUp({
|
||||
current,
|
||||
next,
|
||||
layouts: { header },
|
||||
}: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
|
||||
const progress = add(
|
||||
current.progress.interpolate({
|
||||
@@ -248,7 +249,7 @@ export function forSlideUp({
|
||||
|
||||
const translateY = progress.interpolate({
|
||||
inputRange: [0, 1, 2],
|
||||
outputRange: ['-100%', '0%', '-100%'],
|
||||
outputRange: [-header.height, 0, -header.height],
|
||||
});
|
||||
|
||||
const transform = [{ translateY }];
|
||||
|
||||
@@ -548,6 +548,10 @@ export type StackHeaderInterpolationProps = {
|
||||
* Layout measurements for various items we use for animation.
|
||||
*/
|
||||
layouts: {
|
||||
/**
|
||||
* Layout of the header
|
||||
*/
|
||||
header: Layout;
|
||||
/**
|
||||
* Layout of the whole screen.
|
||||
*/
|
||||
|
||||
@@ -55,11 +55,14 @@ export default React.memo(function Header(props: StackHeaderProps) {
|
||||
}
|
||||
onGoBack={
|
||||
previous
|
||||
? () =>
|
||||
navigation.dispatch({
|
||||
...StackActions.pop(),
|
||||
source: scene.route.key,
|
||||
})
|
||||
? () => {
|
||||
if (navigation.canGoBack()) {
|
||||
navigation.dispatch({
|
||||
...StackActions.pop(),
|
||||
source: scene.route.key,
|
||||
});
|
||||
}
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
styleInterpolator={styleInterpolator}
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as React from 'react';
|
||||
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
import {
|
||||
NavigationContext,
|
||||
NavigationRouteContext,
|
||||
Route,
|
||||
ParamListBase,
|
||||
} from '@react-navigation/native';
|
||||
@@ -119,35 +120,37 @@ export default function HeaderContainer({
|
||||
key={scene.route.key}
|
||||
value={scene.descriptor.navigation}
|
||||
>
|
||||
<View
|
||||
onLayout={
|
||||
onContentHeightChange
|
||||
? e =>
|
||||
onContentHeightChange({
|
||||
route: scene.route,
|
||||
height: e.nativeEvent.layout.height,
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
pointerEvents={isFocused ? 'box-none' : 'none'}
|
||||
accessibilityElementsHidden={!isFocused}
|
||||
importantForAccessibility={
|
||||
isFocused ? 'auto' : 'no-hide-descendants'
|
||||
}
|
||||
style={
|
||||
mode === 'float' || options.headerTransparent
|
||||
? styles.header
|
||||
: null
|
||||
}
|
||||
>
|
||||
{options.headerShown !== false ? (
|
||||
options.header !== undefined ? (
|
||||
options.header(props)
|
||||
) : (
|
||||
<Header {...props} />
|
||||
)
|
||||
) : null}
|
||||
</View>
|
||||
<NavigationRouteContext.Provider value={scene.route}>
|
||||
<View
|
||||
onLayout={
|
||||
onContentHeightChange
|
||||
? e =>
|
||||
onContentHeightChange({
|
||||
route: scene.route,
|
||||
height: e.nativeEvent.layout.height,
|
||||
})
|
||||
: undefined
|
||||
}
|
||||
pointerEvents={isFocused ? 'box-none' : 'none'}
|
||||
accessibilityElementsHidden={!isFocused}
|
||||
importantForAccessibility={
|
||||
isFocused ? 'auto' : 'no-hide-descendants'
|
||||
}
|
||||
style={
|
||||
mode === 'float' || options.headerTransparent
|
||||
? styles.header
|
||||
: null
|
||||
}
|
||||
>
|
||||
{options.headerShown !== false ? (
|
||||
options.header !== undefined ? (
|
||||
options.header(props)
|
||||
) : (
|
||||
<Header {...props} />
|
||||
)
|
||||
) : null}
|
||||
</View>
|
||||
</NavigationRouteContext.Provider>
|
||||
</NavigationContext.Provider>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -56,7 +56,7 @@ const warnIfHeaderStylesDefined = (styles: Record<string, any>) => {
|
||||
export const getDefaultHeaderHeight = (
|
||||
layout: Layout,
|
||||
statusBarHeight: number
|
||||
) => {
|
||||
): number => {
|
||||
const isLandscape = layout.width > layout.height;
|
||||
|
||||
let headerHeight;
|
||||
@@ -120,12 +120,17 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
||||
current: Animated.AnimatedInterpolation,
|
||||
next: Animated.AnimatedInterpolation | undefined,
|
||||
titleLayout: Layout | undefined,
|
||||
leftLabelLayout: Layout | undefined
|
||||
leftLabelLayout: Layout | undefined,
|
||||
headerHeight: number
|
||||
) =>
|
||||
styleInterpolator({
|
||||
current: { progress: current },
|
||||
next: next && { progress: next },
|
||||
layouts: {
|
||||
header: {
|
||||
height: headerHeight,
|
||||
width: layout.width,
|
||||
},
|
||||
screen: layout,
|
||||
title: titleLayout,
|
||||
leftLabel: leftLabelLayout,
|
||||
@@ -172,23 +177,10 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
||||
|
||||
const { leftLabelLayout, titleLayout } = this.state;
|
||||
|
||||
const {
|
||||
titleStyle,
|
||||
leftButtonStyle,
|
||||
leftLabelStyle,
|
||||
rightButtonStyle,
|
||||
backgroundStyle,
|
||||
} = this.getInterpolatedStyle(
|
||||
styleInterpolator,
|
||||
layout,
|
||||
scene.progress.current,
|
||||
scene.progress.next,
|
||||
titleLayout,
|
||||
previousTitle ? leftLabelLayout : undefined
|
||||
);
|
||||
const defaultHeight = getDefaultHeaderHeight(layout, headerStatusBarHeight);
|
||||
|
||||
const {
|
||||
height = getDefaultHeaderHeight(layout, headerStatusBarHeight),
|
||||
height = defaultHeight,
|
||||
minHeight,
|
||||
maxHeight,
|
||||
backgroundColor,
|
||||
@@ -281,6 +273,22 @@ export default class HeaderSegment extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
titleStyle,
|
||||
leftButtonStyle,
|
||||
leftLabelStyle,
|
||||
rightButtonStyle,
|
||||
backgroundStyle,
|
||||
} = this.getInterpolatedStyle(
|
||||
styleInterpolator,
|
||||
layout,
|
||||
scene.progress.current,
|
||||
scene.progress.next,
|
||||
titleLayout,
|
||||
previousTitle ? leftLabelLayout : undefined,
|
||||
typeof height === 'number' ? height : defaultHeight
|
||||
);
|
||||
|
||||
const leftButton = left
|
||||
? left({
|
||||
backImage,
|
||||
|
||||
Reference in New Issue
Block a user