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

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 (233) hide show
  1. package/README.md +421 -371
  2. package/lib/commonjs/blank-stack/components/{Overlay.js → overlay.js} +11 -12
  3. package/lib/commonjs/blank-stack/components/overlay.js.map +1 -0
  4. package/lib/commonjs/blank-stack/components/{Screens.js → screens.js} +8 -10
  5. package/lib/commonjs/blank-stack/components/screens.js.map +1 -0
  6. package/lib/commonjs/blank-stack/components/stack-view.js +95 -0
  7. package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -0
  8. package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js +2 -3
  9. package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js.map +1 -1
  10. package/lib/commonjs/blank-stack/index.js +1 -8
  11. package/lib/commonjs/blank-stack/index.js.map +1 -1
  12. package/lib/commonjs/blank-stack/navigators/{createBlankStackNavigator.js → create-blank-stack-navigator.js} +3 -3
  13. package/lib/commonjs/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -0
  14. package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/are-descriptors-equal.js.map +1 -0
  15. package/lib/{module/blank-stack/utils/with-stack-navigation/_utils → commonjs/blank-stack/utils/with-stack-navigation/helpers}/calculate-active-screens-limit.js.map +1 -1
  16. package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js +15 -0
  17. package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js.map +1 -0
  18. package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/have-same-route-keys.js.map +1 -0
  19. package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/routes-are-identical.js.map +1 -0
  20. package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.js +1 -12
  21. package/lib/commonjs/blank-stack/utils/with-stack-navigation/hooks/use-closing-route-keys.js.map +1 -0
  22. package/lib/commonjs/blank-stack/utils/with-stack-navigation/hooks/use-previous.js.map +1 -0
  23. package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.js +4 -4
  24. package/lib/commonjs/blank-stack/utils/with-stack-navigation/hooks/use-stack-navigation-state.js.map +1 -0
  25. package/lib/commonjs/blank-stack/utils/with-stack-navigation/index.js +50 -56
  26. package/lib/commonjs/blank-stack/utils/with-stack-navigation/index.js.map +1 -1
  27. package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_types.js → types.js} +1 -1
  28. package/lib/commonjs/blank-stack/utils/with-stack-navigation/types.js.map +1 -0
  29. package/lib/commonjs/shared/configs/presets.js +8 -2
  30. package/lib/commonjs/shared/configs/presets.js.map +1 -1
  31. package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +42 -21
  32. package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
  33. package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  34. package/lib/commonjs/shared/providers/flags.provider.js +25 -0
  35. package/lib/commonjs/shared/providers/flags.provider.js.map +1 -0
  36. package/lib/commonjs/shared/providers/register-bounds.provider.js +71 -45
  37. package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -1
  38. package/lib/commonjs/shared/stores/bounds.store.js +91 -47
  39. package/lib/commonjs/shared/stores/bounds.store.js.map +1 -1
  40. package/lib/commonjs/shared/utils/bounds/helpers/is-bounds-equal.js +1 -1
  41. package/lib/commonjs/shared/utils/bounds/helpers/is-bounds-equal.js.map +1 -1
  42. package/lib/commonjs/shared/utils/bounds/index.js +4 -5
  43. package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
  44. package/lib/commonjs/shared/utils/create-provider.js +20 -1
  45. package/lib/commonjs/shared/utils/create-provider.js.map +1 -1
  46. package/lib/commonjs/shared/utils/reset-stores-for-screen.js +2 -0
  47. package/lib/commonjs/shared/utils/reset-stores-for-screen.js.map +1 -1
  48. package/lib/module/blank-stack/components/{Overlay.js → overlay.js} +11 -12
  49. package/lib/module/blank-stack/components/overlay.js.map +1 -0
  50. package/lib/module/blank-stack/components/{Screens.js → screens.js} +8 -10
  51. package/lib/module/blank-stack/components/screens.js.map +1 -0
  52. package/lib/module/blank-stack/components/stack-view.js +90 -0
  53. package/lib/module/blank-stack/components/stack-view.js.map +1 -0
  54. package/lib/module/blank-stack/hooks/use-overlay-animation.js +2 -3
  55. package/lib/module/blank-stack/hooks/use-overlay-animation.js.map +1 -1
  56. package/lib/module/blank-stack/index.js +1 -2
  57. package/lib/module/blank-stack/index.js.map +1 -1
  58. package/lib/module/blank-stack/navigators/{createBlankStackNavigator.js → create-blank-stack-navigator.js} +2 -2
  59. package/lib/module/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -0
  60. package/lib/module/blank-stack/utils/with-stack-navigation/helpers/are-descriptors-equal.js.map +1 -0
  61. package/lib/module/blank-stack/utils/with-stack-navigation/helpers/calculate-active-screens-limit.js.map +1 -0
  62. package/lib/module/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js +10 -0
  63. package/lib/module/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js.map +1 -0
  64. package/lib/module/blank-stack/utils/with-stack-navigation/helpers/have-same-route-keys.js.map +1 -0
  65. package/lib/module/blank-stack/utils/with-stack-navigation/helpers/routes-are-identical.js.map +1 -0
  66. package/lib/module/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.js +1 -12
  67. package/lib/module/blank-stack/utils/with-stack-navigation/hooks/use-closing-route-keys.js.map +1 -0
  68. package/lib/module/blank-stack/utils/with-stack-navigation/hooks/use-previous.js.map +1 -0
  69. package/lib/module/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.js +4 -4
  70. package/lib/module/blank-stack/utils/with-stack-navigation/hooks/use-stack-navigation-state.js.map +1 -0
  71. package/lib/module/blank-stack/utils/with-stack-navigation/index.js +49 -55
  72. package/lib/module/blank-stack/utils/with-stack-navigation/index.js.map +1 -1
  73. package/lib/module/blank-stack/utils/with-stack-navigation/types.js +4 -0
  74. package/lib/module/blank-stack/utils/with-stack-navigation/types.js.map +1 -0
  75. package/lib/module/shared/configs/presets.js +8 -2
  76. package/lib/module/shared/configs/presets.js.map +1 -1
  77. package/lib/module/shared/hooks/animation/use-screen-animation.js +42 -21
  78. package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
  79. package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  80. package/lib/module/shared/providers/flags.provider.js +19 -0
  81. package/lib/module/shared/providers/flags.provider.js.map +1 -0
  82. package/lib/module/shared/providers/register-bounds.provider.js +71 -45
  83. package/lib/module/shared/providers/register-bounds.provider.js.map +1 -1
  84. package/lib/module/shared/stores/bounds.store.js +91 -47
  85. package/lib/module/shared/stores/bounds.store.js.map +1 -1
  86. package/lib/module/shared/utils/bounds/helpers/is-bounds-equal.js +1 -1
  87. package/lib/module/shared/utils/bounds/helpers/is-bounds-equal.js.map +1 -1
  88. package/lib/module/shared/utils/bounds/index.js +4 -5
  89. package/lib/module/shared/utils/bounds/index.js.map +1 -1
  90. package/lib/module/shared/utils/create-provider.js +20 -1
  91. package/lib/module/shared/utils/create-provider.js.map +1 -1
  92. package/lib/module/shared/utils/reset-stores-for-screen.js +2 -0
  93. package/lib/module/shared/utils/reset-stores-for-screen.js.map +1 -1
  94. package/lib/typescript/blank-stack/components/{Overlay.d.ts → overlay.d.ts} +1 -1
  95. package/lib/typescript/blank-stack/components/overlay.d.ts.map +1 -0
  96. package/lib/typescript/blank-stack/components/{Screens.d.ts → screens.d.ts} +1 -1
  97. package/lib/typescript/blank-stack/components/{Screens.d.ts.map → screens.d.ts.map} +1 -1
  98. package/lib/typescript/blank-stack/components/stack-view.d.ts +3 -0
  99. package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -0
  100. package/lib/typescript/blank-stack/index.d.ts +1 -2
  101. package/lib/typescript/blank-stack/index.d.ts.map +1 -1
  102. package/lib/typescript/blank-stack/navigators/{createBlankStackNavigator.d.ts → create-blank-stack-navigator.d.ts} +1 -1
  103. package/lib/typescript/blank-stack/navigators/create-blank-stack-navigator.d.ts.map +1 -0
  104. package/lib/typescript/blank-stack/types.d.ts +23 -105
  105. package/lib/typescript/blank-stack/types.d.ts.map +1 -1
  106. package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/are-descriptors-equal.d.ts.map +1 -0
  107. package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/calculate-active-screens-limit.d.ts.map +1 -0
  108. package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.d.ts.map +1 -0
  109. package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/have-same-route-keys.d.ts.map +1 -0
  110. package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/routes-are-identical.d.ts.map +1 -0
  111. package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.d.ts.map +1 -1
  112. package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.d.ts.map +1 -1
  113. package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.d.ts +1 -1
  114. package/lib/typescript/blank-stack/utils/with-stack-navigation/hooks/use-stack-navigation-state.d.ts.map +1 -0
  115. package/lib/typescript/blank-stack/utils/with-stack-navigation/index.d.ts +3 -5
  116. package/lib/typescript/blank-stack/utils/with-stack-navigation/index.d.ts.map +1 -1
  117. package/lib/typescript/blank-stack/utils/with-stack-navigation/{_types.d.ts → types.d.ts} +1 -1
  118. package/lib/typescript/blank-stack/utils/with-stack-navigation/types.d.ts.map +1 -0
  119. package/lib/typescript/native-stack/types.d.ts +7 -1
  120. package/lib/typescript/native-stack/types.d.ts.map +1 -1
  121. package/lib/typescript/shared/configs/index.d.ts.map +1 -1
  122. package/lib/typescript/shared/configs/presets.d.ts.map +1 -1
  123. package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
  124. package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
  125. package/lib/typescript/shared/index.d.ts +32 -32
  126. package/lib/typescript/shared/index.d.ts.map +1 -1
  127. package/lib/typescript/shared/providers/flags.provider.d.ts +10 -0
  128. package/lib/typescript/shared/providers/flags.provider.d.ts.map +1 -0
  129. package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -1
  130. package/lib/typescript/shared/stores/bounds.store.d.ts +23 -11
  131. package/lib/typescript/shared/stores/bounds.store.d.ts.map +1 -1
  132. package/lib/typescript/shared/types/bounds.types.d.ts +2 -2
  133. package/lib/typescript/shared/types/bounds.types.d.ts.map +1 -1
  134. package/lib/typescript/shared/types/core.types.d.ts +0 -4
  135. package/lib/typescript/shared/types/core.types.d.ts.map +1 -1
  136. package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
  137. package/lib/typescript/shared/utils/create-provider.d.ts +2 -2
  138. package/lib/typescript/shared/utils/create-provider.d.ts.map +1 -1
  139. package/lib/typescript/shared/utils/reset-stores-for-screen.d.ts.map +1 -1
  140. package/package.json +2 -1
  141. package/src/blank-stack/components/{Overlay.tsx → overlay.tsx} +9 -12
  142. package/src/blank-stack/components/{Screens.tsx → screens.tsx} +7 -9
  143. package/src/blank-stack/components/stack-view.tsx +104 -0
  144. package/src/blank-stack/hooks/use-overlay-animation.tsx +11 -11
  145. package/src/blank-stack/index.ts +1 -2
  146. package/src/blank-stack/navigators/{createBlankStackNavigator.tsx → create-blank-stack-navigator.tsx} +1 -1
  147. package/src/blank-stack/types.ts +31 -109
  148. package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/compose-descriptors.ts +1 -8
  149. package/src/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.tsx +1 -12
  150. package/src/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.tsx +5 -5
  151. package/src/blank-stack/utils/with-stack-navigation/index.tsx +43 -63
  152. package/src/native-stack/types.ts +8 -1
  153. package/src/shared/__tests__/bounds.store.test.ts +398 -167
  154. package/src/shared/__tests__/determine-dismissal.test.ts +2 -12
  155. package/src/shared/__tests__/geometry.test.ts +1 -1
  156. package/src/shared/__tests__/gesture.velocity.test.ts +2 -10
  157. package/src/shared/configs/presets.ts +8 -2
  158. package/src/shared/hooks/animation/use-screen-animation.tsx +65 -31
  159. package/src/shared/hooks/gestures/use-build-gestures.tsx +4 -1
  160. package/src/shared/providers/flags.provider.tsx +21 -0
  161. package/src/shared/providers/register-bounds.provider.tsx +85 -54
  162. package/src/shared/stores/bounds.store.ts +90 -54
  163. package/src/shared/types/bounds.types.ts +2 -2
  164. package/src/shared/types/core.types.ts +4 -6
  165. package/src/shared/utils/bounds/helpers/is-bounds-equal.ts +1 -1
  166. package/src/shared/utils/bounds/index.ts +7 -10
  167. package/src/shared/utils/create-provider.tsx +35 -1
  168. package/src/shared/utils/reset-stores-for-screen.ts +2 -0
  169. package/lib/commonjs/blank-stack/components/Overlay.js.map +0 -1
  170. package/lib/commonjs/blank-stack/components/Screens.js.map +0 -1
  171. package/lib/commonjs/blank-stack/components/StackView.js +0 -93
  172. package/lib/commonjs/blank-stack/components/StackView.js.map +0 -1
  173. package/lib/commonjs/blank-stack/navigators/createBlankStackNavigator.js.map +0 -1
  174. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +0 -1
  175. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +0 -1
  176. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +0 -1
  177. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_types.js.map +0 -1
  178. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +0 -1
  179. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/calculate-active-screens-limit.js.map +0 -1
  180. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +0 -25
  181. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +0 -1
  182. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +0 -1
  183. package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +0 -1
  184. package/lib/module/blank-stack/components/Overlay.js.map +0 -1
  185. package/lib/module/blank-stack/components/Screens.js.map +0 -1
  186. package/lib/module/blank-stack/components/StackView.js +0 -88
  187. package/lib/module/blank-stack/components/StackView.js.map +0 -1
  188. package/lib/module/blank-stack/navigators/createBlankStackNavigator.js.map +0 -1
  189. package/lib/module/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +0 -1
  190. package/lib/module/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +0 -1
  191. package/lib/module/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +0 -1
  192. package/lib/module/blank-stack/utils/with-stack-navigation/_types.js +0 -4
  193. package/lib/module/blank-stack/utils/with-stack-navigation/_types.js.map +0 -1
  194. package/lib/module/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +0 -1
  195. package/lib/module/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +0 -20
  196. package/lib/module/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +0 -1
  197. package/lib/module/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +0 -1
  198. package/lib/module/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +0 -1
  199. package/lib/typescript/blank-stack/components/Overlay.d.ts.map +0 -1
  200. package/lib/typescript/blank-stack/components/StackView.d.ts +0 -2
  201. package/lib/typescript/blank-stack/components/StackView.d.ts.map +0 -1
  202. package/lib/typescript/blank-stack/navigators/createBlankStackNavigator.d.ts.map +0 -1
  203. package/lib/typescript/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.d.ts.map +0 -1
  204. package/lib/typescript/blank-stack/utils/with-stack-navigation/_types.d.ts.map +0 -1
  205. package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.d.ts.map +0 -1
  206. package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/calculate-active-screens-limit.d.ts.map +0 -1
  207. package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.d.ts.map +0 -1
  208. package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.d.ts.map +0 -1
  209. package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.d.ts.map +0 -1
  210. package/src/blank-stack/components/StackView.tsx +0 -108
  211. /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.js +0 -0
  212. /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.js +0 -0
  213. /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.js +0 -0
  214. /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.js +0 -0
  215. /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.js +0 -0
  216. /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.js +0 -0
  217. /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.js +0 -0
  218. /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.js +0 -0
  219. /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.js +0 -0
  220. /package/lib/module/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.js +0 -0
  221. /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.d.ts +0 -0
  222. /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.d.ts +0 -0
  223. /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/compose-descriptors.d.ts +0 -0
  224. /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.d.ts +0 -0
  225. /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.d.ts +0 -0
  226. /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.d.ts +0 -0
  227. /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.d.ts +0 -0
  228. /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.ts +0 -0
  229. /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.ts +0 -0
  230. /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.ts +0 -0
  231. /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.ts +0 -0
  232. /package/src/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.tsx +0 -0
  233. /package/src/blank-stack/utils/with-stack-navigation/{_types.ts → types.ts} +0 -0
