react-native-screen-transitions 3.2.0-beta.0 → 3.2.0-beta.1

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 (273) hide show
  1. package/README.md +103 -8
  2. package/lib/commonjs/blank-stack/components/adjusted-screen-container.js +36 -0
  3. package/lib/commonjs/blank-stack/components/adjusted-screen-container.js.map +1 -0
  4. package/lib/commonjs/blank-stack/components/{screens.js → adjusted-screen.js} +31 -11
  5. package/lib/commonjs/blank-stack/components/adjusted-screen.js.map +1 -0
  6. package/lib/commonjs/blank-stack/components/stack-view.js +33 -41
  7. package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -1
  8. package/lib/commonjs/blank-stack/components/stack-view.native.js +81 -0
  9. package/lib/commonjs/blank-stack/components/stack-view.native.js.map +1 -0
  10. package/lib/commonjs/component-stack/components/component-screen-container.js +23 -0
  11. package/lib/commonjs/component-stack/components/component-screen-container.js.map +1 -0
  12. package/lib/commonjs/component-stack/components/component-screen.js +36 -0
  13. package/lib/commonjs/component-stack/components/component-screen.js.map +1 -0
  14. package/lib/commonjs/component-stack/components/stack-view.js +64 -0
  15. package/lib/commonjs/component-stack/components/stack-view.js.map +1 -0
  16. package/lib/commonjs/component-stack/index.js +3 -10
  17. package/lib/commonjs/component-stack/index.js.map +1 -1
  18. package/lib/commonjs/component-stack/navigators/create-component-stack-navigator.js +52 -0
  19. package/lib/commonjs/component-stack/navigators/create-component-stack-navigator.js.map +1 -0
  20. package/lib/commonjs/native-stack/views/NativeStackView.native.js +103 -105
  21. package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
  22. package/lib/commonjs/shared/components/overlay/helpers/get-active-overlay.js +0 -25
  23. package/lib/commonjs/shared/components/overlay/helpers/get-active-overlay.js.map +1 -1
  24. package/lib/commonjs/shared/components/overlay/index.js +1 -3
  25. package/lib/commonjs/shared/components/overlay/index.js.map +1 -1
  26. package/lib/commonjs/shared/constants.js +3 -1
  27. package/lib/commonjs/shared/constants.js.map +1 -1
  28. package/lib/commonjs/{blank-stack/controllers/blank-stack-lifecycle.js → shared/controller/managed-lifecycle.js} +16 -19
  29. package/lib/commonjs/shared/controller/managed-lifecycle.js.map +1 -0
  30. package/lib/commonjs/shared/hooks/animation/use-high-refresh-rate.js +7 -1
  31. package/lib/commonjs/shared/hooks/animation/use-high-refresh-rate.js.map +1 -1
  32. package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +2 -2
  33. package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
  34. package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +3 -1
  35. package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  36. package/lib/commonjs/shared/hooks/navigation/use-stack.js.map +1 -1
  37. package/lib/commonjs/shared/hooks/reanimated/use-shared-value-state.js +5 -0
  38. package/lib/commonjs/shared/hooks/reanimated/use-shared-value-state.js.map +1 -1
  39. package/lib/commonjs/shared/providers/layout-anchor.provider.js +73 -0
  40. package/lib/commonjs/shared/providers/layout-anchor.provider.js.map +1 -0
  41. package/lib/commonjs/shared/providers/register-bounds.provider.js +9 -4
  42. package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -1
  43. package/lib/commonjs/shared/providers/screen/keys.provider.js +2 -2
  44. package/lib/commonjs/shared/providers/screen/styles.provider.js +38 -4
  45. package/lib/commonjs/shared/providers/screen/styles.provider.js.map +1 -1
  46. package/lib/commonjs/shared/providers/stack/core.provider.js +35 -12
  47. package/lib/commonjs/shared/providers/stack/core.provider.js.map +1 -1
  48. package/lib/commonjs/shared/providers/stack/direct.provider.js +6 -4
  49. package/lib/commonjs/shared/providers/stack/direct.provider.js.map +1 -1
  50. package/lib/commonjs/shared/providers/stack/managed.provider.js +7 -5
  51. package/lib/commonjs/shared/providers/stack/managed.provider.js.map +1 -1
  52. package/lib/commonjs/shared/types/index.js.map +1 -1
  53. package/lib/commonjs/shared/types/stack.types.js +26 -0
  54. package/lib/commonjs/shared/types/stack.types.js.map +1 -1
  55. package/lib/commonjs/shared/utils/bounds/index.js +13 -1
  56. package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
  57. package/lib/commonjs/shared/utils/navigation/sync-routes-with-removed.js +20 -45
  58. package/lib/commonjs/shared/utils/navigation/sync-routes-with-removed.js.map +1 -1
  59. package/lib/module/blank-stack/components/adjusted-screen-container.js +31 -0
  60. package/lib/module/blank-stack/components/adjusted-screen-container.js.map +1 -0
  61. package/lib/module/blank-stack/components/{screens.js → adjusted-screen.js} +30 -10
  62. package/lib/module/blank-stack/components/adjusted-screen.js.map +1 -0
  63. package/lib/module/blank-stack/components/stack-view.js +33 -41
  64. package/lib/module/blank-stack/components/stack-view.js.map +1 -1
  65. package/lib/module/blank-stack/components/stack-view.native.js +76 -0
  66. package/lib/module/blank-stack/components/stack-view.native.js.map +1 -0
  67. package/lib/module/component-stack/components/component-screen-container.js +18 -0
  68. package/lib/module/component-stack/components/component-screen-container.js.map +1 -0
  69. package/lib/module/component-stack/components/component-screen.js +30 -0
  70. package/lib/module/component-stack/components/component-screen.js.map +1 -0
  71. package/lib/module/component-stack/components/stack-view.js +59 -0
  72. package/lib/module/component-stack/components/stack-view.js.map +1 -0
  73. package/lib/module/component-stack/index.js +1 -2
  74. package/lib/module/component-stack/index.js.map +1 -1
  75. package/lib/module/component-stack/navigators/create-component-stack-navigator.js +48 -0
  76. package/lib/module/component-stack/navigators/create-component-stack-navigator.js.map +1 -0
  77. package/lib/module/native-stack/views/NativeStackView.native.js +103 -105
  78. package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
  79. package/lib/module/shared/components/overlay/helpers/get-active-overlay.js +0 -24
  80. package/lib/module/shared/components/overlay/helpers/get-active-overlay.js.map +1 -1
  81. package/lib/module/shared/components/overlay/index.js +1 -3
  82. package/lib/module/shared/components/overlay/index.js.map +1 -1
  83. package/lib/module/shared/constants.js +2 -0
  84. package/lib/module/shared/constants.js.map +1 -1
  85. package/lib/module/{blank-stack/controllers/blank-stack-lifecycle.js → shared/controller/managed-lifecycle.js} +14 -17
  86. package/lib/module/shared/controller/managed-lifecycle.js.map +1 -0
  87. package/lib/module/shared/hooks/animation/use-high-refresh-rate.js +8 -1
  88. package/lib/module/shared/hooks/animation/use-high-refresh-rate.js.map +1 -1
  89. package/lib/module/shared/hooks/animation/use-screen-animation.js +2 -2
  90. package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
  91. package/lib/module/shared/hooks/gestures/use-build-gestures.js +4 -2
  92. package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
  93. package/lib/module/shared/hooks/navigation/use-stack.js.map +1 -1
  94. package/lib/module/shared/hooks/reanimated/use-shared-value-state.js +5 -0
  95. package/lib/module/shared/hooks/reanimated/use-shared-value-state.js.map +1 -1
  96. package/lib/module/shared/providers/layout-anchor.provider.js +67 -0
  97. package/lib/module/shared/providers/layout-anchor.provider.js.map +1 -0
  98. package/lib/module/shared/providers/register-bounds.provider.js +9 -4
  99. package/lib/module/shared/providers/register-bounds.provider.js.map +1 -1
  100. package/lib/module/shared/providers/screen/keys.provider.js +2 -2
  101. package/lib/module/shared/providers/screen/styles.provider.js +39 -5
  102. package/lib/module/shared/providers/screen/styles.provider.js.map +1 -1
  103. package/lib/module/shared/providers/stack/core.provider.js +34 -11
  104. package/lib/module/shared/providers/stack/core.provider.js.map +1 -1
  105. package/lib/module/shared/providers/stack/direct.provider.js +6 -4
  106. package/lib/module/shared/providers/stack/direct.provider.js.map +1 -1
  107. package/lib/module/shared/providers/stack/managed.provider.js +7 -5
  108. package/lib/module/shared/providers/stack/managed.provider.js.map +1 -1
  109. package/lib/module/shared/types/index.js.map +1 -1
  110. package/lib/module/shared/types/stack.types.js +30 -1
  111. package/lib/module/shared/types/stack.types.js.map +1 -1
  112. package/lib/module/shared/utils/bounds/index.js +13 -1
  113. package/lib/module/shared/utils/bounds/index.js.map +1 -1
  114. package/lib/module/shared/utils/navigation/sync-routes-with-removed.js +20 -45
  115. package/lib/module/shared/utils/navigation/sync-routes-with-removed.js.map +1 -1
  116. package/lib/typescript/blank-stack/components/adjusted-screen-container.d.ts +6 -0
  117. package/lib/typescript/blank-stack/components/adjusted-screen-container.d.ts.map +1 -0
  118. package/lib/typescript/blank-stack/components/{screens.d.ts → adjusted-screen.d.ts} +2 -2
  119. package/lib/typescript/blank-stack/components/adjusted-screen.d.ts.map +1 -0
  120. package/lib/typescript/blank-stack/components/stack-view.d.ts +1 -1
  121. package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -1
  122. package/lib/typescript/blank-stack/components/stack-view.native.d.ts +4 -0
  123. package/lib/typescript/blank-stack/components/stack-view.native.d.ts.map +1 -0
  124. package/lib/typescript/blank-stack/types.d.ts +3 -1
  125. package/lib/typescript/blank-stack/types.d.ts.map +1 -1
  126. package/lib/typescript/component-stack/components/component-screen-container.d.ts +6 -0
  127. package/lib/typescript/component-stack/components/component-screen-container.d.ts.map +1 -0
  128. package/lib/typescript/component-stack/components/component-screen.d.ts +8 -0
  129. package/lib/typescript/component-stack/components/component-screen.d.ts.map +1 -0
  130. package/lib/typescript/component-stack/components/stack-view.d.ts +4 -0
  131. package/lib/typescript/component-stack/components/stack-view.d.ts.map +1 -0
  132. package/lib/typescript/component-stack/index.d.ts +2 -3
  133. package/lib/typescript/component-stack/index.d.ts.map +1 -1
  134. package/lib/typescript/component-stack/navigators/create-component-stack-navigator.d.ts +16 -0
  135. package/lib/typescript/component-stack/navigators/create-component-stack-navigator.d.ts.map +1 -0
  136. package/lib/typescript/component-stack/types.d.ts +24 -191
  137. package/lib/typescript/component-stack/types.d.ts.map +1 -1
  138. package/lib/typescript/native-stack/views/NativeStackView.native.d.ts +1 -1
  139. package/lib/typescript/native-stack/views/NativeStackView.native.d.ts.map +1 -1
  140. package/lib/typescript/shared/components/overlay/helpers/get-active-overlay.d.ts +0 -9
  141. package/lib/typescript/shared/components/overlay/helpers/get-active-overlay.d.ts.map +1 -1
  142. package/lib/typescript/shared/components/overlay/index.d.ts +0 -2
  143. package/lib/typescript/shared/components/overlay/index.d.ts.map +1 -1
  144. package/lib/typescript/shared/constants.d.ts +1 -0
  145. package/lib/typescript/shared/constants.d.ts.map +1 -1
  146. package/lib/typescript/shared/controller/managed-lifecycle.d.ts +9 -0
  147. package/lib/typescript/shared/controller/managed-lifecycle.d.ts.map +1 -0
  148. package/lib/typescript/shared/hooks/animation/use-high-refresh-rate.d.ts +7 -0
  149. package/lib/typescript/shared/hooks/animation/use-high-refresh-rate.d.ts.map +1 -1
  150. package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts +2 -1
  151. package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
  152. package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
  153. package/lib/typescript/shared/hooks/navigation/use-stack.d.ts +4 -9
  154. package/lib/typescript/shared/hooks/navigation/use-stack.d.ts.map +1 -1
  155. package/lib/typescript/shared/hooks/reanimated/use-shared-value-state.d.ts.map +1 -1
  156. package/lib/typescript/shared/index.d.ts +13 -13
  157. package/lib/typescript/shared/index.d.ts.map +1 -1
  158. package/lib/typescript/shared/providers/layout-anchor.provider.d.ts +34 -0
  159. package/lib/typescript/shared/providers/layout-anchor.provider.d.ts.map +1 -0
  160. package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -1
  161. package/lib/typescript/shared/providers/screen/keys.provider.d.ts +2 -2
  162. package/lib/typescript/shared/providers/screen/styles.provider.d.ts.map +1 -1
  163. package/lib/typescript/shared/providers/stack/core.provider.d.ts +15 -4
  164. package/lib/typescript/shared/providers/stack/core.provider.d.ts.map +1 -1
  165. package/lib/typescript/shared/providers/stack/direct.provider.d.ts.map +1 -1
  166. package/lib/typescript/shared/providers/stack/managed.provider.d.ts +1 -1
  167. package/lib/typescript/shared/providers/stack/managed.provider.d.ts.map +1 -1
  168. package/lib/typescript/shared/types/bounds.types.d.ts +1 -0
  169. package/lib/typescript/shared/types/bounds.types.d.ts.map +1 -1
  170. package/lib/typescript/shared/types/index.d.ts +1 -1
  171. package/lib/typescript/shared/types/index.d.ts.map +1 -1
  172. package/lib/typescript/shared/types/overlay.types.d.ts +1 -12
  173. package/lib/typescript/shared/types/overlay.types.d.ts.map +1 -1
  174. package/lib/typescript/shared/types/screen.types.d.ts +2 -2
  175. package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
  176. package/lib/typescript/shared/types/stack.types.d.ts +5 -2
  177. package/lib/typescript/shared/types/stack.types.d.ts.map +1 -1
  178. package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
  179. package/lib/typescript/shared/utils/navigation/sync-routes-with-removed.d.ts.map +1 -1
  180. package/package.json +1 -1
  181. package/src/blank-stack/components/adjusted-screen-container.tsx +25 -0
  182. package/src/blank-stack/components/{screens.tsx → adjusted-screen.tsx} +33 -12
  183. package/src/blank-stack/components/stack-view.native.tsx +94 -0
  184. package/src/blank-stack/components/stack-view.tsx +41 -47
  185. package/src/blank-stack/types.ts +3 -2
  186. package/src/component-stack/components/component-screen-container.tsx +15 -0
  187. package/src/component-stack/components/component-screen.tsx +40 -0
  188. package/src/component-stack/components/stack-view.tsx +74 -0
  189. package/src/component-stack/index.ts +6 -12
  190. package/src/component-stack/navigators/create-component-stack-navigator.tsx +88 -0
  191. package/src/component-stack/types.ts +80 -188
  192. package/src/native-stack/views/NativeStackView.native.tsx +104 -106
  193. package/src/shared/__tests__/sync-routes-with-removed.test.ts +0 -146
  194. package/src/shared/components/overlay/helpers/get-active-overlay.ts +0 -26
  195. package/src/shared/components/overlay/index.ts +0 -2
  196. package/src/shared/constants.ts +3 -0
  197. package/src/{blank-stack/controllers/blank-stack-lifecycle.tsx → shared/controller/managed-lifecycle.tsx} +14 -18
  198. package/src/shared/hooks/animation/use-high-refresh-rate.tsx +7 -1
  199. package/src/shared/hooks/animation/use-screen-animation.tsx +5 -3
  200. package/src/shared/hooks/gestures/use-build-gestures.tsx +9 -1
  201. package/src/shared/hooks/navigation/use-stack.tsx +4 -15
  202. package/src/shared/hooks/reanimated/use-shared-value-state.ts +5 -0
  203. package/src/shared/index.ts +2 -1
  204. package/src/shared/providers/layout-anchor.provider.tsx +81 -0
  205. package/src/shared/providers/register-bounds.provider.tsx +11 -4
  206. package/src/shared/providers/screen/keys.provider.tsx +2 -2
  207. package/src/shared/providers/screen/styles.provider.tsx +50 -5
  208. package/src/shared/providers/stack/core.provider.tsx +51 -28
  209. package/src/shared/providers/stack/direct.provider.tsx +4 -1
  210. package/src/shared/providers/stack/managed.provider.tsx +5 -2
  211. package/src/shared/types/bounds.types.ts +5 -0
  212. package/src/shared/types/index.ts +0 -1
  213. package/src/shared/types/overlay.types.ts +1 -14
  214. package/src/shared/types/screen.types.ts +2 -8
  215. package/src/shared/types/stack.types.ts +6 -2
  216. package/src/shared/utils/bounds/index.ts +18 -1
  217. package/src/shared/utils/navigation/sync-routes-with-removed.ts +28 -58
  218. package/lib/commonjs/blank-stack/components/screens.js.map +0 -1
  219. package/lib/commonjs/blank-stack/controllers/blank-stack-lifecycle.js.map +0 -1
  220. package/lib/commonjs/component-stack/components/component-view.js +0 -63
  221. package/lib/commonjs/component-stack/components/component-view.js.map +0 -1
  222. package/lib/commonjs/component-stack/components/screens.js +0 -64
  223. package/lib/commonjs/component-stack/components/screens.js.map +0 -1
  224. package/lib/commonjs/component-stack/controllers/component-stack-lifecycle.js +0 -82
  225. package/lib/commonjs/component-stack/controllers/component-stack-lifecycle.js.map +0 -1
  226. package/lib/commonjs/component-stack/hooks/use-component-navigation-builder.js +0 -321
  227. package/lib/commonjs/component-stack/hooks/use-component-navigation-builder.js.map +0 -1
  228. package/lib/commonjs/component-stack/hooks/use-component-navigation.js +0 -28
  229. package/lib/commonjs/component-stack/hooks/use-component-navigation.js.map +0 -1
  230. package/lib/commonjs/component-stack/navigators/create-component-navigator.js +0 -97
  231. package/lib/commonjs/component-stack/navigators/create-component-navigator.js.map +0 -1
  232. package/lib/commonjs/shared/components/overlay/variations/container-overlay.js +0 -99
  233. package/lib/commonjs/shared/components/overlay/variations/container-overlay.js.map +0 -1
  234. package/lib/module/blank-stack/components/screens.js.map +0 -1
  235. package/lib/module/blank-stack/controllers/blank-stack-lifecycle.js.map +0 -1
  236. package/lib/module/component-stack/components/component-view.js +0 -58
  237. package/lib/module/component-stack/components/component-view.js.map +0 -1
  238. package/lib/module/component-stack/components/screens.js +0 -58
  239. package/lib/module/component-stack/components/screens.js.map +0 -1
  240. package/lib/module/component-stack/controllers/component-stack-lifecycle.js +0 -76
  241. package/lib/module/component-stack/controllers/component-stack-lifecycle.js.map +0 -1
  242. package/lib/module/component-stack/hooks/use-component-navigation-builder.js +0 -316
  243. package/lib/module/component-stack/hooks/use-component-navigation-builder.js.map +0 -1
  244. package/lib/module/component-stack/hooks/use-component-navigation.js +0 -25
  245. package/lib/module/component-stack/hooks/use-component-navigation.js.map +0 -1
  246. package/lib/module/component-stack/navigators/create-component-navigator.js +0 -91
  247. package/lib/module/component-stack/navigators/create-component-navigator.js.map +0 -1
  248. package/lib/module/shared/components/overlay/variations/container-overlay.js +0 -97
  249. package/lib/module/shared/components/overlay/variations/container-overlay.js.map +0 -1
  250. package/lib/typescript/blank-stack/components/screens.d.ts.map +0 -1
  251. package/lib/typescript/blank-stack/controllers/blank-stack-lifecycle.d.ts +0 -9
  252. package/lib/typescript/blank-stack/controllers/blank-stack-lifecycle.d.ts.map +0 -1
  253. package/lib/typescript/component-stack/components/component-view.d.ts +0 -4
  254. package/lib/typescript/component-stack/components/component-view.d.ts.map +0 -1
  255. package/lib/typescript/component-stack/components/screens.d.ts +0 -9
  256. package/lib/typescript/component-stack/components/screens.d.ts.map +0 -1
  257. package/lib/typescript/component-stack/controllers/component-stack-lifecycle.d.ts +0 -10
  258. package/lib/typescript/component-stack/controllers/component-stack-lifecycle.d.ts.map +0 -1
  259. package/lib/typescript/component-stack/hooks/use-component-navigation-builder.d.ts +0 -19
  260. package/lib/typescript/component-stack/hooks/use-component-navigation-builder.d.ts.map +0 -1
  261. package/lib/typescript/component-stack/hooks/use-component-navigation.d.ts +0 -19
  262. package/lib/typescript/component-stack/hooks/use-component-navigation.d.ts.map +0 -1
  263. package/lib/typescript/component-stack/navigators/create-component-navigator.d.ts +0 -35
  264. package/lib/typescript/component-stack/navigators/create-component-navigator.d.ts.map +0 -1
  265. package/lib/typescript/shared/components/overlay/variations/container-overlay.d.ts +0 -8
  266. package/lib/typescript/shared/components/overlay/variations/container-overlay.d.ts.map +0 -1
  267. package/src/component-stack/components/component-view.tsx +0 -72
  268. package/src/component-stack/components/screens.tsx +0 -86
  269. package/src/component-stack/controllers/component-stack-lifecycle.tsx +0 -80
  270. package/src/component-stack/hooks/use-component-navigation-builder.tsx +0 -388
  271. package/src/component-stack/hooks/use-component-navigation.tsx +0 -22
  272. package/src/component-stack/navigators/create-component-navigator.tsx +0 -104
  273. package/src/shared/components/overlay/variations/container-overlay.tsx +0 -98
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- import { memo, useMemo } from "react";
4
- import { useWindowDimensions } from "react-native";
5
- import { useDerivedValue } from "react-native-reanimated";
6
- import { useSafeAreaInsets } from "react-native-safe-area-context";
7
- import { useStack } from "../../../hooks/navigation/use-stack";
8
- import { getActiveContainerOverlay } from "../helpers/get-active-overlay";
9
-
10
- /**
11
- * Inner component that renders when container overlay is active.
12
- * Separated to ensure hooks are called unconditionally.
13
- */
14
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
15
- const ContainerOverlayHost = /*#__PURE__*/memo(function ContainerOverlayHost({
16
- children,
17
- scene,
18
- scenes,
19
- overlayIndex
20
- }) {
21
- const {
22
- routes,
23
- focusedIndex,
24
- stackProgress
25
- } = useStack();
26
- const screen = useWindowDimensions();
27
- const insets = useSafeAreaInsets();
28
- const OverlayComponent = scene.descriptor.options.overlay;
29
-
30
- // Compute relative progress from overlay position
31
- const relativeProgress = useDerivedValue(() => {
32
- "worklet";
33
-
34
- return stackProgress.value - overlayIndex;
35
- });
36
- const overlayAnimation = useDerivedValue(() => ({
37
- progress: relativeProgress.value,
38
- layouts: {
39
- screen
40
- },
41
- insets
42
- }));
43
-
44
- // Get focused scene for meta and route info
45
- const focusedScene = scenes[focusedIndex] ?? scene;
46
- if (!OverlayComponent) {
47
- return /*#__PURE__*/_jsx(_Fragment, {
48
- children: children
49
- });
50
- }
51
- const overlayProps = {
52
- children,
53
- routes,
54
- overlayAnimation,
55
- // screenAnimation is not available at container level, pass a placeholder
56
- screenAnimation: overlayAnimation,
57
- focusedRoute: focusedScene.route,
58
- focusedIndex,
59
- meta: focusedScene.descriptor.options.meta,
60
- navigation: scene.descriptor.navigation
61
- };
62
- return /*#__PURE__*/_jsx(OverlayComponent, {
63
- ...overlayProps
64
- });
65
- });
66
-
67
- /**
68
- * Container overlay component that wraps all screen content.
69
- * Receives children (the screens) and passes them to the overlay component.
70
- */
71
- export function ContainerOverlay({
72
- children
73
- }) {
74
- const {
75
- scenes,
76
- flags
77
- } = useStack();
78
- const activeOverlay = useMemo(() => getActiveContainerOverlay(scenes, flags.TRANSITIONS_ALWAYS_ON), [scenes, flags.TRANSITIONS_ALWAYS_ON]);
79
-
80
- // If no container overlay, just render children directly
81
- if (!activeOverlay) {
82
- return /*#__PURE__*/_jsx(_Fragment, {
83
- children: children
84
- });
85
- }
86
- const {
87
- scene,
88
- overlayIndex
89
- } = activeOverlay;
90
- return /*#__PURE__*/_jsx(ContainerOverlayHost, {
91
- scene: scene,
92
- scenes: scenes,
93
- overlayIndex: overlayIndex,
94
- children: children
95
- });
96
- }
97
- //# sourceMappingURL=container-overlay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["memo","useMemo","useWindowDimensions","useDerivedValue","useSafeAreaInsets","useStack","getActiveContainerOverlay","Fragment","_Fragment","jsx","_jsx","ContainerOverlayHost","children","scene","scenes","overlayIndex","routes","focusedIndex","stackProgress","screen","insets","OverlayComponent","descriptor","options","overlay","relativeProgress","value","overlayAnimation","progress","layouts","focusedScene","overlayProps","screenAnimation","focusedRoute","route","meta","navigation","ContainerOverlay","flags","activeOverlay","TRANSITIONS_ALWAYS_ON"],"sourceRoot":"../../../../../../src","sources":["shared/components/overlay/variations/container-overlay.tsx"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,OAAO,QAAQ,OAAO;AACrC,SAASC,mBAAmB,QAAQ,cAAc;AAClD,SAASC,eAAe,QAAQ,yBAAyB;AACzD,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,SAA0BC,QAAQ,QAAQ,qCAAqC;AAG/E,SAASC,yBAAyB,QAAQ,+BAA+B;;AAEzE;AACA;AACA;AACA;AAHA,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAIA,MAAMC,oBAAoB,gBAAGX,IAAI,CAAC,SAASW,oBAAoBA,CAAC;EAC/DC,QAAQ;EACRC,KAAK;EACLC,MAAM;EACNC;AAMD,CAAC,EAAE;EACF,MAAM;IAAEC,MAAM;IAAEC,YAAY;IAAEC;EAAc,CAAC,GAAGb,QAAQ,CAAC,CAAC;EAC1D,MAAMc,MAAM,GAAGjB,mBAAmB,CAAC,CAAC;EACpC,MAAMkB,MAAM,GAAGhB,iBAAiB,CAAC,CAAC;EAElC,MAAMiB,gBAAgB,GAAGR,KAAK,CAACS,UAAU,CAACC,OAAO,CAACC,OAAO;;EAEzD;EACA,MAAMC,gBAAgB,GAAGtB,eAAe,CAAC,MAAM;IAC9C,SAAS;;IACT,OAAOe,aAAa,CAACQ,KAAK,GAAGX,YAAY;EAC1C,CAAC,CAAC;EAEF,MAAMY,gBAAgB,GAAGxB,eAAe,CAA4B,OAAO;IAC1EyB,QAAQ,EAAEH,gBAAgB,CAACC,KAAK;IAChCG,OAAO,EAAE;MAAEV;IAAO,CAAC;IACnBC;EACD,CAAC,CAAC,CAAC;;EAEH;EACA,MAAMU,YAAY,GAAGhB,MAAM,CAACG,YAAY,CAAC,IAAIJ,KAAK;EAElD,IAAI,CAACQ,gBAAgB,EAAE;IACtB,oBAAOX,IAAA,CAAAF,SAAA;MAAAI,QAAA,EAAGA;IAAQ,CAAG,CAAC;EACvB;EAEA,MAAMmB,YAEL,GAAG;IACHnB,QAAQ;IACRI,MAAM;IACNW,gBAAgB;IAChB;IACAK,eAAe,EAAEL,gBAEhB;IACDM,YAAY,EAAEH,YAAY,CAACI,KAAK;IAChCjB,YAAY;IACZkB,IAAI,EAAEL,YAAY,CAACR,UAAU,CAACC,OAAO,CAACY,IAAI;IAC1CC,UAAU,EAAEvB,KAAK,CAACS,UAAU,CAACc;EAC9B,CAAC;EAED,oBAAO1B,IAAA,CAACW,gBAAgB;IAAA,GAAKU;EAAY,CAAG,CAAC;AAC9C,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA,OAAO,SAASM,gBAAgBA,CAAC;EAAEzB;AAAwC,CAAC,EAAE;EAC7E,MAAM;IAAEE,MAAM;IAAEwB;EAAM,CAAC,GAAGjC,QAAQ,CAAC,CAAC;EAEpC,MAAMkC,aAAa,GAAGtC,OAAO,CAC5B,MAAMK,yBAAyB,CAACQ,MAAM,EAAEwB,KAAK,CAACE,qBAAqB,CAAC,EACpE,CAAC1B,MAAM,EAAEwB,KAAK,CAACE,qBAAqB,CACrC,CAAC;;EAED;EACA,IAAI,CAACD,aAAa,EAAE;IACnB,oBAAO7B,IAAA,CAAAF,SAAA;MAAAI,QAAA,EAAGA;IAAQ,CAAG,CAAC;EACvB;EAEA,MAAM;IAAEC,KAAK;IAAEE;EAAa,CAAC,GAAGwB,aAAa;EAE7C,oBACC7B,IAAA,CAACC,oBAAoB;IACpBE,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfC,YAAY,EAAEA,YAAa;IAAAH,QAAA,EAE1BA;EAAQ,CACY,CAAC;AAEzB","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"screens.d.ts","sourceRoot":"","sources":["../../../../src/blank-stack/components/screens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAYpC,UAAU,WAAW;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAWD,eAAO,MAAM,MAAM,GAAI,yEAOpB,WAAW,4CA8Db,CAAC"}
@@ -1,9 +0,0 @@
1
- interface Props {
2
- children: React.ReactNode;
3
- }
4
- /**
5
- * Lifecycle controller built out for Blank Stack implementation.
6
- */
7
- export declare const BlankStackScreenLifecycleController: ({ children }: Props) => import("react").ReactNode;
8
- export {};
9
- //# sourceMappingURL=blank-stack-lifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blank-stack-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/blank-stack/controllers/blank-stack-lifecycle.tsx"],"names":[],"mappings":"AAWA,UAAU,KAAK;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,mCAAmC,GAAI,cAAc,KAAK,8BA0DtE,CAAC"}
@@ -1,4 +0,0 @@
1
- import * as React from "react";
2
- import type { ComponentNavigation, ComponentStackDescriptor } from "../types";
3
- export declare const ComponentView: React.FC<import("../../shared/providers/stack/managed.provider").ManagedStackProps<ComponentStackDescriptor, ComponentNavigation>>;
4
- //# sourceMappingURL=component-view.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component-view.d.ts","sourceRoot":"","sources":["../../../../src/component-stack/components/component-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAkB9E,eAAO,MAAM,aAAa,oIAyCzB,CAAC"}
@@ -1,9 +0,0 @@
1
- import type * as React from "react";
2
- interface ScreenProps {
3
- routeKey: string;
4
- index: number;
5
- children: React.ReactNode;
6
- }
7
- export declare const Screen: ({ routeKey, index, children }: ScreenProps) => import("react/jsx-runtime").JSX.Element;
8
- export {};
9
- //# sourceMappingURL=screens.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"screens.d.ts","sourceRoot":"","sources":["../../../../src/component-stack/components/screens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AAWpC,UAAU,WAAW;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAUD,eAAO,MAAM,MAAM,GAAI,+BAA+B,WAAW,4CA4DhE,CAAC"}
@@ -1,10 +0,0 @@
1
- interface Props {
2
- children: React.ReactNode;
3
- }
4
- /**
5
- * Lifecycle controller built out for Component Stack implementation.
6
- * Uses the shared ManagedStackContext for closing route handling.
7
- */
8
- export declare const ComponentStackScreenLifecycleController: ({ children, }: Props) => import("react").ReactNode;
9
- export {};
10
- //# sourceMappingURL=component-stack-lifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component-stack-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/component-stack/controllers/component-stack-lifecycle.tsx"],"names":[],"mappings":"AAWA,UAAU,KAAK;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,uCAAuC,GAAI,eAErD,KAAK,8BA0DP,CAAC"}
@@ -1,19 +0,0 @@
1
- import * as React from "react";
2
- import type { ComponentNavigation, ComponentRoute, ComponentStackDescriptor, ComponentStackDescriptorMap, ComponentStackNavigationOptions, ComponentStackState } from "../types";
3
- interface UseComponentNavigationBuilderOptions {
4
- children: React.ReactNode;
5
- initialRouteName?: string;
6
- screenOptions?: ComponentStackNavigationOptions;
7
- }
8
- interface ComponentNavigationBuilderResult {
9
- state: ComponentStackState;
10
- navigation: ComponentNavigation;
11
- describe: (route: ComponentRoute, placeholder: boolean) => ComponentStackDescriptor;
12
- descriptors: ComponentStackDescriptorMap;
13
- NavigationContent: React.FC<{
14
- children: React.ReactNode;
15
- }>;
16
- }
17
- export declare function useComponentNavigationBuilder({ children, initialRouteName, screenOptions, }: UseComponentNavigationBuilderOptions): ComponentNavigationBuilderResult;
18
- export {};
19
- //# sourceMappingURL=use-component-navigation-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-component-navigation-builder.d.ts","sourceRoot":"","sources":["../../../../src/component-stack/hooks/use-component-navigation-builder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EACX,mBAAmB,EACnB,cAAc,EAGd,wBAAwB,EACxB,2BAA2B,EAC3B,+BAA+B,EAC/B,mBAAmB,EACnB,MAAM,UAAU,CAAC;AAwIlB,UAAU,oCAAoC;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,+BAA+B,CAAC;CAChD;AAED,UAAU,gCAAgC;IACzC,KAAK,EAAE,mBAAmB,CAAC;IAC3B,UAAU,EAAE,mBAAmB,CAAC;IAChC,QAAQ,EAAE,CACT,KAAK,EAAE,cAAc,EACrB,WAAW,EAAE,OAAO,KAChB,wBAAwB,CAAC;IAC9B,WAAW,EAAE,2BAA2B,CAAC;IACzC,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAC;CAC3D;AA2BD,wBAAgB,6BAA6B,CAAC,EAC7C,QAAQ,EACR,gBAAgB,EAChB,aAAa,GACb,EAAE,oCAAoC,GAAG,gCAAgC,CAkMzE"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Hook to access the component navigation object from within a screen.
3
- *
4
- * @example
5
- * ```tsx
6
- * function MyScreen() {
7
- * const navigation = useComponentNavigation();
8
- *
9
- * return (
10
- * <Button
11
- * title="Go to Details"
12
- * onPress={() => navigation.push('Details')}
13
- * />
14
- * );
15
- * }
16
- * ```
17
- */
18
- export declare function useComponentNavigation(): import("..").ComponentNavigation;
19
- //# sourceMappingURL=use-component-navigation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-component-navigation.d.ts","sourceRoot":"","sources":["../../../../src/component-stack/hooks/use-component-navigation.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,qCAErC"}
@@ -1,35 +0,0 @@
1
- import * as React from "react";
2
- import type { ComponentNavigation, ComponentNavigatorProps, ComponentScreenProps } from "../types";
3
- export declare function useComponentNavigationContext(): ComponentNavigation;
4
- interface ComponentStack {
5
- Navigator: React.FC<ComponentNavigatorProps>;
6
- Screen: React.FC<ComponentScreenProps>;
7
- }
8
- /**
9
- * Creates a component navigation stack.
10
- *
11
- * @example
12
- * ```tsx
13
- * const Stack = createComponentNavigator();
14
- *
15
- * function MyComponent() {
16
- * return (
17
- * <Stack.Navigator initialRouteName="Home">
18
- * <Stack.Screen
19
- * name="Home"
20
- * component={HomeScreen}
21
- * options={{ ...SlideFromBottom() }}
22
- * />
23
- * <Stack.Screen
24
- * name="Details"
25
- * component={DetailsScreen}
26
- * options={{ ...SlideFromBottom() }}
27
- * />
28
- * </Stack.Navigator>
29
- * );
30
- * }
31
- * ```
32
- */
33
- export declare function createComponentNavigator(): ComponentStack;
34
- export {};
35
- //# sourceMappingURL=create-component-navigator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-component-navigator.d.ts","sourceRoot":"","sources":["../../../../src/component-stack/navigators/create-component-navigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EACX,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EAEpB,MAAM,UAAU,CAAC;AAMlB,wBAAgB,6BAA6B,IAAI,mBAAmB,CAQnE;AA6CD,UAAU,cAAc;IACvB,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC;IAC7C,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAKzD"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Container overlay component that wraps all screen content.
3
- * Receives children (the screens) and passes them to the overlay component.
4
- */
5
- export declare function ContainerOverlay({ children }: {
6
- children: React.ReactNode;
7
- }): import("react/jsx-runtime").JSX.Element;
8
- //# sourceMappingURL=container-overlay.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"container-overlay.d.ts","sourceRoot":"","sources":["../../../../../../src/shared/components/overlay/variations/container-overlay.tsx"],"names":[],"mappings":"AAqEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAwB3E"}
@@ -1,72 +0,0 @@
1
- import * as React from "react";
2
- import { Fragment } from "react";
3
- import { StyleSheet, View } from "react-native";
4
- import { Overlay } from "../../shared/components/overlay";
5
- import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
6
- import { withStackCore } from "../../shared/providers/stack/core.provider";
7
- import { withManagedStack } from "../../shared/providers/stack/managed.provider";
8
- import { ComponentStackScreenLifecycleController } from "../controllers/component-stack-lifecycle";
9
- import type { ComponentNavigation, ComponentStackDescriptor } from "../types";
10
- import { Screen } from "./screens";
11
-
12
- type SceneViewProps = {
13
- descriptor: ComponentStackDescriptor;
14
- };
15
-
16
- const SceneView = React.memo(function SceneView({
17
- descriptor,
18
- }: SceneViewProps) {
19
- return (
20
- <>
21
- {descriptor.options.overlayMode === "screen" && <Overlay.Screen />}
22
- {descriptor.render()}
23
- </>
24
- );
25
- });
26
-
27
- export const ComponentView = withStackCore(
28
- { TRANSITIONS_ALWAYS_ON: true },
29
- withManagedStack<ComponentStackDescriptor, ComponentNavigation>(
30
- ({ scenes, shouldShowFloatOverlay }) => {
31
- return (
32
- <Fragment>
33
- {shouldShowFloatOverlay ? <Overlay.Float /> : null}
34
- <Overlay.Container>
35
- <View style={styles.container}>
36
- {scenes.map((scene, sceneIndex) => {
37
- const descriptor = scene.descriptor;
38
- const route = scene.route;
39
-
40
- const previousDescriptor = scenes[sceneIndex - 1]?.descriptor;
41
- const nextDescriptor = scenes[sceneIndex + 1]?.descriptor;
42
-
43
- return (
44
- <Screen
45
- key={route.key}
46
- index={sceneIndex}
47
- routeKey={route.key}
48
- >
49
- <ScreenComposer
50
- previous={previousDescriptor}
51
- current={descriptor}
52
- next={nextDescriptor}
53
- LifecycleController={
54
- ComponentStackScreenLifecycleController
55
- }
56
- >
57
- <SceneView key={route.key} descriptor={descriptor} />
58
- </ScreenComposer>
59
- </Screen>
60
- );
61
- })}
62
- </View>
63
- </Overlay.Container>
64
- </Fragment>
65
- );
66
- },
67
- ),
68
- );
69
-
70
- const styles = StyleSheet.create({
71
- container: { flex: 1 },
72
- });
@@ -1,86 +0,0 @@
1
- import type * as React from "react";
2
- import { StyleSheet } from "react-native";
3
- import Animated, {
4
- interpolate,
5
- useAnimatedProps,
6
- useDerivedValue,
7
- useSharedValue,
8
- } from "react-native-reanimated";
9
- import { useManagedStackContext } from "../../shared/providers/stack/managed.provider";
10
- import { AnimationStore } from "../../shared/stores/animation.store";
11
-
12
- interface ScreenProps {
13
- routeKey: string;
14
- index: number;
15
- children: React.ReactNode;
16
- }
17
-
18
- enum ScreenActivity {
19
- INACTIVE = 0,
20
- TRANSITIONING_OR_BELOW_TOP = 1,
21
- ON_TOP = 2,
22
- }
23
-
24
- const EPSILON = 1e-5;
25
-
26
- export const Screen = ({ routeKey, index, children }: ScreenProps) => {
27
- const { activeScreensLimit, routes } = useManagedStackContext();
28
- const routesLength = routes.length;
29
-
30
- const sceneProgress = AnimationStore.getAnimation(routeKey, "progress");
31
- const sceneClosing = AnimationStore.getAnimation(routeKey, "closing");
32
- const screenActivity = useSharedValue<ScreenActivity>(
33
- ScreenActivity.TRANSITIONING_OR_BELOW_TOP,
34
- );
35
-
36
- useDerivedValue(() => {
37
- if (!sceneProgress) {
38
- screenActivity.set(ScreenActivity.TRANSITIONING_OR_BELOW_TOP);
39
- return;
40
- }
41
-
42
- if (index < routesLength - activeScreensLimit - 1) {
43
- screenActivity.set(ScreenActivity.INACTIVE);
44
- } else {
45
- const outputValue =
46
- index === routesLength - 1
47
- ? ScreenActivity.ON_TOP
48
- : index >= routesLength - activeScreensLimit
49
- ? ScreenActivity.TRANSITIONING_OR_BELOW_TOP
50
- : ScreenActivity.INACTIVE;
51
-
52
- const v = interpolate(
53
- sceneProgress.get(),
54
- [0, 1 - EPSILON, 1],
55
- [1, 1, outputValue],
56
- "clamp",
57
- );
58
-
59
- const next = Math.trunc(v) ?? ScreenActivity.TRANSITIONING_OR_BELOW_TOP;
60
-
61
- if (next !== screenActivity.get()) {
62
- screenActivity.set(next);
63
- }
64
- }
65
- });
66
-
67
- const animatedProps = useAnimatedProps(() => {
68
- // const activity = screenActivity.get();
69
- return {
70
- // activityState: activity,
71
- // shouldFreeze: activity === ScreenActivity.INACTIVE && shouldFreeze,
72
- pointerEvents: sceneClosing.get()
73
- ? ("none" as const)
74
- : ("box-none" as const),
75
- };
76
- });
77
-
78
- return (
79
- <Animated.View
80
- style={StyleSheet.absoluteFill}
81
- animatedProps={animatedProps}
82
- >
83
- {children}
84
- </Animated.View>
85
- );
86
- };
@@ -1,80 +0,0 @@
1
- import { useLayoutEffect } from "react";
2
- import { runOnJS, useAnimatedReaction } from "react-native-reanimated";
3
- import { useHighRefreshRate } from "../../shared/hooks/animation/use-high-refresh-rate";
4
- import useStableCallback from "../../shared/hooks/use-stable-callback";
5
- import { useKeys } from "../../shared/providers/screen/keys.provider";
6
- import { useManagedStackContext } from "../../shared/providers/stack/managed.provider";
7
- import { AnimationStore } from "../../shared/stores/animation.store";
8
- import { startScreenTransition } from "../../shared/utils/animation/start-screen-transition";
9
- import { resetStoresForScreen } from "../../shared/utils/reset-stores-for-screen";
10
- import type { ComponentStackDescriptor } from "../types";
11
-
12
- interface Props {
13
- children: React.ReactNode;
14
- }
15
-
16
- /**
17
- * Lifecycle controller built out for Component Stack implementation.
18
- * Uses the shared ManagedStackContext for closing route handling.
19
- */
20
- export const ComponentStackScreenLifecycleController = ({
21
- children,
22
- }: Props) => {
23
- const { current } = useKeys<ComponentStackDescriptor>();
24
- const { handleCloseRoute, closingRouteKeysShared } = useManagedStackContext();
25
-
26
- const animations = AnimationStore.getAll(current.route.key);
27
-
28
- const { deactivateHighRefreshRate, activateHighRefreshRate } =
29
- useHighRefreshRate(current);
30
-
31
- const handleInitialize = useStableCallback(() => {
32
- activateHighRefreshRate();
33
- startScreenTransition({
34
- target: "open",
35
- spec: current.options.transitionSpec,
36
- animations,
37
- onAnimationFinish: deactivateHighRefreshRate,
38
- });
39
- });
40
-
41
- const handleCleanup = useStableCallback(() => {
42
- resetStoresForScreen(current);
43
- });
44
-
45
- const handleCloseEnd = useStableCallback((finished: boolean) => {
46
- deactivateHighRefreshRate();
47
- if (!finished) {
48
- return;
49
- }
50
- handleCloseRoute({ route: current.route });
51
- });
52
-
53
- useAnimatedReaction(
54
- () => ({
55
- keys: closingRouteKeysShared.value,
56
- }),
57
- ({ keys }) => {
58
- if (!keys.includes(current.route.key)) {
59
- return;
60
- }
61
-
62
- runOnJS(activateHighRefreshRate)();
63
- startScreenTransition({
64
- target: "close",
65
- spec: current.options.transitionSpec,
66
- animations,
67
- onAnimationFinish: handleCloseEnd,
68
- });
69
- },
70
- );
71
-
72
- useLayoutEffect(() => {
73
- handleInitialize();
74
- return () => {
75
- handleCleanup();
76
- };
77
- }, [handleInitialize, handleCleanup]);
78
-
79
- return children;
80
- };