mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-15 22:45:41 +08:00
Compare commits
13 Commits
@react-nav
...
@react-nav
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b75744abd5 | ||
|
|
6dbda1a0c2 | ||
|
|
70029d6c13 | ||
|
|
469d0542c7 | ||
|
|
0dcaea3242 | ||
|
|
646cbfb28e | ||
|
|
660cac3557 | ||
|
|
e637250a7e | ||
|
|
82af7bed71 | ||
|
|
cb46d0bca4 | ||
|
|
b3665a325d | ||
|
|
0cc7a12b9c | ||
|
|
90e417248d |
2
.github/workflows/expo-preview.yml
vendored
2
.github/workflows/expo-preview.yml
vendored
@@ -44,7 +44,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Get expo link
|
- name: Get expo link
|
||||||
id: expo
|
id: expo
|
||||||
run: echo "::set-output name=path::@react-navigation/react-react-navigationample?release-channel=pr-${{ github.event.number }}"
|
run: echo "::set-output name=path::@react-navigation/react-navigation-example?release-channel=pr-${{ github.event.number }}"
|
||||||
|
|
||||||
- name: Comment on PR
|
- name: Comment on PR
|
||||||
uses: unsplash/comment-on-pr@master
|
uses: unsplash/comment-on-pr@master
|
||||||
|
|||||||
20
.github/workflows/stale.yml
vendored
20
.github/workflows/stale.yml
vendored
@@ -1,20 +0,0 @@
|
|||||||
name: "Close stale issues and pull requests"
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 0 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
stale:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/stale@v1
|
|
||||||
with:
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
stale-issue-message: 'Hello 👋, this issue has been open for more than 3 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 3 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.'
|
|
||||||
days-before-stale: 90
|
|
||||||
days-before-close: 7
|
|
||||||
stale-issue-label: 'stale'
|
|
||||||
stale-pr-label: 'stale'
|
|
||||||
exempt-issue-label: 'keep open'
|
|
||||||
exempt-pr-label: 'keep open'
|
|
||||||
11
.github/workflows/triage.yml
vendored
11
.github/workflows/triage.yml
vendored
@@ -36,3 +36,14 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
args: comment "Hey! Thanks for opening the issue. The issue tracker is intended for only tracking bug reports. This helps us prioritize fixing bugs in the library. Seems you have a usage question. Please ask the question on [StackOverflow](https://stackoverflow.com/questions/tagged/react-navigation) instead using the `react-navigation` label. You can also chat with other community members on [Reactiflux Discord server](https://www.reactiflux.com/) in the `#react-navigation` channel."
|
args: comment "Hey! Thanks for opening the issue. The issue tracker is intended for only tracking bug reports. This helps us prioritize fixing bugs in the library. Seems you have a usage question. Please ask the question on [StackOverflow](https://stackoverflow.com/questions/tagged/react-navigation) instead using the `react-navigation` label. You can also chat with other community members on [Reactiflux Discord server](https://www.reactiflux.com/) in the `#react-navigation` channel."
|
||||||
|
|
||||||
|
feature-request:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.label.name == 'feature-request'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
- uses: actions/github@v1.0.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
args: comment "Hey! Thanks for opening the issue. The issue tracker is intended for only tracking bug reports. Seems you have a feature request. Please post the feature request on [Canny](https://react-navigation.canny.io/feature-requests). This lets other users upvote your feature request and helps us prioritize the most requested features."
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,6 +6,7 @@
|
|||||||
.gradle
|
.gradle
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
|
.history
|
||||||
|
|
||||||
local.properties
|
local.properties
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/vector-icons": "^10.0.0",
|
"@expo/vector-icons": "^10.0.0",
|
||||||
"@react-native-community/masked-view": "0.1.6",
|
"@react-native-community/masked-view": "0.1.7",
|
||||||
"@types/react-native-restart": "^0.0.0",
|
"@types/react-native-restart": "^0.0.0",
|
||||||
"color": "^3.1.2",
|
"color": "^3.1.2",
|
||||||
"expo": "^36.0.2",
|
"expo": "^36.0.2",
|
||||||
@@ -21,22 +21,22 @@
|
|||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-dom": "~16.9.0",
|
"react-dom": "~16.9.0",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.61.5",
|
||||||
"react-native-gesture-handler": "^1.5.6",
|
"react-native-gesture-handler": "^1.6.0",
|
||||||
"react-native-paper": "^3.6.0",
|
"react-native-paper": "^3.6.0",
|
||||||
"react-native-reanimated": "^1.7.0",
|
"react-native-reanimated": "^1.7.0",
|
||||||
"react-native-restart": "^0.0.13",
|
"react-native-restart": "^0.0.14",
|
||||||
"react-native-safe-area-context": "^0.7.2",
|
"react-native-safe-area-context": "^0.7.3",
|
||||||
"react-native-screens": "^2.0.0-beta.2",
|
"react-native-screens": "^2.3.0",
|
||||||
"react-native-tab-view": "2.13.0",
|
"react-native-tab-view": "2.13.0",
|
||||||
"react-native-unimodules": "^0.7.0",
|
"react-native-unimodules": "^0.7.0",
|
||||||
"react-native-web": "^0.11.7"
|
"react-native-web": "^0.11.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@expo/webpack-config": "^0.10.12",
|
"@expo/webpack-config": "^0.11.7",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.61.22",
|
||||||
"babel-preset-expo": "^8.0.0",
|
"babel-preset-expo": "^8.0.0",
|
||||||
"expo-cli": "^3.11.9",
|
"expo-cli": "^3.13.8",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const error = console.error;
|
const error = console.error;
|
||||||
|
|
||||||
console.error = (...args) =>
|
console.error = (...args) =>
|
||||||
// Supress error messages regarding error boundary in tests
|
// Suppress error messages regarding error boundary in tests
|
||||||
/(Consider adding an error boundary to your tree to customize error handling behavior|React will try to recreate this component tree from scratch using the error boundary you provided|Error boundaries should implement getDerivedStateFromError)/m.test(
|
/(Consider adding an error boundary to your tree to customize error handling behavior|React will try to recreate this component tree from scratch using the error boundary you provided|Error boundaries should implement getDerivedStateFromError)/m.test(
|
||||||
args[0]
|
args[0]
|
||||||
)
|
)
|
||||||
|
|||||||
10
package.json
10
package.json
@@ -27,20 +27,20 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
|
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
|
||||||
"@babel/preset-env": "^7.8.4",
|
"@babel/preset-env": "^7.8.7",
|
||||||
"@babel/preset-flow": "^7.8.3",
|
"@babel/preset-flow": "^7.8.3",
|
||||||
"@babel/preset-react": "^7.8.3",
|
"@babel/preset-react": "^7.8.3",
|
||||||
"@babel/preset-typescript": "^7.8.3",
|
"@babel/preset-typescript": "^7.8.3",
|
||||||
"@babel/runtime": "^7.8.4",
|
"@babel/runtime": "^7.8.7",
|
||||||
"@commitlint/config-conventional": "^8.3.4",
|
"@commitlint/config-conventional": "^8.3.4",
|
||||||
"@types/jest": "^25.1.2",
|
"@types/jest": "^25.1.4",
|
||||||
"codecov": "^3.6.5",
|
"codecov": "^3.6.5",
|
||||||
"commitlint": "^8.3.5",
|
"commitlint": "^8.3.5",
|
||||||
"core-js": "^3.6.4",
|
"core-js": "^3.6.4",
|
||||||
"detox": "^15.1.4",
|
"detox": "^16.0.0",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-config-satya164": "^3.1.5",
|
"eslint-config-satya164": "^3.1.5",
|
||||||
"husky": "^4.2.1",
|
"husky": "^4.2.3",
|
||||||
"jest": "^25.1.0",
|
"jest": "^25.1.0",
|
||||||
"lerna": "^3.20.2",
|
"lerna": "^3.20.2",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
|
|||||||
@@ -3,6 +3,17 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.1.1...@react-navigation/bottom-tabs@5.2.0) (2020-03-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add safeAreaInsets to bottom tabs ([82af7be](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/commit/82af7bed7135e42e24693b48cf7f1c6f9f5a6981))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.1.0...@react-navigation/bottom-tabs@5.1.1) (2020-03-03)
|
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/bottom-tabs/compare/@react-navigation/bottom-tabs@5.1.0...@react-navigation/bottom-tabs@5.1.1) (2020-03-03)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
**Note:** Version bump only for package @react-navigation/bottom-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/bottom-tabs",
|
"name": "@react-navigation/bottom-tabs",
|
||||||
"description": "Bottom tab navigator following iOS design guidelines",
|
"description": "Bottom tab navigator following iOS design guidelines",
|
||||||
"version": "5.1.1",
|
"version": "5.2.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -34,22 +34,24 @@
|
|||||||
"react-native-iphone-x-helper": "^1.2.1"
|
"react-native-iphone-x-helper": "^1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@react-navigation/native": "^5.0.9",
|
"@react-navigation/native": "^5.0.10",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.61.22",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.61.5",
|
||||||
"react-native-safe-area-context": "^0.7.2",
|
"react-native-safe-area-context": "^0.7.3",
|
||||||
|
"react-native-screens": "^2.3.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@react-navigation/native": "^5.0.5",
|
"@react-navigation/native": "^5.0.5",
|
||||||
"react": "*",
|
"react": "*",
|
||||||
"react-native": "*",
|
"react-native": "*",
|
||||||
"react-native-safe-area-context": ">= 0.6.0"
|
"react-native-safe-area-context": ">= 0.6.0",
|
||||||
|
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0 || >= 2.0.0"
|
||||||
},
|
},
|
||||||
"@react-native-community/bob": {
|
"@react-native-community/bob": {
|
||||||
"source": "src",
|
"source": "src",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
ParamListBase,
|
ParamListBase,
|
||||||
Descriptor,
|
Descriptor,
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
|
TabActionHelpers,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
|
|
||||||
export type BottomTabNavigationEventMap = {
|
export type BottomTabNavigationEventMap = {
|
||||||
@@ -40,19 +41,8 @@ export type BottomTabNavigationProp<
|
|||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
BottomTabNavigationOptions,
|
BottomTabNavigationOptions,
|
||||||
BottomTabNavigationEventMap
|
BottomTabNavigationEventMap
|
||||||
> & {
|
> &
|
||||||
/**
|
TabActionHelpers<ParamList>;
|
||||||
* Jump to an existing tab.
|
|
||||||
*
|
|
||||||
* @param name Name of the route for the tab.
|
|
||||||
* @param [params] Params object for the route.
|
|
||||||
*/
|
|
||||||
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
|
||||||
...args: ParamList[RouteName] extends undefined | any
|
|
||||||
? [RouteName] | [RouteName, ParamList[RouteName]]
|
|
||||||
: [RouteName, ParamList[RouteName]]
|
|
||||||
): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type BottomTabNavigationOptions = {
|
export type BottomTabNavigationOptions = {
|
||||||
/**
|
/**
|
||||||
@@ -184,6 +174,16 @@ export type BottomTabBarOptions = {
|
|||||||
* Whether the label position should adapt to the orientation.
|
* Whether the label position should adapt to the orientation.
|
||||||
*/
|
*/
|
||||||
adaptive?: boolean;
|
adaptive?: boolean;
|
||||||
|
/**
|
||||||
|
* Safe area insets for the tab bar. This is used to avoid elements like the navigation bar on Android and bottom safe area on iOS.
|
||||||
|
* By default, the device's safe area insets are automatically detected. You can override the behavior with this option.
|
||||||
|
*/
|
||||||
|
safeAreaInsets?: {
|
||||||
|
top?: number;
|
||||||
|
right?: number;
|
||||||
|
bottom?: number;
|
||||||
|
left?: number;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Style object for the tab bar container.
|
* Style object for the tab bar container.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
CommonActions,
|
CommonActions,
|
||||||
useTheme,
|
useTheme,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
import { SafeAreaConsumer } from 'react-native-safe-area-context';
|
import { useSafeArea } from 'react-native-safe-area-context';
|
||||||
|
|
||||||
import BottomTabItem from './BottomTabItem';
|
import BottomTabItem from './BottomTabItem';
|
||||||
import { BottomTabBarProps } from '../types';
|
import { BottomTabBarProps } from '../types';
|
||||||
@@ -43,6 +43,7 @@ export default function BottomTabBar({
|
|||||||
keyboardHidesTabBar = false,
|
keyboardHidesTabBar = false,
|
||||||
labelPosition,
|
labelPosition,
|
||||||
labelStyle,
|
labelStyle,
|
||||||
|
safeAreaInsets,
|
||||||
showIcon,
|
showIcon,
|
||||||
showLabel,
|
showLabel,
|
||||||
style,
|
style,
|
||||||
@@ -158,116 +159,122 @@ export default function BottomTabBar({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const defaultInsets = useSafeArea();
|
||||||
|
|
||||||
|
const insets = {
|
||||||
|
top: safeAreaInsets?.top ?? defaultInsets.top,
|
||||||
|
right: safeAreaInsets?.right ?? defaultInsets.right,
|
||||||
|
bottom: safeAreaInsets?.bottom ?? defaultInsets.bottom,
|
||||||
|
left: safeAreaInsets?.left ?? defaultInsets.left,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaConsumer>
|
<Animated.View
|
||||||
{insets => (
|
style={[
|
||||||
<Animated.View
|
styles.tabBar,
|
||||||
style={[
|
{
|
||||||
styles.tabBar,
|
backgroundColor: colors.card,
|
||||||
{
|
borderTopColor: colors.border,
|
||||||
backgroundColor: colors.card,
|
},
|
||||||
borderTopColor: colors.border,
|
keyboardHidesTabBar
|
||||||
},
|
? {
|
||||||
keyboardHidesTabBar
|
// When the keyboard is shown, slide down the tab bar
|
||||||
? {
|
transform: [
|
||||||
// When the keyboard is shown, slide down the tab bar
|
{
|
||||||
transform: [
|
translateY: visible.interpolate({
|
||||||
{
|
inputRange: [0, 1],
|
||||||
translateY: visible.interpolate({
|
outputRange: [layout.height, 0],
|
||||||
inputRange: [0, 1],
|
}),
|
||||||
outputRange: [layout.height, 0],
|
},
|
||||||
}),
|
],
|
||||||
},
|
// Absolutely position the tab bar so that the content is below it
|
||||||
],
|
// This is needed to avoid gap at bottom when the tab bar is hidden
|
||||||
// Absolutely position the tab bar so that the content is below it
|
position: keyboardShown ? 'absolute' : null,
|
||||||
// This is needed to avoid gap at bottom when the tab bar is hidden
|
}
|
||||||
position: keyboardShown ? 'absolute' : null,
|
: null,
|
||||||
}
|
{
|
||||||
: null,
|
height: DEFAULT_TABBAR_HEIGHT + insets.bottom,
|
||||||
{
|
paddingBottom: insets.bottom,
|
||||||
height: DEFAULT_TABBAR_HEIGHT + (insets ? insets.bottom : 0),
|
paddingHorizontal: Math.max(insets.left, insets.right),
|
||||||
paddingBottom: insets ? insets.bottom : 0,
|
},
|
||||||
},
|
style,
|
||||||
style,
|
]}
|
||||||
]}
|
pointerEvents={keyboardHidesTabBar && keyboardShown ? 'none' : 'auto'}
|
||||||
pointerEvents={keyboardHidesTabBar && keyboardShown ? 'none' : 'auto'}
|
>
|
||||||
>
|
<View style={styles.content} onLayout={handleLayout}>
|
||||||
<View style={styles.content} onLayout={handleLayout}>
|
{routes.map((route, index) => {
|
||||||
{routes.map((route, index) => {
|
const focused = index === state.index;
|
||||||
const focused = index === state.index;
|
const { options } = descriptors[route.key];
|
||||||
const { options } = descriptors[route.key];
|
|
||||||
|
|
||||||
const onPress = () => {
|
const onPress = () => {
|
||||||
const event = navigation.emit({
|
const event = navigation.emit({
|
||||||
type: 'tabPress',
|
type: 'tabPress',
|
||||||
target: route.key,
|
target: route.key,
|
||||||
canPreventDefault: true,
|
canPreventDefault: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!focused && !event.defaultPrevented) {
|
if (!focused && !event.defaultPrevented) {
|
||||||
navigation.dispatch({
|
navigation.dispatch({
|
||||||
...CommonActions.navigate(route.name),
|
...CommonActions.navigate(route.name),
|
||||||
target: state.key,
|
target: state.key,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLongPress = () => {
|
const onLongPress = () => {
|
||||||
navigation.emit({
|
navigation.emit({
|
||||||
type: 'tabLongPress',
|
type: 'tabLongPress',
|
||||||
target: route.key,
|
target: route.key,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const label =
|
const label =
|
||||||
options.tabBarLabel !== undefined
|
options.tabBarLabel !== undefined
|
||||||
? options.tabBarLabel
|
? options.tabBarLabel
|
||||||
: options.title !== undefined
|
: options.title !== undefined
|
||||||
? options.title
|
? options.title
|
||||||
: route.name;
|
: route.name;
|
||||||
|
|
||||||
const accessibilityLabel =
|
const accessibilityLabel =
|
||||||
options.tabBarAccessibilityLabel !== undefined
|
options.tabBarAccessibilityLabel !== undefined
|
||||||
? options.tabBarAccessibilityLabel
|
? options.tabBarAccessibilityLabel
|
||||||
: typeof label === 'string'
|
: typeof label === 'string'
|
||||||
? `${label}, tab, ${index + 1} of ${routes.length}`
|
? `${label}, tab, ${index + 1} of ${routes.length}`
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationContext.Provider
|
<NavigationContext.Provider
|
||||||
key={route.key}
|
key={route.key}
|
||||||
value={descriptors[route.key].navigation}
|
value={descriptors[route.key].navigation}
|
||||||
>
|
>
|
||||||
<NavigationRouteContext.Provider value={route}>
|
<NavigationRouteContext.Provider value={route}>
|
||||||
<BottomTabItem
|
<BottomTabItem
|
||||||
route={route}
|
route={route}
|
||||||
focused={focused}
|
focused={focused}
|
||||||
horizontal={shouldUseHorizontalLabels()}
|
horizontal={shouldUseHorizontalLabels()}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onLongPress={onLongPress}
|
onLongPress={onLongPress}
|
||||||
accessibilityLabel={accessibilityLabel}
|
accessibilityLabel={accessibilityLabel}
|
||||||
testID={options.tabBarTestID}
|
testID={options.tabBarTestID}
|
||||||
allowFontScaling={allowFontScaling}
|
allowFontScaling={allowFontScaling}
|
||||||
activeTintColor={activeTintColor}
|
activeTintColor={activeTintColor}
|
||||||
inactiveTintColor={inactiveTintColor}
|
inactiveTintColor={inactiveTintColor}
|
||||||
activeBackgroundColor={activeBackgroundColor}
|
activeBackgroundColor={activeBackgroundColor}
|
||||||
inactiveBackgroundColor={inactiveBackgroundColor}
|
inactiveBackgroundColor={inactiveBackgroundColor}
|
||||||
button={options.tabBarButton}
|
button={options.tabBarButton}
|
||||||
icon={options.tabBarIcon}
|
icon={options.tabBarIcon}
|
||||||
label={label}
|
label={label}
|
||||||
showIcon={showIcon}
|
showIcon={showIcon}
|
||||||
showLabel={showLabel}
|
showLabel={showLabel}
|
||||||
labelStyle={labelStyle}
|
labelStyle={labelStyle}
|
||||||
style={tabStyle}
|
style={tabStyle}
|
||||||
/>
|
/>
|
||||||
</NavigationRouteContext.Provider>
|
</NavigationRouteContext.Provider>
|
||||||
</NavigationContext.Provider>
|
</NavigationContext.Provider>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</View>
|
</View>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)}
|
|
||||||
</SafeAreaConsumer>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.1.1...@react-navigation/compat@5.1.2) (2020-03-16)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/compat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.1.0...@react-navigation/compat@5.1.1) (2020-03-03)
|
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/compat/compare/@react-navigation/compat@5.1.0...@react-navigation/compat@5.1.1) (2020-03-03)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/compat
|
**Note:** Version bump only for package @react-navigation/compat
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/compat",
|
"name": "@react-navigation/compat",
|
||||||
"description": "Compatibility layer to write navigator definitions in static configuration format",
|
"description": "Compatibility layer to write navigator definitions in static configuration format",
|
||||||
"version": "5.1.1",
|
"version": "5.1.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/compat",
|
"repository": "https://github.com/react-navigation/react-navigation/tree/master/packages/compat",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -25,9 +25,9 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@react-navigation/native": "^5.0.9",
|
"@react-navigation/native": "^5.0.10",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [5.2.2](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.2.1...@react-navigation/core@5.2.2) (2020-03-16)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/core
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.2.1](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.2.0...@react-navigation/core@5.2.1) (2020-03-03)
|
## [5.2.1](https://github.com/react-navigation/react-navigation/tree/master/packages/core/compare/@react-navigation/core@5.2.0...@react-navigation/core@5.2.1) (2020-03-03)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/core",
|
"name": "@react-navigation/core",
|
||||||
"description": "Core utilities for building navigators",
|
"description": "Core utilities for building navigators",
|
||||||
"version": "5.2.1",
|
"version": "5.2.2",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-native",
|
"react-native",
|
||||||
@@ -29,23 +29,23 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/routers": "^5.1.0",
|
"@react-navigation/routers": "^5.1.1",
|
||||||
"escape-string-regexp": "^2.0.0",
|
"escape-string-regexp": "^2.0.0",
|
||||||
"query-string": "^6.10.1",
|
"query-string": "^6.11.1",
|
||||||
"react-is": "^16.12.0",
|
"react-is": "^16.13.0",
|
||||||
"shortid": "^2.2.15",
|
"shortid": "^2.2.15",
|
||||||
"use-subscription": "^1.3.0"
|
"use-subscription": "^1.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-is": "^16.7.1",
|
"@types/react-is": "^16.7.1",
|
||||||
"@types/shortid": "^0.0.29",
|
"@types/shortid": "^0.0.29",
|
||||||
"@types/use-subscription": "^1.0.0",
|
"@types/use-subscription": "^1.0.0",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-native-testing-library": "^1.12.0",
|
"react-native-testing-library": "^1.12.0",
|
||||||
"react-test-renderer": "~16.12.0",
|
"react-test-renderer": "~16.9.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -168,18 +168,6 @@ type NavigationHelpersCommon<
|
|||||||
| { name: RouteName; key?: string; params: ParamList[RouteName] }
|
| { name: RouteName; key?: string; params: ParamList[RouteName] }
|
||||||
): void;
|
): void;
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the current route with a new one.
|
|
||||||
*
|
|
||||||
* @param name Route name of the new route.
|
|
||||||
* @param [params] Params object for the new route.
|
|
||||||
*/
|
|
||||||
replace<RouteName extends keyof ParamList>(
|
|
||||||
...args: ParamList[RouteName] extends undefined
|
|
||||||
? [RouteName] | [RouteName, ParamList[RouteName]]
|
|
||||||
: [RouteName, ParamList[RouteName]]
|
|
||||||
): void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the navigation state to the provided state.
|
* Reset the navigation state to the provided state.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,6 +3,17 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.1.1...@react-navigation/drawer@5.2.0) (2020-03-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* make useIsDrawerOpen workable inside drawer content ([#7746](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/issues/7746)) ([cb46d0b](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/commit/cb46d0bca4e17e847fff46ac94276213ac9697bf))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.1.0...@react-navigation/drawer@5.1.1) (2020-03-03)
|
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/drawer/compare/@react-navigation/drawer@5.1.0...@react-navigation/drawer@5.1.1) (2020-03-03)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/drawer
|
**Note:** Version bump only for package @react-navigation/drawer
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/drawer",
|
"name": "@react-navigation/drawer",
|
||||||
"description": "Drawer navigator component with animated transitions and gesturess",
|
"description": "Drawer navigator component with animated transitions and gesturess",
|
||||||
"version": "5.1.1",
|
"version": "5.2.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -39,17 +39,17 @@
|
|||||||
"react-native-iphone-x-helper": "^1.2.1"
|
"react-native-iphone-x-helper": "^1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@react-navigation/native": "^5.0.9",
|
"@react-navigation/native": "^5.0.10",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.61.22",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.61.5",
|
||||||
"react-native-gesture-handler": "^1.5.6",
|
"react-native-gesture-handler": "^1.6.0",
|
||||||
"react-native-reanimated": "^1.7.0",
|
"react-native-reanimated": "^1.7.0",
|
||||||
"react-native-safe-area-context": "^0.7.2",
|
"react-native-safe-area-context": "^0.7.3",
|
||||||
"react-native-screens": "^2.0.0-beta.2",
|
"react-native-screens": "^2.3.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
"react-native-gesture-handler": ">= 1.0.0",
|
"react-native-gesture-handler": ">= 1.0.0",
|
||||||
"react-native-reanimated": ">= 1.0.0",
|
"react-native-reanimated": ">= 1.0.0",
|
||||||
"react-native-safe-area-context": ">= 0.6.0",
|
"react-native-safe-area-context": ">= 0.6.0",
|
||||||
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0"
|
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0 || >= 2.0.0"
|
||||||
},
|
},
|
||||||
"@react-native-community/bob": {
|
"@react-native-community/bob": {
|
||||||
"source": "src",
|
"source": "src",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
Descriptor,
|
Descriptor,
|
||||||
NavigationHelpers,
|
NavigationHelpers,
|
||||||
DrawerNavigationState,
|
DrawerNavigationState,
|
||||||
|
DrawerActionHelpers,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
import { PanGestureHandler } from 'react-native-gesture-handler';
|
import { PanGestureHandler } from 'react-native-gesture-handler';
|
||||||
|
|
||||||
@@ -190,22 +191,8 @@ export type DrawerNavigationProp<
|
|||||||
DrawerNavigationState,
|
DrawerNavigationState,
|
||||||
DrawerNavigationOptions,
|
DrawerNavigationOptions,
|
||||||
DrawerNavigationEventMap
|
DrawerNavigationEventMap
|
||||||
> & {
|
> &
|
||||||
/**
|
DrawerActionHelpers<ParamList>;
|
||||||
* Open the drawer sidebar.
|
|
||||||
*/
|
|
||||||
openDrawer(): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close the drawer sidebar.
|
|
||||||
*/
|
|
||||||
closeDrawer(): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open the drawer sidebar if closed, or close if opened.
|
|
||||||
*/
|
|
||||||
toggleDrawer(): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DrawerDescriptor = Descriptor<
|
export type DrawerDescriptor = Descriptor<
|
||||||
ParamListBase,
|
ParamListBase,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useNavigation, ParamListBase } from '@react-navigation/native';
|
import { useNavigation, ParamListBase } from '@react-navigation/native';
|
||||||
import { DrawerNavigationProp } from '../types';
|
import { DrawerNavigationProp } from '../types';
|
||||||
|
import DrawerOpenContext from '../views/DrawerOpenContext';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook to detect if the drawer is open in a parent navigator.
|
* Hook to detect if the drawer is open in a parent navigator.
|
||||||
@@ -10,6 +11,8 @@ export default function useIsDrawerOpen() {
|
|||||||
|
|
||||||
let drawer = navigation as DrawerNavigationProp<ParamListBase>;
|
let drawer = navigation as DrawerNavigationProp<ParamListBase>;
|
||||||
|
|
||||||
|
const drawerOpenContext = React.useContext(DrawerOpenContext);
|
||||||
|
|
||||||
// The screen might be inside another navigator such as stack nested in drawer
|
// The screen might be inside another navigator such as stack nested in drawer
|
||||||
// We need to find the closest drawer navigator and add the listener there
|
// We need to find the closest drawer navigator and add the listener there
|
||||||
while (drawer && drawer.dangerouslyGetState().type !== 'drawer') {
|
while (drawer && drawer.dangerouslyGetState().type !== 'drawer') {
|
||||||
@@ -34,5 +37,9 @@ export default function useIsDrawerOpen() {
|
|||||||
return unsubscribe;
|
return unsubscribe;
|
||||||
}, [drawer, isDrawerOpen]);
|
}, [drawer, isDrawerOpen]);
|
||||||
|
|
||||||
|
if (drawerOpenContext !== null) {
|
||||||
|
return drawerOpenContext;
|
||||||
|
}
|
||||||
|
|
||||||
return isDrawerOpen;
|
return isDrawerOpen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from 'react-native-gesture-handler';
|
} from 'react-native-gesture-handler';
|
||||||
import Animated from 'react-native-reanimated';
|
import Animated from 'react-native-reanimated';
|
||||||
import Overlay from './Overlay';
|
import Overlay from './Overlay';
|
||||||
|
import DrawerOpenContext from './DrawerOpenContext';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Clock,
|
Clock,
|
||||||
@@ -635,7 +636,9 @@ export default class DrawerView extends React.PureComponent<Props> {
|
|||||||
drawerStyle as any,
|
drawerStyle as any,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{renderDrawerContent({ progress: this.progress })}
|
<DrawerOpenContext.Provider value={open}>
|
||||||
|
{renderDrawerContent({ progress: this.progress })}
|
||||||
|
</DrawerOpenContext.Provider>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
</PanGestureHandler>
|
</PanGestureHandler>
|
||||||
|
|||||||
5
packages/drawer/src/views/DrawerOpenContext.tsx
Normal file
5
packages/drawer/src/views/DrawerOpenContext.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
const DrawerOpenContext = React.createContext<boolean | null>(null);
|
||||||
|
|
||||||
|
export default DrawerOpenContext;
|
||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.1.1...@react-navigation/material-bottom-tabs@5.1.2) (2020-03-16)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.1.0...@react-navigation/material-bottom-tabs@5.1.1) (2020-03-03)
|
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/material-bottom-tabs/compare/@react-navigation/material-bottom-tabs@5.1.0...@react-navigation/material-bottom-tabs@5.1.1) (2020-03-03)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/material-bottom-tabs",
|
"name": "@react-navigation/material-bottom-tabs",
|
||||||
"description": "Integration for bottom navigation component from react-native-paper",
|
"description": "Integration for bottom navigation component from react-native-paper",
|
||||||
"version": "5.1.1",
|
"version": "5.1.2",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -35,10 +35,10 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@react-navigation/native": "^5.0.9",
|
"@react-navigation/native": "^5.0.10",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.61.22",
|
||||||
"@types/react-native-vector-icons": "^6.4.5",
|
"@types/react-native-vector-icons": "^6.4.5",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
NavigationProp,
|
NavigationProp,
|
||||||
NavigationHelpers,
|
NavigationHelpers,
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
|
TabActionHelpers,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
|
|
||||||
export type MaterialBottomTabNavigationEventMap = {
|
export type MaterialBottomTabNavigationEventMap = {
|
||||||
@@ -28,19 +29,8 @@ export type MaterialBottomTabNavigationProp<
|
|||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
MaterialBottomTabNavigationOptions,
|
MaterialBottomTabNavigationOptions,
|
||||||
MaterialBottomTabNavigationEventMap
|
MaterialBottomTabNavigationEventMap
|
||||||
> & {
|
> &
|
||||||
/**
|
TabActionHelpers<ParamList>;
|
||||||
* Jump to an existing tab.
|
|
||||||
*
|
|
||||||
* @param name Name of the route for the tab.
|
|
||||||
* @param [params] Params object for the route.
|
|
||||||
*/
|
|
||||||
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
|
||||||
...args: ParamList[RouteName] extends undefined | any
|
|
||||||
? [RouteName] | [RouteName, ParamList[RouteName]]
|
|
||||||
: [RouteName, ParamList[RouteName]]
|
|
||||||
): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type MaterialBottomTabNavigationOptions = {
|
export type MaterialBottomTabNavigationOptions = {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [5.1.2](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.1.1...@react-navigation/material-top-tabs@5.1.2) (2020-03-16)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.1.0...@react-navigation/material-top-tabs@5.1.1) (2020-03-03)
|
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/material-top-tabs/compare/@react-navigation/material-top-tabs@5.1.0...@react-navigation/material-top-tabs@5.1.1) (2020-03-03)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
**Note:** Version bump only for package @react-navigation/material-top-tabs
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/material-top-tabs",
|
"name": "@react-navigation/material-top-tabs",
|
||||||
"description": "Integration for the animated tab view component from react-native-tab-view",
|
"description": "Integration for the animated tab view component from react-native-tab-view",
|
||||||
"version": "5.1.1",
|
"version": "5.1.2",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -38,14 +38,14 @@
|
|||||||
"color": "^3.1.2"
|
"color": "^3.1.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@react-navigation/native": "^5.0.9",
|
"@react-navigation/native": "^5.0.10",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.61.22",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.61.5",
|
||||||
"react-native-gesture-handler": "^1.5.6",
|
"react-native-gesture-handler": "^1.6.0",
|
||||||
"react-native-reanimated": "^1.7.0",
|
"react-native-reanimated": "^1.7.0",
|
||||||
"react-native-tab-view": "^2.13.0",
|
"react-native-tab-view": "^2.13.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
Route,
|
Route,
|
||||||
NavigationProp,
|
NavigationProp,
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
|
TabActionHelpers,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
|
|
||||||
export type MaterialTopTabNavigationEventMap = {
|
export type MaterialTopTabNavigationEventMap = {
|
||||||
@@ -42,19 +43,8 @@ export type MaterialTopTabNavigationProp<
|
|||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
MaterialTopTabNavigationOptions,
|
MaterialTopTabNavigationOptions,
|
||||||
MaterialTopTabNavigationEventMap
|
MaterialTopTabNavigationEventMap
|
||||||
> & {
|
> &
|
||||||
/**
|
TabActionHelpers<ParamList>;
|
||||||
* Jump to an existing tab.
|
|
||||||
*
|
|
||||||
* @param name Name of the route for the tab.
|
|
||||||
* @param [params] Params object for the route.
|
|
||||||
*/
|
|
||||||
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
|
||||||
...args: ParamList[RouteName] extends undefined | any
|
|
||||||
? [RouteName] | [RouteName, ParamList[RouteName]]
|
|
||||||
: [RouteName, ParamList[RouteName]]
|
|
||||||
): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type MaterialTopTabNavigationOptions = {
|
export type MaterialTopTabNavigationOptions = {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [5.0.10](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.9...@react-navigation/native@5.0.10) (2020-03-16)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.0.9](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.8...@react-navigation/native@5.0.9) (2020-03-03)
|
## [5.0.9](https://github.com/react-navigation/react-navigation/tree/master/packages/native/compare/@react-navigation/native@5.0.8...@react-navigation/native@5.0.9) (2020-03-03)
|
||||||
|
|
||||||
**Note:** Version bump only for package @react-navigation/native
|
**Note:** Version bump only for package @react-navigation/native
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/native",
|
"name": "@react-navigation/native",
|
||||||
"description": "React Native integration for React Navigation",
|
"description": "React Native integration for React Navigation",
|
||||||
"version": "5.0.9",
|
"version": "5.0.10",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native",
|
"react-native",
|
||||||
"react-navigation",
|
"react-navigation",
|
||||||
@@ -31,12 +31,12 @@
|
|||||||
"clean": "del lib"
|
"clean": "del lib"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-navigation/core": "^5.2.1"
|
"@react-navigation/core": "^5.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.61.22",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.61.5",
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ type ScrollOptions = { y?: number; animated?: boolean };
|
|||||||
type ScrollableView =
|
type ScrollableView =
|
||||||
| { scrollToTop(): void }
|
| { scrollToTop(): void }
|
||||||
| { scrollTo(options: ScrollOptions): void }
|
| { scrollTo(options: ScrollOptions): void }
|
||||||
| { scrollToOffset(options: ScrollOptions): void }
|
| { scrollToOffset(options: { offset?: number; animated?: boolean }): void }
|
||||||
| { scrollResponderScrollTo(options: ScrollOptions): void };
|
| { scrollResponderScrollTo(options: ScrollOptions): void };
|
||||||
|
|
||||||
type ScrollableWrapper =
|
type ScrollableWrapper =
|
||||||
| { getScrollResponder(): ScrollableView }
|
| { getScrollResponder(): React.ReactNode }
|
||||||
| { getNode(): ScrollableView }
|
| { getNode(): ScrollableView }
|
||||||
| ScrollableView;
|
| ScrollableView;
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ export default function useScrollToTop(
|
|||||||
// Run the operation in the next frame so we're sure all listeners have been run
|
// Run the operation in the next frame so we're sure all listeners have been run
|
||||||
// This is necessary to know if preventDefault() has been called
|
// This is necessary to know if preventDefault() has been called
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
const scrollable = getScrollableNode(ref);
|
const scrollable = getScrollableNode(ref) as ScrollableWrapper;
|
||||||
|
|
||||||
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
|
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
|
||||||
if ('scrollToTop' in scrollable) {
|
if ('scrollToTop' in scrollable) {
|
||||||
@@ -87,7 +87,7 @@ export default function useScrollToTop(
|
|||||||
} else if ('scrollTo' in scrollable) {
|
} else if ('scrollTo' in scrollable) {
|
||||||
scrollable.scrollTo({ y: 0, animated: true });
|
scrollable.scrollTo({ y: 0, animated: true });
|
||||||
} else if ('scrollToOffset' in scrollable) {
|
} else if ('scrollToOffset' in scrollable) {
|
||||||
scrollable.scrollToOffset({ y: 0, animated: true });
|
scrollable.scrollToOffset({ offset: 0, animated: true });
|
||||||
} else if ('scrollResponderScrollTo' in scrollable) {
|
} else if ('scrollResponderScrollTo' in scrollable) {
|
||||||
scrollable.scrollResponderScrollTo({ y: 0, animated: true });
|
scrollable.scrollResponderScrollTo({ y: 0, animated: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,17 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/compare/@react-navigation/routers@5.1.0...@react-navigation/routers@5.1.1) (2020-03-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* don't handle action if no routes are present ([660cac3](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/commit/660cac3557bce8978812ce2750e961e7ada92d13))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [5.1.0](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/compare/@react-navigation/routers@5.0.3...@react-navigation/routers@5.1.0) (2020-03-03)
|
# [5.1.0](https://github.com/react-navigation/react-navigation/tree/master/packages/routers/compare/@react-navigation/routers@5.0.3...@react-navigation/routers@5.1.0) (2020-03-03)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/routers",
|
"name": "@react-navigation/routers",
|
||||||
"description": "Routers to help build custom navigators",
|
"description": "Routers to help build custom navigators",
|
||||||
"version": "5.1.0",
|
"version": "5.1.1",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"react-native",
|
"react-native",
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"shortid": "^2.2.15"
|
"shortid": "^2.2.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ const BaseRouter = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
nextState.routes.length === 0 ||
|
||||||
nextState.routes.some(
|
nextState.routes.some(
|
||||||
(route: { name: string }) => !state.routeNames.includes(route.name)
|
(route: { name: string }) => !state.routeNames.includes(route.name)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
import shortid from 'shortid';
|
import shortid from 'shortid';
|
||||||
import { PartialState, CommonNavigationAction, Router } from './types';
|
import {
|
||||||
|
PartialState,
|
||||||
|
CommonNavigationAction,
|
||||||
|
Router,
|
||||||
|
ParamListBase,
|
||||||
|
} from './types';
|
||||||
import TabRouter, {
|
import TabRouter, {
|
||||||
TabActions,
|
TabActions,
|
||||||
TabActionType,
|
TabActionType,
|
||||||
TabRouterOptions,
|
TabRouterOptions,
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
|
TabActionHelpers,
|
||||||
} from './TabRouter';
|
} from './TabRouter';
|
||||||
|
|
||||||
export type DrawerActionType =
|
export type DrawerActionType =
|
||||||
@@ -31,6 +37,25 @@ export type DrawerNavigationState = Omit<
|
|||||||
history: ({ type: 'route'; key: string } | { type: 'drawer' })[];
|
history: ({ type: 'route'; key: string } | { type: 'drawer' })[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DrawerActionHelpers<
|
||||||
|
ParamList extends ParamListBase
|
||||||
|
> = TabActionHelpers<ParamList> & {
|
||||||
|
/**
|
||||||
|
* Open the drawer sidebar.
|
||||||
|
*/
|
||||||
|
openDrawer(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the drawer sidebar.
|
||||||
|
*/
|
||||||
|
closeDrawer(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open the drawer sidebar if closed, or close if opened.
|
||||||
|
*/
|
||||||
|
toggleDrawer(): void;
|
||||||
|
};
|
||||||
|
|
||||||
export const DrawerActions = {
|
export const DrawerActions = {
|
||||||
...TabActions,
|
...TabActions,
|
||||||
openDrawer(): DrawerActionType {
|
openDrawer(): DrawerActionType {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
DefaultRouterOptions,
|
DefaultRouterOptions,
|
||||||
Route,
|
Route,
|
||||||
|
ParamListBase,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
export type StackActionType =
|
export type StackActionType =
|
||||||
@@ -42,6 +43,42 @@ export type StackNavigationState = NavigationState & {
|
|||||||
type: 'stack';
|
type: 'stack';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type StackActionHelpers<ParamList extends ParamListBase> = {
|
||||||
|
/**
|
||||||
|
* Replace the current route with a new one.
|
||||||
|
*
|
||||||
|
* @param name Route name of the new route.
|
||||||
|
* @param [params] Params object for the new route.
|
||||||
|
*/
|
||||||
|
replace<RouteName extends keyof ParamList>(
|
||||||
|
...args: ParamList[RouteName] extends undefined
|
||||||
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
|
: [RouteName, ParamList[RouteName]]
|
||||||
|
): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push a new screen onto the stack.
|
||||||
|
*
|
||||||
|
* @param name Name of the route for the tab.
|
||||||
|
* @param [params] Params object for the route.
|
||||||
|
*/
|
||||||
|
push<RouteName extends keyof ParamList>(
|
||||||
|
...args: ParamList[RouteName] extends undefined | any
|
||||||
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
|
: [RouteName, ParamList[RouteName]]
|
||||||
|
): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop a screen from the stack.
|
||||||
|
*/
|
||||||
|
pop(count?: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop to the first route in the stack, dismissing all other screens.
|
||||||
|
*/
|
||||||
|
popToTop(): void;
|
||||||
|
};
|
||||||
|
|
||||||
export const StackActions = {
|
export const StackActions = {
|
||||||
replace(name: string, params?: object): StackActionType {
|
replace(name: string, params?: object): StackActionType {
|
||||||
return { type: 'REPLACE', payload: { name, params } };
|
return { type: 'REPLACE', payload: { name, params } };
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
Router,
|
Router,
|
||||||
DefaultRouterOptions,
|
DefaultRouterOptions,
|
||||||
Route,
|
Route,
|
||||||
|
ParamListBase,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
export type TabActionType = {
|
export type TabActionType = {
|
||||||
@@ -33,6 +34,20 @@ export type TabNavigationState = Omit<NavigationState, 'history'> & {
|
|||||||
history: { type: 'route'; key: string }[];
|
history: { type: 'route'; key: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TabActionHelpers<ParamList extends ParamListBase> = {
|
||||||
|
/**
|
||||||
|
* Jump to an existing tab.
|
||||||
|
*
|
||||||
|
* @param name Name of the route for the tab.
|
||||||
|
* @param [params] Params object for the route.
|
||||||
|
*/
|
||||||
|
jumpTo<RouteName extends Extract<keyof ParamList, string>>(
|
||||||
|
...args: ParamList[RouteName] extends undefined | any
|
||||||
|
? [RouteName] | [RouteName, ParamList[RouteName]]
|
||||||
|
: [RouteName, ParamList[RouteName]]
|
||||||
|
): void;
|
||||||
|
};
|
||||||
|
|
||||||
const TYPE_ROUTE = 'route' as const;
|
const TYPE_ROUTE = 'route' as const;
|
||||||
|
|
||||||
export const TabActions = {
|
export const TabActions = {
|
||||||
|
|||||||
@@ -114,3 +114,15 @@ it("doesn't handle RESET if routeNames don't match", () => {
|
|||||||
|
|
||||||
expect(result).toEqual(null);
|
expect(result).toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("doesn't handle RESET if there are no routes", () => {
|
||||||
|
const result = BaseRouter.getStateForAction(
|
||||||
|
STATE,
|
||||||
|
CommonActions.reset({
|
||||||
|
index: 0,
|
||||||
|
routes: [],
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toEqual(null);
|
||||||
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export { default as BaseRouter } from './BaseRouter';
|
|||||||
export {
|
export {
|
||||||
default as StackRouter,
|
default as StackRouter,
|
||||||
StackActions,
|
StackActions,
|
||||||
|
StackActionHelpers,
|
||||||
StackActionType,
|
StackActionType,
|
||||||
StackRouterOptions,
|
StackRouterOptions,
|
||||||
StackNavigationState,
|
StackNavigationState,
|
||||||
@@ -15,6 +16,7 @@ export {
|
|||||||
export {
|
export {
|
||||||
default as TabRouter,
|
default as TabRouter,
|
||||||
TabActions,
|
TabActions,
|
||||||
|
TabActionHelpers,
|
||||||
TabActionType,
|
TabActionType,
|
||||||
TabRouterOptions,
|
TabRouterOptions,
|
||||||
TabNavigationState,
|
TabNavigationState,
|
||||||
@@ -23,6 +25,7 @@ export {
|
|||||||
export {
|
export {
|
||||||
default as DrawerRouter,
|
default as DrawerRouter,
|
||||||
DrawerActions,
|
DrawerActions,
|
||||||
|
DrawerActionHelpers,
|
||||||
DrawerActionType,
|
DrawerActionType,
|
||||||
DrawerRouterOptions,
|
DrawerRouterOptions,
|
||||||
DrawerNavigationState,
|
DrawerNavigationState,
|
||||||
|
|||||||
@@ -3,6 +3,23 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
# [5.2.0](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.1.1...@react-navigation/stack@5.2.0) (2020-03-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix android header title font weight ([#7720](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/issues/7720)) ([0dcaea3](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/0dcaea32428484cdc9b4d56f7bf38f9f1bdf1dee))
|
||||||
|
* fix back gesture cancellation ([#7700](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/issues/7700)) ([469d054](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/469d0542c7341dc524a597d70216ba743602a51e)), closes [#6782](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/issues/6782)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add an option to change use a custom card overlay ([#7809](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/issues/7809)) ([70029d6](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/commit/70029d6c130f0f47de94b6a6c4cbee6afa12b405))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.1.0...@react-navigation/stack@5.1.1) (2020-03-03)
|
## [5.1.1](https://github.com/react-navigation/react-navigation/tree/master/packages/stack/compare/@react-navigation/stack@5.1.0...@react-navigation/stack@5.1.1) (2020-03-03)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@react-navigation/stack",
|
"name": "@react-navigation/stack",
|
||||||
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
|
||||||
"version": "5.1.1",
|
"version": "5.2.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react-native-component",
|
"react-native-component",
|
||||||
"react-component",
|
"react-component",
|
||||||
@@ -38,18 +38,18 @@
|
|||||||
"react-native-iphone-x-helper": "^1.2.1"
|
"react-native-iphone-x-helper": "^1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@react-native-community/bob": "^0.9.3",
|
"@react-native-community/bob": "^0.10.0",
|
||||||
"@react-native-community/masked-view": "^0.1.6",
|
"@react-native-community/masked-view": "^0.1.7",
|
||||||
"@react-navigation/native": "^5.0.9",
|
"@react-navigation/native": "^5.0.10",
|
||||||
"@types/color": "^3.0.1",
|
"@types/color": "^3.0.1",
|
||||||
"@types/react": "^16.9.19",
|
"@types/react": "^16.9.23",
|
||||||
"@types/react-native": "^0.60.30",
|
"@types/react-native": "^0.61.22",
|
||||||
"del-cli": "^3.0.0",
|
"del-cli": "^3.0.0",
|
||||||
"react": "~16.9.0",
|
"react": "~16.9.0",
|
||||||
"react-native": "~0.61.5",
|
"react-native": "~0.61.5",
|
||||||
"react-native-gesture-handler": "^1.5.6",
|
"react-native-gesture-handler": "^1.6.0",
|
||||||
"react-native-safe-area-context": "^0.7.2",
|
"react-native-safe-area-context": "^0.7.3",
|
||||||
"react-native-screens": "^2.0.0-beta.2",
|
"react-native-screens": "^2.3.0",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.7.5"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
"react-native": "*",
|
"react-native": "*",
|
||||||
"react-native-gesture-handler": ">= 1.0.0",
|
"react-native-gesture-handler": ">= 1.0.0",
|
||||||
"react-native-safe-area-context": ">= 0.6.0",
|
"react-native-safe-area-context": ">= 0.6.0",
|
||||||
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0"
|
"react-native-screens": ">= 2.0.0-alpha.0 || >= 2.0.0-beta.0 || >= 2.0.0"
|
||||||
},
|
},
|
||||||
"@react-native-community/bob": {
|
"@react-native-community/bob": {
|
||||||
"source": "src",
|
"source": "src",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import * as React from 'react';
|
||||||
import {
|
import {
|
||||||
Animated,
|
Animated,
|
||||||
StyleProp,
|
StyleProp,
|
||||||
@@ -13,6 +14,7 @@ import {
|
|||||||
Route,
|
Route,
|
||||||
NavigationHelpers,
|
NavigationHelpers,
|
||||||
StackNavigationState,
|
StackNavigationState,
|
||||||
|
StackActionHelpers,
|
||||||
} from '@react-navigation/native';
|
} from '@react-navigation/native';
|
||||||
|
|
||||||
export type StackNavigationEventMap = {
|
export type StackNavigationEventMap = {
|
||||||
@@ -40,29 +42,8 @@ export type StackNavigationProp<
|
|||||||
StackNavigationState,
|
StackNavigationState,
|
||||||
StackNavigationOptions,
|
StackNavigationOptions,
|
||||||
StackNavigationEventMap
|
StackNavigationEventMap
|
||||||
> & {
|
> &
|
||||||
/**
|
StackActionHelpers<ParamList>;
|
||||||
* Push a new screen onto the stack.
|
|
||||||
*
|
|
||||||
* @param name Name of the route for the tab.
|
|
||||||
* @param [params] Params object for the route.
|
|
||||||
*/
|
|
||||||
push<RouteName extends keyof ParamList>(
|
|
||||||
...args: ParamList[RouteName] extends undefined | any
|
|
||||||
? [RouteName] | [RouteName, ParamList[RouteName]]
|
|
||||||
: [RouteName, ParamList[RouteName]]
|
|
||||||
): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pop a screen from the stack.
|
|
||||||
*/
|
|
||||||
pop(count?: number): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pop to the first route in the stack, dismissing all other screens.
|
|
||||||
*/
|
|
||||||
popToTop(): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Layout = { width: number; height: number };
|
export type Layout = { width: number; height: number };
|
||||||
|
|
||||||
@@ -122,7 +103,7 @@ export type StackHeaderOptions = {
|
|||||||
/**
|
/**
|
||||||
* Style object for the title component.
|
* Style object for the title component.
|
||||||
*/
|
*/
|
||||||
headerTitleStyle?: StyleProp<TextStyle>;
|
headerTitleStyle?: React.ComponentProps<typeof Animated.Text>['style'];
|
||||||
/**
|
/**
|
||||||
* Style object for the container of the `headerTitle` component, for example to add padding.
|
* Style object for the container of the `headerTitle` component, for example to add padding.
|
||||||
* By default, `headerTitleContainerStyle` is with an absolute position style and offsets both `left` and `right`.
|
* By default, `headerTitleContainerStyle` is with an absolute position style and offsets both `left` and `right`.
|
||||||
@@ -279,6 +260,10 @@ export type StackNavigationOptions = StackHeaderOptions &
|
|||||||
* Defaults to `true` on Android and `false` on iOS.
|
* Defaults to `true` on Android and `false` on iOS.
|
||||||
*/
|
*/
|
||||||
cardOverlayEnabled?: boolean;
|
cardOverlayEnabled?: boolean;
|
||||||
|
/**
|
||||||
|
* Function that returns a React Element to display as a overlay for the card.
|
||||||
|
*/
|
||||||
|
cardOverlay?: (props: { style: StyleProp<ViewStyle> }) => React.ReactNode;
|
||||||
/**
|
/**
|
||||||
* Style object for the card in stack.
|
* Style object for the card in stack.
|
||||||
* You can provide a custom background color to use instead of the default background here.
|
* You can provide a custom background color to use instead of the default background here.
|
||||||
@@ -430,7 +415,7 @@ export type StackHeaderTitleProps = {
|
|||||||
/**
|
/**
|
||||||
* Style object for the title element.
|
* Style object for the title element.
|
||||||
*/
|
*/
|
||||||
style?: StyleProp<TextStyle>;
|
style?: React.ComponentProps<typeof Animated.Text>['style'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TransitionSpec =
|
export type TransitionSpec =
|
||||||
|
|||||||
@@ -32,13 +32,14 @@ export default class BorderlessButton extends React.Component<Props> {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.onActiveStateChange && this.props.onActiveStateChange(active);
|
this.props.onActiveStateChange?.(active);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { children, style, enabled, ...rest } = this.props;
|
const { children, style, enabled, ...rest } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// @ts-ignore
|
||||||
<AnimatedBaseButton
|
<AnimatedBaseButton
|
||||||
{...rest}
|
{...rest}
|
||||||
onActiveStateChange={this.handleActiveStateChange}
|
onActiveStateChange={this.handleActiveStateChange}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { Animated, StyleSheet, Platform, TextProps } from 'react-native';
|
import { Animated, StyleSheet, Platform } from 'react-native';
|
||||||
import { useTheme } from '@react-navigation/native';
|
import { useTheme } from '@react-navigation/native';
|
||||||
|
|
||||||
type Props = TextProps & {
|
type Props = React.ComponentProps<typeof Animated.Text> & {
|
||||||
tintColor?: string;
|
tintColor?: string;
|
||||||
children?: string;
|
children?: string;
|
||||||
};
|
};
|
||||||
@@ -32,7 +32,8 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
android: {
|
android: {
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: '500',
|
fontFamily: 'sans-serif-medium',
|
||||||
|
fontWeight: 'normal',
|
||||||
},
|
},
|
||||||
default: {
|
default: {
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ type Props = ViewProps & {
|
|||||||
onGestureCanceled?: () => void;
|
onGestureCanceled?: () => void;
|
||||||
onGestureEnd?: () => void;
|
onGestureEnd?: () => void;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
overlay: (props: { style: StyleProp<ViewStyle> }) => React.ReactNode;
|
||||||
overlayEnabled: boolean;
|
overlayEnabled: boolean;
|
||||||
shadowEnabled: boolean;
|
shadowEnabled: boolean;
|
||||||
gestureEnabled: boolean;
|
gestureEnabled: boolean;
|
||||||
@@ -80,6 +81,10 @@ export default class Card extends React.Component<Props> {
|
|||||||
shadowEnabled: true,
|
shadowEnabled: true,
|
||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
gestureVelocityImpact: GESTURE_VELOCITY_IMPACT,
|
gestureVelocityImpact: GESTURE_VELOCITY_IMPACT,
|
||||||
|
overlay: ({ style }: { style: StyleProp<ViewStyle> }) =>
|
||||||
|
style ? (
|
||||||
|
<Animated.View pointerEvents="none" style={[styles.overlay, style]} />
|
||||||
|
) : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -267,8 +272,7 @@ export default class Card extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const closing =
|
const closing =
|
||||||
Math.abs(translation + velocity * gestureVelocityImpact) >
|
translation + velocity * gestureVelocityImpact > distance / 2
|
||||||
distance / 2
|
|
||||||
? velocity !== 0 || translation !== 0
|
? velocity !== 0 || translation !== 0
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
@@ -409,6 +413,7 @@ export default class Card extends React.Component<Props> {
|
|||||||
next,
|
next,
|
||||||
layout,
|
layout,
|
||||||
insets,
|
insets,
|
||||||
|
overlay,
|
||||||
overlayEnabled,
|
overlayEnabled,
|
||||||
shadowEnabled,
|
shadowEnabled,
|
||||||
gestureEnabled,
|
gestureEnabled,
|
||||||
@@ -470,55 +475,54 @@ export default class Card extends React.Component<Props> {
|
|||||||
: false;
|
: false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View pointerEvents="box-none" {...rest}>
|
<CardAnimationContext.Provider value={animationContext}>
|
||||||
{overlayEnabled && overlayStyle ? (
|
<View pointerEvents="box-none" {...rest}>
|
||||||
|
{overlayEnabled ? (
|
||||||
|
<View style={StyleSheet.absoluteFill}>
|
||||||
|
{overlay({ style: overlayStyle })}
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
<Animated.View
|
<Animated.View
|
||||||
pointerEvents="none"
|
style={[styles.container, containerStyle, customContainerStyle]}
|
||||||
style={[styles.overlay, overlayStyle]}
|
pointerEvents="box-none"
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
<Animated.View
|
|
||||||
style={[styles.container, containerStyle, customContainerStyle]}
|
|
||||||
pointerEvents="box-none"
|
|
||||||
>
|
|
||||||
<PanGestureHandler
|
|
||||||
ref={this.gestureRef}
|
|
||||||
enabled={layout.width !== 0 && gestureEnabled}
|
|
||||||
onGestureEvent={handleGestureEvent}
|
|
||||||
onHandlerStateChange={this.handleGestureStateChange}
|
|
||||||
{...this.gestureActivationCriteria()}
|
|
||||||
>
|
>
|
||||||
<Animated.View style={[styles.container, cardStyle]}>
|
<PanGestureHandler
|
||||||
{shadowEnabled && shadowStyle && !isTransparent ? (
|
ref={this.gestureRef}
|
||||||
<Animated.View
|
enabled={layout.width !== 0 && gestureEnabled}
|
||||||
style={[
|
onGestureEvent={handleGestureEvent}
|
||||||
styles.shadow,
|
onHandlerStateChange={this.handleGestureStateChange}
|
||||||
gestureDirection === 'horizontal'
|
{...this.gestureActivationCriteria()}
|
||||||
? [styles.shadowHorizontal, styles.shadowLeft]
|
>
|
||||||
: gestureDirection === 'horizontal-inverted'
|
<Animated.View style={[styles.container, cardStyle]}>
|
||||||
? [styles.shadowHorizontal, styles.shadowRight]
|
{shadowEnabled && shadowStyle && !isTransparent ? (
|
||||||
: gestureDirection === 'vertical'
|
<Animated.View
|
||||||
? [styles.shadowVertical, styles.shadowTop]
|
style={[
|
||||||
: [styles.shadowVertical, styles.shadowBottom],
|
styles.shadow,
|
||||||
shadowStyle,
|
gestureDirection === 'horizontal'
|
||||||
]}
|
? [styles.shadowHorizontal, styles.shadowLeft]
|
||||||
pointerEvents="none"
|
: gestureDirection === 'horizontal-inverted'
|
||||||
/>
|
? [styles.shadowHorizontal, styles.shadowRight]
|
||||||
) : null}
|
: gestureDirection === 'vertical'
|
||||||
<View
|
? [styles.shadowVertical, styles.shadowTop]
|
||||||
ref={this.contentRef}
|
: [styles.shadowVertical, styles.shadowBottom],
|
||||||
style={[styles.content, contentStyle]}
|
shadowStyle,
|
||||||
>
|
]}
|
||||||
<StackGestureRefContext.Provider value={this.gestureRef}>
|
pointerEvents="none"
|
||||||
<CardAnimationContext.Provider value={animationContext}>
|
/>
|
||||||
|
) : null}
|
||||||
|
<View
|
||||||
|
ref={this.contentRef}
|
||||||
|
style={[styles.content, contentStyle]}
|
||||||
|
>
|
||||||
|
<StackGestureRefContext.Provider value={this.gestureRef}>
|
||||||
{children}
|
{children}
|
||||||
</CardAnimationContext.Provider>
|
</StackGestureRefContext.Provider>
|
||||||
</StackGestureRefContext.Provider>
|
</View>
|
||||||
</View>
|
</Animated.View>
|
||||||
</Animated.View>
|
</PanGestureHandler>
|
||||||
</PanGestureHandler>
|
</Animated.View>
|
||||||
</Animated.View>
|
</View>
|
||||||
</View>
|
</CardAnimationContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -532,7 +536,7 @@ const styles = StyleSheet.create({
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
},
|
},
|
||||||
overlay: {
|
overlay: {
|
||||||
...StyleSheet.absoluteFillObject,
|
flex: 1,
|
||||||
backgroundColor: '#000',
|
backgroundColor: '#000',
|
||||||
},
|
},
|
||||||
shadow: {
|
shadow: {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type Props = TransitionPreset & {
|
|||||||
safeAreaInsetRight: number;
|
safeAreaInsetRight: number;
|
||||||
safeAreaInsetBottom: number;
|
safeAreaInsetBottom: number;
|
||||||
safeAreaInsetLeft: number;
|
safeAreaInsetLeft: number;
|
||||||
|
cardOverlay?: (props: { style: StyleProp<ViewStyle> }) => React.ReactNode;
|
||||||
cardOverlayEnabled?: boolean;
|
cardOverlayEnabled?: boolean;
|
||||||
cardShadowEnabled?: boolean;
|
cardShadowEnabled?: boolean;
|
||||||
cardStyle?: StyleProp<ViewStyle>;
|
cardStyle?: StyleProp<ViewStyle>;
|
||||||
@@ -58,6 +59,7 @@ const EPSILON = 0.1;
|
|||||||
|
|
||||||
function CardContainer({
|
function CardContainer({
|
||||||
active,
|
active,
|
||||||
|
cardOverlay,
|
||||||
cardOverlayEnabled,
|
cardOverlayEnabled,
|
||||||
cardShadowEnabled,
|
cardShadowEnabled,
|
||||||
cardStyle,
|
cardStyle,
|
||||||
@@ -162,6 +164,7 @@ function CardContainer({
|
|||||||
closing={closing}
|
closing={closing}
|
||||||
onOpen={handleOpen}
|
onOpen={handleOpen}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
|
overlay={cardOverlay}
|
||||||
overlayEnabled={cardOverlayEnabled}
|
overlayEnabled={cardOverlayEnabled}
|
||||||
shadowEnabled={cardShadowEnabled}
|
shadowEnabled={cardShadowEnabled}
|
||||||
onTransitionStart={handleTransitionStart}
|
onTransitionStart={handleTransitionStart}
|
||||||
|
|||||||
@@ -431,6 +431,7 @@ export default class CardStack extends React.Component<Props, State> {
|
|||||||
headerTransparent,
|
headerTransparent,
|
||||||
cardShadowEnabled,
|
cardShadowEnabled,
|
||||||
cardOverlayEnabled,
|
cardOverlayEnabled,
|
||||||
|
cardOverlay,
|
||||||
cardStyle,
|
cardStyle,
|
||||||
animationEnabled,
|
animationEnabled,
|
||||||
gestureResponseDistance,
|
gestureResponseDistance,
|
||||||
@@ -528,6 +529,7 @@ export default class CardStack extends React.Component<Props, State> {
|
|||||||
safeAreaInsetRight={safeAreaInsetRight}
|
safeAreaInsetRight={safeAreaInsetRight}
|
||||||
safeAreaInsetBottom={safeAreaInsetBottom}
|
safeAreaInsetBottom={safeAreaInsetBottom}
|
||||||
safeAreaInsetLeft={safeAreaInsetLeft}
|
safeAreaInsetLeft={safeAreaInsetLeft}
|
||||||
|
cardOverlay={cardOverlay}
|
||||||
cardOverlayEnabled={cardOverlayEnabled}
|
cardOverlayEnabled={cardOverlayEnabled}
|
||||||
cardShadowEnabled={cardShadowEnabled}
|
cardShadowEnabled={cardShadowEnabled}
|
||||||
cardStyle={cardStyle}
|
cardStyle={cardStyle}
|
||||||
|
|||||||
Reference in New Issue
Block a user