|
1 | 1 | diff --git a/node_modules/@react-navigation/stack/lib/typescript/src/index.d.ts b/node_modules/@react-navigation/stack/lib/typescript/src/index.d.ts |
2 | | -index 35a863b..66239cd 100644 |
| 2 | +index 35a863b..d8dbca3 100644 |
3 | 3 | --- a/node_modules/@react-navigation/stack/lib/typescript/src/index.d.ts |
4 | 4 | +++ b/node_modules/@react-navigation/stack/lib/typescript/src/index.d.ts |
5 | 5 | @@ -22,6 +22,8 @@ export { default as CardAnimationContext } from './utils/CardAnimationContext'; |
6 | 6 | export { default as GestureHandlerRefContext } from './utils/GestureHandlerRefContext'; |
7 | 7 | export { default as useCardAnimation } from './utils/useCardAnimation'; |
8 | 8 | export { default as useGestureHandlerRef } from './utils/useGestureHandlerRef'; |
9 | | -+export { CardModalGestureContext } from './utils/CardModalGestureContext'; |
| 9 | ++export { ModalGestureContext, ModalGestureContextType } from './utils/ModalGestureContext'; |
10 | 10 | + |
11 | 11 | /** |
12 | 12 | * Types |
13 | 13 | */ |
14 | | -diff --git a/node_modules/@react-navigation/stack/lib/typescript/src/utils/CardModalGestureContext.d.ts b/node_modules/@react-navigation/stack/lib/typescript/src/utils/CardModalGestureContext.d.ts |
| 14 | +diff --git a/node_modules/@react-navigation/stack/lib/typescript/src/utils/ModalGestureContext.ts b/node_modules/@react-navigation/stack/lib/typescript/src/utils/ModalGestureContext.ts |
15 | 15 | new file mode 100644 |
16 | | -index 0000000..590bf05 |
| 16 | +index 0000000..9cd9184 |
17 | 17 | --- /dev/null |
18 | | -+++ b/node_modules/@react-navigation/stack/lib/typescript/src/utils/CardModalGestureContext.d.ts |
| 18 | ++++ b/node_modules/@react-navigation/stack/lib/typescript/src/utils/ModalGestureContext.ts |
19 | 19 | @@ -0,0 +1,9 @@ |
20 | 20 | +import * as React from 'react'; |
21 | 21 | +import type { Animated } from 'react-native'; |
22 | 22 | + |
23 | | -+export interface CardModalGestureContextType { |
| 23 | ++export interface ModalGestureContextType { |
24 | 24 | + scrollableGestureRef: React.RefObject<any>; |
25 | | -+ cardModalTranslateY: Animated.Value; |
| 25 | ++ modalTranslateY: Animated.Value; |
26 | 26 | +} |
27 | 27 | + |
28 | | -+export declare const CardModalGestureContext: React.Context<CardModalGestureContextType>; |
| 28 | ++export declare const ModalGestureContext: React.Context<ModalGestureContextType>; |
29 | 29 | diff --git a/node_modules/@react-navigation/stack/src/index.tsx b/node_modules/@react-navigation/stack/src/index.tsx |
30 | | -index f20d3fb..d914384 100644 |
| 30 | +index f20d3fb..a8475dd 100644 |
31 | 31 | --- a/node_modules/@react-navigation/stack/src/index.tsx |
32 | 32 | +++ b/node_modules/@react-navigation/stack/src/index.tsx |
33 | 33 | @@ -31,6 +31,7 @@ export { default as CardAnimationContext } from './utils/CardAnimationContext'; |
34 | 34 | export { default as GestureHandlerRefContext } from './utils/GestureHandlerRefContext'; |
35 | 35 | export { default as useCardAnimation } from './utils/useCardAnimation'; |
36 | 36 | export { default as useGestureHandlerRef } from './utils/useGestureHandlerRef'; |
37 | | -+export { CardModalGestureContext } from './utils/CardModalGestureContext'; |
| 37 | ++export { ModalGestureContext } from './utils/ModalGestureContext'; |
38 | 38 |
|
39 | 39 | /** |
40 | 40 | * Types |
41 | | -diff --git a/node_modules/@react-navigation/stack/src/utils/CardModalGestureContext.tsx b/node_modules/@react-navigation/stack/src/utils/CardModalGestureContext.tsx |
| 41 | +diff --git a/node_modules/@react-navigation/stack/src/utils/ModalGestureContext.ts b/node_modules/@react-navigation/stack/src/utils/ModalGestureContext.ts |
42 | 42 | new file mode 100644 |
43 | | -index 0000000..4b041b8 |
| 43 | +index 0000000..8b35adf |
44 | 44 | --- /dev/null |
45 | | -+++ b/node_modules/@react-navigation/stack/src/utils/CardModalGestureContext.tsx |
46 | | -@@ -0,0 +1,25 @@ |
| 45 | ++++ b/node_modules/@react-navigation/stack/src/utils/ModalGestureContext.ts |
| 46 | +@@ -0,0 +1,10 @@ |
47 | 47 | +import React from 'react'; |
48 | 48 | +import { Animated } from 'react-native'; |
49 | 49 | + |
50 | | -+interface CardModalGestureContextType { |
| 50 | ++export interface ModalGestureContextType { |
51 | 51 | + scrollableGestureRef: React.RefObject<any>; |
52 | | -+ cardModalTranslateY: Animated.Value; |
| 52 | ++ modalTranslateY: Animated.Value; |
53 | 53 | +} |
54 | 54 | + |
55 | | -+export const CardModalGestureContext = |
56 | | -+ React.createContext<CardModalGestureContextType | null>(null); |
| 55 | ++export const ModalGestureContext = |
| 56 | ++ React.createContext<ModalGestureContextType | null>(null); |
| 57 | +diff --git a/node_modules/@react-navigation/stack/src/views/ModalGestureProvider.tsx b/node_modules/@react-navigation/stack/src/views/ModalGestureProvider.tsx |
| 58 | +new file mode 100644 |
| 59 | +index 0000000..cda7e29 |
| 60 | +--- /dev/null |
| 61 | ++++ b/node_modules/@react-navigation/stack/src/views/ModalGestureProvider.tsx |
| 62 | +@@ -0,0 +1,38 @@ |
| 63 | ++import React from 'react'; |
| 64 | ++import { ModalGestureContext, ModalGestureContextType } from "../utils/ModalGestureContext" |
| 65 | ++ |
| 66 | ++interface ModalGestureProviderProps { |
| 67 | ++ /** |
| 68 | ++ * Context value. |
| 69 | ++ * |
| 70 | ++ * @type ModalGestureContextType |
| 71 | ++ */ |
| 72 | ++ value: ModalGestureContextType; |
| 73 | ++ |
| 74 | ++ /** |
| 75 | ++ * Defines if current card is a iOS modal. |
| 76 | ++ * |
| 77 | ++ * @type boolean |
| 78 | ++ * @default false |
| 79 | ++ */ |
| 80 | ++ enabled?: boolean; |
57 | 81 | + |
58 | | -+export const CardModalGestureContextProvider = (props: { |
59 | | -+ value: CardModalGestureContextType; |
60 | | -+ enable?: boolean; |
| 82 | ++ /** |
| 83 | ++ * Child component |
| 84 | ++ * |
| 85 | ++ * @type React.ReactNode |
| 86 | ++ */ |
61 | 87 | + children: React.ReactNode; |
62 | | -+}) => { |
63 | | -+ if (props.enable) { |
64 | | -+ return ( |
65 | | -+ <CardModalGestureContext.Provider value={props.value}> |
66 | | -+ {props.children} |
67 | | -+ </CardModalGestureContext.Provider> |
68 | | -+ ); |
69 | | -+ } |
70 | | -+ return <>{props.children}</>; |
71 | | -+}; |
| 88 | ++} |
| 89 | ++ |
| 90 | ++const ModalGestureProvider = ({ |
| 91 | ++ value, |
| 92 | ++ children, |
| 93 | ++ enabled = false |
| 94 | ++}: ModalGestureProviderProps) => enabled ? ( |
| 95 | ++ <ModalGestureContext.Provider value={value}> |
| 96 | ++ {children} |
| 97 | ++ </ModalGestureContext.Provider> |
| 98 | ++) : children; |
| 99 | ++ |
| 100 | ++export default ModalGestureProvider; |
| 101 | +\ No newline at end of file |
72 | 102 | diff --git a/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx b/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx |
73 | | -index a013ff9..5542ab4 100755 |
| 103 | +index a013ff9..fa5db2d 100755 |
74 | 104 | --- a/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx |
75 | 105 | +++ b/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx |
76 | | -@@ -21,6 +21,10 @@ import type { |
| 106 | +@@ -21,6 +21,7 @@ import type { |
77 | 107 | TransitionSpec, |
78 | 108 | } from '../../types'; |
79 | 109 | import CardAnimationContext from '../../utils/CardAnimationContext'; |
80 | | -+import { |
81 | | -+ CardModalGestureContext, |
82 | | -+ CardModalGestureContextProvider, |
83 | | -+} from '@react-navigation/stack/src/utils/CardModalGestureContext'; |
| 110 | ++import ModalGestureProvider from '../ModalGestureProvider' |
84 | 111 | import getDistanceForDirection from '../../utils/getDistanceForDirection'; |
85 | 112 | import getInvertedMultiplier from '../../utils/getInvertedMultiplier'; |
86 | 113 | import memoize from '../../utils/memoize'; |
87 | | -@@ -294,6 +298,8 @@ export default class Card extends React.Component<Props> { |
| 114 | +@@ -104,6 +105,8 @@ export default class Card extends React.Component<Props> { |
| 115 | + ) : null, |
| 116 | + }; |
| 117 | + |
| 118 | ++ private scrollableGestureRef = React.createRef<any>(); |
| 119 | ++ |
| 120 | + componentDidMount() { |
| 121 | + this.animate({ closing: this.props.closing }); |
| 122 | + this.isCurrentlyMounted = true; |
| 123 | +@@ -294,6 +297,21 @@ export default class Card extends React.Component<Props> { |
88 | 124 | case GestureState.END: { |
89 | 125 | this.isSwiping.setValue(FALSE); |
90 | 126 |
|
91 | 127 | + this.isSwiping.removeListener |
| 128 | ++ |
| 129 | ++ /** |
| 130 | ++ * if scrollable modal is enabled, and the gesture value is small than the scrollable offset, |
| 131 | ++ * then we exit the method and reset gesture value. |
| 132 | ++ */ |
| 133 | ++ if(this.scrollableGestureRef.current && |
| 134 | ++ // @ts-ignore |
| 135 | ++ this.props.gesture._value < Math.abs(this.props.gesture._offset) |
| 136 | ++ ) { |
| 137 | ++ this.props.gesture.setValue(0); |
| 138 | ++ this.props.gesture.setOffset(0); |
| 139 | ++ return; |
| 140 | ++ } |
92 | 141 | + |
93 | 142 | let distance; |
94 | 143 | let translation; |
95 | 144 | let velocity; |
96 | | -@@ -303,8 +309,16 @@ export default class Card extends React.Component<Props> { |
97 | | - gestureDirection === 'vertical-inverted' |
98 | | - ) { |
99 | | - distance = layout.height; |
100 | | -- translation = nativeEvent.translationY; |
101 | | -- velocity = nativeEvent.velocityY; |
102 | | -+ // @ts-ignore |
103 | | -+ if(this.props.gesture._offset < 0) { |
104 | | -+ // @ts-ignore |
105 | | -+ translation = this.props.gesture._offset - this.props.gesture._value; |
106 | | -+ velocity = nativeEvent.velocityY / 2; |
107 | | -+ }else{ |
108 | | -+ // @ts-ignore |
109 | | -+ translation = this.props.gesture._value; |
110 | | -+ velocity = nativeEvent.velocityY; |
111 | | -+ } |
112 | | - } else { |
113 | | - distance = layout.width; |
114 | | - translation = nativeEvent.translationX; |
115 | | -@@ -392,7 +406,7 @@ export default class Card extends React.Component<Props> { |
| 145 | +@@ -392,7 +410,7 @@ export default class Card extends React.Component<Props> { |
116 | 146 | return { |
117 | 147 | maxDeltaX: 15, |
118 | 148 | minOffsetY: 5, |
119 | 149 | - hitSlop: { bottom: -layout.height + distance }, |
120 | | -+ // hitSlop: { bottom: -layout.height + distance }, |
| 150 | ++ hitSlop: this.scrollableGestureRef.current ? {} : { bottom: -layout.height + distance }, |
121 | 151 | enableTrackpadTwoFingerGesture, |
122 | 152 | }; |
123 | 153 | } else if (gestureDirection === 'vertical-inverted') { |
124 | | -@@ -425,6 +439,7 @@ export default class Card extends React.Component<Props> { |
125 | | - } |
126 | | - |
127 | | - private contentRef = React.createRef<View>(); |
128 | | -+ private scrollableGestureRef = React.createRef<any>(); |
| 154 | +@@ -448,6 +466,11 @@ export default class Card extends React.Component<Props> { |
| 155 | + ...rest |
| 156 | + } = this.props; |
129 | 157 |
|
130 | | - render() { |
131 | | - const { |
132 | | -@@ -526,10 +541,12 @@ export default class Card extends React.Component<Props> { |
| 158 | ++ const modalGestureValue = { |
| 159 | ++ scrollableGestureRef: this.scrollableGestureRef, |
| 160 | ++ modalTranslateY: gesture |
| 161 | ++ } |
| 162 | ++ |
| 163 | + const interpolationProps = this.getCardAnimation( |
| 164 | + interpolationIndex, |
| 165 | + current, |
| 166 | +@@ -526,43 +549,49 @@ export default class Card extends React.Component<Props> { |
133 | 167 | style={[styles.container, containerStyle, customContainerStyle]} |
134 | 168 | pointerEvents="box-none" |
135 | 169 | > |
136 | | -+ <CardModalGestureContextProvider enable={!next && getIsModalPresentation(styleInterpolator)} value={{ scrollableGestureRef: this.scrollableGestureRef, cardModalTranslateY: gesture }}> |
137 | | - <PanGestureHandler |
138 | | - enabled={layout.width !== 0 && gestureEnabled} |
139 | | - onGestureEvent={handleGestureEvent} |
140 | | - onHandlerStateChange={this.handleGestureStateChange} |
141 | | -+ simultaneousHandlers={this.scrollableGestureRef} |
142 | | - {...this.gestureActivationCriteria()} |
| 170 | +- <PanGestureHandler |
| 171 | +- enabled={layout.width !== 0 && gestureEnabled} |
| 172 | +- onGestureEvent={handleGestureEvent} |
| 173 | +- onHandlerStateChange={this.handleGestureStateChange} |
| 174 | +- {...this.gestureActivationCriteria()} |
| 175 | ++ <ModalGestureProvider |
| 176 | ++ enabled={!next && getIsModalPresentation(styleInterpolator)} |
| 177 | ++ value={modalGestureValue} |
143 | 178 | > |
144 | | - <Animated.View |
145 | | -@@ -563,6 +580,7 @@ export default class Card extends React.Component<Props> { |
146 | | - </CardSheet> |
147 | | - </Animated.View> |
148 | | - </PanGestureHandler> |
149 | | -+ </CardModalGestureContextProvider> |
| 179 | +- <Animated.View |
| 180 | +- needsOffscreenAlphaCompositing={hasOpacityStyle(cardStyle)} |
| 181 | +- style={[styles.container, cardStyle]} |
| 182 | ++ <PanGestureHandler |
| 183 | ++ enabled={layout.width !== 0 && gestureEnabled} |
| 184 | ++ onGestureEvent={handleGestureEvent} |
| 185 | ++ onHandlerStateChange={this.handleGestureStateChange} |
| 186 | ++ simultaneousHandlers={this.scrollableGestureRef} |
| 187 | ++ {...this.gestureActivationCriteria()} |
| 188 | + > |
| 189 | +- {shadowEnabled && shadowStyle && !isTransparent ? ( |
| 190 | +- <Animated.View |
| 191 | +- style={[ |
| 192 | +- styles.shadow, |
| 193 | +- gestureDirection === 'horizontal' |
| 194 | +- ? [styles.shadowHorizontal, styles.shadowLeft] |
| 195 | +- : gestureDirection === 'horizontal-inverted' |
| 196 | +- ? [styles.shadowHorizontal, styles.shadowRight] |
| 197 | +- : gestureDirection === 'vertical' |
| 198 | +- ? [styles.shadowVertical, styles.shadowTop] |
| 199 | +- : [styles.shadowVertical, styles.shadowBottom], |
| 200 | +- { backgroundColor }, |
| 201 | +- shadowStyle, |
| 202 | +- ]} |
| 203 | +- pointerEvents="none" |
| 204 | +- /> |
| 205 | +- ) : null} |
| 206 | +- <CardSheet |
| 207 | +- ref={this.contentRef} |
| 208 | +- enabled={pageOverflowEnabled} |
| 209 | +- layout={layout} |
| 210 | +- style={contentStyle} |
| 211 | ++ <Animated.View |
| 212 | ++ needsOffscreenAlphaCompositing={hasOpacityStyle(cardStyle)} |
| 213 | ++ style={[styles.container, cardStyle]} |
| 214 | + > |
| 215 | +- {children} |
| 216 | +- </CardSheet> |
| 217 | +- </Animated.View> |
| 218 | +- </PanGestureHandler> |
| 219 | ++ {shadowEnabled && shadowStyle && !isTransparent ? ( |
| 220 | ++ <Animated.View |
| 221 | ++ style={[ |
| 222 | ++ styles.shadow, |
| 223 | ++ gestureDirection === 'horizontal' |
| 224 | ++ ? [styles.shadowHorizontal, styles.shadowLeft] |
| 225 | ++ : gestureDirection === 'horizontal-inverted' |
| 226 | ++ ? [styles.shadowHorizontal, styles.shadowRight] |
| 227 | ++ : gestureDirection === 'vertical' |
| 228 | ++ ? [styles.shadowVertical, styles.shadowTop] |
| 229 | ++ : [styles.shadowVertical, styles.shadowBottom], |
| 230 | ++ { backgroundColor }, |
| 231 | ++ shadowStyle, |
| 232 | ++ ]} |
| 233 | ++ pointerEvents="none" |
| 234 | ++ /> |
| 235 | ++ ) : null} |
| 236 | ++ <CardSheet |
| 237 | ++ ref={this.contentRef} |
| 238 | ++ enabled={pageOverflowEnabled} |
| 239 | ++ layout={layout} |
| 240 | ++ style={contentStyle} |
| 241 | ++ > |
| 242 | ++ {children} |
| 243 | ++ </CardSheet> |
| 244 | ++ </Animated.View> |
| 245 | ++ </PanGestureHandler> |
| 246 | ++ </ModalGestureProvider> |
150 | 247 | </Animated.View> |
151 | 248 | </View> |
152 | 249 | </CardAnimationContext.Provider> |
0 commit comments