@amazon-devices/react-native-screens 3.0.9000000000 → 3.0.9000000003

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 (274) hide show
  1. package/SystemModules/amzn__react-native-screens-3.private.modules.txt +116 -61
  2. package/kepler-compatibility.json +5 -2
  3. package/lib/commonjs/TransitionProgressContext.js.map +1 -1
  4. package/lib/commonjs/components/DebugContainer.js.map +1 -1
  5. package/lib/commonjs/components/DebugContainer.web.js.map +1 -1
  6. package/lib/commonjs/components/Screen.web.js.map +1 -1
  7. package/lib/commonjs/components/ScreenStackHeaderConfig.js.map +1 -1
  8. package/lib/commonjs/components/ScreenStackHeaderConfig.web.js.map +1 -1
  9. package/lib/commonjs/components/ScreenStackItem.js.map +1 -1
  10. package/lib/commonjs/components/SearchBar.js.map +1 -1
  11. package/lib/commonjs/components/helpers/usePrevious.js.map +1 -1
  12. package/lib/commonjs/gesture-handler/ScreenGestureDetector.js.map +1 -1
  13. package/lib/commonjs/index.js +0 -210
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  16. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -1
  17. package/lib/commonjs/native-stack/utils/HeaderHeightContext.js.map +1 -1
  18. package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  19. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -1
  20. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
  21. package/lib/commonjs/native-stack/utils/useHeaderHeight.js.map +1 -1
  22. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  23. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  24. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js.map +1 -1
  25. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  26. package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
  27. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js.map +1 -1
  28. package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js.map +1 -1
  29. package/lib/commonjs/useTransitionProgress.js.map +1 -1
  30. package/lib/module/components/Screen.web.js.map +1 -1
  31. package/lib/module/components/ScreenStackHeaderConfig.js.map +1 -1
  32. package/lib/module/components/ScreenStackHeaderConfig.web.js.map +1 -1
  33. package/lib/module/components/SearchBar.js.map +1 -1
  34. package/lib/module/components/helpers/usePrevious.js.map +1 -1
  35. package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -1
  36. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  37. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  38. package/lib/typescript/components/Screen.web.d.ts +1 -1
  39. package/lib/typescript/components/Screen.web.d.ts.map +1 -1
  40. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts +5 -5
  41. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts.map +1 -1
  42. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts +6 -6
  43. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts.map +1 -1
  44. package/lib/typescript/components/SearchBar.d.ts.map +1 -1
  45. package/lib/typescript/components/helpers/usePrevious.d.ts.map +1 -1
  46. package/lib/typescript/native-stack/utils/useBackPressSubscription.d.ts.map +1 -1
  47. package/lib/typescript/native-stack/views/HeaderConfig.d.ts +2 -2
  48. package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -1
  49. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
  50. package/lib/typescript/types.d.ts +2 -2
  51. package/lib/typescript/types.d.ts.map +1 -1
  52. package/oss-attribution/attribution.txt +77 -0
  53. package/oss-attribution/licenseInfos.json +27 -0
  54. package/package.json +1 -1
  55. package/src/index.tsx +0 -55
  56. package/SystemBundles/31d5b6b69618249f6233b73a1de7c4d890c86be7ccb031ce7cf2dcc41783f9f7.bundle +0 -45301
  57. package/SystemBundles/31d5b6b69618249f6233b73a1de7c4d890c86be7ccb031ce7cf2dcc41783f9f7.map +0 -13711
  58. package/lib/commonjs/TransitionProgressContext.js +0 -12
  59. package/lib/commonjs/components/DebugContainer.js +0 -39
  60. package/lib/commonjs/components/DebugContainer.web.js +0 -15
  61. package/lib/commonjs/components/FullWindowOverlay.js +0 -31
  62. package/lib/commonjs/components/FullWindowOverlay.web.js +0 -9
  63. package/lib/commonjs/components/Screen.js +0 -286
  64. package/lib/commonjs/components/Screen.web.js +0 -47
  65. package/lib/commonjs/components/ScreenContainer.js +0 -32
  66. package/lib/commonjs/components/ScreenContainer.web.js +0 -10
  67. package/lib/commonjs/components/ScreenContentWrapper.js +0 -17
  68. package/lib/commonjs/components/ScreenContentWrapper.web.js +0 -10
  69. package/lib/commonjs/components/ScreenFooter.js +0 -25
  70. package/lib/commonjs/components/ScreenFooter.web.js +0 -11
  71. package/lib/commonjs/components/ScreenStack.js +0 -67
  72. package/lib/commonjs/components/ScreenStack.web.js +0 -10
  73. package/lib/commonjs/components/ScreenStackHeaderConfig.js +0 -90
  74. package/lib/commonjs/components/ScreenStackHeaderConfig.web.js +0 -27
  75. package/lib/commonjs/components/ScreenStackItem.js +0 -107
  76. package/lib/commonjs/components/SearchBar.js +0 -63
  77. package/lib/commonjs/components/SearchBar.web.js +0 -10
  78. package/lib/commonjs/components/helpers/DelayedFreeze.js +0 -31
  79. package/lib/commonjs/components/helpers/usePrevious.js +0 -15
  80. package/lib/commonjs/contexts.js +0 -11
  81. package/lib/commonjs/core.js +0 -40
  82. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +0 -26
  83. package/lib/commonjs/fabric/ModalScreenNativeComponent.js +0 -14
  84. package/lib/commonjs/fabric/NativeScreensModule.js +0 -10
  85. package/lib/commonjs/fabric/NativeScreensModule.web.js +0 -8
  86. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +0 -30
  87. package/lib/commonjs/fabric/ScreenContentWrapperNativeComponent.js +0 -18
  88. package/lib/commonjs/fabric/ScreenFooterNativeComponent.js +0 -10
  89. package/lib/commonjs/fabric/ScreenNativeComponent.js +0 -70
  90. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +0 -12
  91. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js +0 -32
  92. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js +0 -15
  93. package/lib/commonjs/fabric/ScreenStackNativeComponent.js +0 -32
  94. package/lib/commonjs/fabric/SearchBarNativeComponent.js +0 -18
  95. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js +0 -19
  96. package/lib/commonjs/gesture-handler/RNScreensTurboModule.js +0 -8
  97. package/lib/commonjs/gesture-handler/ScreenGestureDetector.js +0 -201
  98. package/lib/commonjs/gesture-handler/constraints.js +0 -64
  99. package/lib/commonjs/gesture-handler/defaults.js +0 -45
  100. package/lib/commonjs/gesture-handler/fabricUtils.js +0 -66
  101. package/lib/commonjs/gesture-handler/fabricUtils.web.js +0 -17
  102. package/lib/commonjs/gesture-handler/index.js +0 -14
  103. package/lib/commonjs/native-stack/contexts/GHContext.js +0 -12
  104. package/lib/commonjs/native-stack/index.js +0 -49
  105. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +0 -76
  106. package/lib/commonjs/native-stack/types.js +0 -6
  107. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js +0 -12
  108. package/lib/commonjs/native-stack/utils/HeaderHeightContext.js +0 -12
  109. package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js +0 -75
  110. package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js +0 -35
  111. package/lib/commonjs/native-stack/utils/getStatusBarHeight.js +0 -22
  112. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js +0 -19
  113. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js +0 -52
  114. package/lib/commonjs/native-stack/utils/useHeaderHeight.js +0 -19
  115. package/lib/commonjs/native-stack/views/FontProcessor.js +0 -19
  116. package/lib/commonjs/native-stack/views/FooterComponent.js +0 -17
  117. package/lib/commonjs/native-stack/views/HeaderConfig.js +0 -149
  118. package/lib/commonjs/native-stack/views/NativeStackView.js +0 -420
  119. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js +0 -12
  120. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +0 -95
  121. package/lib/commonjs/reanimated/ReanimatedScreen.js +0 -22
  122. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +0 -39
  123. package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js +0 -12
  124. package/lib/commonjs/reanimated/index.js +0 -28
  125. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js +0 -19
  126. package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js +0 -19
  127. package/lib/commonjs/types.js +0 -6
  128. package/lib/commonjs/useTransitionProgress.js +0 -19
  129. package/lib/commonjs/utils.js +0 -43
  130. package/lib/module/TransitionProgressContext.js +0 -5
  131. package/lib/module/components/DebugContainer.js +0 -30
  132. package/lib/module/components/DebugContainer.web.js +0 -6
  133. package/lib/module/components/FullWindowOverlay.js +0 -24
  134. package/lib/module/components/FullWindowOverlay.web.js +0 -3
  135. package/lib/module/components/Screen.js +0 -282
  136. package/lib/module/components/Screen.web.js +0 -40
  137. package/lib/module/components/ScreenContainer.js +0 -26
  138. package/lib/module/components/ScreenContainer.web.js +0 -4
  139. package/lib/module/components/ScreenContentWrapper.js +0 -10
  140. package/lib/module/components/ScreenContentWrapper.web.js +0 -4
  141. package/lib/module/components/ScreenFooter.js +0 -18
  142. package/lib/module/components/ScreenFooter.web.js +0 -6
  143. package/lib/module/components/ScreenStack.js +0 -63
  144. package/lib/module/components/ScreenStack.web.js +0 -4
  145. package/lib/module/components/ScreenStackHeaderConfig.js +0 -81
  146. package/lib/module/components/ScreenStackHeaderConfig.web.js +0 -14
  147. package/lib/module/components/ScreenStackItem.js +0 -98
  148. package/lib/module/components/SearchBar.js +0 -57
  149. package/lib/module/components/SearchBar.web.js +0 -4
  150. package/lib/module/components/helpers/DelayedFreeze.js +0 -24
  151. package/lib/module/components/helpers/usePrevious.js +0 -9
  152. package/lib/module/contexts.js +0 -4
  153. package/lib/module/core.js +0 -31
  154. package/lib/module/fabric/FullWindowOverlayNativeComponent.js +0 -20
  155. package/lib/module/fabric/ModalScreenNativeComponent.js +0 -10
  156. package/lib/module/fabric/NativeScreensModule.js +0 -5
  157. package/lib/module/fabric/NativeScreensModule.web.js +0 -2
  158. package/lib/module/fabric/ScreenContainerNativeComponent.js +0 -24
  159. package/lib/module/fabric/ScreenContentWrapperNativeComponent.js +0 -10
  160. package/lib/module/fabric/ScreenFooterNativeComponent.js +0 -3
  161. package/lib/module/fabric/ScreenNativeComponent.js +0 -66
  162. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js +0 -6
  163. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js +0 -29
  164. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js +0 -11
  165. package/lib/module/fabric/ScreenStackNativeComponent.js +0 -28
  166. package/lib/module/fabric/SearchBarNativeComponent.js +0 -12
  167. package/lib/module/gesture-handler/GestureDetectorProvider.js +0 -12
  168. package/lib/module/gesture-handler/RNScreensTurboModule.js +0 -2
  169. package/lib/module/gesture-handler/ScreenGestureDetector.js +0 -193
  170. package/lib/module/gesture-handler/constraints.js +0 -56
  171. package/lib/module/gesture-handler/defaults.js +0 -39
  172. package/lib/module/gesture-handler/fabricUtils.js +0 -61
  173. package/lib/module/gesture-handler/fabricUtils.web.js +0 -10
  174. package/lib/module/gesture-handler/index.js +0 -5
  175. package/lib/module/index.js +0 -33
  176. package/lib/module/native-stack/contexts/GHContext.js +0 -6
  177. package/lib/module/native-stack/index.js +0 -22
  178. package/lib/module/native-stack/navigators/createNativeStackNavigator.js +0 -73
  179. package/lib/module/native-stack/types.js +0 -2
  180. package/lib/module/native-stack/utils/AnimatedHeaderHeightContext.js +0 -4
  181. package/lib/module/native-stack/utils/HeaderHeightContext.js +0 -4
  182. package/lib/module/native-stack/utils/SafeAreaProviderCompat.js +0 -68
  183. package/lib/module/native-stack/utils/getDefaultHeaderHeight.js +0 -29
  184. package/lib/module/native-stack/utils/getStatusBarHeight.js +0 -16
  185. package/lib/module/native-stack/utils/useAnimatedHeaderHeight.js +0 -10
  186. package/lib/module/native-stack/utils/useBackPressSubscription.js +0 -45
  187. package/lib/module/native-stack/utils/useHeaderHeight.js +0 -10
  188. package/lib/module/native-stack/views/FontProcessor.js +0 -12
  189. package/lib/module/native-stack/views/FooterComponent.js +0 -10
  190. package/lib/module/native-stack/views/HeaderConfig.js +0 -139
  191. package/lib/module/native-stack/views/NativeStackView.js +0 -423
  192. package/lib/module/reanimated/ReanimatedHeaderHeightContext.js +0 -5
  193. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +0 -93
  194. package/lib/module/reanimated/ReanimatedScreen.js +0 -16
  195. package/lib/module/reanimated/ReanimatedScreenProvider.js +0 -32
  196. package/lib/module/reanimated/ReanimatedTransitionProgressContext.js +0 -5
  197. package/lib/module/reanimated/index.js +0 -4
  198. package/lib/module/reanimated/useReanimatedHeaderHeight.js +0 -10
  199. package/lib/module/reanimated/useReanimatedTransitionProgress.js +0 -10
  200. package/lib/module/types.js +0 -2
  201. package/lib/module/useTransitionProgress.js +0 -10
  202. package/lib/module/utils.js +0 -35
  203. package/src/TransitionProgressContext.tsx +0 -14
  204. package/src/components/DebugContainer.tsx +0 -46
  205. package/src/components/DebugContainer.web.tsx +0 -7
  206. package/src/components/FullWindowOverlay.tsx +0 -33
  207. package/src/components/FullWindowOverlay.web.tsx +0 -6
  208. package/src/components/Screen.tsx +0 -392
  209. package/src/components/Screen.web.tsx +0 -46
  210. package/src/components/ScreenContainer.tsx +0 -28
  211. package/src/components/ScreenContainer.web.tsx +0 -5
  212. package/src/components/ScreenContentWrapper.tsx +0 -9
  213. package/src/components/ScreenContentWrapper.web.tsx +0 -5
  214. package/src/components/ScreenFooter.tsx +0 -20
  215. package/src/components/ScreenFooter.web.tsx +0 -7
  216. package/src/components/ScreenStack.tsx +0 -112
  217. package/src/components/ScreenStack.web.tsx +0 -5
  218. package/src/components/ScreenStackHeaderConfig.tsx +0 -122
  219. package/src/components/ScreenStackHeaderConfig.web.tsx +0 -39
  220. package/src/components/ScreenStackItem.tsx +0 -174
  221. package/src/components/SearchBar.tsx +0 -102
  222. package/src/components/SearchBar.web.tsx +0 -5
  223. package/src/components/helpers/DelayedFreeze.tsx +0 -27
  224. package/src/components/helpers/usePrevious.tsx +0 -11
  225. package/src/contexts.tsx +0 -9
  226. package/src/core.ts +0 -45
  227. package/src/fabric/FullWindowOverlayNativeComponent.ts +0 -23
  228. package/src/fabric/ModalScreenNativeComponent.ts +0 -115
  229. package/src/fabric/NativeScreensModule.ts +0 -8
  230. package/src/fabric/NativeScreensModule.web.ts +0 -1
  231. package/src/fabric/ScreenContainerNativeComponent.ts +0 -28
  232. package/src/fabric/ScreenContentWrapperNativeComponent.ts +0 -14
  233. package/src/fabric/ScreenFooterNativeComponent.ts +0 -6
  234. package/src/fabric/ScreenNativeComponent.ts +0 -171
  235. package/src/fabric/ScreenNavigationContainerNativeComponent.ts +0 -12
  236. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +0 -97
  237. package/src/fabric/ScreenStackHeaderSubviewNativeComponent.ts +0 -26
  238. package/src/fabric/ScreenStackNativeComponent.ts +0 -34
  239. package/src/fabric/SearchBarNativeComponent.ts +0 -83
  240. package/src/gesture-handler/GestureDetectorProvider.tsx +0 -16
  241. package/src/gesture-handler/RNScreensTurboModule.ts +0 -13
  242. package/src/gesture-handler/ScreenGestureDetector.tsx +0 -241
  243. package/src/gesture-handler/constraints.ts +0 -87
  244. package/src/gesture-handler/defaults.ts +0 -46
  245. package/src/gesture-handler/fabricUtils.ts +0 -86
  246. package/src/gesture-handler/fabricUtils.web.ts +0 -10
  247. package/src/gesture-handler/index.tsx +0 -4
  248. package/src/native-stack/contexts/GHContext.tsx +0 -9
  249. package/src/native-stack/index.tsx +0 -27
  250. package/src/native-stack/navigators/createNativeStackNavigator.tsx +0 -110
  251. package/src/native-stack/types.tsx +0 -659
  252. package/src/native-stack/utils/AnimatedHeaderHeightContext.tsx +0 -8
  253. package/src/native-stack/utils/HeaderHeightContext.tsx +0 -5
  254. package/src/native-stack/utils/SafeAreaProviderCompat.tsx +0 -78
  255. package/src/native-stack/utils/getDefaultHeaderHeight.tsx +0 -41
  256. package/src/native-stack/utils/getStatusBarHeight.tsx +0 -22
  257. package/src/native-stack/utils/useAnimatedHeaderHeight.tsx +0 -15
  258. package/src/native-stack/utils/useBackPressSubscription.tsx +0 -66
  259. package/src/native-stack/utils/useHeaderHeight.tsx +0 -15
  260. package/src/native-stack/views/FontProcessor.tsx +0 -14
  261. package/src/native-stack/views/FooterComponent.tsx +0 -10
  262. package/src/native-stack/views/HeaderConfig.tsx +0 -202
  263. package/src/native-stack/views/NativeStackView.tsx +0 -550
  264. package/src/reanimated/ReanimatedHeaderHeightContext.tsx +0 -7
  265. package/src/reanimated/ReanimatedNativeStackScreen.tsx +0 -132
  266. package/src/reanimated/ReanimatedScreen.tsx +0 -26
  267. package/src/reanimated/ReanimatedScreenProvider.tsx +0 -43
  268. package/src/reanimated/ReanimatedTransitionProgressContext.tsx +0 -13
  269. package/src/reanimated/index.tsx +0 -3
  270. package/src/reanimated/useReanimatedHeaderHeight.tsx +0 -14
  271. package/src/reanimated/useReanimatedTransitionProgress.tsx +0 -14
  272. package/src/types.tsx +0 -869
  273. package/src/useTransitionProgress.tsx +0 -15
  274. package/src/utils.ts +0 -40
