@react-navigation/stack 8.0.0-alpha.6 → 8.0.0-alpha.60

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 (147) hide show
  1. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +280 -84
  2. package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  3. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +11 -44
  4. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  5. package/lib/module/TransitionConfigs/TransitionEasings.js +71 -0
  6. package/lib/module/TransitionConfigs/TransitionEasings.js.map +1 -0
  7. package/lib/module/TransitionConfigs/TransitionPresets.js +50 -10
  8. package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
  9. package/lib/module/TransitionConfigs/TransitionSpecs.js +69 -34
  10. package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
  11. package/lib/module/index.js +2 -2
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/module/navigators/createStackNavigator.js +37 -33
  14. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  15. package/lib/module/utils/GestureHandlerContext.js +5 -0
  16. package/lib/module/utils/GestureHandlerContext.js.map +1 -0
  17. package/lib/module/utils/gestureActivationCriteria.js +10 -8
  18. package/lib/module/utils/gestureActivationCriteria.js.map +1 -1
  19. package/lib/module/utils/useCardAnimation.js +1 -1
  20. package/lib/module/utils/useCardAnimation.js.map +1 -1
  21. package/lib/module/utils/useGestureHandler.js +9 -0
  22. package/lib/module/utils/useGestureHandler.js.map +1 -0
  23. package/lib/module/utils/useKeyboardManager.js +71 -26
  24. package/lib/module/utils/useKeyboardManager.js.map +1 -1
  25. package/lib/module/views/GestureHandler.js +15 -14
  26. package/lib/module/views/GestureHandler.js.map +1 -1
  27. package/lib/module/views/GestureHandlerNative.js +16 -10
  28. package/lib/module/views/GestureHandlerNative.js.map +1 -1
  29. package/lib/module/views/Header/Header.js +4 -2
  30. package/lib/module/views/Header/Header.js.map +1 -1
  31. package/lib/module/views/Header/HeaderContainer.js +60 -21
  32. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  33. package/lib/module/views/Header/HeaderSegment.js +6 -9
  34. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  35. package/lib/module/views/Stack/Card.js +170 -123
  36. package/lib/module/views/Stack/Card.js.map +1 -1
  37. package/lib/module/views/Stack/CardContainer.js +96 -98
  38. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  39. package/lib/module/views/Stack/CardContent.js +10 -37
  40. package/lib/module/views/Stack/CardContent.js.map +1 -1
  41. package/lib/module/views/Stack/CardStack.js +211 -147
  42. package/lib/module/views/Stack/CardStack.js.map +1 -1
  43. package/lib/module/views/Stack/StackView.js +106 -57
  44. package/lib/module/views/Stack/StackView.js.map +1 -1
  45. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts +20 -12
  46. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -1
  47. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +4 -4
  48. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
  49. package/lib/typescript/src/TransitionConfigs/TransitionEasings.d.ts +38 -0
  50. package/lib/typescript/src/TransitionConfigs/TransitionEasings.d.ts.map +1 -0
  51. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts +15 -3
  52. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -1
  53. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts +44 -15
  54. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -1
  55. package/lib/typescript/src/index.d.ts +12 -12
  56. package/lib/typescript/src/index.d.ts.map +1 -1
  57. package/lib/typescript/src/navigators/createStackNavigator.d.ts +10 -15
  58. package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
  59. package/lib/typescript/src/types.d.ts +120 -108
  60. package/lib/typescript/src/types.d.ts.map +1 -1
  61. package/lib/typescript/src/utils/CardAnimationContext.d.ts +1 -1
  62. package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +1 -1
  63. package/lib/typescript/src/utils/GestureHandlerContext.d.ts +3 -0
  64. package/lib/typescript/src/utils/GestureHandlerContext.d.ts.map +1 -0
  65. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts +4 -51
  66. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts.map +1 -1
  67. package/lib/typescript/src/utils/getDistanceForDirection.d.ts +1 -1
  68. package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +1 -1
  69. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts +1 -1
  70. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +1 -1
  71. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts +1 -1
  72. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +1 -1
  73. package/lib/typescript/src/utils/getShadowStyle.d.ts +5 -5
  74. package/lib/typescript/src/utils/useCardAnimation.d.ts +1 -1
  75. package/lib/typescript/src/utils/useCardAnimation.d.ts.map +1 -1
  76. package/lib/typescript/src/utils/useGestureHandler.d.ts +2 -0
  77. package/lib/typescript/src/utils/useGestureHandler.d.ts.map +1 -0
  78. package/lib/typescript/src/utils/useKeyboardManager.d.ts +12 -2
  79. package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +1 -1
  80. package/lib/typescript/src/views/GestureHandler.android.d.ts +1 -1
  81. package/lib/typescript/src/views/GestureHandler.android.d.ts.map +1 -1
  82. package/lib/typescript/src/views/GestureHandler.d.ts +7 -11
  83. package/lib/typescript/src/views/GestureHandler.d.ts.map +1 -1
  84. package/lib/typescript/src/views/GestureHandler.ios.d.ts +1 -1
  85. package/lib/typescript/src/views/GestureHandler.ios.d.ts.map +1 -1
  86. package/lib/typescript/src/views/GestureHandlerNative.d.ts +9 -4
  87. package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +1 -1
  88. package/lib/typescript/src/views/Header/Header.d.ts +2 -2
  89. package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
  90. package/lib/typescript/src/views/Header/HeaderContainer.d.ts +9 -3
  91. package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
  92. package/lib/typescript/src/views/Header/HeaderSegment.d.ts +6 -4
  93. package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
  94. package/lib/typescript/src/views/Stack/Card.d.ts +14 -8
  95. package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
  96. package/lib/typescript/src/views/Stack/CardContainer.d.ts +7 -7
  97. package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
  98. package/lib/typescript/src/views/Stack/CardContent.d.ts +1 -1
  99. package/lib/typescript/src/views/Stack/CardContent.d.ts.map +1 -1
  100. package/lib/typescript/src/views/Stack/CardStack.d.ts +10 -6
  101. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  102. package/lib/typescript/src/views/Stack/StackView.d.ts +14 -17
  103. package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
  104. package/package.json +23 -24
  105. package/src/TransitionConfigs/CardStyleInterpolators.tsx +399 -100
  106. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +15 -46
  107. package/src/TransitionConfigs/TransitionEasings.tsx +90 -0
  108. package/src/TransitionConfigs/TransitionPresets.tsx +56 -10
  109. package/src/TransitionConfigs/TransitionSpecs.tsx +68 -34
  110. package/src/index.tsx +3 -2
  111. package/src/navigators/createStackNavigator.tsx +74 -91
  112. package/src/types.tsx +149 -123
  113. package/src/utils/GestureHandlerContext.tsx +5 -0
  114. package/src/utils/gestureActivationCriteria.tsx +14 -10
  115. package/src/utils/useCardAnimation.tsx +1 -1
  116. package/src/utils/useGestureHandler.tsx +9 -0
  117. package/src/utils/useKeyboardManager.tsx +96 -33
  118. package/src/views/GestureHandler.tsx +24 -16
  119. package/src/views/GestureHandlerNative.tsx +24 -13
  120. package/src/views/Header/Header.tsx +4 -2
  121. package/src/views/Header/HeaderContainer.tsx +79 -37
  122. package/src/views/Header/HeaderSegment.tsx +10 -11
  123. package/src/views/Stack/Card.tsx +241 -154
  124. package/src/views/Stack/CardContainer.tsx +111 -127
  125. package/src/views/Stack/CardContent.tsx +13 -51
  126. package/src/views/Stack/CardStack.tsx +478 -335
  127. package/src/views/Stack/StackView.tsx +181 -82
  128. package/lib/module/utils/GestureHandlerRefContext.js +0 -5
  129. package/lib/module/utils/GestureHandlerRefContext.js.map +0 -1
  130. package/lib/module/utils/findLastIndex.js +0 -11
  131. package/lib/module/utils/findLastIndex.js.map +0 -1
  132. package/lib/module/utils/useGestureHandlerRef.js +0 -12
  133. package/lib/module/utils/useGestureHandlerRef.js.map +0 -1
  134. package/lib/module/views/Stack/CardA11yWrapper.js +0 -43
  135. package/lib/module/views/Stack/CardA11yWrapper.js.map +0 -1
  136. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts +0 -3
  137. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +0 -1
  138. package/lib/typescript/src/utils/findLastIndex.d.ts +0 -2
  139. package/lib/typescript/src/utils/findLastIndex.d.ts.map +0 -1
  140. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts +0 -3
  141. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +0 -1
  142. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts +0 -15
  143. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts.map +0 -1
  144. package/src/utils/GestureHandlerRefContext.tsx +0 -5
  145. package/src/utils/findLastIndex.tsx +0 -9
  146. package/src/utils/useGestureHandlerRef.tsx +0 -15
  147. package/src/views/Stack/CardA11yWrapper.tsx +0 -67
