@amazon-devices/react-navigation__stack 8.0.9000000001 → 8.0.9000000002

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 (76) hide show
  1. package/kepler-compatibility.json +2 -1
  2. package/lib/module/index.js +0 -34
  3. package/lib/module/views/Stack/CardStack.js.map +1 -1
  4. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  5. package/package.json +1 -1
  6. package/src/index.tsx +0 -56
  7. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +0 -394
  8. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +0 -262
  9. package/lib/module/TransitionConfigs/TransitionPresets.js +0 -156
  10. package/lib/module/TransitionConfigs/TransitionSpecs.js +0 -124
  11. package/lib/module/navigators/createStackNavigator.js +0 -71
  12. package/lib/module/types.js +0 -4
  13. package/lib/module/utils/CardAnimationContext.js +0 -5
  14. package/lib/module/utils/GestureHandlerRefContext.js +0 -5
  15. package/lib/module/utils/ModalPresentationContext.js +0 -5
  16. package/lib/module/utils/conditional.js +0 -28
  17. package/lib/module/utils/findLastIndex.js +0 -11
  18. package/lib/module/utils/gestureActivationCriteria.js +0 -60
  19. package/lib/module/utils/getDistanceForDirection.js +0 -15
  20. package/lib/module/utils/getInvertedMultiplier.js +0 -15
  21. package/lib/module/utils/getModalRoutesKeys.js +0 -12
  22. package/lib/module/utils/getShadowStyle.js +0 -24
  23. package/lib/module/utils/throttle.js +0 -14
  24. package/lib/module/utils/useCardAnimation.js +0 -12
  25. package/lib/module/utils/useGestureHandlerRef.js +0 -12
  26. package/lib/module/utils/useKeyboardManager.js +0 -90
  27. package/lib/module/views/GestureHandler.android.js +0 -4
  28. package/lib/module/views/GestureHandler.ios.js +0 -4
  29. package/lib/module/views/GestureHandler.js +0 -21
  30. package/lib/module/views/GestureHandler.kepler.js +0 -4
  31. package/lib/module/views/GestureHandlerNative.js +0 -18
  32. package/lib/module/views/Header/Header.js +0 -56
  33. package/lib/module/views/Header/HeaderContainer.js +0 -128
  34. package/lib/module/views/Header/HeaderSegment.js +0 -142
  35. package/lib/module/views/Screens.js +0 -42
  36. package/lib/module/views/Stack/Card.js +0 -433
  37. package/lib/module/views/Stack/CardA11yWrapper.js +0 -43
  38. package/lib/module/views/Stack/CardContainer.js +0 -276
  39. package/lib/module/views/Stack/CardContent.js +0 -74
  40. package/lib/module/views/Stack/CardStack.js +0 -498
  41. package/lib/module/views/Stack/StackView.js +0 -339
  42. package/src/TransitionConfigs/CardStyleInterpolators.tsx +0 -460
  43. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +0 -286
  44. package/src/TransitionConfigs/TransitionPresets.tsx +0 -182
  45. package/src/TransitionConfigs/TransitionSpecs.tsx +0 -124
  46. package/src/navigators/createStackNavigator.tsx +0 -120
  47. package/src/types.tsx +0 -639
  48. package/src/utils/CardAnimationContext.tsx +0 -7
  49. package/src/utils/GestureHandlerRefContext.tsx +0 -5
  50. package/src/utils/ModalPresentationContext.tsx +0 -3
  51. package/src/utils/conditional.tsx +0 -33
  52. package/src/utils/findLastIndex.tsx +0 -9
  53. package/src/utils/gestureActivationCriteria.tsx +0 -70
  54. package/src/utils/getDistanceForDirection.tsx +0 -19
  55. package/src/utils/getInvertedMultiplier.tsx +0 -17
  56. package/src/utils/getModalRoutesKeys.ts +0 -21
  57. package/src/utils/getShadowStyle.tsx +0 -37
  58. package/src/utils/throttle.tsx +0 -16
  59. package/src/utils/useCardAnimation.tsx +0 -15
  60. package/src/utils/useGestureHandlerRef.tsx +0 -15
  61. package/src/utils/useKeyboardManager.tsx +0 -103
  62. package/src/views/GestureHandler.android.tsx +0 -1
  63. package/src/views/GestureHandler.ios.tsx +0 -1
  64. package/src/views/GestureHandler.kepler.tsx +0 -1
  65. package/src/views/GestureHandler.tsx +0 -23
  66. package/src/views/GestureHandlerNative.tsx +0 -23
  67. package/src/views/Header/Header.tsx +0 -73
  68. package/src/views/Header/HeaderContainer.tsx +0 -191
  69. package/src/views/Header/HeaderSegment.tsx +0 -203
  70. package/src/views/Screens.tsx +0 -45
  71. package/src/views/Stack/Card.tsx +0 -646
  72. package/src/views/Stack/CardA11yWrapper.tsx +0 -67
  73. package/src/views/Stack/CardContainer.tsx +0 -339
  74. package/src/views/Stack/CardContent.tsx +0 -92
  75. package/src/views/Stack/CardStack.tsx +0 -849
  76. package/src/views/Stack/StackView.tsx +0 -485
