@react-navigation/stack 7.0.13 → 7.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,19 +18,6 @@ var _jsxRuntime = require("react/jsx-runtime");
18
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
19
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
22
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
23
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
24
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
25
- function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
26
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
27
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
28
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
29
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
30
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
31
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
32
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
33
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
34
21
  const GESTURE_VELOCITY_IMPACT = 0.3;
35
22
  const TRUE = 1;
36
23
  const FALSE = 0;
@@ -48,432 +35,414 @@ const hasOpacityStyle = style => {
48
35
  }
49
36
  return false;
50
37
  };
51
- let Card = exports.Card = /*#__PURE__*/function (_React$Component) {
52
- function Card(...args) {
53
- var _this;
54
- _classCallCheck(this, Card);
55
- _this = _callSuper(this, Card, [...args]);
56
- _defineProperty(_this, "isCurrentlyMounted", false);
57
- _defineProperty(_this, "isClosing", new _reactNative.Animated.Value(FALSE));
58
- _defineProperty(_this, "inverted", new _reactNative.Animated.Value((0, _getInvertedMultiplier.getInvertedMultiplier)(_this.props.gestureDirection, _this.props.direction === 'rtl')));
59
- _defineProperty(_this, "layout", {
60
- width: new _reactNative.Animated.Value(_this.props.layout.width),
61
- height: new _reactNative.Animated.Value(_this.props.layout.height)
62
- });
63
- _defineProperty(_this, "isSwiping", new _reactNative.Animated.Value(FALSE));
64
- _defineProperty(_this, "interactionHandle", void 0);
65
- _defineProperty(_this, "pendingGestureCallback", void 0);
66
- _defineProperty(_this, "lastToValue", void 0);
67
- _defineProperty(_this, "animate", ({
68
- closing,
69
- velocity
70
- }) => {
71
- const {
72
- transitionSpec,
73
- onOpen,
74
- onClose,
75
- onTransition,
76
- gesture
77
- } = _this.props;
78
- const toValue = _this.getAnimateToValue({
79
- ..._this.props,
80
- closing
38
+ class Card extends React.Component {
39
+ static defaultProps = {
40
+ shadowEnabled: false,
41
+ gestureEnabled: true,
42
+ gestureVelocityImpact: GESTURE_VELOCITY_IMPACT,
43
+ overlay: ({
44
+ style
45
+ }) => style ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
46
+ pointerEvents: "none",
47
+ style: [styles.overlay, style]
48
+ }) : null
49
+ };
50
+ componentDidMount() {
51
+ if (!this.props.preloaded) {
52
+ this.animate({
53
+ closing: this.props.closing
81
54
  });
82
- _this.lastToValue = toValue;
83
- _this.isClosing.setValue(closing ? TRUE : FALSE);
84
- const spec = closing ? transitionSpec.close : transitionSpec.open;
85
- const animation = spec.animation === 'spring' ? _reactNative.Animated.spring : _reactNative.Animated.timing;
86
- _this.setPointerEventsEnabled(!closing);
87
- _this.handleStartInteraction();
88
- clearTimeout(_this.pendingGestureCallback);
89
- onTransition?.({
90
- closing,
91
- gesture: velocity !== undefined
55
+ }
56
+ this.isCurrentlyMounted = true;
57
+ }
58
+ componentDidUpdate(prevProps) {
59
+ const {
60
+ gesture,
61
+ direction,
62
+ layout,
63
+ gestureDirection,
64
+ opening,
65
+ closing
66
+ } = this.props;
67
+ const {
68
+ width,
69
+ height
70
+ } = layout;
71
+ if (width !== prevProps.layout.width) {
72
+ this.layout.width.setValue(width);
73
+ }
74
+ if (height !== prevProps.layout.height) {
75
+ this.layout.height.setValue(height);
76
+ }
77
+ if (gestureDirection !== prevProps.gestureDirection) {
78
+ this.inverted.setValue((0, _getInvertedMultiplier.getInvertedMultiplier)(gestureDirection, direction === 'rtl'));
79
+ }
80
+ const toValue = this.getAnimateToValue(this.props);
81
+ if (this.getAnimateToValue(prevProps) !== toValue || this.lastToValue !== toValue) {
82
+ // We need to trigger the animation when route was closed
83
+ // The route might have been closed by a `POP` action or by a gesture
84
+ // When route was closed due to a gesture, the animation would've happened already
85
+ // It's still important to trigger the animation so that `onClose` is called
86
+ // If `onClose` is not called, cleanup step won't be performed for gestures
87
+ this.animate({
88
+ closing
92
89
  });
93
- animation(gesture, {
94
- ...spec.config,
95
- velocity,
96
- toValue,
97
- useNativeDriver,
98
- isInteraction: false
99
- }).start(({
100
- finished
101
- }) => {
102
- _this.handleEndInteraction();
103
- clearTimeout(_this.pendingGestureCallback);
104
- if (finished) {
105
- if (closing) {
106
- onClose();
107
- } else {
108
- onOpen();
109
- }
110
- if (_this.isCurrentlyMounted) {
111
- // Make sure to re-open screen if it wasn't removed
112
- _this.forceUpdate();
113
- }
114
- }
90
+ } else if (opening && !prevProps.opening) {
91
+ // This can happen when screen somewhere below in the stack comes into focus via rearranging
92
+ // Also reset the animated value to make sure that the animation starts from the beginning
93
+ gesture.setValue((0, _getDistanceForDirection.getDistanceForDirection)(layout, gestureDirection, direction === 'rtl'));
94
+ this.animate({
95
+ closing
115
96
  });
97
+ }
98
+ }
99
+ componentWillUnmount() {
100
+ this.props.gesture?.stopAnimation();
101
+ this.isCurrentlyMounted = false;
102
+ this.handleEndInteraction();
103
+ }
104
+ isCurrentlyMounted = false;
105
+ isClosing = new _reactNative.Animated.Value(FALSE);
106
+ inverted = new _reactNative.Animated.Value((0, _getInvertedMultiplier.getInvertedMultiplier)(this.props.gestureDirection, this.props.direction === 'rtl'));
107
+ layout = {
108
+ width: new _reactNative.Animated.Value(this.props.layout.width),
109
+ height: new _reactNative.Animated.Value(this.props.layout.height)
110
+ };
111
+ isSwiping = new _reactNative.Animated.Value(FALSE);
112
+ animate = ({
113
+ closing,
114
+ velocity
115
+ }) => {
116
+ const {
117
+ transitionSpec,
118
+ onOpen,
119
+ onClose,
120
+ onTransition,
121
+ gesture
122
+ } = this.props;
123
+ const toValue = this.getAnimateToValue({
124
+ ...this.props,
125
+ closing
116
126
  });
117
- _defineProperty(_this, "getAnimateToValue", ({
127
+ this.lastToValue = toValue;
128
+ this.isClosing.setValue(closing ? TRUE : FALSE);
129
+ const spec = closing ? transitionSpec.close : transitionSpec.open;
130
+ const animation = spec.animation === 'spring' ? _reactNative.Animated.spring : _reactNative.Animated.timing;
131
+ this.setPointerEventsEnabled(!closing);
132
+ this.handleStartInteraction();
133
+ clearTimeout(this.pendingGestureCallback);
134
+ onTransition?.({
118
135
  closing,
119
- layout,
120
- gestureDirection,
121
- direction,
122
- preloaded
123
- }) => {
124
- if (!closing && !preloaded) {
125
- return 0;
126
- }
127
- return (0, _getDistanceForDirection.getDistanceForDirection)(layout, gestureDirection, direction === 'rtl');
136
+ gesture: velocity !== undefined
128
137
  });
129
- _defineProperty(_this, "setPointerEventsEnabled", enabled => {
130
- const pointerEvents = enabled ? 'box-none' : 'none';
131
- _this.ref.current?.setPointerEvents(pointerEvents);
132
- });
133
- _defineProperty(_this, "handleStartInteraction", () => {
134
- if (_this.interactionHandle === undefined) {
135
- _this.interactionHandle = _reactNative.InteractionManager.createInteractionHandle();
136
- }
137
- });
138
- _defineProperty(_this, "handleEndInteraction", () => {
139
- if (_this.interactionHandle !== undefined) {
140
- _reactNative.InteractionManager.clearInteractionHandle(_this.interactionHandle);
141
- _this.interactionHandle = undefined;
138
+ animation(gesture, {
139
+ ...spec.config,
140
+ velocity,
141
+ toValue,
142
+ useNativeDriver,
143
+ isInteraction: false
144
+ }).start(({
145
+ finished
146
+ }) => {
147
+ this.handleEndInteraction();
148
+ clearTimeout(this.pendingGestureCallback);
149
+ if (finished) {
150
+ if (closing) {
151
+ onClose();
152
+ } else {
153
+ onOpen();
154
+ }
155
+ if (this.isCurrentlyMounted) {
156
+ // Make sure to re-open screen if it wasn't removed
157
+ this.forceUpdate();
158
+ }
142
159
  }
143
160
  });
144
- _defineProperty(_this, "handleGestureStateChange", ({
145
- nativeEvent
146
- }) => {
147
- const {
148
- direction,
149
- layout,
150
- onClose,
151
- onGestureBegin,
152
- onGestureCanceled,
153
- onGestureEnd,
154
- gestureDirection,
155
- gestureVelocityImpact
156
- } = _this.props;
157
- switch (nativeEvent.state) {
158
- case _GestureHandler.GestureState.ACTIVE:
159
- _this.isSwiping.setValue(TRUE);
160
- _this.handleStartInteraction();
161
- onGestureBegin?.();
161
+ };
162
+ getAnimateToValue = ({
163
+ closing,
164
+ layout,
165
+ gestureDirection,
166
+ direction,
167
+ preloaded
168
+ }) => {
169
+ if (!closing && !preloaded) {
170
+ return 0;
171
+ }
172
+ return (0, _getDistanceForDirection.getDistanceForDirection)(layout, gestureDirection, direction === 'rtl');
173
+ };
174
+ setPointerEventsEnabled = enabled => {
175
+ const pointerEvents = enabled ? 'box-none' : 'none';
176
+ this.ref.current?.setPointerEvents(pointerEvents);
177
+ };
178
+ handleStartInteraction = () => {
179
+ if (this.interactionHandle === undefined) {
180
+ this.interactionHandle = _reactNative.InteractionManager.createInteractionHandle();
181
+ }
182
+ };
183
+ handleEndInteraction = () => {
184
+ if (this.interactionHandle !== undefined) {
185
+ _reactNative.InteractionManager.clearInteractionHandle(this.interactionHandle);
186
+ this.interactionHandle = undefined;
187
+ }
188
+ };
189
+ handleGestureStateChange = ({
190
+ nativeEvent
191
+ }) => {
192
+ const {
193
+ direction,
194
+ layout,
195
+ onClose,
196
+ onGestureBegin,
197
+ onGestureCanceled,
198
+ onGestureEnd,
199
+ gestureDirection,
200
+ gestureVelocityImpact
201
+ } = this.props;
202
+ switch (nativeEvent.state) {
203
+ case _GestureHandler.GestureState.ACTIVE:
204
+ this.isSwiping.setValue(TRUE);
205
+ this.handleStartInteraction();
206
+ onGestureBegin?.();
207
+ break;
208
+ case _GestureHandler.GestureState.CANCELLED:
209
+ case _GestureHandler.GestureState.FAILED:
210
+ {
211
+ this.isSwiping.setValue(FALSE);
212
+ this.handleEndInteraction();
213
+ const velocity = gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted' ? nativeEvent.velocityY : nativeEvent.velocityX;
214
+ this.animate({
215
+ closing: this.props.closing,
216
+ velocity
217
+ });
218
+ onGestureCanceled?.();
162
219
  break;
163
- case _GestureHandler.GestureState.CANCELLED:
164
- case _GestureHandler.GestureState.FAILED:
165
- {
166
- _this.isSwiping.setValue(FALSE);
167
- _this.handleEndInteraction();
168
- const velocity = gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted' ? nativeEvent.velocityY : nativeEvent.velocityX;
169
- _this.animate({
170
- closing: _this.props.closing,
171
- velocity
172
- });
173
- onGestureCanceled?.();
174
- break;
220
+ }
221
+ case _GestureHandler.GestureState.END:
222
+ {
223
+ this.isSwiping.setValue(FALSE);
224
+ let distance;
225
+ let translation;
226
+ let velocity;
227
+ if (gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted') {
228
+ distance = layout.height;
229
+ translation = nativeEvent.translationY;
230
+ velocity = nativeEvent.velocityY;
231
+ } else {
232
+ distance = layout.width;
233
+ translation = nativeEvent.translationX;
234
+ velocity = nativeEvent.velocityX;
175
235
  }
176
- case _GestureHandler.GestureState.END:
177
- {
178
- _this.isSwiping.setValue(FALSE);
179
- let distance;
180
- let translation;
181
- let velocity;
182
- if (gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted') {
183
- distance = layout.height;
184
- translation = nativeEvent.translationY;
185
- velocity = nativeEvent.velocityY;
186
- } else {
187
- distance = layout.width;
188
- translation = nativeEvent.translationX;
189
- velocity = nativeEvent.velocityX;
190
- }
191
- const closing = (translation + velocity * gestureVelocityImpact) * (0, _getInvertedMultiplier.getInvertedMultiplier)(gestureDirection, direction === 'rtl') > distance / 2 ? velocity !== 0 || translation !== 0 : _this.props.closing;
192
- _this.animate({
193
- closing,
194
- velocity
195
- });
196
- if (closing) {
197
- // We call onClose with a delay to make sure that the animation has already started
198
- // This will make sure that the state update caused by this doesn't affect start of animation
199
- _this.pendingGestureCallback = setTimeout(() => {
200
- onClose();
236
+ const closing = (translation + velocity * gestureVelocityImpact) * (0, _getInvertedMultiplier.getInvertedMultiplier)(gestureDirection, direction === 'rtl') > distance / 2 ? velocity !== 0 || translation !== 0 : this.props.closing;
237
+ this.animate({
238
+ closing,
239
+ velocity
240
+ });
241
+ if (closing) {
242
+ // We call onClose with a delay to make sure that the animation has already started
243
+ // This will make sure that the state update caused by this doesn't affect start of animation
244
+ this.pendingGestureCallback = setTimeout(() => {
245
+ onClose();
201
246
 
202
- // Trigger an update after we dispatch the action to remove the screen
203
- // This will make sure that we check if the screen didn't get removed so we can cancel the animation
204
- _this.forceUpdate();
205
- }, 32);
206
- }
207
- onGestureEnd?.();
208
- break;
247
+ // Trigger an update after we dispatch the action to remove the screen
248
+ // This will make sure that we check if the screen didn't get removed so we can cancel the animation
249
+ this.forceUpdate();
250
+ }, 32);
209
251
  }
210
- }
211
- });
212
- // Memoize this to avoid extra work on re-render
213
- _defineProperty(_this, "getInterpolatedStyle", (0, _memoize.memoize)((styleInterpolator, animation) => styleInterpolator(animation)));
214
- // Keep track of the animation context when deps changes.
215
- _defineProperty(_this, "getCardAnimation", (0, _memoize.memoize)((interpolationIndex, current, next, layout, insetTop, insetRight, insetBottom, insetLeft) => ({
216
- index: interpolationIndex,
217
- current: {
218
- progress: current
219
- },
220
- next: next && {
221
- progress: next
222
- },
223
- closing: _this.isClosing,
224
- swiping: _this.isSwiping,
225
- inverted: _this.inverted,
226
- layouts: {
227
- screen: layout
228
- },
229
- insets: {
230
- top: insetTop,
231
- right: insetRight,
232
- bottom: insetBottom,
233
- left: insetLeft
234
- }
235
- })));
236
- _defineProperty(_this, "ref", /*#__PURE__*/React.createRef());
237
- return _this;
238
- }
239
- _inherits(Card, _React$Component);
240
- return _createClass(Card, [{
241
- key: "componentDidMount",
242
- value: function componentDidMount() {
243
- if (!this.props.preloaded) {
244
- this.animate({
245
- closing: this.props.closing
246
- });
247
- }
248
- this.isCurrentlyMounted = true;
249
- }
250
- }, {
251
- key: "componentDidUpdate",
252
- value: function componentDidUpdate(prevProps) {
253
- const {
254
- gesture,
255
- direction,
256
- layout,
257
- gestureDirection,
258
- opening,
259
- closing
260
- } = this.props;
261
- const {
262
- width,
263
- height
264
- } = layout;
265
- if (width !== prevProps.layout.width) {
266
- this.layout.width.setValue(width);
267
- }
268
- if (height !== prevProps.layout.height) {
269
- this.layout.height.setValue(height);
270
- }
271
- if (gestureDirection !== prevProps.gestureDirection) {
272
- this.inverted.setValue((0, _getInvertedMultiplier.getInvertedMultiplier)(gestureDirection, direction === 'rtl'));
273
- }
274
- const toValue = this.getAnimateToValue(this.props);
275
- if (this.getAnimateToValue(prevProps) !== toValue || this.lastToValue !== toValue) {
276
- // We need to trigger the animation when route was closed
277
- // The route might have been closed by a `POP` action or by a gesture
278
- // When route was closed due to a gesture, the animation would've happened already
279
- // It's still important to trigger the animation so that `onClose` is called
280
- // If `onClose` is not called, cleanup step won't be performed for gestures
281
- this.animate({
282
- closing
283
- });
284
- } else if (opening && !prevProps.opening) {
285
- // This can happen when screen somewhere below in the stack comes into focus via rearranging
286
- // Also reset the animated value to make sure that the animation starts from the beginning
287
- gesture.setValue((0, _getDistanceForDirection.getDistanceForDirection)(layout, gestureDirection, direction === 'rtl'));
288
- this.animate({
289
- closing
290
- });
291
- }
252
+ onGestureEnd?.();
253
+ break;
254
+ }
292
255
  }
293
- }, {
294
- key: "componentWillUnmount",
295
- value: function componentWillUnmount() {
296
- this.props.gesture?.stopAnimation();
297
- this.isCurrentlyMounted = false;
298
- this.handleEndInteraction();
256
+ };
257
+
258
+ // Memoize this to avoid extra work on re-render
259
+ getInterpolatedStyle = (0, _memoize.memoize)((styleInterpolator, animation) => styleInterpolator(animation));
260
+
261
+ // Keep track of the animation context when deps changes.
262
+ getCardAnimation = (0, _memoize.memoize)((interpolationIndex, current, next, layout, insetTop, insetRight, insetBottom, insetLeft) => ({
263
+ index: interpolationIndex,
264
+ current: {
265
+ progress: current
266
+ },
267
+ next: next && {
268
+ progress: next
269
+ },
270
+ closing: this.isClosing,
271
+ swiping: this.isSwiping,
272
+ inverted: this.inverted,
273
+ layouts: {
274
+ screen: layout
275
+ },
276
+ insets: {
277
+ top: insetTop,
278
+ right: insetRight,
279
+ bottom: insetBottom,
280
+ left: insetLeft
299
281
  }
300
- }, {
301
- key: "gestureActivationCriteria",
302
- value: function gestureActivationCriteria() {
303
- const {
304
- direction,
305
- layout,
306
- gestureDirection,
307
- gestureResponseDistance
308
- } = this.props;
309
- const enableTrackpadTwoFingerGesture = true;
310
- const distance = gestureResponseDistance !== undefined ? gestureResponseDistance : gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted' ? GESTURE_RESPONSE_DISTANCE_VERTICAL : GESTURE_RESPONSE_DISTANCE_HORIZONTAL;
311
- if (gestureDirection === 'vertical') {
282
+ }));
283
+ gestureActivationCriteria() {
284
+ const {
285
+ direction,
286
+ layout,
287
+ gestureDirection,
288
+ gestureResponseDistance
289
+ } = this.props;
290
+ const enableTrackpadTwoFingerGesture = true;
291
+ const distance = gestureResponseDistance !== undefined ? gestureResponseDistance : gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted' ? GESTURE_RESPONSE_DISTANCE_VERTICAL : GESTURE_RESPONSE_DISTANCE_HORIZONTAL;
292
+ if (gestureDirection === 'vertical') {
293
+ return {
294
+ maxDeltaX: 15,
295
+ minOffsetY: 5,
296
+ hitSlop: {
297
+ bottom: -layout.height + distance
298
+ },
299
+ enableTrackpadTwoFingerGesture
300
+ };
301
+ } else if (gestureDirection === 'vertical-inverted') {
302
+ return {
303
+ maxDeltaX: 15,
304
+ minOffsetY: -5,
305
+ hitSlop: {
306
+ top: -layout.height + distance
307
+ },
308
+ enableTrackpadTwoFingerGesture
309
+ };
310
+ } else {
311
+ const hitSlop = -layout.width + distance;
312
+ const invertedMultiplier = (0, _getInvertedMultiplier.getInvertedMultiplier)(gestureDirection, direction === 'rtl');
313
+ if (invertedMultiplier === 1) {
312
314
  return {
313
- maxDeltaX: 15,
314
- minOffsetY: 5,
315
+ minOffsetX: 5,
316
+ maxDeltaY: 20,
315
317
  hitSlop: {
316
- bottom: -layout.height + distance
318
+ right: hitSlop
317
319
  },
318
320
  enableTrackpadTwoFingerGesture
319
321
  };
320
- } else if (gestureDirection === 'vertical-inverted') {
322
+ } else {
321
323
  return {
322
- maxDeltaX: 15,
323
- minOffsetY: -5,
324
+ minOffsetX: -5,
325
+ maxDeltaY: 20,
324
326
  hitSlop: {
325
- top: -layout.height + distance
327
+ left: hitSlop
326
328
  },
327
329
  enableTrackpadTwoFingerGesture
328
330
  };
329
- } else {
330
- const hitSlop = -layout.width + distance;
331
- const invertedMultiplier = (0, _getInvertedMultiplier.getInvertedMultiplier)(gestureDirection, direction === 'rtl');
332
- if (invertedMultiplier === 1) {
333
- return {
334
- minOffsetX: 5,
335
- maxDeltaY: 20,
336
- hitSlop: {
337
- right: hitSlop
338
- },
339
- enableTrackpadTwoFingerGesture
340
- };
341
- } else {
342
- return {
343
- minOffsetX: -5,
344
- maxDeltaY: 20,
345
- hitSlop: {
346
- left: hitSlop
347
- },
348
- enableTrackpadTwoFingerGesture
349
- };
350
- }
351
331
  }
352
332
  }
353
- }, {
354
- key: "render",
355
- value: function render() {
356
- const {
357
- styleInterpolator,
358
- interpolationIndex,
359
- current,
360
- gesture,
361
- next,
362
- layout,
363
- insets,
364
- overlay,
365
- overlayEnabled,
366
- shadowEnabled,
367
- gestureEnabled,
368
- gestureDirection,
369
- pageOverflowEnabled,
370
- children,
371
- containerStyle: customContainerStyle,
372
- contentStyle,
373
- /* eslint-disable @typescript-eslint/no-unused-vars */
374
- closing,
375
- direction,
376
- gestureResponseDistance,
377
- gestureVelocityImpact,
378
- onClose,
379
- onGestureBegin,
380
- onGestureCanceled,
381
- onGestureEnd,
382
- onOpen,
383
- onTransition,
384
- transitionSpec,
385
- /* eslint-enable @typescript-eslint/no-unused-vars */
386
- ...rest
387
- } = this.props;
388
- const interpolationProps = this.getCardAnimation(interpolationIndex, current, next, layout, insets.top, insets.right, insets.bottom, insets.left);
389
- const interpolatedStyle = this.getInterpolatedStyle(styleInterpolator, interpolationProps);
390
- const {
391
- containerStyle,
392
- cardStyle,
393
- overlayStyle,
394
- shadowStyle
395
- } = interpolatedStyle;
396
- const handleGestureEvent = gestureEnabled ? _reactNative.Animated.event([{
397
- nativeEvent: gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted' ? {
398
- translationY: gesture
399
- } : {
400
- translationX: gesture
333
+ }
334
+ ref = /*#__PURE__*/React.createRef();
335
+ render() {
336
+ const {
337
+ styleInterpolator,
338
+ interpolationIndex,
339
+ current,
340
+ gesture,
341
+ next,
342
+ layout,
343
+ insets,
344
+ overlay,
345
+ overlayEnabled,
346
+ shadowEnabled,
347
+ gestureEnabled,
348
+ gestureDirection,
349
+ pageOverflowEnabled,
350
+ children,
351
+ containerStyle: customContainerStyle,
352
+ contentStyle,
353
+ /* eslint-disable @typescript-eslint/no-unused-vars */
354
+ closing,
355
+ direction,
356
+ gestureResponseDistance,
357
+ gestureVelocityImpact,
358
+ onClose,
359
+ onGestureBegin,
360
+ onGestureCanceled,
361
+ onGestureEnd,
362
+ onOpen,
363
+ onTransition,
364
+ transitionSpec,
365
+ /* eslint-enable @typescript-eslint/no-unused-vars */
366
+ ...rest
367
+ } = this.props;
368
+ const interpolationProps = this.getCardAnimation(interpolationIndex, current, next, layout, insets.top, insets.right, insets.bottom, insets.left);
369
+ const interpolatedStyle = this.getInterpolatedStyle(styleInterpolator, interpolationProps);
370
+ const {
371
+ containerStyle,
372
+ cardStyle,
373
+ overlayStyle,
374
+ shadowStyle
375
+ } = interpolatedStyle;
376
+ const handleGestureEvent = gestureEnabled ? _reactNative.Animated.event([{
377
+ nativeEvent: gestureDirection === 'vertical' || gestureDirection === 'vertical-inverted' ? {
378
+ translationY: gesture
379
+ } : {
380
+ translationX: gesture
381
+ }
382
+ }], {
383
+ useNativeDriver
384
+ }) : undefined;
385
+ const {
386
+ backgroundColor
387
+ } = _reactNative.StyleSheet.flatten(contentStyle || {});
388
+ const isTransparent = typeof backgroundColor === 'string' ? (0, _color.default)(backgroundColor).alpha() === 0 : false;
389
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CardAnimationContext.CardAnimationContext.Provider, {
390
+ value: interpolationProps,
391
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
392
+ style: {
393
+ // This is a dummy style that doesn't actually change anything visually.
394
+ // Animated needs the animated value to be used somewhere, otherwise things don't update properly.
395
+ // If we disable animations and hide header, it could end up making the value unused.
396
+ // So we have this dummy style that will always be used regardless of what else changed.
397
+ opacity: current
401
398
  }
402
- }], {
403
- useNativeDriver
404
- }) : undefined;
405
- const {
406
- backgroundColor
407
- } = _reactNative.StyleSheet.flatten(contentStyle || {});
408
- const isTransparent = typeof backgroundColor === 'string' ? (0, _color.default)(backgroundColor).alpha() === 0 : false;
409
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CardAnimationContext.CardAnimationContext.Provider, {
410
- value: interpolationProps,
411
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
412
- style: {
413
- // This is a dummy style that doesn't actually change anything visually.
414
- // Animated needs the animated value to be used somewhere, otherwise things don't update properly.
415
- // If we disable animations and hide header, it could end up making the value unused.
416
- // So we have this dummy style that will always be used regardless of what else changed.
417
- opacity: current
418
- }
419
- // Make sure that this view isn't removed. If this view is removed, our style with animated value won't apply
420
- ,
421
- collapsable: false
422
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
423
- pointerEvents: "box-none"
424
- // Make sure this view is not removed on the new architecture, as it causes focus loss during navigation on Android.
425
- // This can happen when the view flattening results in different trees - due to `overflow` style changing in a parent.
426
- ,
427
- collapsable: false,
428
- ...rest,
429
- children: [overlayEnabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
430
- pointerEvents: "box-none",
431
- style: _reactNative.StyleSheet.absoluteFill,
432
- children: overlay({
433
- style: overlayStyle
434
- })
435
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
436
- style: [styles.container, containerStyle, customContainerStyle],
437
- pointerEvents: "box-none",
438
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GestureHandler.PanGestureHandler, {
439
- enabled: layout.width !== 0 && gestureEnabled,
440
- onGestureEvent: handleGestureEvent,
441
- onHandlerStateChange: this.handleGestureStateChange,
442
- ...this.gestureActivationCriteria(),
443
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
444
- needsOffscreenAlphaCompositing: hasOpacityStyle(cardStyle),
445
- style: [styles.container, cardStyle],
446
- children: [shadowEnabled && shadowStyle && !isTransparent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
447
- style: [styles.shadow, gestureDirection === 'horizontal' ? [styles.shadowHorizontal, styles.shadowStart] : gestureDirection === 'horizontal-inverted' ? [styles.shadowHorizontal, styles.shadowEnd] : gestureDirection === 'vertical' ? [styles.shadowVertical, styles.shadowTop] : [styles.shadowVertical, styles.shadowBottom], {
448
- backgroundColor
449
- }, shadowStyle],
450
- pointerEvents: "none"
451
- }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardSheet.CardSheet, {
452
- ref: this.ref,
453
- enabled: pageOverflowEnabled,
454
- layout: layout,
455
- style: contentStyle,
456
- children: children
457
- })]
458
- })
399
+ // Make sure that this view isn't removed. If this view is removed, our style with animated value won't apply
400
+ ,
401
+ collapsable: false
402
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
403
+ pointerEvents: "box-none"
404
+ // Make sure this view is not removed on the new architecture, as it causes focus loss during navigation on Android.
405
+ // This can happen when the view flattening results in different trees - due to `overflow` style changing in a parent.
406
+ ,
407
+ collapsable: false,
408
+ ...rest,
409
+ children: [overlayEnabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
410
+ pointerEvents: "box-none",
411
+ style: _reactNative.StyleSheet.absoluteFill,
412
+ children: overlay({
413
+ style: overlayStyle
414
+ })
415
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
416
+ style: [styles.container, containerStyle, customContainerStyle],
417
+ pointerEvents: "box-none",
418
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_GestureHandler.PanGestureHandler, {
419
+ enabled: layout.width !== 0 && gestureEnabled,
420
+ onGestureEvent: handleGestureEvent,
421
+ onHandlerStateChange: this.handleGestureStateChange,
422
+ ...this.gestureActivationCriteria(),
423
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
424
+ needsOffscreenAlphaCompositing: hasOpacityStyle(cardStyle),
425
+ style: [styles.container, cardStyle],
426
+ children: [shadowEnabled && shadowStyle && !isTransparent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
427
+ style: [styles.shadow, gestureDirection === 'horizontal' ? [styles.shadowHorizontal, styles.shadowStart] : gestureDirection === 'horizontal-inverted' ? [styles.shadowHorizontal, styles.shadowEnd] : gestureDirection === 'vertical' ? [styles.shadowVertical, styles.shadowTop] : [styles.shadowVertical, styles.shadowBottom], {
428
+ backgroundColor
429
+ }, shadowStyle],
430
+ pointerEvents: "none"
431
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardSheet.CardSheet, {
432
+ ref: this.ref,
433
+ enabled: pageOverflowEnabled,
434
+ layout: layout,
435
+ style: contentStyle,
436
+ children: children
437
+ })]
459
438
  })
460
- })]
439
+ })
461
440
  })]
462
- });
463
- }
464
- }]);
465
- }(React.Component);
466
- _defineProperty(Card, "defaultProps", {
467
- shadowEnabled: false,
468
- gestureEnabled: true,
469
- gestureVelocityImpact: GESTURE_VELOCITY_IMPACT,
470
- overlay: ({
471
- style
472
- }) => style ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
473
- pointerEvents: "none",
474
- style: [styles.overlay, style]
475
- }) : null
476
- });
441
+ })]
442
+ });
443
+ }
444
+ }
445
+ exports.Card = Card;
477
446
  const styles = _reactNative.StyleSheet.create({
478
447
  container: {
479
448
  flex: 1