@@ -1,45 +1,50 @@
1
- import { type ComponentType, createContext, useContext, useMemo } from "react";
1
+ import { useMemo } from "react";
2
+ import createProvider from "../../../shared/utils/create-provider";
2
3
  import type { BlankStackScene } from "../../types";
3
- import { useStackNavigationState } from "./_hooks/use-stack-navigation-state";
4
+ import { calculateActiveScreensLimit } from "./helpers/calculate-active-screens-limit";
5
+ import { useStackNavigationState } from "./hooks/use-stack-navigation-state";
4
6
  import type {
5
7
  StackNavigationContextProps,
6
8
  StackNavigationContextValue,
7
- } from "./_types";
8
- import { calculateActiveScreensLimit } from "./_utils/calculate-active-screens-limit";
9
+ } from "./types";
9
10
 
10
- export const StackNavigationContext =
11
- createContext<StackNavigationContextValue | null>(null);
12
-
13
- export function withStackNavigationProvider(
14
- Component: ComponentType<StackNavigationContextValue>,
15
- ) {
16
- return function StackNavigationWrapper(props: StackNavigationContextProps) {
11
+ const { withStackNavigationProvider, useStackNavigationContext } =
12
+ createProvider("StackNavigation")<
13
+ StackNavigationContextProps,
14
+ StackNavigationContextValue
15
+ >((props) => {
17
16
  const { state, handleCloseRoute, closingRouteKeys } =
18
17
  useStackNavigationState(props);
19
18
 
20
- const scenes = useMemo(() => {
21
- return state.routes.reduce((acc, route) => {
22
- acc.push({
23
- route,
24
- descriptor: state.descriptors[route.key],
25
- });
26
- return acc;
27
- }, [] as BlankStackScene[]);
28
- }, [state.routes, state.descriptors]);
29
-
30
- const activeScreensLimit = useMemo(() => {
31
- return calculateActiveScreensLimit(state.routes, state.descriptors);
32
- }, [state.routes, state.descriptors]);
33
-
34
- const shouldShowFloatOverlay = useMemo(() => {
35
- return state.routes.some((route) => {
36
- const options = state.descriptors[route.key]?.options;
37
- return options?.overlayMode === "float" && options?.overlayShown;
38
- });
39
- }, [state.routes, state.descriptors]);
40
-
41
- const contextValue = useMemo<StackNavigationContextValue>(() => {
42
- return {
19
+ const { scenes, activeScreensLimit, shouldShowFloatOverlay } =
20
+ useMemo(() => {
21
+ const scenes: BlankStackScene[] = [];
22
+ let shouldShowFloatOverlay = false;
23
+
24
+ for (const route of state.routes) {
25
+ const descriptor = state.descriptors[route.key];
26
+ scenes.push({ route, descriptor });
27
+
28
+ if (!shouldShowFloatOverlay) {
29
+ const options = descriptor?.options;
30
+ shouldShowFloatOverlay =
31
+ options?.overlayMode === "float" &&
32
+ options?.overlayShown === true;
33
+ }
34
+ }
35
+
36
+ return {
37
+ scenes,
38
+ activeScreensLimit: calculateActiveScreensLimit(
39
+ state.routes,
40
+ state.descriptors,
41
+ ),
42
+ shouldShowFloatOverlay,
43
+ };
44
+ }, [state.routes, state.descriptors]);
45
+
46
+ return {
47
+ value: {
43
48
  routes: state.routes,
44
49
  focusedIndex: props.state.index,
45
50
  descriptors: state.descriptors,
@@ -48,33 +53,8 @@ export function withStackNavigationProvider(
48
53
  handleCloseRoute,
49
54
  scenes,
50
55
  shouldShowFloatOverlay,
51
- };
52
- }, [
53
- state,
54
- scenes,
55
- activeScreensLimit,
56
- closingRouteKeys,
57
- handleCloseRoute,
58
- props.state.index,
59
- shouldShowFloatOverlay,
60
- ]);
61
-
62
- return (
63
- <StackNavigationContext.Provider value={contextValue}>
64
- <Component {...contextValue} />
65
- </StackNavigationContext.Provider>
66
- );
67
- };
68
- }
69
-
70
- export const useStackNavigationContext = () => {
71
- const context = useContext(StackNavigationContext);
72
-
73
- if (!context) {
74
- throw new Error(
75
- "StackNavigationContext.Provider is missing in the component tree.",
76
- );
77
- }
56
+ },
57
+ };
58
+ });
78
59
 
79
- return context;
80
- };
60
+ export { useStackNavigationContext, withStackNavigationProvider };
@@ -143,7 +143,14 @@ export type NativeStackHeaderLeftProps = NativeStackHeaderRightProps & {
143
143
  href?: string;
144
144
  };
145
145
 
146
- export type NativeStackNavigationOptions = ScreenTransitionConfig & {
146
+ export type NativeStackScreenTransitionConfig = ScreenTransitionConfig & {
147
+ /**
148
+ * Whether to enable transitions. It sets the presentation to containedTransparentModal, animation none, and headerShown to false.
149
+ */
150
+ enableTransitions?: boolean;
151
+ };
152
+
153
+ export type NativeStackNavigationOptions = NativeStackScreenTransitionConfig & {
147
154
  /**
148
155
  * String that can be displayed in the header as a fallback for `headerTitle`.
149
156
  */