mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-29 04:45:19 +08:00
chore: sync latest stack
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
"devDependencies": {
|
||||
"@react-native-community/bob": "^0.9.7",
|
||||
"@react-native-community/masked-view": "^0.1.6",
|
||||
"@react-navigation/stack": "^5.1.1",
|
||||
"@react-navigation/stack": "^5.2.0",
|
||||
"@types/color": "^3.0.1",
|
||||
"@types/react": "^16.9.22",
|
||||
"@types/react-native": "^0.61.17",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/index.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/index.tsx 2020-03-04 00:03:45.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/index.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/index.tsx 2020-03-16 14:41:12.000000000 +0100
|
||||
@@ -3,11 +3,6 @@
|
||||
import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
|
||||
import * as TransitionPresets from './TransitionConfigs/TransitionPresets';
|
||||
@@ -28,7 +28,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/index.tsx src/vendor/i
|
||||
StackHeaderTitleProps,
|
||||
StackCardInterpolatedStyle,
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx src/vendor/navigators/createStackNavigator.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/navigators/createStackNavigator.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/navigators/createStackNavigator.tsx 1970-01-01 01:00:00.000000000 +0100
|
||||
@@ -1,81 +0,0 @@
|
||||
-import * as React from 'react';
|
||||
@@ -113,9 +113,9 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/navigators/createStack
|
||||
- typeof StackNavigator
|
||||
->(StackNavigator);
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/types.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/types.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
@@ -7,13 +7,28 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/types.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/types.tsx 2020-03-16 14:47:01.000000000 +0100
|
||||
@@ -8,14 +8,28 @@
|
||||
} from 'react-native';
|
||||
import { EdgeInsets } from 'react-native-safe-area-context';
|
||||
import {
|
||||
@@ -128,6 +128,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
- Route,
|
||||
- NavigationHelpers,
|
||||
- StackNavigationState,
|
||||
- StackActionHelpers,
|
||||
-} from '@react-navigation/native';
|
||||
+ NavigationParams,
|
||||
+ NavigationNavigateAction,
|
||||
@@ -150,7 +151,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
|
||||
export type StackNavigationEventMap = {
|
||||
/**
|
||||
@@ -26,42 +41,29 @@
|
||||
@@ -28,22 +42,29 @@
|
||||
transitionEnd: { data: { closing: boolean } };
|
||||
};
|
||||
|
||||
@@ -158,8 +159,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
- ParamListBase,
|
||||
- StackNavigationEventMap
|
||||
->;
|
||||
-
|
||||
+export type StackNavigationHelpers = NavigationProp<NavigationStackState>;
|
||||
|
||||
export type StackNavigationProp<
|
||||
- ParamList extends ParamListBase,
|
||||
- RouteName extends keyof ParamList = string
|
||||
@@ -169,28 +170,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
- StackNavigationState,
|
||||
- StackNavigationOptions,
|
||||
- StackNavigationEventMap
|
||||
-> & {
|
||||
- /**
|
||||
- * 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;
|
||||
-> &
|
||||
- StackActionHelpers<ParamList>;
|
||||
+ State = NavigationRoute,
|
||||
+ Params = NavigationParams
|
||||
+> = NavigationScreenProp<State, Params> & {
|
||||
@@ -211,10 +192,11 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
+ event: NavigationStackEventName,
|
||||
+ callback: NavigationEventCallback
|
||||
+ ) => NavigationEventSubscription;
|
||||
};
|
||||
+};
|
||||
|
||||
export type Layout = { width: number; height: number };
|
||||
@@ -237,24 +239,27 @@
|
||||
|
||||
@@ -218,24 +239,27 @@
|
||||
/**
|
||||
* Navigation prop for the header.
|
||||
*/
|
||||
@@ -248,7 +230,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
export type StackNavigationOptions = StackHeaderOptions &
|
||||
Partial<TransitionPreset> & {
|
||||
/**
|
||||
@@ -332,6 +337,8 @@
|
||||
@@ -317,6 +341,8 @@
|
||||
bottom?: number;
|
||||
left?: number;
|
||||
};
|
||||
@@ -257,20 +239,9 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/types.tsx src/vendor/t
|
||||
};
|
||||
|
||||
export type StackNavigationConfig = {
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/BorderlessButton.tsx src/vendor/views/BorderlessButton.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/BorderlessButton.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/BorderlessButton.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
@@ -39,6 +39,7 @@
|
||||
const { children, style, enabled, ...rest } = this.props;
|
||||
|
||||
return (
|
||||
+ // @ts-ignore
|
||||
<AnimatedBaseButton
|
||||
{...rest}
|
||||
onActiveStateChange={this.handleActiveStateChange}
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx src/vendor/views/Header/Header.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Header/Header.tsx 2020-03-04 00:04:05.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/Header.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Header/Header.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -1,12 +1,14 @@
|
||||
import * as React from 'react';
|
||||
-import { StackActions } from '@react-navigation/native';
|
||||
@@ -350,8 +321,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/Header.ts
|
||||
+
|
||||
+export default Header;
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx src/vendor/views/Header/HeaderBackButton.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackButton.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackButton.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -8,9 +8,9 @@
|
||||
StyleSheet,
|
||||
LayoutChangeEvent,
|
||||
@@ -364,8 +335,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
|
||||
|
||||
type Props = StackHeaderLeftButtonProps;
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx src/vendor/views/Header/HeaderBackground.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBackground.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderBackground.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { Animated, StyleSheet, Platform, ViewProps } from 'react-native';
|
||||
@@ -375,8 +346,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderBac
|
||||
type Props = ViewProps & {
|
||||
children?: React.ReactNode;
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx src/vendor/views/Header/HeaderContainer.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderContainer.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderContainer.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -1,11 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
@@ -428,8 +399,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderCon
|
||||
);
|
||||
})}
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx src/vendor/views/Header/HeaderSegment.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSegment.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderSegment.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -8,7 +8,7 @@
|
||||
ViewStyle,
|
||||
} from 'react-native';
|
||||
@@ -449,24 +420,20 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderSeg
|
||||
};
|
||||
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx src/vendor/views/Header/HeaderTitle.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
@@ -1,8 +1,8 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Header/HeaderTitle.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Header/HeaderTitle.tsx 2020-03-16 14:43:23.000000000 +0100
|
||||
@@ -1,6 +1,6 @@
|
||||
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 { Animated, StyleSheet, Platform } from 'react-native';
|
||||
+import useTheme from '../../../utils/useTheme';
|
||||
|
||||
-type Props = TextProps & {
|
||||
+type Props = React.ComponentProps<typeof Animated.Text> & {
|
||||
type Props = React.ComponentProps<typeof Animated.Text> & {
|
||||
tintColor?: string;
|
||||
children?: string;
|
||||
};
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx src/vendor/views/Stack/Card.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Stack/Card.tsx 2020-03-04 00:03:48.000000000 +0100
|
||||
@@ -133,7 +133,7 @@
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Stack/Card.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
private interactionHandle: number | undefined;
|
||||
|
||||
@@ -475,18 +442,9 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/Card.tsx s
|
||||
|
||||
private animate = ({
|
||||
closing,
|
||||
@@ -507,7 +507,7 @@
|
||||
) : null}
|
||||
<View
|
||||
ref={this.contentRef}
|
||||
- style={[styles.content, contentStyle]}
|
||||
+ style={[styles.content, contentStyle] as any}
|
||||
>
|
||||
<StackGestureRefContext.Provider value={this.gestureRef}>
|
||||
<CardAnimationContext.Provider value={animationContext}>
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx src/vendor/views/Stack/CardContainer.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardContainer.tsx 2020-03-04 13:24:38.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardContainer.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -1,10 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import { Animated, View, StyleSheet, StyleProp, ViewStyle } from 'react-native';
|
||||
@@ -506,7 +464,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContai
|
||||
|
||||
type Props = TransitionPreset & {
|
||||
index: number;
|
||||
@@ -35,6 +41,7 @@
|
||||
@@ -36,6 +42,7 @@
|
||||
closing: boolean
|
||||
) => void;
|
||||
onTransitionEnd?: (props: { route: Route<string> }, closing: boolean) => void;
|
||||
@@ -514,7 +472,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContai
|
||||
onPageChangeStart?: () => void;
|
||||
onPageChangeConfirm?: () => void;
|
||||
onPageChangeCancel?: () => void;
|
||||
@@ -81,6 +88,7 @@
|
||||
@@ -83,6 +90,7 @@
|
||||
layout,
|
||||
onCloseRoute,
|
||||
onOpenRoute,
|
||||
@@ -522,7 +480,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContai
|
||||
onPageChangeCancel,
|
||||
onPageChangeConfirm,
|
||||
onPageChangeStart,
|
||||
@@ -150,6 +158,9 @@
|
||||
@@ -152,6 +160,9 @@
|
||||
};
|
||||
}, [pointerEvents, scene.progress.next]);
|
||||
|
||||
@@ -532,7 +490,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContai
|
||||
return (
|
||||
<Card
|
||||
index={index}
|
||||
@@ -180,7 +191,7 @@
|
||||
@@ -183,7 +194,7 @@
|
||||
? { marginTop: headerHeight }
|
||||
: null
|
||||
}
|
||||
@@ -542,8 +500,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardContai
|
||||
>
|
||||
<View style={styles.container}>
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx src/vendor/views/Stack/CardStack.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardStack.tsx 2020-03-04 13:31:28.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Stack/CardStack.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -9,9 +9,8 @@
|
||||
ViewProps,
|
||||
} from 'react-native';
|
||||
@@ -579,7 +537,7 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.
|
||||
onTransitionStart,
|
||||
onTransitionEnd,
|
||||
onPageChangeStart,
|
||||
@@ -546,6 +548,7 @@
|
||||
@@ -548,6 +550,7 @@
|
||||
renderScene={renderScene}
|
||||
onOpenRoute={onOpenRoute}
|
||||
onCloseRoute={onCloseRoute}
|
||||
@@ -588,8 +546,8 @@ diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/CardStack.
|
||||
onTransitionEnd={onTransitionEnd}
|
||||
gestureEnabled={index !== 0 && getGesturesEnabled({ route })}
|
||||
diff -Naur ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx src/vendor/views/Stack/StackView.tsx
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-03-03 23:57:02.000000000 +0100
|
||||
+++ src/vendor/views/Stack/StackView.tsx 2020-03-04 13:24:28.000000000 +0100
|
||||
--- ../../node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx 2020-03-16 14:39:49.000000000 +0100
|
||||
+++ src/vendor/views/Stack/StackView.tsx 2020-03-16 14:41:16.000000000 +0100
|
||||
@@ -4,9 +4,9 @@
|
||||
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||
import {
|
||||
|
||||
10
packages/stack/src/vendor/types.tsx
vendored
10
packages/stack/src/vendor/types.tsx
vendored
@@ -1,3 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
Animated,
|
||||
StyleProp,
|
||||
@@ -42,7 +43,6 @@ export type StackNavigationEventMap = {
|
||||
};
|
||||
|
||||
export type StackNavigationHelpers = NavigationProp<NavigationStackState>;
|
||||
|
||||
export type StackNavigationProp<
|
||||
State = NavigationRoute,
|
||||
Params = NavigationParams
|
||||
@@ -124,7 +124,7 @@ export type StackHeaderOptions = {
|
||||
/**
|
||||
* 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.
|
||||
* By default, `headerTitleContainerStyle` is with an absolute position style and offsets both `left` and `right`.
|
||||
@@ -284,6 +284,10 @@ export type StackNavigationOptions = StackHeaderOptions &
|
||||
* Defaults to `true` on Android and `false` on iOS.
|
||||
*/
|
||||
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.
|
||||
* You can provide a custom background color to use instead of the default background here.
|
||||
@@ -437,7 +441,7 @@ export type StackHeaderTitleProps = {
|
||||
/**
|
||||
* Style object for the title element.
|
||||
*/
|
||||
style?: StyleProp<TextStyle>;
|
||||
style?: React.ComponentProps<typeof Animated.Text>['style'];
|
||||
};
|
||||
|
||||
export type TransitionSpec =
|
||||
|
||||
@@ -32,7 +32,7 @@ export default class BorderlessButton extends React.Component<Props> {
|
||||
}).start();
|
||||
}
|
||||
|
||||
this.props.onActiveStateChange && this.props.onActiveStateChange(active);
|
||||
this.props.onActiveStateChange?.(active);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
@@ -32,7 +32,8 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
android: {
|
||||
fontSize: 20,
|
||||
fontWeight: '500',
|
||||
fontFamily: 'sans-serif-medium',
|
||||
fontWeight: 'normal',
|
||||
},
|
||||
default: {
|
||||
fontSize: 18,
|
||||
|
||||
102
packages/stack/src/vendor/views/Stack/Card.tsx
vendored
102
packages/stack/src/vendor/views/Stack/Card.tsx
vendored
@@ -44,6 +44,7 @@ type Props = ViewProps & {
|
||||
onGestureCanceled?: () => void;
|
||||
onGestureEnd?: () => void;
|
||||
children: React.ReactNode;
|
||||
overlay: (props: { style: StyleProp<ViewStyle> }) => React.ReactNode;
|
||||
overlayEnabled: boolean;
|
||||
shadowEnabled: boolean;
|
||||
gestureEnabled: boolean;
|
||||
@@ -80,6 +81,10 @@ export default class Card extends React.Component<Props> {
|
||||
shadowEnabled: true,
|
||||
gestureEnabled: true,
|
||||
gestureVelocityImpact: GESTURE_VELOCITY_IMPACT,
|
||||
overlay: ({ style }: { style: StyleProp<ViewStyle> }) =>
|
||||
style ? (
|
||||
<Animated.View pointerEvents="none" style={[styles.overlay, style]} />
|
||||
) : null,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -267,8 +272,7 @@ export default class Card extends React.Component<Props> {
|
||||
}
|
||||
|
||||
const closing =
|
||||
Math.abs(translation + velocity * gestureVelocityImpact) >
|
||||
distance / 2
|
||||
translation + velocity * gestureVelocityImpact > distance / 2
|
||||
? velocity !== 0 || translation !== 0
|
||||
: false;
|
||||
|
||||
@@ -409,6 +413,7 @@ export default class Card extends React.Component<Props> {
|
||||
next,
|
||||
layout,
|
||||
insets,
|
||||
overlay,
|
||||
overlayEnabled,
|
||||
shadowEnabled,
|
||||
gestureEnabled,
|
||||
@@ -470,55 +475,54 @@ export default class Card extends React.Component<Props> {
|
||||
: false;
|
||||
|
||||
return (
|
||||
<View pointerEvents="box-none" {...rest}>
|
||||
{overlayEnabled && overlayStyle ? (
|
||||
<CardAnimationContext.Provider value={animationContext}>
|
||||
<View pointerEvents="box-none" {...rest}>
|
||||
{overlayEnabled ? (
|
||||
<View style={StyleSheet.absoluteFill}>
|
||||
{overlay({ style: overlayStyle })}
|
||||
</View>
|
||||
) : null}
|
||||
<Animated.View
|
||||
pointerEvents="none"
|
||||
style={[styles.overlay, overlayStyle]}
|
||||
/>
|
||||
) : 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()}
|
||||
style={[styles.container, containerStyle, customContainerStyle]}
|
||||
pointerEvents="box-none"
|
||||
>
|
||||
<Animated.View style={[styles.container, cardStyle]}>
|
||||
{shadowEnabled && shadowStyle && !isTransparent ? (
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.shadow,
|
||||
gestureDirection === 'horizontal'
|
||||
? [styles.shadowHorizontal, styles.shadowLeft]
|
||||
: gestureDirection === 'horizontal-inverted'
|
||||
? [styles.shadowHorizontal, styles.shadowRight]
|
||||
: gestureDirection === 'vertical'
|
||||
? [styles.shadowVertical, styles.shadowTop]
|
||||
: [styles.shadowVertical, styles.shadowBottom],
|
||||
shadowStyle,
|
||||
]}
|
||||
pointerEvents="none"
|
||||
/>
|
||||
) : null}
|
||||
<View
|
||||
ref={this.contentRef}
|
||||
style={[styles.content, contentStyle] as any}
|
||||
>
|
||||
<StackGestureRefContext.Provider value={this.gestureRef}>
|
||||
<CardAnimationContext.Provider value={animationContext}>
|
||||
<PanGestureHandler
|
||||
ref={this.gestureRef}
|
||||
enabled={layout.width !== 0 && gestureEnabled}
|
||||
onGestureEvent={handleGestureEvent}
|
||||
onHandlerStateChange={this.handleGestureStateChange}
|
||||
{...this.gestureActivationCriteria()}
|
||||
>
|
||||
<Animated.View style={[styles.container, cardStyle]}>
|
||||
{shadowEnabled && shadowStyle && !isTransparent ? (
|
||||
<Animated.View
|
||||
style={[
|
||||
styles.shadow,
|
||||
gestureDirection === 'horizontal'
|
||||
? [styles.shadowHorizontal, styles.shadowLeft]
|
||||
: gestureDirection === 'horizontal-inverted'
|
||||
? [styles.shadowHorizontal, styles.shadowRight]
|
||||
: gestureDirection === 'vertical'
|
||||
? [styles.shadowVertical, styles.shadowTop]
|
||||
: [styles.shadowVertical, styles.shadowBottom],
|
||||
shadowStyle,
|
||||
]}
|
||||
pointerEvents="none"
|
||||
/>
|
||||
) : null}
|
||||
<View
|
||||
ref={this.contentRef}
|
||||
style={[styles.content, contentStyle]}
|
||||
>
|
||||
<StackGestureRefContext.Provider value={this.gestureRef}>
|
||||
{children}
|
||||
</CardAnimationContext.Provider>
|
||||
</StackGestureRefContext.Provider>
|
||||
</View>
|
||||
</Animated.View>
|
||||
</PanGestureHandler>
|
||||
</Animated.View>
|
||||
</View>
|
||||
</StackGestureRefContext.Provider>
|
||||
</View>
|
||||
</Animated.View>
|
||||
</PanGestureHandler>
|
||||
</Animated.View>
|
||||
</View>
|
||||
</CardAnimationContext.Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -532,7 +536,7 @@ const styles = StyleSheet.create({
|
||||
overflow: 'hidden',
|
||||
},
|
||||
overlay: {
|
||||
...StyleSheet.absoluteFillObject,
|
||||
flex: 1,
|
||||
backgroundColor: '#000',
|
||||
},
|
||||
shadow: {
|
||||
|
||||
@@ -25,6 +25,7 @@ type Props = TransitionPreset & {
|
||||
safeAreaInsetRight: number;
|
||||
safeAreaInsetBottom: number;
|
||||
safeAreaInsetLeft: number;
|
||||
cardOverlay?: (props: { style: StyleProp<ViewStyle> }) => React.ReactNode;
|
||||
cardOverlayEnabled?: boolean;
|
||||
cardShadowEnabled?: boolean;
|
||||
cardStyle?: StyleProp<ViewStyle>;
|
||||
@@ -65,6 +66,7 @@ const EPSILON = 0.1;
|
||||
|
||||
function CardContainer({
|
||||
active,
|
||||
cardOverlay,
|
||||
cardOverlayEnabled,
|
||||
cardShadowEnabled,
|
||||
cardStyle,
|
||||
@@ -173,6 +175,7 @@ function CardContainer({
|
||||
closing={closing}
|
||||
onOpen={handleOpen}
|
||||
onClose={handleClose}
|
||||
overlay={cardOverlay}
|
||||
overlayEnabled={cardOverlayEnabled}
|
||||
shadowEnabled={cardShadowEnabled}
|
||||
onTransitionStart={handleTransitionStart}
|
||||
|
||||
@@ -433,6 +433,7 @@ export default class CardStack extends React.Component<Props, State> {
|
||||
headerTransparent,
|
||||
cardShadowEnabled,
|
||||
cardOverlayEnabled,
|
||||
cardOverlay,
|
||||
cardStyle,
|
||||
animationEnabled,
|
||||
gestureResponseDistance,
|
||||
@@ -530,6 +531,7 @@ export default class CardStack extends React.Component<Props, State> {
|
||||
safeAreaInsetRight={safeAreaInsetRight}
|
||||
safeAreaInsetBottom={safeAreaInsetBottom}
|
||||
safeAreaInsetLeft={safeAreaInsetLeft}
|
||||
cardOverlay={cardOverlay}
|
||||
cardOverlayEnabled={cardOverlayEnabled}
|
||||
cardShadowEnabled={cardShadowEnabled}
|
||||
cardStyle={cardStyle}
|
||||
|
||||
@@ -3036,10 +3036,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@react-native-community/masked-view/-/masked-view-0.1.6.tgz#c7f2ac187c1f25aa8c30d11baa8f4398eca3bb84"
|
||||
integrity sha512-PpMoeXwPUoldCRKDuSi+zK5rT+sJTW6ri6RdGPkSKRzU77Q1d9IaR0O5IKvBj0XSdL3p+dcOa05gk35aGDffBQ==
|
||||
|
||||
"@react-navigation/stack@^5.1.1":
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.1.1.tgz#4fff1dc3fec66d7b71cfc31691d6e83d8777d5f8"
|
||||
integrity sha512-tQV4SNESAeqViItGFT8bLrCGWxYfSjw4uXGrCokzSBOMtrdUwINwXDqo40LZt/KZOT0kVN6MdzHq57ILB1LsGA==
|
||||
"@react-navigation/stack@^5.2.0":
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@react-navigation/stack/-/stack-5.2.0.tgz#e16138cd23b457594e790999552ab3d72e8e2707"
|
||||
integrity sha512-lFTVV1S9YEPsIxzLUPY95Y2lqmday79uOadOopQkjq3JWmZTXBJDMW9jgV8B+F5EfUh0VabQ2zX06OfjxrvtUw==
|
||||
dependencies:
|
||||
color "^3.1.2"
|
||||
react-native-iphone-x-helper "^1.2.1"
|
||||
|
||||
Reference in New Issue
Block a user