@@ -14,11 +14,9 @@ const { add, multiply } = Animated;
14
14
  export function forUIKit({
15
15
  current,
16
16
  next,
17
- direction,
17
+ inverted,
18
18
  layouts,
19
19
  }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
20
- const multiplier = direction === 'rtl' ? -1 : 1;
21
-
22
20
  const progress = add(
23
21
  current.progress.interpolate({
24
22
  inputRange: [0, 1],
@@ -45,7 +43,7 @@ export function forUIKit({
45
43
  });
46
44
 
47
45
  const translateX = multiply(
48
- multiplier,
46
+ inverted,
49
47
  progress.interpolate({
50
48
  inputRange: [0, 1, 2],
51
49
  outputRange: [layouts.screen.width, 0, -layouts.screen.width * 0.3],
@@ -128,10 +126,9 @@ export function forFade({
128
126
  export function forSlideLeft({
129
127
  current,
130
128
  next,
131
- direction,
129
+ inverted,
132
130
  layouts: { screen },
133
131
  }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
134
- const isRTL = direction === 'rtl';
135
132
  const progress = add(
136
133
  current.progress.interpolate({
137
134
  inputRange: [0, 1],
@@ -147,12 +144,13 @@ export function forSlideLeft({
147
144
  : 0
148
145
  );
149
146
 
150
- const translateX = progress.interpolate({
151
- inputRange: [0, 1, 2],
152
- outputRange: isRTL
153
- ? [-screen.width, 0, screen.width]
154
- : [screen.width, 0, -screen.width],
155
- });
147
+ const translateX = multiply(
148
+ inverted,
149
+ progress.interpolate({
150
+ inputRange: [0, 1, 2],
151
+ outputRange: [screen.width, 0, -screen.width],
152
+ })
153
+ );
156
154
 
157
155
  const transform = [{ translateX }];
158
156
 
@@ -168,42 +166,13 @@ export function forSlideLeft({
168
166
  * Simple translate animation to translate the header to right.
169
167
  */
170
168
  export function forSlideRight({
171
- current,
172
- next,
173
- direction,
174
- layouts: { screen },
169
+ inverted,
170
+ ...rest
175
171
  }: StackHeaderInterpolationProps): StackHeaderInterpolatedStyle {
176
- const isRTL = direction === 'rtl';
177
- const progress = add(
178
- current.progress.interpolate({
179
- inputRange: [0, 1],
180
- outputRange: [0, 1],
181
- extrapolate: 'clamp',
182
- }),
183
- next
184
- ? next.progress.interpolate({
185
- inputRange: [0, 1],
186
- outputRange: [0, 1],
187
- extrapolate: 'clamp',
188
- })
189
- : 0
190
- );
191
-
192
- const translateX = progress.interpolate({
193
- inputRange: [0, 1, 2],
194
- outputRange: isRTL
195
- ? [screen.width, 0, -screen.width]
196
- : [-screen.width, 0, screen.width],
172
+ return forSlideLeft({
173
+ ...rest,
174
+ inverted: inverted === 1 ? -1 : 1,
197
175
  });
198
-
199
- const transform = [{ translateX }];
200
-
201
- return {
202
- leftButtonStyle: { transform },
203
- rightButtonStyle: { transform },
204
- titleStyle: { transform },
205
- backgroundStyle: { transform },
206
- };
207
176
  }
208
177
 
209
178
  /**
@@ -0,0 +1,90 @@
1
+ import { Easing } from 'react-native';
2
+
3
+ /**
4
+ * Exact piecewise path for Android's fast-out-extra-slow-in easing.
5
+ * 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
6
+ */
7
+ const FAST_OUT_EXTRA_SLOW_IN_INITIAL = Easing.bezier(0.3, 0, 0.8, 0.15);
8
+ const FAST_OUT_EXTRA_SLOW_IN_FINAL = Easing.bezier(0.05, 0.7, 0.1, 1);
9
+
10
+ export const FAST_OUT_EXTRA_SLOW_IN = (t: number) => {
11
+ const breakpoint = 1 / 6;
12
+
13
+ if (t < breakpoint) {
14
+ return 0.4 * FAST_OUT_EXTRA_SLOW_IN_INITIAL(t / breakpoint);
15
+ }
16
+
17
+ return (
18
+ 0.4 +
19
+ 0.6 * FAST_OUT_EXTRA_SLOW_IN_FINAL((t - breakpoint) / (1 - breakpoint))
20
+ );
21
+ };
22
+
23
+ /**
24
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/core/res/res/interpolator/fast_out_slow_in.xml
25
+ */
26
+ export const FAST_OUT_SLOW_IN = Easing.bezier(0.4, 0, 0.2, 1);
27
+
28
+ /**
29
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/core/res/res/interpolator/linear_out_slow_in.xml
30
+ */
31
+ export const LINEAR_OUT_SLOW_IN = Easing.bezier(0, 0, 0.2, 1);
32
+
33
+ /**
34
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r47/core/res/res/interpolator/activity_close_dim.xml
35
+ */
36
+ export const ACTIVITY_CLOSE_DIM = Easing.bezier(0.33, 0, 1, 1);
37
+
38
+ export const decelerate = (power: number, t: number) => 1 - (1 - t) ** power;
39
+
40
+ export const accelerate = (power: number, t: number) => t ** power;
41
+
42
+ export const clamp = (value: number) => Math.min(1, Math.max(0, value));
43
+
44
+ /**
45
+ * Creates interpolation ranges for a property that follows its own timeline.
46
+ *
47
+ * @param options - Options for the property timeline.
48
+ * @param options.duration - Total transition duration in milliseconds.
49
+ * @param options.easing - Easing used by the transition.
50
+ * @param options.closing - Whether the transition is closing.
51
+ * @param options.stops - Times in milliseconds to include in the ranges.
52
+ * @param options.output - Returns the property value at a time in milliseconds.
53
+ */
54
+ export function timeline({
55
+ duration,
56
+ easing,
57
+ closing = false,
58
+ stops = [],
59
+ output,
60
+ }: {
61
+ duration: number;
62
+ easing: (value: number) => number;
63
+ closing?: boolean;
64
+ stops?: number[];
65
+ output: (time: number) => number;
66
+ }) {
67
+ const times = [
68
+ ...new Set([
69
+ ...Array.from(
70
+ { length: Math.floor(duration / 10) + 1 },
71
+ (_, index) => index * 10
72
+ ),
73
+ ...stops,
74
+ duration,
75
+ ]),
76
+ ].sort((a, b) => a - b);
77
+
78
+ const points = times
79
+ .map((time) => ({
80
+ input: closing ? 1 - easing(time / duration) : easing(time / duration),
81
+ output: output(time),
82
+ }))
83
+ .sort((a, b) => a.input - b.input);
84
+
85
+ return {
86
+ inputRange: points.map(({ input }) => input),
87
+ outputRange: points.map(({ output }) => output),
88
+ extrapolate: 'clamp' as const,
89
+ };
90
+ }
@@ -3,11 +3,13 @@ import { Platform } from 'react-native';
3
3
  import type { TransitionPreset } from '../types';
4
4
  import {
5
5
  forBottomSheetAndroid,
6
+ forCrossDissolveIOS,
7
+ forDialogAndroid,
6
8
  forFadeFromBottomAndroid,
7
- forFadeFromCenter as forFadeCard,
9
+ forFadeFromCenter,
8
10
  forFadeFromRightAndroid,
11
+ forFlipIOS,
9
12
  forHorizontalIOS,
10
- forHorizontalIOSInverted,
11
13
  forModalPresentationIOS,
12
14
  forRevealFromBottomAndroid,
13
15
  forScaleFromCenterAndroid,
@@ -17,8 +19,12 @@ import { forFade, forUIKit } from './HeaderStyleInterpolators';
17
19
  import {
18
20
  BottomSheetSlideInSpec,
19
21
  BottomSheetSlideOutSpec,
22
+ DialogAndroidSpec,
20
23
  FadeInFromBottomAndroidSpec,
24
+ FadeInFromRightAndroidSpec,
21
25
  FadeOutToBottomAndroidSpec,
26
+ FadeOutToRightAndroidSpec,
27
+ FlipIOSSpec,
22
28
  RevealFromBottomAndroidSpec,
23
29
  ScaleFromCenterAndroidSpec,
24
30
  TransitionIOSSpec,
@@ -80,6 +86,19 @@ export const FadeFromBottomAndroid: TransitionPreset = {
80
86
  headerStyleInterpolator: forFade,
81
87
  };
82
88
 
89
+ /**
90
+ * Standard Android dialog transition.
91
+ */
92
+ export const DialogAndroid: TransitionPreset = {
93
+ gestureDirection: 'vertical',
94
+ transitionSpec: {
95
+ open: DialogAndroidSpec,
96
+ close: DialogAndroidSpec,
97
+ },
98
+ cardStyleInterpolator: forDialogAndroid,
99
+ headerStyleInterpolator: forFade,
100
+ };
101
+
83
102
  /**
84
103
  * Standard Android navigation transition when opening or closing an Activity on Android 9 (Pie).
85
104
  */
@@ -107,20 +126,20 @@ export const ScaleFromCenterAndroid: TransitionPreset = {
107
126
  };
108
127
 
109
128
  /**
110
- * Standard Android navigation transition when opening or closing an Activity on Android 14.
129
+ * Standard Android navigation transition when opening or closing an Activity on Android 14 and later.
111
130
  */
112
131
  export const FadeFromRightAndroid: TransitionPreset = {
113
132
  gestureDirection: 'horizontal',
114
133
  transitionSpec: {
115
- open: FadeInFromBottomAndroidSpec,
116
- close: FadeOutToBottomAndroidSpec,
134
+ open: FadeInFromRightAndroidSpec,
135
+ close: FadeOutToRightAndroidSpec,
117
136
  },
118
137
  cardStyleInterpolator: forFadeFromRightAndroid,
119
138
  headerStyleInterpolator: forFade,
120
139
  };
121
140
 
122
141
  /**
123
- * Standard bottom sheet slide transition for Android 10.
142
+ * Standard Material 3 bottom sheet transition.
124
143
  */
125
144
  export const BottomSheetAndroid: TransitionPreset = {
126
145
  gestureDirection: 'vertical',
@@ -138,10 +157,36 @@ export const BottomSheetAndroid: TransitionPreset = {
138
157
  export const ModalFadeTransition: TransitionPreset = {
139
158
  gestureDirection: 'vertical',
140
159
  transitionSpec: {
141
- open: BottomSheetSlideInSpec,
142
- close: BottomSheetSlideOutSpec,
160
+ open: TransitionIOSSpec,
161
+ close: TransitionIOSSpec,
143
162
  },
144
- cardStyleInterpolator: forFadeCard,
163
+ cardStyleInterpolator: forFadeFromCenter,
164
+ headerStyleInterpolator: forFade,
165
+ };
166
+
167
+ /**
168
+ * Standard iOS horizontal flip transition.
169
+ */
170
+ export const ModalFlipIOS: TransitionPreset = {
171
+ gestureDirection: 'horizontal',
172
+ transitionSpec: {
173
+ open: FlipIOSSpec,
174
+ close: FlipIOSSpec,
175
+ },
176
+ cardStyleInterpolator: forFlipIOS,
177
+ headerStyleInterpolator: forFade,
178
+ };
179
+
180
+ /**
181
+ * Standard iOS cross-dissolve transition.
182
+ */
183
+ export const CrossDissolveIOS: TransitionPreset = {
184
+ gestureDirection: 'horizontal',
185
+ transitionSpec: {
186
+ open: TransitionIOSSpec,
187
+ close: TransitionIOSSpec,
188
+ },
189
+ cardStyleInterpolator: forCrossDissolveIOS,
145
190
  headerStyleInterpolator: forFade,
146
191
  };
147
192
 
@@ -174,5 +219,6 @@ export const ModalTransition = Platform.select({
174
219
  */
175
220
  export const SlideFromLeftIOS: TransitionPreset = {
176
221
  ...SlideFromRightIOS,
177
- cardStyleInterpolator: forHorizontalIOSInverted,
222
+ gestureDirection: 'horizontal-inverted',
223
+ cardStyleInterpolator: forHorizontalIOS,
178
224
  };
@@ -1,9 +1,10 @@
1
1
  import { Easing } from 'react-native';
2
2
 
3
3
  import type { TransitionSpec } from '../types';
4
+ import { FAST_OUT_EXTRA_SLOW_IN } from './TransitionEasings';
4
5
 
5
6
  /**
6
- * Exact values from UINavigationController's animation configuration.
7
+ * Approximation of the standard iOS navigation transition.
7
8
  */
8
9
  export const TransitionIOSSpec: TransitionSpec = {
9
10
  animation: 'spring',
@@ -17,9 +18,21 @@ export const TransitionIOSSpec: TransitionSpec = {
17
18
  },
18
19
  };
19
20
 
21
+ /**
22
+ * Configuration for the standard iOS horizontal flip transition.
23
+ */
24
+ export const FlipIOSSpec: TransitionSpec = {
25
+ animation: 'timing',
26
+ config: {
27
+ duration: 700,
28
+ easing: Easing.inOut(Easing.ease),
29
+ },
30
+ };
31
+
20
32
  /**
21
33
  * 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
34
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-7.1.2_r37/core/res/res/anim/activity_open_enter.xml
35
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-7.1.2_r37/core/res/res/anim/activity_open_exit.xml
23
36
  */
24
37
  export const FadeInFromBottomAndroidSpec: TransitionSpec = {
25
38
  animation: 'timing',
@@ -31,94 +44,115 @@ export const FadeInFromBottomAndroidSpec: TransitionSpec = {
31
44
 
32
45
  /**
33
46
  * 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
47
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-7.1.2_r37/core/res/res/anim/activity_close_enter.xml
48
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-7.1.2_r37/core/res/res/anim/activity_close_exit.xml
35
49
  */
36
50
  export const FadeOutToBottomAndroidSpec: TransitionSpec = {
37
51
  animation: 'timing',
38
52
  config: {
39
- duration: 150,
40
- easing: Easing.in(Easing.linear),
53
+ duration: 250,
54
+ easing: Easing.in(Easing.poly(4)),
41
55
  },
42
56
  };
43
57
 
44
58
  /**
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
59
+ * Configuration for the standard Android dialog transition.
60
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/core/res/res/anim/dialog_enter.xml
61
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/core/res/res/anim/dialog_exit.xml
62
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/core/res/res/values/config.xml
63
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/core/res/res/values/themes_material.xml
64
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
65
+ */
66
+ export const DialogAndroidSpec: TransitionSpec = {
67
+ animation: 'timing',
68
+ config: {
69
+ duration: 220,
70
+ easing: Easing.out(Easing.poly(5)),
71
+ },
72
+ };
73
+
74
+ /**
75
+ * Configuration for activity open animation from Android Pie.
76
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r47/core/res/res/anim/activity_open_enter.xml
77
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r47/core/res/res/anim/activity_open_exit.xml
78
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r47/core/res/res/anim/activity_close_enter.xml
79
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-9.0.0_r47/core/res/res/anim/activity_close_exit.xml
47
80
  */
48
81
  export const RevealFromBottomAndroidSpec: TransitionSpec = {
49
82
  animation: 'timing',
50
83
  config: {
51
84
  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),
85
+ easing: FAST_OUT_EXTRA_SLOW_IN,
55
86
  },
56
87
  };
57
88
 
58
89
  /**
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
90
+ * Configuration for activity open animation from Android Q.
91
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-10.0.0_r2/core/res/res/anim/activity_open_enter.xml
92
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-10.0.0_r2/core/res/res/anim/activity_open_exit.xml
93
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-10.0.0_r2/core/res/res/anim/activity_close_enter.xml
94
+ * See https://android.googlesource.com/platform/frameworks/base/+/android-10.0.0_r2/core/res/res/anim/activity_close_exit.xml
61
95
  */
62
96
  export const ScaleFromCenterAndroidSpec: TransitionSpec = {
63
97
  animation: 'timing',
64
98
  config: {
65
99
  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),
100
+ easing: FAST_OUT_EXTRA_SLOW_IN,
69
101
  },
70
102
  };
71
103
 
72
104
  /**
73
- * Approximate configuration for activity open animation from Android 14.
105
+ * Configuration for activity open animation from Android 14 and later.
74
106
  * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/anim/activity_open_enter.xml
107
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/anim/activity_open_exit.xml
75
108
  */
76
109
  export const FadeInFromRightAndroidSpec: TransitionSpec = {
77
110
  animation: 'timing',
78
111
  config: {
79
112
  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),
113
+ easing: FAST_OUT_EXTRA_SLOW_IN,
83
114
  },
84
115
  };
85
116
 
86
117
  /**
87
- * Approximate configuration for activity close animation from Android 14.
118
+ * Configuration for activity close animation from Android 14 and later.
119
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/anim/activity_close_enter.xml
88
120
  * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-14.0.0_r51/core/res/res/anim/activity_close_exit.xml
89
121
  */
90
- export const FadeOutToLeftAndroidSpec: TransitionSpec = {
122
+ export const FadeOutToRightAndroidSpec: TransitionSpec = {
91
123
  animation: 'timing',
92
124
  config: {
93
125
  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),
126
+ easing: FAST_OUT_EXTRA_SLOW_IN,
97
127
  },
98
128
  };
99
129
 
100
130
  /**
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
131
+ * Configuration for bottom sheet slide in animation from Material 3.
132
+ * See https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/bottomsheet/res/anim/m3_bottom_sheet_slide_in.xml
133
+ * See https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/motion/res/values/tokens.xml
134
+ * See https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/dialog/res/values/tokens.xml
135
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
103
136
  */
104
137
  export const BottomSheetSlideInSpec: TransitionSpec = {
105
138
  animation: 'timing',
106
139
  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,
140
+ duration: 400,
141
+ easing: FAST_OUT_EXTRA_SLOW_IN,
110
142
  },
111
143
  };
112
144
 
113
145
  /**
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
146
+ * Configuration for bottom sheet slide out animation from Material 3.
147
+ * See https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/bottomsheet/res/anim/m3_bottom_sheet_slide_out.xml
148
+ * See https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/motion/res/values/tokens.xml
149
+ * See https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/dialog/res/values/tokens.xml
150
+ * See https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-17.0.0_r1/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
116
151
  */
117
152
  export const BottomSheetSlideOutSpec: TransitionSpec = {
118
153
  animation: 'timing',
119
154
  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)),
155
+ duration: 350,
156
+ easing: FAST_OUT_EXTRA_SLOW_IN,
123
157
  },
124
158
  };
package/src/index.tsx CHANGED
@@ -9,6 +9,7 @@ import * as TransitionSpecs from './TransitionConfigs/TransitionSpecs';
9
9
  export {
10
10
  createStackNavigator,
11
11
  createStackScreen,
12
+ type StackTypeBag,
12
13
  } from './navigators/createStackNavigator';
13
14
 
14
15
  /**
@@ -31,9 +32,9 @@ export {
31
32
  * Utilities
32
33
  */
33
34
  export { CardAnimationContext } from './utils/CardAnimationContext';
34
- export { GestureHandlerRefContext } from './utils/GestureHandlerRefContext';
35
+ export { GestureHandlerContext } from './utils/GestureHandlerContext';
35
36
  export { useCardAnimation } from './utils/useCardAnimation';
36
- export { useGestureHandlerRef } from './utils/useGestureHandlerRef';
37
+ export { useGestureHandler } from './utils/useGestureHandler';
37
38
 
38
39
  /**
39
40
  * Types