@@ -1,241 +0,0 @@
1
- import React, { useEffect } from 'react';
2
- import { Dimensions, Platform, findNodeHandle } from 'react-native';
3
- import {
4
- GestureDetector,
5
- Gesture,
6
- PanGestureHandlerEventPayload,
7
- GestureUpdateEvent,
8
- } from 'react-native-gesture-handler';
9
- import {
10
- useSharedValue,
11
- measure,
12
- startScreenTransition,
13
- finishScreenTransition,
14
- makeMutable,
15
- runOnUI,
16
- } from 'react-native-reanimated';
17
- import { getShadowNodeWrapperAndTagFromRef, isFabric } from './fabricUtils';
18
- import { RNScreensTurboModule } from './RNScreensTurboModule';
19
- import { DefaultEvent, DefaultScreenDimensions } from './defaults';
20
- import {
21
- checkBoundaries,
22
- checkIfTransitionCancelled,
23
- getAnimationForTransition,
24
- } from './constraints';
25
- import { GestureProviderProps } from '../types';
26
-
27
- const EmptyGestureHandler = Gesture.Fling();
28
-
29
- const ScreenGestureDetector = ({
30
- children,
31
- gestureDetectorBridge,
32
- goBackGesture,
33
- screenEdgeGesture,
34
- transitionAnimation: customTransitionAnimation,
35
- screensRefs,
36
- currentScreenId,
37
- }: GestureProviderProps) => {
38
- const sharedEvent = useSharedValue(DefaultEvent);
39
- const startingGesturePosition = useSharedValue(DefaultEvent);
40
- const canPerformUpdates = makeMutable(false);
41
- const transitionAnimation = getAnimationForTransition(
42
- goBackGesture,
43
- customTransitionAnimation,
44
- );
45
- const screenTransitionConfig = makeMutable({
46
- stackTag: -1,
47
- belowTopScreenId: -1,
48
- topScreenId: -1,
49
- sharedEvent,
50
- startingGesturePosition,
51
- screenTransition: transitionAnimation,
52
- isTransitionCanceled: false,
53
- goBackGesture: goBackGesture ?? 'swipeRight',
54
- screenDimensions: DefaultScreenDimensions,
55
- onFinishAnimation: () => {
56
- 'worklet';
57
- },
58
- });
59
- const stackTag = makeMutable(-1);
60
- const screenTagToNodeWrapperUI = makeMutable<Record<string, any>>({});
61
- const IS_FABRIC = isFabric();
62
-
63
- gestureDetectorBridge.current.stackUseEffectCallback = stackRef => {
64
- if (!goBackGesture) {
65
- return;
66
- }
67
- stackTag.value = findNodeHandle(stackRef.current as any) as number;
68
- if (Platform.OS === 'ios') {
69
- runOnUI(() => {
70
- RNScreensTurboModule.disableSwipeBackForTopScreen(stackTag.value);
71
- })();
72
- }
73
- };
74
-
75
- useEffect(() => {
76
- if (!IS_FABRIC || !goBackGesture || screensRefs === undefined) {
77
- return;
78
- }
79
- const screenTagToNodeWrapper: Record<string, Record<string, unknown>> = {};
80
- for (const key in screensRefs.current) {
81
- const screenRef = screensRefs.current[key];
82
- const screenData = getShadowNodeWrapperAndTagFromRef(screenRef.current);
83
- if (screenData.tag && screenData.shadowNodeWrapper) {
84
- screenTagToNodeWrapper[screenData.tag] = screenData.shadowNodeWrapper;
85
- } else {
86
- console.warn('[RNScreens] Failed to find tag for screen.');
87
- }
88
- }
89
- screenTagToNodeWrapperUI.value = screenTagToNodeWrapper;
90
- }, [currentScreenId, goBackGesture]);
91
-
92
- function computeProgress(
93
- event: GestureUpdateEvent<PanGestureHandlerEventPayload>,
94
- ) {
95
- 'worklet';
96
- let progress = 0;
97
- const screenDimensions = screenTransitionConfig.value.screenDimensions;
98
- const startingPosition = startingGesturePosition.value;
99
- if (goBackGesture === 'swipeRight') {
100
- progress =
101
- event.translationX /
102
- (screenDimensions.width - startingPosition.absoluteX);
103
- } else if (goBackGesture === 'swipeLeft') {
104
- progress = (-1 * event.translationX) / startingPosition.absoluteX;
105
- } else if (goBackGesture === 'swipeDown') {
106
- progress =
107
- (-1 * event.translationY) /
108
- (screenDimensions.height - startingPosition.absoluteY);
109
- } else if (goBackGesture === 'swipeUp') {
110
- progress = event.translationY / startingPosition.absoluteY;
111
- } else if (goBackGesture === 'horizontalSwipe') {
112
- progress = Math.abs(event.translationX / screenDimensions.width / 2);
113
- } else if (goBackGesture === 'verticalSwipe') {
114
- progress = Math.abs(event.translationY / screenDimensions.height / 2);
115
- } else if (goBackGesture === 'twoDimensionalSwipe') {
116
- const progressX = Math.abs(
117
- event.translationX / screenDimensions.width / 2,
118
- );
119
- const progressY = Math.abs(
120
- event.translationY / screenDimensions.height / 2,
121
- );
122
- progress = Math.max(progressX, progressY);
123
- }
124
- return progress;
125
- }
126
-
127
- function onStart(event: GestureUpdateEvent<PanGestureHandlerEventPayload>) {
128
- 'worklet';
129
- sharedEvent.value = event;
130
- const transitionConfig = screenTransitionConfig.value;
131
- const transitionData = RNScreensTurboModule.startTransition(stackTag.value);
132
- if (transitionData.canStartTransition === false) {
133
- canPerformUpdates.value = false;
134
- return;
135
- }
136
-
137
- if (IS_FABRIC) {
138
- transitionConfig.topScreenId =
139
- screenTagToNodeWrapperUI.value[transitionData.topScreenTag];
140
- transitionConfig.belowTopScreenId =
141
- screenTagToNodeWrapperUI.value[transitionData.belowTopScreenTag];
142
- } else {
143
- transitionConfig.topScreenId = transitionData.topScreenTag;
144
- transitionConfig.belowTopScreenId = transitionData.belowTopScreenTag;
145
- }
146
-
147
- transitionConfig.stackTag = stackTag.value;
148
- startingGesturePosition.value = event;
149
- const animatedRefMock = () => {
150
- return screenTransitionConfig.value.topScreenId;
151
- };
152
- const screenSize = measure(animatedRefMock as any);
153
- if (screenSize == null) {
154
- throw new Error('[RNScreens] Failed to measure screen.');
155
- }
156
- if (screenSize == null) {
157
- canPerformUpdates.value = false;
158
- RNScreensTurboModule.finishTransition(stackTag.value, true);
159
- return;
160
- }
161
- transitionConfig.screenDimensions = screenSize;
162
- startScreenTransition(transitionConfig);
163
- canPerformUpdates.value = true;
164
- }
165
-
166
- function onUpdate(event: GestureUpdateEvent<PanGestureHandlerEventPayload>) {
167
- 'worklet';
168
- if (!canPerformUpdates.value) {
169
- return;
170
- }
171
- checkBoundaries(goBackGesture, event);
172
- const progress = computeProgress(event);
173
- sharedEvent.value = event;
174
- const stackTag = screenTransitionConfig.value.stackTag;
175
- RNScreensTurboModule.updateTransition(stackTag, progress);
176
- }
177
-
178
- function onEnd(event: GestureUpdateEvent<PanGestureHandlerEventPayload>) {
179
- 'worklet';
180
- if (!canPerformUpdates.value) {
181
- return;
182
- }
183
-
184
- const velocityFactor = 0.3;
185
- const screenSize = screenTransitionConfig.value.screenDimensions;
186
- const distanceX =
187
- event.translationX + Math.min(event.velocityX * velocityFactor, 100);
188
- const distanceY =
189
- event.translationY + Math.min(event.velocityY * velocityFactor, 100);
190
- const requiredXDistance = screenSize.width / 2;
191
- const requiredYDistance = screenSize.height / 2;
192
- const isTransitionCanceled = checkIfTransitionCancelled(
193
- goBackGesture,
194
- distanceX,
195
- requiredXDistance,
196
- distanceY,
197
- requiredYDistance,
198
- );
199
- const stackTag = screenTransitionConfig.value.stackTag;
200
- screenTransitionConfig.value.onFinishAnimation = () => {
201
- RNScreensTurboModule.finishTransition(stackTag, isTransitionCanceled);
202
- };
203
- screenTransitionConfig.value.isTransitionCanceled = isTransitionCanceled;
204
- finishScreenTransition(screenTransitionConfig.value);
205
- }
206
-
207
- let panGesture = Gesture.Pan()
208
- .onStart(onStart)
209
- .onUpdate(onUpdate)
210
- .onEnd(onEnd);
211
-
212
- if (screenEdgeGesture) {
213
- const HIT_SLOP_SIZE = 50;
214
- const ACTIVATION_DISTANCE = 30;
215
- if (goBackGesture === 'swipeRight') {
216
- panGesture = panGesture
217
- .activeOffsetX(ACTIVATION_DISTANCE)
218
- .hitSlop({ left: 0, top: 0, width: HIT_SLOP_SIZE });
219
- } else if (goBackGesture === 'swipeLeft') {
220
- panGesture = panGesture
221
- .activeOffsetX(-ACTIVATION_DISTANCE)
222
- .hitSlop({ right: 0, top: 0, width: HIT_SLOP_SIZE });
223
- } else if (goBackGesture === 'swipeDown') {
224
- panGesture = panGesture
225
- .activeOffsetY(ACTIVATION_DISTANCE)
226
- .hitSlop({ top: 0, height: Dimensions.get('window').height * 0.2 });
227
- // workaround, because we don't have access to header height
228
- } else if (goBackGesture === 'swipeUp') {
229
- panGesture = panGesture
230
- .activeOffsetY(-ACTIVATION_DISTANCE)
231
- .hitSlop({ bottom: 0, height: HIT_SLOP_SIZE });
232
- }
233
- }
234
- return (
235
- <GestureDetector gesture={goBackGesture ? panGesture : EmptyGestureHandler}>
236
- {children}
237
- </GestureDetector>
238
- );
239
- };
240
-
241
- export default ScreenGestureDetector;
@@ -1,87 +0,0 @@
1
- import { ScreenTransition } from 'react-native-reanimated';
2
- import {
3
- AnimatedScreenTransition,
4
- GoBackGesture,
5
- PanGestureHandlerEventPayload,
6
- } from '../native-stack/types';
7
- import { AnimationForGesture } from './defaults';
8
- import { GestureUpdateEvent } from 'react-native-gesture-handler';
9
-
10
- const SupportedGestures = [
11
- 'swipeRight',
12
- 'swipeLeft',
13
- 'swipeDown',
14
- 'swipeUp',
15
- 'horizontalSwipe',
16
- 'verticalSwipe',
17
- 'twoDimensionalSwipe',
18
- ];
19
-
20
- export function getAnimationForTransition(
21
- goBackGesture: GoBackGesture | undefined,
22
- customTransitionAnimation: AnimatedScreenTransition | undefined,
23
- ) {
24
- let transitionAnimation = ScreenTransition.SwipeRight;
25
- if (customTransitionAnimation) {
26
- transitionAnimation = customTransitionAnimation;
27
- if (!goBackGesture) {
28
- throw new Error(
29
- '[RNScreens] You have to specify `goBackGesture` when using `transitionAnimation`.',
30
- );
31
- }
32
- } else {
33
- if (!!goBackGesture && SupportedGestures.includes(goBackGesture)) {
34
- transitionAnimation = AnimationForGesture[goBackGesture];
35
- } else if (goBackGesture !== undefined) {
36
- throw new Error(
37
- `[RNScreens] Unknown goBackGesture parameter has been specified: ${goBackGesture}.`,
38
- );
39
- }
40
- }
41
- return transitionAnimation;
42
- }
43
-
44
- export function checkBoundaries(
45
- goBackGesture: string | undefined,
46
- event: GestureUpdateEvent<PanGestureHandlerEventPayload>,
47
- ) {
48
- 'worklet';
49
- if (goBackGesture === 'swipeRight' && event.translationX < 0) {
50
- event.translationX = 0;
51
- } else if (goBackGesture === 'swipeLeft' && event.translationX > 0) {
52
- event.translationX = 0;
53
- } else if (goBackGesture === 'swipeDown' && event.translationY < 0) {
54
- event.translationY = 0;
55
- } else if (goBackGesture === 'swipeUp' && event.translationY > 0) {
56
- event.translationY = 0;
57
- }
58
- }
59
-
60
- export function checkIfTransitionCancelled(
61
- goBackGesture: string | undefined,
62
- distanceX: number,
63
- requiredXDistance: number,
64
- distanceY: number,
65
- requiredYDistance: number,
66
- ) {
67
- 'worklet';
68
- let isTransitionCanceled = false;
69
- if (goBackGesture === 'swipeRight') {
70
- isTransitionCanceled = distanceX < requiredXDistance;
71
- } else if (goBackGesture === 'swipeLeft') {
72
- isTransitionCanceled = -distanceX < requiredXDistance;
73
- } else if (goBackGesture === 'horizontalSwipe') {
74
- isTransitionCanceled = Math.abs(distanceX) < requiredXDistance;
75
- } else if (goBackGesture === 'swipeUp') {
76
- isTransitionCanceled = -distanceY < requiredYDistance;
77
- } else if (goBackGesture === 'swipeDown') {
78
- isTransitionCanceled = distanceY < requiredYDistance;
79
- } else if (goBackGesture === 'verticalSwipe') {
80
- isTransitionCanceled = Math.abs(distanceY) < requiredYDistance;
81
- } else if (goBackGesture === 'twoDimensionalSwipe') {
82
- const isCanceledHorizontally = Math.abs(distanceX) < requiredXDistance;
83
- const isCanceledVertically = Math.abs(distanceY) < requiredYDistance;
84
- isTransitionCanceled = isCanceledHorizontally && isCanceledVertically;
85
- }
86
- return isTransitionCanceled;
87
- }
@@ -1,46 +0,0 @@
1
- import {
2
- GestureUpdateEvent,
3
- PanGestureHandlerEventPayload,
4
- PointerType,
5
- } from 'react-native-gesture-handler';
6
- import { ScreenTransition } from 'react-native-reanimated';
7
-
8
- export const DefaultEvent: GestureUpdateEvent<PanGestureHandlerEventPayload> = {
9
- absoluteX: 0,
10
- absoluteY: 0,
11
- handlerTag: 0,
12
- numberOfPointers: 0,
13
- state: 0,
14
- translationX: 0,
15
- translationY: 0,
16
- velocityX: 0,
17
- velocityY: 0,
18
- x: 0,
19
- y: 0,
20
-
21
- // These two were added in recent versions of gesture handler
22
- // and they are required to specify. This should be backward
23
- // compatible unless they strictly parse the objects, which seems
24
- // not likely. PointerType is present since 2.16.0, StylusData since 2.20.0
25
- pointerType: PointerType.TOUCH,
26
- stylusData: undefined,
27
- };
28
-
29
- export const DefaultScreenDimensions = {
30
- width: 0,
31
- height: 0,
32
- x: 0,
33
- y: 0,
34
- pageX: 0,
35
- pageY: 0,
36
- };
37
-
38
- export const AnimationForGesture = {
39
- swipeRight: ScreenTransition.SwipeRight,
40
- swipeLeft: ScreenTransition.SwipeLeft,
41
- swipeDown: ScreenTransition.SwipeDown,
42
- swipeUp: ScreenTransition.SwipeUp,
43
- horizontalSwipe: ScreenTransition.Horizontal,
44
- verticalSwipe: ScreenTransition.Vertical,
45
- twoDimensionalSwipe: ScreenTransition.TwoDimensional,
46
- };
@@ -1,86 +0,0 @@
1
- 'use strict';
2
-
3
- import { View } from 'react-native';
4
-
5
- /* eslint-disable */
6
-
7
- type LocalGlobal = typeof global & Record<string, unknown>;
8
-
9
- export function isFabric() {
10
- return !!(global as LocalGlobal)._IS_FABRIC;
11
- }
12
-
13
- export type ShadowNodeWrapper = {
14
- __hostObjectShadowNodeWrapper: never;
15
- };
16
-
17
- let findHostInstance_DEPRECATED: (ref: unknown) => void;
18
-
19
- let getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {
20
- stateNode: { node: unknown };
21
- };
22
-
23
- // Taken and modifies from reanimated
24
- export function getShadowNodeWrapperAndTagFromRef(ref: View | null): {
25
- shadowNodeWrapper: ShadowNodeWrapper;
26
- tag: number;
27
- } {
28
- // load findHostInstance_DEPRECATED lazily because it may not be available before render
29
- if (findHostInstance_DEPRECATED === undefined) {
30
- try {
31
- findHostInstance_DEPRECATED =
32
- require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
33
- } catch (e) {
34
- findHostInstance_DEPRECATED = (_ref: unknown) => null;
35
- }
36
- }
37
-
38
- if (getInternalInstanceHandleFromPublicInstance === undefined) {
39
- try {
40
- getInternalInstanceHandleFromPublicInstance =
41
- require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
42
- .getInternalInstanceHandleFromPublicInstance ??
43
- ((_ref: any) => _ref._internalInstanceHandle);
44
- } catch (e) {
45
- getInternalInstanceHandleFromPublicInstance = (_ref: any) =>
46
- _ref._internalInstanceHandle;
47
- }
48
- }
49
-
50
- // taken from https://github.com/facebook/react-native/commit/803bb16531697233686efd475f004c1643e03617#diff-d8172256c6d63b5d32db10e54d7b10f37a26b337d5280d89f5bfd7bcea778292R196
51
- // @ts-ignore some weird stuff on RN 0.74 - see examples with scrollView
52
- const scrollViewRef = ref?.getScrollResponder?.()?.getNativeScrollRef?.();
53
- // @ts-ignore some weird stuff on RN 0.74 - see examples with scrollView
54
- const otherScrollViewRef = ref?.getNativeScrollRef?.();
55
- // @ts-ignore some weird stuff on RN 0.74 - see setNativeProps example
56
- const textInputRef = ref?.__internalInstanceHandle?.stateNode?.node;
57
-
58
- let resolvedRef;
59
- if (scrollViewRef) {
60
- resolvedRef = {
61
- shadowNodeWrapper: scrollViewRef.__internalInstanceHandle.stateNode.node,
62
- tag: scrollViewRef._nativeTag,
63
- };
64
- } else if (otherScrollViewRef) {
65
- resolvedRef = {
66
- shadowNodeWrapper:
67
- otherScrollViewRef.__internalInstanceHandle.stateNode.node,
68
- tag: otherScrollViewRef.__nativeTag,
69
- };
70
- } else if (textInputRef) {
71
- resolvedRef = {
72
- shadowNodeWrapper: textInputRef,
73
- tag: (ref as any)?.__nativeTag,
74
- };
75
- } else {
76
- const hostInstance = findHostInstance_DEPRECATED(ref);
77
- resolvedRef = {
78
- shadowNodeWrapper:
79
- getInternalInstanceHandleFromPublicInstance(hostInstance).stateNode
80
- .node,
81
- tag: (hostInstance as any)?._nativeTag,
82
- };
83
- }
84
-
85
- return resolvedRef;
86
- }
@@ -1,10 +0,0 @@
1
- export function isFabric() {
2
- return false;
3
- }
4
-
5
- export function getShadowNodeWrapperAndTagFromRef() {
6
- return {
7
- shadowNodeWrapper: undefined,
8
- tag: undefined,
9
- };
10
- }
@@ -1,4 +0,0 @@
1
- /*
2
- * Providers
3
- */
4
- export { default as GestureDetectorProvider } from './GestureDetectorProvider';
@@ -1,9 +0,0 @@
1
- 'use client';
2
-
3
- import React, { PropsWithChildren } from 'react';
4
- import { GestureProviderProps } from '../types';
5
-
6
- // context to be used when the user wants full screen swipe (see `gesture-handler` folder in repo)
7
- export const GHContext = React.createContext(
8
- (props: PropsWithChildren<GestureProviderProps>) => <>{props.children}</>,
9
- );
@@ -1,27 +0,0 @@
1
- /**
2
- * Navigators
3
- */
4
- export { default as createNativeStackNavigator } from './navigators/createNativeStackNavigator';
5
-
6
- /**
7
- * Views
8
- */
9
- export { default as NativeStackView } from './views/NativeStackView';
10
-
11
- /**
12
- * Utilities
13
- */
14
- export { default as useHeaderHeight } from './utils/useHeaderHeight';
15
- export { default as HeaderHeightContext } from './utils/HeaderHeightContext';
16
-
17
- export { default as useAnimatedHeaderHeight } from './utils/useAnimatedHeaderHeight';
18
- export { default as AnimatedHeaderHeightContext } from './utils/AnimatedHeaderHeightContext';
19
-
20
- /**
21
- * Types
22
- */
23
- export type {
24
- NativeStackNavigationOptions,
25
- NativeStackNavigationProp,
26
- NativeStackScreenProps,
27
- } from './types';
@@ -1,110 +0,0 @@
1
- /*
2
- * Portions of this file are copyright (c) 2023 Amazon.com, Inc. or its affiliates. All rights reserved.
3
- *
4
- * PORTIONS OF THIS FILE ARE AMAZON PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
5
- *
6
- * Amazon modifications are indicated by [amznmod_* comments].
7
- */
8
-
9
- /*
10
- * Changelog:
11
- * Set up react-native-screens package to build for Kepler
12
- */
13
-
14
- import {
15
- createNavigatorFactory,
16
- EventArg,
17
- StackActions,
18
- StackActionHelpers,
19
- StackNavigationState,
20
- StackRouter,
21
- StackRouterOptions,
22
- ParamListBase,
23
- useNavigationBuilder,
24
- // amznmod_react - change imports to kepler packages
25
- } from '@amazon-devices/react-navigation__native';
26
- import * as React from 'react';
27
- import {
28
- NativeStackNavigationEventMap,
29
- NativeStackNavigationOptions,
30
- NativeStackNavigatorProps,
31
- } from '../types';
32
- import NativeStackView from '../views/NativeStackView';
33
-
34
- function NativeStackNavigator({
35
- initialRouteName,
36
- children,
37
- screenOptions,
38
- ...rest
39
- }: NativeStackNavigatorProps) {
40
- const { state, descriptors, navigation } = useNavigationBuilder<
41
- StackNavigationState<ParamListBase>,
42
- StackRouterOptions,
43
- StackActionHelpers<ParamListBase>,
44
- NativeStackNavigationOptions,
45
- NativeStackNavigationEventMap
46
- >(StackRouter, {
47
- initialRouteName,
48
- children,
49
- screenOptions,
50
- });
51
-
52
- // Starting from React Navigation v6, `native-stack` should be imported from
53
- // `@react-navigation/native-stack` rather than `react-native-screens/native-stack`
54
- React.useEffect(() => {
55
- // @ts-ignore navigation.dangerouslyGetParent was removed in v6
56
- if (navigation?.dangerouslyGetParent === undefined) {
57
- console.warn(
58
- 'Looks like you are importing `native-stack` from `react-native-screens/native-stack`. Since version 6 of `react-navigation`, it should be imported from `@react-navigation/native-stack`.',
59
- );
60
- }
61
- }, [navigation]);
62
-
63
- React.useEffect(
64
- () =>
65
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
- (navigation as typeof navigation & { addListener: any })?.addListener?.(
67
- 'tabPress',
68
- (e: any) => {
69
- const isFocused = navigation.isFocused();
70
-
71
- // Run the operation in the next frame so we're sure all listeners have been run
72
- // This is necessary to know if preventDefault() has been called
73
- requestAnimationFrame(() => {
74
- if (
75
- state.index > 0 &&
76
- isFocused &&
77
- !(e as EventArg<'tabPress', true>).defaultPrevented
78
- ) {
79
- // When user taps on already focused tab and we're inside the tab,
80
- // reset the stack to replicate native behaviour
81
- navigation.dispatch({
82
- ...StackActions.popToTop(),
83
- target: state.key,
84
- });
85
- }
86
- });
87
- },
88
- ),
89
- [navigation, state.index, state.key],
90
- );
91
-
92
- return (
93
- <NativeStackView
94
- {...rest}
95
- state={state}
96
- navigation={navigation}
97
- descriptors={descriptors}
98
- />
99
- );
100
- }
101
-
102
- /**
103
- * @deprecated NativeStack has been moved from react-native-screens/native-stack to @react-navigation/native since version v6. With react-native-screens v4 native stack v5 (react-native-screens/native-stack) is deprecated and marked for removal in the upcoming minor release, react-native-screens v4 will support only @react-navigation/native-stack v7.
104
- */
105
- export default createNavigatorFactory<
106
- StackNavigationState<ParamListBase>,
107
- NativeStackNavigationOptions,
108
- NativeStackNavigationEventMap,
109
- typeof NativeStackNavigator
110
- >(NativeStackNavigator);