react-native-screen-transitions 3.0.0-rc.3 → 3.0.0-rc.4
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.
- package/lib/commonjs/blank-stack/components/screens.js +16 -11
- package/lib/commonjs/blank-stack/components/screens.js.map +1 -1
- package/lib/commonjs/blank-stack/components/stack-view.js +42 -36
- package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.native.js +110 -103
- package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/shared/components/controllers/blank-stack-lifecycle.js +72 -0
- package/lib/commonjs/shared/components/controllers/blank-stack-lifecycle.js.map +1 -0
- package/lib/commonjs/shared/components/controllers/native-stack-lifecycle.js +79 -0
- package/lib/commonjs/shared/components/controllers/native-stack-lifecycle.js.map +1 -0
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +11 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +11 -6
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js +7 -7
- package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
- package/lib/commonjs/shared/providers/gestures.provider.js +32 -5
- package/lib/commonjs/shared/providers/gestures.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/register-bounds.provider.js +4 -3
- package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/routes.provider.js +48 -0
- package/lib/commonjs/shared/providers/routes.provider.js.map +1 -0
- package/lib/commonjs/shared/providers/screen-transition.provider.js.map +1 -1
- package/lib/commonjs/shared/types/state.types.js +9 -0
- package/lib/commonjs/shared/types/state.types.js.map +1 -0
- package/lib/commonjs/shared/utils/animation/compute-stack-progress.js +20 -0
- package/lib/commonjs/shared/utils/animation/compute-stack-progress.js.map +1 -0
- package/lib/commonjs/shared/utils/animation/derivations.js +1 -1
- package/lib/commonjs/shared/utils/animation/start-screen-transition.js +11 -11
- package/lib/commonjs/shared/utils/animation/start-screen-transition.js.map +1 -1
- package/lib/module/blank-stack/components/screens.js +16 -11
- package/lib/module/blank-stack/components/screens.js.map +1 -1
- package/lib/module/blank-stack/components/stack-view.js +42 -36
- package/lib/module/blank-stack/components/stack-view.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.native.js +109 -102
- package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/shared/components/controllers/blank-stack-lifecycle.js +66 -0
- package/lib/module/shared/components/controllers/blank-stack-lifecycle.js.map +1 -0
- package/lib/module/shared/components/controllers/native-stack-lifecycle.js +73 -0
- package/lib/module/shared/components/controllers/native-stack-lifecycle.js.map +1 -0
- package/lib/module/shared/hooks/animation/use-screen-animation.js +11 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js +11 -6
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js +7 -7
- package/lib/module/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
- package/lib/module/shared/providers/gestures.provider.js +31 -4
- package/lib/module/shared/providers/gestures.provider.js.map +1 -1
- package/lib/module/shared/providers/register-bounds.provider.js +4 -3
- package/lib/module/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/module/shared/providers/routes.provider.js +42 -0
- package/lib/module/shared/providers/routes.provider.js.map +1 -0
- package/lib/module/shared/providers/screen-transition.provider.js.map +1 -1
- package/lib/module/shared/types/state.types.js +5 -0
- package/lib/module/shared/types/state.types.js.map +1 -0
- package/lib/module/shared/utils/animation/compute-stack-progress.js +15 -0
- package/lib/module/shared/utils/animation/compute-stack-progress.js.map +1 -0
- package/lib/module/shared/utils/animation/derivations.js +1 -1
- package/lib/module/shared/utils/animation/start-screen-transition.js +11 -11
- package/lib/module/shared/utils/animation/start-screen-transition.js.map +1 -1
- package/lib/typescript/blank-stack/components/screens.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -1
- package/lib/typescript/blank-stack/types.d.ts +1 -39
- package/lib/typescript/blank-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/shared/components/controllers/blank-stack-lifecycle.d.ts +8 -0
- package/lib/typescript/shared/components/controllers/blank-stack-lifecycle.d.ts.map +1 -0
- package/lib/typescript/shared/components/controllers/native-stack-lifecycle.d.ts +8 -0
- package/lib/typescript/shared/components/controllers/native-stack-lifecycle.d.ts.map +1 -0
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts +2 -2
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/providers/gestures.provider.d.ts +8 -2
- package/lib/typescript/shared/providers/gestures.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/routes.provider.d.ts +19 -0
- package/lib/typescript/shared/providers/routes.provider.d.ts.map +1 -0
- package/lib/typescript/shared/providers/screen-transition.provider.d.ts +2 -2
- package/lib/typescript/shared/providers/screen-transition.provider.d.ts.map +1 -1
- package/lib/typescript/shared/types/animation.types.d.ts +12 -0
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/state.types.d.ts +3 -0
- package/lib/typescript/shared/types/state.types.d.ts.map +1 -0
- package/lib/typescript/shared/utils/animation/compute-stack-progress.d.ts +3 -0
- package/lib/typescript/shared/utils/animation/compute-stack-progress.d.ts.map +1 -0
- package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blank-stack/components/screens.tsx +21 -15
- package/src/blank-stack/components/stack-view.tsx +55 -44
- package/src/blank-stack/types.ts +1 -24
- package/src/native-stack/views/NativeStackView.native.tsx +121 -112
- package/src/shared/__tests__/bounds.store.test.ts +14 -36
- package/src/shared/components/controllers/blank-stack-lifecycle.tsx +70 -0
- package/src/shared/components/controllers/native-stack-lifecycle.tsx +87 -0
- package/src/shared/hooks/animation/use-screen-animation.tsx +11 -6
- package/src/shared/hooks/gestures/use-build-gestures.tsx +12 -6
- package/src/shared/hooks/gestures/use-scroll-registry.tsx +7 -7
- package/src/shared/providers/gestures.provider.tsx +34 -5
- package/src/shared/providers/register-bounds.provider.tsx +4 -3
- package/src/shared/providers/routes.provider.tsx +54 -0
- package/src/shared/providers/screen-transition.provider.tsx +2 -2
- package/src/shared/types/animation.types.ts +13 -0
- package/src/shared/types/state.types.ts +2 -0
- package/src/shared/utils/animation/compute-stack-progress.ts +16 -0
- package/src/shared/utils/animation/derivations.ts +1 -1
- package/src/shared/utils/animation/start-screen-transition.ts +13 -10
- package/lib/commonjs/shared/components/controllers/screen-lifecycle.js +0 -142
- package/lib/commonjs/shared/components/controllers/screen-lifecycle.js.map +0 -1
- package/lib/commonjs/shared/hooks/gestures/use-parent-gesture-registry.js +0 -28
- package/lib/commonjs/shared/hooks/gestures/use-parent-gesture-registry.js.map +0 -1
- package/lib/module/shared/components/controllers/screen-lifecycle.js +0 -136
- package/lib/module/shared/components/controllers/screen-lifecycle.js.map +0 -1
- package/lib/module/shared/hooks/gestures/use-parent-gesture-registry.js +0 -23
- package/lib/module/shared/hooks/gestures/use-parent-gesture-registry.js.map +0 -1
- package/lib/typescript/shared/components/controllers/screen-lifecycle.d.ts +0 -12
- package/lib/typescript/shared/components/controllers/screen-lifecycle.d.ts.map +0 -1
- package/lib/typescript/shared/hooks/gestures/use-parent-gesture-registry.d.ts +0 -6
- package/lib/typescript/shared/hooks/gestures/use-parent-gesture-registry.d.ts.map +0 -1
- package/src/shared/components/controllers/screen-lifecycle.tsx +0 -154
- package/src/shared/hooks/gestures/use-parent-gesture-registry.tsx +0 -18
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useParentGestureRegistry = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var _gestures = require("../../providers/gestures.provider");
|
|
9
|
-
var _useStableCallback = _interopRequireDefault(require("../use-stable-callback"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
/**
|
|
12
|
-
* Registers native gestures with parent gestures to enable proper gesture handling
|
|
13
|
-
* in nested navigators that contain scrollable content.
|
|
14
|
-
*/
|
|
15
|
-
const useParentGestureRegistry = () => {
|
|
16
|
-
const {
|
|
17
|
-
parentContext,
|
|
18
|
-
nativeGesture
|
|
19
|
-
} = (0, _gestures.useGestureContext)();
|
|
20
|
-
const registerNativeGesture = (0, _useStableCallback.default)(() => {
|
|
21
|
-
if (parentContext?.panGesture && nativeGesture) {
|
|
22
|
-
parentContext.panGesture.blocksExternalGesture(nativeGesture);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
(0, _react.useEffect)(registerNativeGesture);
|
|
26
|
-
};
|
|
27
|
-
exports.useParentGestureRegistry = useParentGestureRegistry;
|
|
28
|
-
//# sourceMappingURL=use-parent-gesture-registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_gestures","_useStableCallback","_interopRequireDefault","e","__esModule","default","useParentGestureRegistry","parentContext","nativeGesture","useGestureContext","registerNativeGesture","useStableCallback","panGesture","blocksExternalGesture","useEffect","exports"],"sourceRoot":"../../../../../src","sources":["shared/hooks/gestures/use-parent-gesture-registry.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAuD,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEvD;AACA;AACA;AACA;AACO,MAAMG,wBAAwB,GAAGA,CAAA,KAAM;EAC7C,MAAM;IAAEC,aAAa;IAAEC;EAAc,CAAC,GAAG,IAAAC,2BAAiB,EAAC,CAAC;EAC5D,MAAMC,qBAAqB,GAAG,IAAAC,0BAAiB,EAAC,MAAM;IACrD,IAAIJ,aAAa,EAAEK,UAAU,IAAIJ,aAAa,EAAE;MAC/CD,aAAa,CAACK,UAAU,CAACC,qBAAqB,CAACL,aAAa,CAAC;IAC9D;EACD,CAAC,CAAC;EAEF,IAAAM,gBAAS,EAACJ,qBAAqB,CAAC;AACjC,CAAC;AAACK,OAAA,CAAAT,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useEffect, useLayoutEffect } from "react";
|
|
4
|
-
import { useAnimatedReaction, useDerivedValue } from "react-native-reanimated";
|
|
5
|
-
import { useStackNavigationContext } from "../../../blank-stack/utils/with-stack-navigation";
|
|
6
|
-
import { useParentGestureRegistry } from "../../hooks/gestures/use-parent-gesture-registry";
|
|
7
|
-
import { useSharedValueState } from "../../hooks/reanimated/use-shared-value-state";
|
|
8
|
-
import useStableCallback from "../../hooks/use-stable-callback";
|
|
9
|
-
import { useGestureContext } from "../../providers/gestures.provider";
|
|
10
|
-
import { useKeys } from "../../providers/keys.provider";
|
|
11
|
-
import { AnimationStore } from "../../stores/animation.store";
|
|
12
|
-
import { startScreenTransition } from "../../utils/animation/start-screen-transition";
|
|
13
|
-
import { resetStoresForScreen } from "../../utils/reset-stores-for-screen";
|
|
14
|
-
/**
|
|
15
|
-
* ScreenLifecycleController built out for Native Stack implementation.
|
|
16
|
-
*/
|
|
17
|
-
export const NativeStackScreenLifecycleController = ({
|
|
18
|
-
children
|
|
19
|
-
}) => {
|
|
20
|
-
const {
|
|
21
|
-
current
|
|
22
|
-
} = useKeys();
|
|
23
|
-
const {
|
|
24
|
-
parentContext
|
|
25
|
-
} = useGestureContext();
|
|
26
|
-
const isParentDismissingViaGesture = useSharedValueState(useDerivedValue(() => {
|
|
27
|
-
"worklet";
|
|
28
|
-
|
|
29
|
-
return parentContext?.gestureAnimationValues.isDismissing?.value ?? false;
|
|
30
|
-
}));
|
|
31
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
32
|
-
const handleBeforeRemove = useStableCallback(e => {
|
|
33
|
-
const isEnabled = current.options.enableTransitions;
|
|
34
|
-
const isFirstScreen = current.navigation.getState().index === 0;
|
|
35
|
-
|
|
36
|
-
// If transitions are disabled, or the dismissal was on the local root, or this is the first screen of the stack, reset the stores
|
|
37
|
-
if (!isEnabled || isParentDismissingViaGesture || isFirstScreen) {
|
|
38
|
-
resetStoresForScreen(current);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
const onAnimationFinish = finished => {
|
|
43
|
-
if (finished) {
|
|
44
|
-
current.navigation.dispatch(e.data.action);
|
|
45
|
-
|
|
46
|
-
// we'll ensure the dispatch is complete before resetting stores
|
|
47
|
-
requestAnimationFrame(() => {
|
|
48
|
-
resetStoresForScreen(current);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
startScreenTransition({
|
|
53
|
-
target: "close",
|
|
54
|
-
spec: current.options.transitionSpec,
|
|
55
|
-
onAnimationFinish,
|
|
56
|
-
animations
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
const handleInitialize = useStableCallback(() => {
|
|
60
|
-
startScreenTransition({
|
|
61
|
-
target: "open",
|
|
62
|
-
spec: current.options.transitionSpec,
|
|
63
|
-
animations
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
const unsubscribe = current.navigation.addListener("beforeRemove", handleBeforeRemove);
|
|
68
|
-
return unsubscribe;
|
|
69
|
-
}, [current.navigation, handleBeforeRemove]);
|
|
70
|
-
useLayoutEffect(handleInitialize, []);
|
|
71
|
-
|
|
72
|
-
// important for t.a scrollviews inside nested navigators.
|
|
73
|
-
useParentGestureRegistry();
|
|
74
|
-
return children;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* ScreenLifecycleController built out for Blank Stack implementation.
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
export const BlankStackScreenLifecycleController = ({
|
|
82
|
-
children
|
|
83
|
-
}) => {
|
|
84
|
-
const {
|
|
85
|
-
current
|
|
86
|
-
} = useKeys();
|
|
87
|
-
const {
|
|
88
|
-
handleCloseRoute,
|
|
89
|
-
closingRouteKeysShared
|
|
90
|
-
} = useStackNavigationContext();
|
|
91
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
92
|
-
const handleInitialize = useStableCallback(() => {
|
|
93
|
-
startScreenTransition({
|
|
94
|
-
target: "open",
|
|
95
|
-
spec: current.options.transitionSpec,
|
|
96
|
-
animations
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
const handleCleanup = useStableCallback(() => {
|
|
100
|
-
resetStoresForScreen(current);
|
|
101
|
-
});
|
|
102
|
-
const handleCloseEnd = useStableCallback(finished => {
|
|
103
|
-
if (!finished) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
handleCloseRoute({
|
|
107
|
-
route: current.route
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
useAnimatedReaction(() => ({
|
|
111
|
-
keys: closingRouteKeysShared.value
|
|
112
|
-
}), ({
|
|
113
|
-
keys
|
|
114
|
-
}) => {
|
|
115
|
-
if (!keys.includes(current.route.key)) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
startScreenTransition({
|
|
119
|
-
target: "close",
|
|
120
|
-
spec: current.options.transitionSpec,
|
|
121
|
-
animations,
|
|
122
|
-
onAnimationFinish: handleCloseEnd
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
useLayoutEffect(() => {
|
|
126
|
-
handleInitialize();
|
|
127
|
-
return () => {
|
|
128
|
-
handleCleanup();
|
|
129
|
-
};
|
|
130
|
-
}, [handleInitialize, handleCleanup]);
|
|
131
|
-
|
|
132
|
-
// important for t.a scrollviews inside nested navigators.
|
|
133
|
-
useParentGestureRegistry();
|
|
134
|
-
return children;
|
|
135
|
-
};
|
|
136
|
-
//# sourceMappingURL=screen-lifecycle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useAnimatedReaction","useDerivedValue","useStackNavigationContext","useParentGestureRegistry","useSharedValueState","useStableCallback","useGestureContext","useKeys","AnimationStore","startScreenTransition","resetStoresForScreen","NativeStackScreenLifecycleController","children","current","parentContext","isParentDismissingViaGesture","gestureAnimationValues","isDismissing","value","animations","getAll","route","key","handleBeforeRemove","e","isEnabled","options","enableTransitions","isFirstScreen","navigation","getState","index","preventDefault","onAnimationFinish","finished","dispatch","data","action","requestAnimationFrame","target","spec","transitionSpec","handleInitialize","unsubscribe","addListener","BlankStackScreenLifecycleController","handleCloseRoute","closingRouteKeysShared","handleCleanup","handleCloseEnd","keys","includes"],"sourceRoot":"../../../../../src","sources":["shared/components/controllers/screen-lifecycle.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAClD,SAASC,mBAAmB,EAAEC,eAAe,QAAQ,yBAAyB;AAE9E,SAASC,yBAAyB,QAAQ,kDAAkD;AAE5F,SAASC,wBAAwB,QAAQ,kDAAkD;AAC3F,SAASC,mBAAmB,QAAQ,+CAA+C;AACnF,OAAOC,iBAAiB,MAAM,iCAAiC;AAC/D,SAASC,iBAAiB,QAAQ,mCAAmC;AACrE,SAASC,OAAO,QAAQ,+BAA+B;AACvD,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,SAASC,qBAAqB,QAA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,QAAiB,IAAK;IAC/D,IAAI,CAACA,QAAQ,EAAE;MACd;IACD;IACAY,gBAAgB,CAAC;MAAEzB,KAAK,EAAER,OAAO,CAACQ;IAAM,CAAC,CAAC;EAC3C,CAAC,CAAC;EAEFrB,mBAAmB,CAClB,OAAO;IACNkD,IAAI,EAAEH,sBAAsB,CAAC7B;EAC9B,CAAC,CAAC,EACF,CAAC;IAAEgC;EAAK,CAAC,KAAK;IACb,IAAI,CAACA,IAAI,CAACC,QAAQ,CAACtC,OAAO,CAACQ,KAAK,CAACC,GAAG,CAAC,EAAE;MACtC;IACD;IAEAb,qBAAqB,CAAC;MACrB8B,MAAM,EAAE,OAAO;MACfC,IAAI,EAAE3B,OAAO,CAACa,OAAO,CAACe,cAAc;MACpCtB,UAAU;MACVc,iBAAiB,EAAEgB;IACpB,CAAC,CAAC;EACH,CACD,CAAC;EAEDlD,eAAe,CAAC,MAAM;IACrB2C,gBAAgB,CAAC,CAAC;IAClB,OAAO,MAAM;MACZM,aAAa,CAAC,CAAC;IAChB,CAAC;EACF,CAAC,EAAE,CAACN,gBAAgB,EAAEM,aAAa,CAAC,CAAC;;EAErC;EACA7C,wBAAwB,CAAC,CAAC;EAE1B,OAAOS,QAAQ;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { useGestureContext } from "../../providers/gestures.provider";
|
|
5
|
-
import useStableCallback from "../use-stable-callback";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Registers native gestures with parent gestures to enable proper gesture handling
|
|
9
|
-
* in nested navigators that contain scrollable content.
|
|
10
|
-
*/
|
|
11
|
-
export const useParentGestureRegistry = () => {
|
|
12
|
-
const {
|
|
13
|
-
parentContext,
|
|
14
|
-
nativeGesture
|
|
15
|
-
} = useGestureContext();
|
|
16
|
-
const registerNativeGesture = useStableCallback(() => {
|
|
17
|
-
if (parentContext?.panGesture && nativeGesture) {
|
|
18
|
-
parentContext.panGesture.blocksExternalGesture(nativeGesture);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
useEffect(registerNativeGesture);
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=use-parent-gesture-registry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useGestureContext","useStableCallback","useParentGestureRegistry","parentContext","nativeGesture","registerNativeGesture","panGesture","blocksExternalGesture"],"sourceRoot":"../../../../../src","sources":["shared/hooks/gestures/use-parent-gesture-registry.tsx"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,iBAAiB,QAAQ,mCAAmC;AACrE,OAAOC,iBAAiB,MAAM,wBAAwB;;AAEtD;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC7C,MAAM;IAAEC,aAAa;IAAEC;EAAc,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EAC5D,MAAMK,qBAAqB,GAAGJ,iBAAiB,CAAC,MAAM;IACrD,IAAIE,aAAa,EAAEG,UAAU,IAAIF,aAAa,EAAE;MAC/CD,aAAa,CAACG,UAAU,CAACC,qBAAqB,CAACH,aAAa,CAAC;IAC9D;EACD,CAAC,CAAC;EAEFL,SAAS,CAACM,qBAAqB,CAAC;AACjC,CAAC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface ScreenLifecycleProps {
|
|
2
|
-
children: React.ReactNode;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* ScreenLifecycleController built out for Native Stack implementation.
|
|
6
|
-
*/
|
|
7
|
-
export declare const NativeStackScreenLifecycleController: ({ children, }: ScreenLifecycleProps) => import("react").ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* ScreenLifecycleController built out for Blank Stack implementation.
|
|
10
|
-
*/
|
|
11
|
-
export declare const BlankStackScreenLifecycleController: ({ children, }: ScreenLifecycleProps) => import("react").ReactNode;
|
|
12
|
-
//# sourceMappingURL=screen-lifecycle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screen-lifecycle.d.ts","sourceRoot":"","sources":["../../../../../src/shared/components/controllers/screen-lifecycle.tsx"],"names":[],"mappings":"AAcA,MAAM,WAAW,oBAAoB;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,oCAAoC,GAAI,eAElD,oBAAoB,8BAmEtB,CAAC;AAEF;;GAEG;AAEH,eAAO,MAAM,mCAAmC,GAAI,eAEjD,oBAAoB,8BAuDtB,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registers native gestures with parent gestures to enable proper gesture handling
|
|
3
|
-
* in nested navigators that contain scrollable content.
|
|
4
|
-
*/
|
|
5
|
-
export declare const useParentGestureRegistry: () => void;
|
|
6
|
-
//# sourceMappingURL=use-parent-gesture-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-parent-gesture-registry.d.ts","sourceRoot":"","sources":["../../../../../src/shared/hooks/gestures/use-parent-gesture-registry.tsx"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,YASpC,CAAC"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
-
import { useAnimatedReaction, useDerivedValue } from "react-native-reanimated";
|
|
3
|
-
import type { BlankStackDescriptor } from "../../../blank-stack/types";
|
|
4
|
-
import { useStackNavigationContext } from "../../../blank-stack/utils/with-stack-navigation";
|
|
5
|
-
import type { NativeStackDescriptor } from "../../../native-stack/types";
|
|
6
|
-
import { useParentGestureRegistry } from "../../hooks/gestures/use-parent-gesture-registry";
|
|
7
|
-
import { useSharedValueState } from "../../hooks/reanimated/use-shared-value-state";
|
|
8
|
-
import useStableCallback from "../../hooks/use-stable-callback";
|
|
9
|
-
import { useGestureContext } from "../../providers/gestures.provider";
|
|
10
|
-
import { useKeys } from "../../providers/keys.provider";
|
|
11
|
-
import { AnimationStore } from "../../stores/animation.store";
|
|
12
|
-
import { startScreenTransition } from "../../utils/animation/start-screen-transition";
|
|
13
|
-
import { resetStoresForScreen } from "../../utils/reset-stores-for-screen";
|
|
14
|
-
|
|
15
|
-
export interface ScreenLifecycleProps {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* ScreenLifecycleController built out for Native Stack implementation.
|
|
21
|
-
*/
|
|
22
|
-
export const NativeStackScreenLifecycleController = ({
|
|
23
|
-
children,
|
|
24
|
-
}: ScreenLifecycleProps) => {
|
|
25
|
-
const { current } = useKeys<NativeStackDescriptor>();
|
|
26
|
-
const { parentContext } = useGestureContext();
|
|
27
|
-
|
|
28
|
-
const isParentDismissingViaGesture = useSharedValueState(
|
|
29
|
-
useDerivedValue(() => {
|
|
30
|
-
"worklet";
|
|
31
|
-
return parentContext?.gestureAnimationValues.isDismissing?.value ?? false;
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
36
|
-
|
|
37
|
-
const handleBeforeRemove = useStableCallback((e: any) => {
|
|
38
|
-
const isEnabled = current.options.enableTransitions;
|
|
39
|
-
|
|
40
|
-
const isFirstScreen = current.navigation.getState().index === 0;
|
|
41
|
-
|
|
42
|
-
// If transitions are disabled, or the dismissal was on the local root, or this is the first screen of the stack, reset the stores
|
|
43
|
-
if (!isEnabled || isParentDismissingViaGesture || isFirstScreen) {
|
|
44
|
-
resetStoresForScreen(current);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
e.preventDefault();
|
|
49
|
-
const onAnimationFinish = (finished: boolean) => {
|
|
50
|
-
if (finished) {
|
|
51
|
-
current.navigation.dispatch(e.data.action);
|
|
52
|
-
|
|
53
|
-
// we'll ensure the dispatch is complete before resetting stores
|
|
54
|
-
requestAnimationFrame(() => {
|
|
55
|
-
resetStoresForScreen(current);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
startScreenTransition({
|
|
61
|
-
target: "close",
|
|
62
|
-
spec: current.options.transitionSpec,
|
|
63
|
-
onAnimationFinish,
|
|
64
|
-
animations,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const handleInitialize = useStableCallback(() => {
|
|
69
|
-
startScreenTransition({
|
|
70
|
-
target: "open",
|
|
71
|
-
spec: current.options.transitionSpec,
|
|
72
|
-
animations,
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const unsubscribe = current.navigation.addListener(
|
|
78
|
-
"beforeRemove",
|
|
79
|
-
handleBeforeRemove,
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
return unsubscribe;
|
|
83
|
-
}, [current.navigation, handleBeforeRemove]);
|
|
84
|
-
|
|
85
|
-
useLayoutEffect(handleInitialize, []);
|
|
86
|
-
|
|
87
|
-
// important for t.a scrollviews inside nested navigators.
|
|
88
|
-
useParentGestureRegistry();
|
|
89
|
-
|
|
90
|
-
return children;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* ScreenLifecycleController built out for Blank Stack implementation.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
export const BlankStackScreenLifecycleController = ({
|
|
98
|
-
children,
|
|
99
|
-
}: ScreenLifecycleProps) => {
|
|
100
|
-
const { current } = useKeys<BlankStackDescriptor>();
|
|
101
|
-
const { handleCloseRoute, closingRouteKeysShared } =
|
|
102
|
-
useStackNavigationContext();
|
|
103
|
-
|
|
104
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
105
|
-
|
|
106
|
-
const handleInitialize = useStableCallback(() => {
|
|
107
|
-
startScreenTransition({
|
|
108
|
-
target: "open",
|
|
109
|
-
spec: current.options.transitionSpec,
|
|
110
|
-
animations,
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const handleCleanup = useStableCallback(() => {
|
|
115
|
-
resetStoresForScreen(current);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const handleCloseEnd = useStableCallback((finished: boolean) => {
|
|
119
|
-
if (!finished) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
handleCloseRoute({ route: current.route });
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
useAnimatedReaction(
|
|
126
|
-
() => ({
|
|
127
|
-
keys: closingRouteKeysShared.value,
|
|
128
|
-
}),
|
|
129
|
-
({ keys }) => {
|
|
130
|
-
if (!keys.includes(current.route.key)) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
startScreenTransition({
|
|
135
|
-
target: "close",
|
|
136
|
-
spec: current.options.transitionSpec,
|
|
137
|
-
animations,
|
|
138
|
-
onAnimationFinish: handleCloseEnd,
|
|
139
|
-
});
|
|
140
|
-
},
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
useLayoutEffect(() => {
|
|
144
|
-
handleInitialize();
|
|
145
|
-
return () => {
|
|
146
|
-
handleCleanup();
|
|
147
|
-
};
|
|
148
|
-
}, [handleInitialize, handleCleanup]);
|
|
149
|
-
|
|
150
|
-
// important for t.a scrollviews inside nested navigators.
|
|
151
|
-
useParentGestureRegistry();
|
|
152
|
-
|
|
153
|
-
return children;
|
|
154
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { useGestureContext } from "../../providers/gestures.provider";
|
|
3
|
-
import useStableCallback from "../use-stable-callback";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Registers native gestures with parent gestures to enable proper gesture handling
|
|
7
|
-
* in nested navigators that contain scrollable content.
|
|
8
|
-
*/
|
|
9
|
-
export const useParentGestureRegistry = () => {
|
|
10
|
-
const { parentContext, nativeGesture } = useGestureContext();
|
|
11
|
-
const registerNativeGesture = useStableCallback(() => {
|
|
12
|
-
if (parentContext?.panGesture && nativeGesture) {
|
|
13
|
-
parentContext.panGesture.blocksExternalGesture(nativeGesture);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
useEffect(registerNativeGesture);
|
|
18
|
-
};
|