@@ -1,286 +0,0 @@
1
- import { Animated, Platform } from 'react-native';
2
-
3
- import type {
4
- StackHeaderInterpolatedStyle,
5
- StackHeaderInterpolationProps,
6
- } from '../types';
7
-
8
- const { add, multiply } = Animated;
9
-
10
- // Width of the screen in split layout on portrait mode on iPad Mini
11
- // Keep in sync with HeaderBackButton.tsx
12
- const IPAD_MINI_MEDIUM_WIDTH = 414;
13
-
14
- /**
15
- * Standard UIKit style animation for the header where the title fades into the back button label.
16
- */
17
- export function forUIKit({
18
- current,
19
- next,
20
- direction,
21
- layouts,
22
- }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
23
- const defaultOffset = 100;
24
- const leftSpacing =
25
- 27 +
26
- (Platform.OS === 'ios' && layouts.screen.width >= IPAD_MINI_MEDIUM_WIDTH
27
- ? 5 // Additional padding on iPad specified in Header.tsx
28
- : 0);
29
-
30
- // The title and back button title should cross-fade to each other
31
- // When screen is fully open, the title should be in center, and back title should be on left
32
- // When screen is closing, the previous title will animate to back title's position
33
- // And back title will animate to title's position
34
- // We achieve this by calculating the offsets needed to translate title to back title's position and vice-versa
35
- const leftLabelOffset = layouts.leftLabel
36
- ? (layouts.screen.width - layouts.leftLabel.width) / 2 - leftSpacing
37
- : defaultOffset;
38
- const titleLeftOffset = layouts.title
39
- ? (layouts.screen.width - layouts.title.width) / 2 - leftSpacing
40
- : defaultOffset;
41
-
42
- // When the current title is animating to right, it is centered in the right half of screen in middle of transition
43
- // The back title also animates in from this position
44
- const rightOffset = layouts.screen.width / 4;
45
-
46
- const multiplier = direction === 'rtl' ? -1 : 1;
47
-
48
- const progress = add(
49
- current.progress.interpolate({
50
- inputRange: [0, 1],
51
- outputRange: [0, 1],
52
- extrapolate: 'clamp',
53
- }),
54
- next
55
- ? next.progress.interpolate({
56
- inputRange: [0, 1],
57
- outputRange: [0, 1],
58
- extrapolate: 'clamp',
59
- })
60
- : 0
61
- );
62
-
63
- return {
64
- leftButtonStyle: {
65
- opacity: progress.interpolate({
66
- inputRange: [0.3, 1, 1.5],
67
- outputRange: [0, 1, 0],
68
- }),
69
- },
70
- leftLabelStyle: {
71
- transform: [
72
- {
73
- translateX: multiply(
74
- multiplier,
75
- progress.interpolate({
76
- inputRange: [0, 1, 2],
77
- outputRange: [leftLabelOffset, 0, -rightOffset],
78
- })
79
- ),
80
- },
81
- ],
82
- },
83
- rightButtonStyle: {
84
- opacity: progress.interpolate({
85
- inputRange: [0.3, 1, 1.5],
86
- outputRange: [0, 1, 0],
87
- }),
88
- },
89
- titleStyle: {
90
- opacity: progress.interpolate({
91
- inputRange: [0, 0.5, 0.75, 1, 1.5],
92
- outputRange: [0, 0, 0.1, 1, 0],
93
- }),
94
- transform: [
95
- {
96
- translateX: multiply(
97
- multiplier,
98
- progress.interpolate({
99
- inputRange: [0.5, 1, 2],
100
- outputRange: [rightOffset, 0, -titleLeftOffset],
101
- })
102
- ),
103
- },
104
- ],
105
- },
106
- backgroundStyle: {
107
- transform: [
108
- {
109
- translateX: multiply(
110
- multiplier,
111
- progress.interpolate({
112
- inputRange: [0, 1, 2],
113
- outputRange: [layouts.screen.width, 0, -layouts.screen.width],
114
- })
115
- ),
116
- },
117
- ],
118
- },
119
- };
120
- }
121
-
122
- /**
123
- * Simple fade animation for the header elements.
124
- */
125
- export function forFade({
126
- current,
127
- next,
128
- }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
129
- const progress = add(
130
- current.progress.interpolate({
131
- inputRange: [0, 1],
132
- outputRange: [0, 1],
133
- extrapolate: 'clamp',
134
- }),
135
- next
136
- ? next.progress.interpolate({
137
- inputRange: [0, 1],
138
- outputRange: [0, 1],
139
- extrapolate: 'clamp',
140
- })
141
- : 0
142
- );
143
-
144
- const opacity = progress.interpolate({
145
- inputRange: [0, 1, 2],
146
- outputRange: [0, 1, 0],
147
- });
148
-
149
- return {
150
- leftButtonStyle: { opacity },
151
- rightButtonStyle: { opacity },
152
- titleStyle: { opacity },
153
- backgroundStyle: {
154
- opacity: progress.interpolate({
155
- inputRange: [0, 1, 1.9, 2],
156
- outputRange: [0, 1, 1, 0],
157
- }),
158
- },
159
- };
160
- }
161
-
162
- /**
163
- * Simple translate animation to translate the header to left.
164
- */
165
- export function forSlideLeft({
166
- current,
167
- next,
168
- direction,
169
- layouts: { screen },
170
- }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
171
- const isRTL = direction === 'rtl';
172
- const progress = add(
173
- current.progress.interpolate({
174
- inputRange: [0, 1],
175
- outputRange: [0, 1],
176
- extrapolate: 'clamp',
177
- }),
178
- next
179
- ? next.progress.interpolate({
180
- inputRange: [0, 1],
181
- outputRange: [0, 1],
182
- extrapolate: 'clamp',
183
- })
184
- : 0
185
- );
186
-
187
- const translateX = progress.interpolate({
188
- inputRange: [0, 1, 2],
189
- outputRange: isRTL
190
- ? [-screen.width, 0, screen.width]
191
- : [screen.width, 0, -screen.width],
192
- });
193
-
194
- const transform = [{ translateX }];
195
-
196
- return {
197
- leftButtonStyle: { transform },
198
- rightButtonStyle: { transform },
199
- titleStyle: { transform },
200
- backgroundStyle: { transform },
201
- };
202
- }
203
-
204
- /**
205
- * Simple translate animation to translate the header to right.
206
- */
207
- export function forSlideRight({
208
- current,
209
- next,
210
- direction,
211
- layouts: { screen },
212
- }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
213
- const isRTL = direction === 'rtl';
214
- const progress = add(
215
- current.progress.interpolate({
216
- inputRange: [0, 1],
217
- outputRange: [0, 1],
218
- extrapolate: 'clamp',
219
- }),
220
- next
221
- ? next.progress.interpolate({
222
- inputRange: [0, 1],
223
- outputRange: [0, 1],
224
- extrapolate: 'clamp',
225
- })
226
- : 0
227
- );
228
-
229
- const translateX = progress.interpolate({
230
- inputRange: [0, 1, 2],
231
- outputRange: isRTL
232
- ? [screen.width, 0, -screen.width]
233
- : [-screen.width, 0, screen.width],
234
- });
235
-
236
- const transform = [{ translateX }];
237
-
238
- return {
239
- leftButtonStyle: { transform },
240
- rightButtonStyle: { transform },
241
- titleStyle: { transform },
242
- backgroundStyle: { transform },
243
- };
244
- }
245
-
246
- /**
247
- * Simple translate animation to translate the header to slide up.
248
- */
249
- export function forSlideUp({
250
- current,
251
- next,
252
- layouts: { header },
253
- }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
254
- const progress = add(
255
- current.progress.interpolate({
256
- inputRange: [0, 1],
257
- outputRange: [0, 1],
258
- extrapolate: 'clamp',
259
- }),
260
- next
261
- ? next.progress.interpolate({
262
- inputRange: [0, 1],
263
- outputRange: [0, 1],
264
- extrapolate: 'clamp',
265
- })
266
- : 0
267
- );
268
-
269
- const translateY = progress.interpolate({
270
- inputRange: [0, 1, 2],
271
- outputRange: [-header.height, 0, -header.height],
272
- });
273
-
274
- const transform = [{ translateY }];
275
-
276
- return {
277
- leftButtonStyle: { transform },
278
- rightButtonStyle: { transform },
279
- titleStyle: { transform },
280
- backgroundStyle: { transform },
281
- };
282
- }
283
-
284
- export function forNoAnimation(): StackHeaderInterpolatedStyle {
285
- return {};
286
- }
@@ -1,182 +0,0 @@
1
- import { Platform } from 'react-native';
2
-
3
- import type { TransitionPreset } from '../types';
4
- import {
5
- forBottomSheetAndroid,
6
- forFadeFromBottomAndroid,
7
- forFadeFromCenter as forFadeCard,
8
- forFadeFromRightAndroid,
9
- forHorizontalIOS,
10
- forHorizontalIOSInverted,
11
- forModalPresentationIOS,
12
- forRevealFromBottomAndroid,
13
- forScaleFromCenterAndroid,
14
- forVerticalIOS,
15
- } from './CardStyleInterpolators';
16
- import { forFade } from './HeaderStyleInterpolators';
17
- import {
18
- BottomSheetSlideInSpec,
19
- BottomSheetSlideOutSpec,
20
- FadeInFromBottomAndroidSpec,
21
- FadeOutToBottomAndroidSpec,
22
- RevealFromBottomAndroidSpec,
23
- ScaleFromCenterAndroidSpec,
24
- TransitionIOSSpec,
25
- } from './TransitionSpecs';
26
-
27
- const ANDROID_VERSION_PIE = 28;
28
- const ANDROID_VERSION_10 = 29;
29
- const ANDROID_VERSION_14 = 34;
30
-
31
- /**
32
- * Standard iOS navigation transition.
33
- */
34
- export const SlideFromRightIOS: TransitionPreset = {
35
- gestureDirection: 'horizontal',
36
- transitionSpec: {
37
- open: TransitionIOSSpec,
38
- close: TransitionIOSSpec,
39
- },
40
- cardStyleInterpolator: forHorizontalIOS,
41
- headerStyleInterpolator: forFade,
42
- };
43
-
44
- /**
45
- * Standard iOS navigation transition for modals.
46
- */
47
- export const ModalSlideFromBottomIOS: TransitionPreset = {
48
- gestureDirection: 'vertical',
49
- transitionSpec: {
50
- open: TransitionIOSSpec,
51
- close: TransitionIOSSpec,
52
- },
53
- cardStyleInterpolator: forVerticalIOS,
54
- headerStyleInterpolator: forFade,
55
- };
56
-
57
- /**
58
- * Standard iOS modal presentation style (introduced in iOS 13).
59
- */
60
- export const ModalPresentationIOS: TransitionPreset = {
61
- gestureDirection: 'vertical',
62
- transitionSpec: {
63
- open: TransitionIOSSpec,
64
- close: TransitionIOSSpec,
65
- },
66
- cardStyleInterpolator: forModalPresentationIOS,
67
- headerStyleInterpolator: forFade,
68
- };
69
-
70
- /**
71
- * Standard Android navigation transition when opening or closing an Activity on Android < 9 (Oreo).
72
- */
73
- export const FadeFromBottomAndroid: TransitionPreset = {
74
- gestureDirection: 'vertical',
75
- transitionSpec: {
76
- open: FadeInFromBottomAndroidSpec,
77
- close: FadeOutToBottomAndroidSpec,
78
- },
79
- cardStyleInterpolator: forFadeFromBottomAndroid,
80
- headerStyleInterpolator: forFade,
81
- };
82
-
83
- /**
84
- * Standard Android navigation transition when opening or closing an Activity on Android 9 (Pie).
85
- */
86
- export const RevealFromBottomAndroid: TransitionPreset = {
87
- gestureDirection: 'vertical',
88
- transitionSpec: {
89
- open: RevealFromBottomAndroidSpec,
90
- close: RevealFromBottomAndroidSpec,
91
- },
92
- cardStyleInterpolator: forRevealFromBottomAndroid,
93
- headerStyleInterpolator: forFade,
94
- };
95
-
96
- /**
97
- * Standard Android navigation transition when opening or closing an Activity on Android 10 (Q).
98
- */
99
- export const ScaleFromCenterAndroid: TransitionPreset = {
100
- gestureDirection: 'horizontal',
101
- transitionSpec: {
102
- open: ScaleFromCenterAndroidSpec,
103
- close: ScaleFromCenterAndroidSpec,
104
- },
105
- cardStyleInterpolator: forScaleFromCenterAndroid,
106
- headerStyleInterpolator: forFade,
107
- };
108
-
109
- /**
110
- * Standard Android navigation transition when opening or closing an Activity on Android 14.
111
- */
112
- export const FadeFromRightAndroid: TransitionPreset = {
113
- gestureDirection: 'horizontal',
114
- transitionSpec: {
115
- open: FadeInFromBottomAndroidSpec,
116
- close: FadeOutToBottomAndroidSpec,
117
- },
118
- cardStyleInterpolator: forFadeFromRightAndroid,
119
- headerStyleInterpolator: forFade,
120
- };
121
-
122
- /**
123
- * Standard bottom sheet slide transition for Android 10.
124
- */
125
- export const BottomSheetAndroid: TransitionPreset = {
126
- gestureDirection: 'vertical',
127
- transitionSpec: {
128
- open: BottomSheetSlideInSpec,
129
- close: BottomSheetSlideOutSpec,
130
- },
131
- cardStyleInterpolator: forBottomSheetAndroid,
132
- headerStyleInterpolator: forFade,
133
- };
134
-
135
- /**
136
- * Fade transition for transparent modals.
137
- */
138
- export const ModalFadeTransition: TransitionPreset = {
139
- gestureDirection: 'vertical',
140
- transitionSpec: {
141
- open: BottomSheetSlideInSpec,
142
- close: BottomSheetSlideOutSpec,
143
- },
144
- cardStyleInterpolator: forFadeCard,
145
- headerStyleInterpolator: forFade,
146
- };
147
-
148
- /**
149
- * Default navigation transition for the current platform.
150
- */
151
- export const DefaultTransition = Platform.select({
152
- // @ts-ignore - add default value for kepler (leaving for easy override)
153
- kepler: ScaleFromCenterAndroid,
154
- ios: SlideFromRightIOS,
155
- android:
156
- Number(Platform.Version) >= ANDROID_VERSION_14
157
- ? FadeFromRightAndroid
158
- : Number(Platform.Version) >= ANDROID_VERSION_10
159
- ? ScaleFromCenterAndroid
160
- : Number(Platform.Version) >= ANDROID_VERSION_PIE
161
- ? RevealFromBottomAndroid
162
- : FadeFromBottomAndroid,
163
- default: ScaleFromCenterAndroid,
164
- });
165
-
166
- /**
167
- * Default modal transition for the current platform.
168
- */
169
- export const ModalTransition = Platform.select({
170
- // @ts-ignore - add default value for kepler (leaving for easy override)
171
- kepler: BottomSheetAndroid,
172
- ios: ModalPresentationIOS,
173
- default: BottomSheetAndroid,
174
- });
175
-
176
- /**
177
- * Slide from left transition.
178
- */
179
- export const SlideFromLeftIOS: TransitionPreset = {
180
- ...SlideFromRightIOS,
181
- cardStyleInterpolator: forHorizontalIOSInverted,
182
- };
@@ -1,124 +0,0 @@
1
- import { Easing } from 'react-native';
2
-
3
- import type { TransitionSpec } from '../types';
4
-
5
- /**
6
- * Exact values from UINavigationController's animation configuration.
7
- */
8
- export const TransitionIOSSpec: TransitionSpec = {
9
- animation: 'spring',
10
- config: {
11
- stiffness: 1000,
12
- damping: 500,
13
- mass: 3,
14
- overshootClamping: true,
15
- restDisplacementThreshold: 10,
16
- restSpeedThreshold: 10,
17
- },
18
- };
19
-
20
- /**
21
- * Configuration for activity open animation from Android Nougat.
22
- * See http://aosp.opersys.com/xref/android-7.1.2_r37/xref/frameworks/base/core/res/res/anim/activity_open_enter.xml
23
- */
24
- export const FadeInFromBottomAndroidSpec: TransitionSpec = {
25
- animation: 'timing',
26
- config: {
27
- duration: 350,
28
- easing: Easing.out(Easing.poly(5)),
29
- },
30
- };
31
-
32
- /**
33
- * Configuration for activity close animation from Android Nougat.
34
- * See http://aosp.opersys.com/xref/android-7.1.2_r37/xref/frameworks/base/core/res/res/anim/activity_close_exit.xml
35
- */
36
- export const FadeOutToBottomAndroidSpec: TransitionSpec = {
37
- animation: 'timing',
38
- config: {
39
- duration: 150,
40
- easing: Easing.in(Easing.linear),
41
- },
42
- };
43
-
44
- /**
45
- * Approximate configuration for activity open animation from Android Pie.
46
- * See http://aosp.opersys.com/xref/android-9.0.0_r47/xref/frameworks/base/core/res/res/anim/activity_open_enter.xml
47
- */
48
- export const RevealFromBottomAndroidSpec: TransitionSpec = {
49
- animation: 'timing',
50
- config: {
51
- duration: 425,
52
- // This is super rough approximation of the path used for the curve by android
53
- // See http://aosp.opersys.com/xref/android-9.0.0_r47/xref/frameworks/base/core/res/res/interpolator/fast_out_extra_slow_in.xml
54
- easing: Easing.bezier(0.20833, 0.82, 0.25, 1),
55
- },
56
- };
57
-
58
- /**
59
- * Approximate configuration for activity open animation from Android Q.
60
- * See http://aosp.opersys.com/xref/android-10.0.0_r2/xref/frameworks/base/core/res/res/anim/activity_open_enter.xml
61
- */
62
- export const ScaleFromCenterAndroidSpec: TransitionSpec = {
63
- animation: 'timing',
64
- config: {
65
- duration: 400,
66
- // This is super rough approximation of the path used for the curve by android
67
- // See http://aosp.opersys.com/xref/android-10.0.0_r2/xref/frameworks/base/core/res/res/interpolator/fast_out_extra_slow_in.xml
68
- easing: Easing.bezier(0.20833, 0.82, 0.25, 1),
69
- },
70
- };
71
-
72
- /**
73
- * Approximate configuration for activity open animation from Android 14.
74
- * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/anim/activity_open_enter.xml
75
- */
76
- export const FadeInFromRightAndroidSpec: TransitionSpec = {
77
- animation: 'timing',
78
- config: {
79
- duration: 450,
80
- // This is super rough approximation of the path used for the curve by android
81
- // See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/interpolator/fast_out_extra_slow_in.xml
82
- easing: Easing.bezier(0.20833, 0.82, 0.25, 1),
83
- },
84
- };
85
-
86
- /**
87
- * Approximate configuration for activity close animation from Android 14.
88
- * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/anim/activity_close_exit.xml
89
- */
90
- export const FadeOutToLeftAndroidSpec: TransitionSpec = {
91
- animation: 'timing',
92
- config: {
93
- duration: 450,
94
- // This is super rough approximation of the path used for the curve by android
95
- // See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/interpolator/fast_out_extra_slow_in.xml
96
- easing: Easing.bezier(0.20833, 0.82, 0.25, 1),
97
- },
98
- };
99
-
100
- /**
101
- * Configuration for bottom sheet slide in animation from Material Design.
102
- * See https://github.com/material-components/material-components-android/blob/fd3639092e1ffef9dc11bcedf79f32801d85e898/lib/java/com/google/android/material/bottomsheet/res/anim/mtrl_bottom_sheet_slide_in.xml
103
- */
104
- export const BottomSheetSlideInSpec: TransitionSpec = {
105
- animation: 'timing',
106
- config: {
107
- duration: 250,
108
- // See https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/animation/AccelerateDecelerateInterpolator.java
109
- easing: (t) => Math.cos((t + 1) * Math.PI) / 2.0 + 0.5,
110
- },
111
- };
112
-
113
- /**
114
- * Configuration for bottom sheet slide out animation from Material Design.
115
- * See https://github.com/material-components/material-components-android/blob/fd3639092e1ffef9dc11bcedf79f32801d85e898/lib/java/com/google/android/material/bottomsheet/res/anim/mtrl_bottom_sheet_slide_in.xml
116
- */
117
- export const BottomSheetSlideOutSpec: TransitionSpec = {
118
- animation: 'timing',
119
- config: {
120
- duration: 200,
121
- // See https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/animation/AccelerateInterpolator.java
122
- easing: (t) => (t === 1.0 ? 1 : Math.pow(t, 2)),
123
- },
124
- };
@@ -1,120 +0,0 @@
1
- import {
2
- createNavigatorFactory,
3
- type EventArg,
4
- type NavigatorTypeBagBase,
5
- type ParamListBase,
6
- type StackActionHelpers,
7
- StackActions,
8
- type StackNavigationState,
9
- StackRouter,
10
- type StackRouterOptions,
11
- type StaticConfig,
12
- type TypedNavigator,
13
- useLocale,
14
- useNavigationBuilder,
15
- } from '@amazon-devices/react-navigation__native';
16
- import * as React from 'react';
17
-
18
- import type {
19
- StackNavigationEventMap,
20
- StackNavigationOptions,
21
- StackNavigationProp,
22
- StackNavigatorProps,
23
- } from '../types';
24
- import { StackView } from '../views/Stack/StackView';
25
-
26
- function StackNavigator({
27
- id,
28
- initialRouteName,
29
- UNSTABLE_routeNamesChangeBehavior,
30
- children,
31
- layout,
32
- screenListeners,
33
- screenOptions,
34
- screenLayout,
35
- UNSTABLE_router,
36
- ...rest
37
- }: StackNavigatorProps) {
38
- const { direction } = useLocale();
39
-
40
- const { state, describe, descriptors, navigation, NavigationContent } =
41
- useNavigationBuilder<
42
- StackNavigationState<ParamListBase>,
43
- StackRouterOptions,
44
- StackActionHelpers<ParamListBase>,
45
- StackNavigationOptions,
46
- StackNavigationEventMap
47
- >(StackRouter, {
48
- id,
49
- initialRouteName,
50
- UNSTABLE_routeNamesChangeBehavior,
51
- children,
52
- layout,
53
- screenListeners,
54
- screenOptions,
55
- screenLayout,
56
- UNSTABLE_router,
57
- });
58
-
59
- React.useEffect(
60
- () =>
61
- // @ts-expect-error: there may not be a tab navigator in parent
62
- navigation.addListener?.('tabPress', (e) => {
63
- const isFocused = navigation.isFocused();
64
-
65
- // Run the operation in the next frame so we're sure all listeners have been run
66
- // This is necessary to know if preventDefault() has been called
67
- requestAnimationFrame(() => {
68
- if (
69
- state.index > 0 &&
70
- isFocused &&
71
- !(e as unknown as EventArg<'tabPress', true>).defaultPrevented
72
- ) {
73
- // When user taps on already focused tab and we're inside the tab,
74
- // reset the stack to replicate native behaviour
75
- navigation.dispatch({
76
- ...StackActions.popToTop(),
77
- target: state.key,
78
- });
79
- }
80
- });
81
- }),
82
- [navigation, state.index, state.key]
83
- );
84
-
85
- return (
86
- <NavigationContent>
87
- <StackView
88
- {...rest}
89
- direction={direction}
90
- state={state}
91
- describe={describe}
92
- descriptors={descriptors}
93
- navigation={navigation}
94
- />
95
- </NavigationContent>
96
- );
97
- }
98
-
99
- export function createStackNavigator<
100
- const ParamList extends ParamListBase,
101
- const NavigatorID extends string | undefined = string | undefined,
102
- const TypeBag extends NavigatorTypeBagBase = {
103
- ParamList: ParamList;
104
- NavigatorID: NavigatorID;
105
- State: StackNavigationState<ParamList>;
106
- ScreenOptions: StackNavigationOptions;
107
- EventMap: StackNavigationEventMap;
108
- NavigationList: {
109
- [RouteName in keyof ParamList]: StackNavigationProp<
110
- ParamList,
111
- RouteName,
112
- NavigatorID
113
- >;
114
- };
115
- Navigator: typeof StackNavigator;
116
- },
117
- const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
118
- >(config?: Config): TypedNavigator<TypeBag, Config> {
119
- return createNavigatorFactory(StackNavigator)(config);
120
- }