react-native-screen-transitions 3.0.0-rc.3 → 3.0.0-rc.5

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.
Files changed (127) hide show
  1. package/lib/commonjs/blank-stack/components/screens.js +22 -13
  2. package/lib/commonjs/blank-stack/components/screens.js.map +1 -1
  3. package/lib/commonjs/blank-stack/components/stack-view.js +42 -39
  4. package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -1
  5. package/lib/commonjs/blank-stack/utils/with-stack-navigation/index.js +11 -10
  6. package/lib/commonjs/blank-stack/utils/with-stack-navigation/index.js.map +1 -1
  7. package/lib/commonjs/native-stack/views/NativeStackView.native.js +110 -103
  8. package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
  9. package/lib/commonjs/shared/components/controllers/blank-stack-lifecycle.js +72 -0
  10. package/lib/commonjs/shared/components/controllers/blank-stack-lifecycle.js.map +1 -0
  11. package/lib/commonjs/shared/components/controllers/native-stack-lifecycle.js +81 -0
  12. package/lib/commonjs/shared/components/controllers/native-stack-lifecycle.js.map +1 -0
  13. package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +11 -1
  14. package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
  15. package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +11 -6
  16. package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  17. package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js +7 -7
  18. package/lib/commonjs/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
  19. package/lib/commonjs/shared/providers/gestures.provider.js +36 -20
  20. package/lib/commonjs/shared/providers/gestures.provider.js.map +1 -1
  21. package/lib/commonjs/shared/providers/register-bounds.provider.js +4 -3
  22. package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -1
  23. package/lib/commonjs/shared/providers/routes.provider.js +48 -0
  24. package/lib/commonjs/shared/providers/routes.provider.js.map +1 -0
  25. package/lib/commonjs/shared/providers/screen-transition.provider.js.map +1 -1
  26. package/lib/commonjs/shared/types/state.types.js +9 -0
  27. package/lib/commonjs/shared/types/state.types.js.map +1 -0
  28. package/lib/commonjs/shared/utils/animation/compute-stack-progress.js +20 -0
  29. package/lib/commonjs/shared/utils/animation/compute-stack-progress.js.map +1 -0
  30. package/lib/commonjs/shared/utils/animation/derivations.js +1 -1
  31. package/lib/commonjs/shared/utils/animation/start-screen-transition.js +11 -11
  32. package/lib/commonjs/shared/utils/animation/start-screen-transition.js.map +1 -1
  33. package/lib/module/blank-stack/components/screens.js +22 -13
  34. package/lib/module/blank-stack/components/screens.js.map +1 -1
  35. package/lib/module/blank-stack/components/stack-view.js +42 -39
  36. package/lib/module/blank-stack/components/stack-view.js.map +1 -1
  37. package/lib/module/blank-stack/utils/with-stack-navigation/index.js +11 -10
  38. package/lib/module/blank-stack/utils/with-stack-navigation/index.js.map +1 -1
  39. package/lib/module/native-stack/views/NativeStackView.native.js +109 -102
  40. package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
  41. package/lib/module/shared/components/controllers/blank-stack-lifecycle.js +66 -0
  42. package/lib/module/shared/components/controllers/blank-stack-lifecycle.js.map +1 -0
  43. package/lib/module/shared/components/controllers/native-stack-lifecycle.js +74 -0
  44. package/lib/module/shared/components/controllers/native-stack-lifecycle.js.map +1 -0
  45. package/lib/module/shared/hooks/animation/use-screen-animation.js +11 -1
  46. package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
  47. package/lib/module/shared/hooks/gestures/use-build-gestures.js +11 -6
  48. package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  49. package/lib/module/shared/hooks/gestures/use-scroll-registry.js +7 -7
  50. package/lib/module/shared/hooks/gestures/use-scroll-registry.js.map +1 -1
  51. package/lib/module/shared/providers/gestures.provider.js +36 -21
  52. package/lib/module/shared/providers/gestures.provider.js.map +1 -1
  53. package/lib/module/shared/providers/register-bounds.provider.js +4 -3
  54. package/lib/module/shared/providers/register-bounds.provider.js.map +1 -1
  55. package/lib/module/shared/providers/routes.provider.js +42 -0
  56. package/lib/module/shared/providers/routes.provider.js.map +1 -0
  57. package/lib/module/shared/providers/screen-transition.provider.js.map +1 -1
  58. package/lib/module/shared/types/state.types.js +5 -0
  59. package/lib/module/shared/types/state.types.js.map +1 -0
  60. package/lib/module/shared/utils/animation/compute-stack-progress.js +15 -0
  61. package/lib/module/shared/utils/animation/compute-stack-progress.js.map +1 -0
  62. package/lib/module/shared/utils/animation/derivations.js +1 -1
  63. package/lib/module/shared/utils/animation/start-screen-transition.js +11 -11
  64. package/lib/module/shared/utils/animation/start-screen-transition.js.map +1 -1
  65. package/lib/typescript/blank-stack/components/screens.d.ts +1 -3
  66. package/lib/typescript/blank-stack/components/screens.d.ts.map +1 -1
  67. package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -1
  68. package/lib/typescript/blank-stack/types.d.ts +1 -39
  69. package/lib/typescript/blank-stack/types.d.ts.map +1 -1
  70. package/lib/typescript/blank-stack/utils/with-stack-navigation/index.d.ts.map +1 -1
  71. package/lib/typescript/native-stack/views/NativeStackView.native.d.ts.map +1 -1
  72. package/lib/typescript/shared/components/controllers/blank-stack-lifecycle.d.ts +8 -0
  73. package/lib/typescript/shared/components/controllers/blank-stack-lifecycle.d.ts.map +1 -0
  74. package/lib/typescript/shared/components/controllers/native-stack-lifecycle.d.ts +8 -0
  75. package/lib/typescript/shared/components/controllers/native-stack-lifecycle.d.ts.map +1 -0
  76. package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
  77. package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts +2 -2
  78. package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
  79. package/lib/typescript/shared/providers/gestures.provider.d.ts +10 -7
  80. package/lib/typescript/shared/providers/gestures.provider.d.ts.map +1 -1
  81. package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -1
  82. package/lib/typescript/shared/providers/routes.provider.d.ts +19 -0
  83. package/lib/typescript/shared/providers/routes.provider.d.ts.map +1 -0
  84. package/lib/typescript/shared/providers/screen-transition.provider.d.ts +2 -2
  85. package/lib/typescript/shared/providers/screen-transition.provider.d.ts.map +1 -1
  86. package/lib/typescript/shared/types/animation.types.d.ts +12 -0
  87. package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
  88. package/lib/typescript/shared/types/state.types.d.ts +3 -0
  89. package/lib/typescript/shared/types/state.types.d.ts.map +1 -0
  90. package/lib/typescript/shared/utils/animation/compute-stack-progress.d.ts +3 -0
  91. package/lib/typescript/shared/utils/animation/compute-stack-progress.d.ts.map +1 -0
  92. package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts.map +1 -1
  93. package/package.json +1 -1
  94. package/src/blank-stack/components/screens.tsx +25 -19
  95. package/src/blank-stack/components/stack-view.tsx +57 -53
  96. package/src/blank-stack/types.ts +1 -24
  97. package/src/blank-stack/utils/with-stack-navigation/index.tsx +17 -3
  98. package/src/native-stack/views/NativeStackView.native.tsx +121 -112
  99. package/src/shared/__tests__/bounds.store.test.ts +14 -36
  100. package/src/shared/components/controllers/blank-stack-lifecycle.tsx +70 -0
  101. package/src/shared/components/controllers/native-stack-lifecycle.tsx +89 -0
  102. package/src/shared/hooks/animation/use-screen-animation.tsx +11 -6
  103. package/src/shared/hooks/gestures/use-build-gestures.tsx +12 -6
  104. package/src/shared/hooks/gestures/use-scroll-registry.tsx +7 -7
  105. package/src/shared/providers/gestures.provider.tsx +49 -48
  106. package/src/shared/providers/register-bounds.provider.tsx +4 -3
  107. package/src/shared/providers/routes.provider.tsx +54 -0
  108. package/src/shared/providers/screen-transition.provider.tsx +2 -2
  109. package/src/shared/types/animation.types.ts +13 -0
  110. package/src/shared/types/state.types.ts +2 -0
  111. package/src/shared/utils/animation/compute-stack-progress.ts +16 -0
  112. package/src/shared/utils/animation/derivations.ts +1 -1
  113. package/src/shared/utils/animation/start-screen-transition.ts +13 -10
  114. package/lib/commonjs/shared/components/controllers/screen-lifecycle.js +0 -142
  115. package/lib/commonjs/shared/components/controllers/screen-lifecycle.js.map +0 -1
  116. package/lib/commonjs/shared/hooks/gestures/use-parent-gesture-registry.js +0 -28
  117. package/lib/commonjs/shared/hooks/gestures/use-parent-gesture-registry.js.map +0 -1
  118. package/lib/module/shared/components/controllers/screen-lifecycle.js +0 -136
  119. package/lib/module/shared/components/controllers/screen-lifecycle.js.map +0 -1
  120. package/lib/module/shared/hooks/gestures/use-parent-gesture-registry.js +0 -23
  121. package/lib/module/shared/hooks/gestures/use-parent-gesture-registry.js.map +0 -1
  122. package/lib/typescript/shared/components/controllers/screen-lifecycle.d.ts +0 -12
  123. package/lib/typescript/shared/components/controllers/screen-lifecycle.d.ts.map +0 -1
  124. package/lib/typescript/shared/hooks/gestures/use-parent-gesture-registry.d.ts +0 -6
  125. package/lib/typescript/shared/hooks/gestures/use-parent-gesture-registry.d.ts.map +0 -1
  126. package/src/shared/components/controllers/screen-lifecycle.tsx +0 -154
  127. package/src/shared/hooks/gestures/use-parent-gesture-registry.tsx +0 -18
@@ -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,+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C,CAAC;EACH,CAAC,CAAC;EAEF,MAAM6B,aAAa,GAAG3C,iBAAiB,CAAC,MAAM;IAC7CK,oBAAoB,CAACG,OAAO,CAAC;EAC9B,CAAC,CAAC;EAEF,MAAMoC,cAAc,GAAG5C,iBAAiB,CAAE6B,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
- };