react-native-screen-transitions 3.0.0-rc.1 → 3.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +421 -371
- package/lib/commonjs/blank-stack/components/{Overlay.js → overlay.js} +11 -12
- package/lib/commonjs/blank-stack/components/overlay.js.map +1 -0
- package/lib/commonjs/blank-stack/components/{Screens.js → screens.js} +8 -10
- package/lib/commonjs/blank-stack/components/screens.js.map +1 -0
- package/lib/commonjs/blank-stack/components/stack-view.js +95 -0
- package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -0
- package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js +2 -3
- package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js.map +1 -1
- package/lib/commonjs/blank-stack/index.js +1 -8
- package/lib/commonjs/blank-stack/index.js.map +1 -1
- package/lib/commonjs/blank-stack/navigators/{createBlankStackNavigator.js → create-blank-stack-navigator.js} +3 -3
- package/lib/commonjs/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/are-descriptors-equal.js.map +1 -0
- package/lib/{module/blank-stack/utils/with-stack-navigation/_utils → commonjs/blank-stack/utils/with-stack-navigation/helpers}/calculate-active-screens-limit.js.map +1 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js +15 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js.map +1 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/have-same-route-keys.js.map +1 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/helpers/routes-are-identical.js.map +1 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.js +1 -12
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/hooks/use-closing-route-keys.js.map +1 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/hooks/use-previous.js.map +1 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.js +4 -4
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/hooks/use-stack-navigation-state.js.map +1 -0
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/index.js +50 -56
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/index.js.map +1 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_types.js → types.js} +1 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/types.js.map +1 -0
- package/lib/commonjs/shared/configs/presets.js +8 -2
- package/lib/commonjs/shared/configs/presets.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +42 -21
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/providers/flags.provider.js +25 -0
- package/lib/commonjs/shared/providers/flags.provider.js.map +1 -0
- package/lib/commonjs/shared/providers/register-bounds.provider.js +71 -45
- package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/commonjs/shared/stores/bounds.store.js +91 -47
- package/lib/commonjs/shared/stores/bounds.store.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/helpers/is-bounds-equal.js +1 -1
- package/lib/commonjs/shared/utils/bounds/helpers/is-bounds-equal.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/index.js +4 -5
- package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
- package/lib/commonjs/shared/utils/create-provider.js +20 -1
- package/lib/commonjs/shared/utils/create-provider.js.map +1 -1
- package/lib/commonjs/shared/utils/reset-stores-for-screen.js +2 -0
- package/lib/commonjs/shared/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/module/blank-stack/components/{Overlay.js → overlay.js} +11 -12
- package/lib/module/blank-stack/components/overlay.js.map +1 -0
- package/lib/module/blank-stack/components/{Screens.js → screens.js} +8 -10
- package/lib/module/blank-stack/components/screens.js.map +1 -0
- package/lib/module/blank-stack/components/stack-view.js +90 -0
- package/lib/module/blank-stack/components/stack-view.js.map +1 -0
- package/lib/module/blank-stack/hooks/use-overlay-animation.js +2 -3
- package/lib/module/blank-stack/hooks/use-overlay-animation.js.map +1 -1
- package/lib/module/blank-stack/index.js +1 -2
- package/lib/module/blank-stack/index.js.map +1 -1
- package/lib/module/blank-stack/navigators/{createBlankStackNavigator.js → create-blank-stack-navigator.js} +2 -2
- package/lib/module/blank-stack/navigators/create-blank-stack-navigator.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/helpers/are-descriptors-equal.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/helpers/calculate-active-screens-limit.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js +10 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/helpers/have-same-route-keys.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/helpers/routes-are-identical.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.js +1 -12
- package/lib/module/blank-stack/utils/with-stack-navigation/hooks/use-closing-route-keys.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/hooks/use-previous.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.js +4 -4
- package/lib/module/blank-stack/utils/with-stack-navigation/hooks/use-stack-navigation-state.js.map +1 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/index.js +49 -55
- package/lib/module/blank-stack/utils/with-stack-navigation/index.js.map +1 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/types.js +4 -0
- package/lib/module/blank-stack/utils/with-stack-navigation/types.js.map +1 -0
- package/lib/module/shared/configs/presets.js +8 -2
- package/lib/module/shared/configs/presets.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js +42 -21
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/providers/flags.provider.js +19 -0
- package/lib/module/shared/providers/flags.provider.js.map +1 -0
- package/lib/module/shared/providers/register-bounds.provider.js +71 -45
- package/lib/module/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/module/shared/stores/bounds.store.js +91 -47
- package/lib/module/shared/stores/bounds.store.js.map +1 -1
- package/lib/module/shared/utils/bounds/helpers/is-bounds-equal.js +1 -1
- package/lib/module/shared/utils/bounds/helpers/is-bounds-equal.js.map +1 -1
- package/lib/module/shared/utils/bounds/index.js +4 -5
- package/lib/module/shared/utils/bounds/index.js.map +1 -1
- package/lib/module/shared/utils/create-provider.js +20 -1
- package/lib/module/shared/utils/create-provider.js.map +1 -1
- package/lib/module/shared/utils/reset-stores-for-screen.js +2 -0
- package/lib/module/shared/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/typescript/blank-stack/components/{Overlay.d.ts → overlay.d.ts} +1 -1
- package/lib/typescript/blank-stack/components/overlay.d.ts.map +1 -0
- package/lib/typescript/blank-stack/components/{Screens.d.ts → screens.d.ts} +1 -1
- package/lib/typescript/blank-stack/components/{Screens.d.ts.map → screens.d.ts.map} +1 -1
- package/lib/typescript/blank-stack/components/stack-view.d.ts +3 -0
- package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -0
- package/lib/typescript/blank-stack/index.d.ts +1 -2
- package/lib/typescript/blank-stack/index.d.ts.map +1 -1
- package/lib/typescript/blank-stack/navigators/{createBlankStackNavigator.d.ts → create-blank-stack-navigator.d.ts} +1 -1
- package/lib/typescript/blank-stack/navigators/create-blank-stack-navigator.d.ts.map +1 -0
- package/lib/typescript/blank-stack/types.d.ts +23 -105
- package/lib/typescript/blank-stack/types.d.ts.map +1 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/are-descriptors-equal.d.ts.map +1 -0
- package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/calculate-active-screens-limit.d.ts.map +1 -0
- package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/compose-descriptors.d.ts.map +1 -0
- package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/have-same-route-keys.d.ts.map +1 -0
- package/lib/typescript/blank-stack/utils/with-stack-navigation/helpers/routes-are-identical.d.ts.map +1 -0
- package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.d.ts.map +1 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.d.ts.map +1 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.d.ts +1 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/hooks/use-stack-navigation-state.d.ts.map +1 -0
- package/lib/typescript/blank-stack/utils/with-stack-navigation/index.d.ts +3 -5
- package/lib/typescript/blank-stack/utils/with-stack-navigation/index.d.ts.map +1 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/{_types.d.ts → types.d.ts} +1 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/types.d.ts.map +1 -0
- package/lib/typescript/native-stack/types.d.ts +7 -1
- package/lib/typescript/native-stack/types.d.ts.map +1 -1
- package/lib/typescript/shared/configs/index.d.ts.map +1 -1
- package/lib/typescript/shared/configs/presets.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +32 -32
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/flags.provider.d.ts +10 -0
- package/lib/typescript/shared/providers/flags.provider.d.ts.map +1 -0
- package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -1
- package/lib/typescript/shared/stores/bounds.store.d.ts +23 -11
- package/lib/typescript/shared/stores/bounds.store.d.ts.map +1 -1
- package/lib/typescript/shared/types/bounds.types.d.ts +2 -2
- package/lib/typescript/shared/types/bounds.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/core.types.d.ts +0 -4
- package/lib/typescript/shared/types/core.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
- package/lib/typescript/shared/utils/create-provider.d.ts +2 -2
- package/lib/typescript/shared/utils/create-provider.d.ts.map +1 -1
- package/lib/typescript/shared/utils/reset-stores-for-screen.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/blank-stack/components/{Overlay.tsx → overlay.tsx} +9 -12
- package/src/blank-stack/components/{Screens.tsx → screens.tsx} +7 -9
- package/src/blank-stack/components/stack-view.tsx +104 -0
- package/src/blank-stack/hooks/use-overlay-animation.tsx +11 -11
- package/src/blank-stack/index.ts +1 -2
- package/src/blank-stack/navigators/{createBlankStackNavigator.tsx → create-blank-stack-navigator.tsx} +1 -1
- package/src/blank-stack/types.ts +31 -109
- package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/compose-descriptors.ts +1 -8
- package/src/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.tsx +1 -12
- package/src/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-stack-navigation-state.tsx +5 -5
- package/src/blank-stack/utils/with-stack-navigation/index.tsx +43 -63
- package/src/native-stack/types.ts +8 -1
- package/src/shared/__tests__/bounds.store.test.ts +398 -167
- package/src/shared/__tests__/determine-dismissal.test.ts +2 -12
- package/src/shared/__tests__/geometry.test.ts +1 -1
- package/src/shared/__tests__/gesture.velocity.test.ts +2 -10
- package/src/shared/configs/presets.ts +8 -2
- package/src/shared/hooks/animation/use-screen-animation.tsx +65 -31
- package/src/shared/hooks/gestures/use-build-gestures.tsx +4 -1
- package/src/shared/providers/flags.provider.tsx +21 -0
- package/src/shared/providers/register-bounds.provider.tsx +85 -54
- package/src/shared/stores/bounds.store.ts +90 -54
- package/src/shared/types/bounds.types.ts +2 -2
- package/src/shared/types/core.types.ts +4 -6
- package/src/shared/utils/bounds/helpers/is-bounds-equal.ts +1 -1
- package/src/shared/utils/bounds/index.ts +7 -10
- package/src/shared/utils/create-provider.tsx +35 -1
- package/src/shared/utils/reset-stores-for-screen.ts +2 -0
- package/lib/commonjs/blank-stack/components/Overlay.js.map +0 -1
- package/lib/commonjs/blank-stack/components/Screens.js.map +0 -1
- package/lib/commonjs/blank-stack/components/StackView.js +0 -93
- package/lib/commonjs/blank-stack/components/StackView.js.map +0 -1
- package/lib/commonjs/blank-stack/navigators/createBlankStackNavigator.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_types.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/calculate-active-screens-limit.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +0 -25
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +0 -1
- package/lib/commonjs/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +0 -1
- package/lib/module/blank-stack/components/Overlay.js.map +0 -1
- package/lib/module/blank-stack/components/Screens.js.map +0 -1
- package/lib/module/blank-stack/components/StackView.js +0 -88
- package/lib/module/blank-stack/components/StackView.js.map +0 -1
- package/lib/module/blank-stack/navigators/createBlankStackNavigator.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_types.js +0 -4
- package/lib/module/blank-stack/utils/with-stack-navigation/_types.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +0 -20
- package/lib/module/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +0 -1
- package/lib/module/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +0 -1
- package/lib/typescript/blank-stack/components/Overlay.d.ts.map +0 -1
- package/lib/typescript/blank-stack/components/StackView.d.ts +0 -2
- package/lib/typescript/blank-stack/components/StackView.d.ts.map +0 -1
- package/lib/typescript/blank-stack/navigators/createBlankStackNavigator.d.ts.map +0 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.d.ts.map +0 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/_types.d.ts.map +0 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.d.ts.map +0 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/calculate-active-screens-limit.d.ts.map +0 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.d.ts.map +0 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.d.ts.map +0 -1
- package/lib/typescript/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.d.ts.map +0 -1
- package/src/blank-stack/components/StackView.tsx +0 -108
- /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.js +0 -0
- /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.js +0 -0
- /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.js +0 -0
- /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.js +0 -0
- /package/lib/commonjs/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.js +0 -0
- /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.js +0 -0
- /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.js +0 -0
- /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.js +0 -0
- /package/lib/module/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.js +0 -0
- /package/lib/module/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.js +0 -0
- /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.d.ts +0 -0
- /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.d.ts +0 -0
- /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/compose-descriptors.d.ts +0 -0
- /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.d.ts +0 -0
- /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.d.ts +0 -0
- /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-closing-route-keys.d.ts +0 -0
- /package/lib/typescript/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.d.ts +0 -0
- /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/are-descriptors-equal.ts +0 -0
- /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/calculate-active-screens-limit.ts +0 -0
- /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/have-same-route-keys.ts +0 -0
- /package/src/blank-stack/utils/with-stack-navigation/{_utils → helpers}/routes-are-identical.ts +0 -0
- /package/src/blank-stack/utils/with-stack-navigation/{_hooks → hooks}/use-previous.tsx +0 -0
- /package/src/blank-stack/utils/with-stack-navigation/{_types.ts → types.ts} +0 -0
|
@@ -13,6 +13,7 @@ export const SlideFromTop = (
|
|
|
13
13
|
config: Partial<ScreenTransitionConfig> = {},
|
|
14
14
|
): ScreenTransitionConfig => {
|
|
15
15
|
return {
|
|
16
|
+
//@ts-expect-error - Should not lead to any issues
|
|
16
17
|
enableTransitions: true,
|
|
17
18
|
gestureEnabled: true,
|
|
18
19
|
gestureDirection: "vertical-inverted",
|
|
@@ -45,6 +46,7 @@ export const ZoomIn = (
|
|
|
45
46
|
config: Partial<ScreenTransitionConfig> = {},
|
|
46
47
|
): ScreenTransitionConfig => {
|
|
47
48
|
return {
|
|
49
|
+
//@ts-expect-error - Should not lead to any issues
|
|
48
50
|
enableTransitions: true,
|
|
49
51
|
gestureEnabled: false,
|
|
50
52
|
screenStyleInterpolator: ({ progress }) => {
|
|
@@ -83,6 +85,7 @@ export const SlideFromBottom = (
|
|
|
83
85
|
config: Partial<ScreenTransitionConfig> = {},
|
|
84
86
|
): ScreenTransitionConfig => {
|
|
85
87
|
return {
|
|
88
|
+
//@ts-expect-error - Should not lead to any issues
|
|
86
89
|
enableTransitions: true,
|
|
87
90
|
gestureEnabled: true,
|
|
88
91
|
gestureDirection: "vertical",
|
|
@@ -114,6 +117,7 @@ export const DraggableCard = (
|
|
|
114
117
|
config: Partial<ScreenTransitionConfig> = {},
|
|
115
118
|
): ScreenTransitionConfig => {
|
|
116
119
|
return {
|
|
120
|
+
//@ts-expect-error - Should not lead to any issues
|
|
117
121
|
enableTransitions: true,
|
|
118
122
|
gestureEnabled: true,
|
|
119
123
|
gestureDirection: ["horizontal", "vertical"],
|
|
@@ -159,6 +163,7 @@ export const ElasticCard = (
|
|
|
159
163
|
} = { elasticFactor: 0.5 },
|
|
160
164
|
): ScreenTransitionConfig => {
|
|
161
165
|
return {
|
|
166
|
+
//@ts-expect-error - Should not lead to any issues
|
|
162
167
|
enableTransitions: true,
|
|
163
168
|
gestureEnabled: true,
|
|
164
169
|
gestureDirection: "bidirectional",
|
|
@@ -535,7 +540,7 @@ export const SharedAppleMusic = ({
|
|
|
535
540
|
damping: 500,
|
|
536
541
|
mass: 3,
|
|
537
542
|
overshootClamping: true,
|
|
538
|
-
//@ts-expect-error
|
|
543
|
+
//@ts-expect-error - Should not lead to any issues
|
|
539
544
|
restSpeedThreshold: 0.02,
|
|
540
545
|
},
|
|
541
546
|
close: {
|
|
@@ -543,7 +548,7 @@ export const SharedAppleMusic = ({
|
|
|
543
548
|
damping: 60,
|
|
544
549
|
mass: 4,
|
|
545
550
|
overshootClamping: false,
|
|
546
|
-
//@ts-expect-error
|
|
551
|
+
//@ts-expect-error - Should not lead to any issues
|
|
547
552
|
restSpeedThreshold: 0.02,
|
|
548
553
|
restDisplacementThreshold: 0.002,
|
|
549
554
|
},
|
|
@@ -559,6 +564,7 @@ export const SharedXImage = ({
|
|
|
559
564
|
sharedBoundTag: string;
|
|
560
565
|
}): ScreenTransitionConfig => {
|
|
561
566
|
return {
|
|
567
|
+
//@ts-expect-error - Should not lead to any issues
|
|
562
568
|
enableTransitions: true,
|
|
563
569
|
gestureEnabled: true,
|
|
564
570
|
gestureDirection: ["vertical", "vertical-inverted"],
|
|
@@ -3,16 +3,21 @@ import { useMemo } from "react";
|
|
|
3
3
|
import { useWindowDimensions } from "react-native";
|
|
4
4
|
import { type SharedValue, useDerivedValue } from "react-native-reanimated";
|
|
5
5
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
6
|
-
|
|
6
|
+
import type { NativeStackScreenTransitionConfig } from "../../../native-stack/types";
|
|
7
7
|
import { DEFAULT_SCREEN_TRANSITION_STATE } from "../../constants";
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import { useFlagsContext } from "../../providers/flags.provider";
|
|
9
|
+
import {
|
|
10
|
+
type TransitionDescriptor,
|
|
11
|
+
useKeys,
|
|
12
|
+
} from "../../providers/keys.provider";
|
|
10
13
|
import { AnimationStore } from "../../stores/animation.store";
|
|
11
14
|
import { GestureStore, type GestureStoreMap } from "../../stores/gesture.store";
|
|
12
15
|
import type {
|
|
13
16
|
ScreenInterpolationProps,
|
|
14
17
|
ScreenTransitionState,
|
|
15
18
|
} from "../../types/animation.types";
|
|
19
|
+
import type { ScreenTransitionConfig } from "../../types/core.types";
|
|
20
|
+
import type { GestureDirection } from "../../types/gesture.types";
|
|
16
21
|
import { derivations } from "../../utils/animation/derivations";
|
|
17
22
|
import { createBounds } from "../../utils/bounds";
|
|
18
23
|
|
|
@@ -22,30 +27,45 @@ type BuiltState = {
|
|
|
22
27
|
animating: SharedValue<number>;
|
|
23
28
|
gesture: GestureStoreMap;
|
|
24
29
|
route: RouteProp<ParamListBase>;
|
|
30
|
+
unwrapped: ScreenTransitionState;
|
|
25
31
|
};
|
|
26
32
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
const createScreenTransitionState = (
|
|
34
|
+
route: RouteProp<ParamListBase>,
|
|
35
|
+
): ScreenTransitionState => ({
|
|
36
|
+
progress: 0,
|
|
37
|
+
closing: 0,
|
|
38
|
+
animating: 0,
|
|
39
|
+
gesture: {
|
|
40
|
+
x: 0,
|
|
41
|
+
y: 0,
|
|
42
|
+
normalizedX: 0,
|
|
43
|
+
normalizedY: 0,
|
|
44
|
+
isDismissing: 0,
|
|
45
|
+
isDragging: 0,
|
|
46
|
+
direction: null,
|
|
47
|
+
},
|
|
48
|
+
route,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const unwrapInto = (s: BuiltState): ScreenTransitionState => {
|
|
31
52
|
"worklet";
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
53
|
+
const out = s.unwrapped;
|
|
54
|
+
out.progress = s.progress.value;
|
|
55
|
+
out.closing = s.closing.value;
|
|
56
|
+
out.animating = s.animating.value;
|
|
57
|
+
out.gesture.x = s.gesture.x.value;
|
|
58
|
+
out.gesture.y = s.gesture.y.value;
|
|
59
|
+
out.gesture.normalizedX = s.gesture.normalizedX.value;
|
|
60
|
+
out.gesture.normalizedY = s.gesture.normalizedY.value;
|
|
61
|
+
out.gesture.isDismissing = s.gesture.isDismissing.value;
|
|
62
|
+
out.gesture.isDragging = s.gesture.isDragging.value;
|
|
63
|
+
out.gesture.direction = s.gesture.direction.value as Omit<
|
|
64
|
+
GestureDirection,
|
|
65
|
+
"bidirectional"
|
|
66
|
+
> | null;
|
|
67
|
+
|
|
68
|
+
return out;
|
|
49
69
|
};
|
|
50
70
|
|
|
51
71
|
const useBuildScreenTransitionState = (
|
|
@@ -62,13 +82,25 @@ const useBuildScreenTransitionState = (
|
|
|
62
82
|
animating: AnimationStore.getAnimation(key, "animating"),
|
|
63
83
|
gesture: GestureStore.getRouteGestures(key),
|
|
64
84
|
route: descriptor.route,
|
|
85
|
+
unwrapped: createScreenTransitionState(descriptor.route),
|
|
65
86
|
};
|
|
66
87
|
}, [key, descriptor?.route]);
|
|
67
88
|
};
|
|
68
89
|
|
|
90
|
+
const hasTransitionsEnabled = (
|
|
91
|
+
options: ScreenTransitionConfig | undefined,
|
|
92
|
+
alwaysOn: boolean,
|
|
93
|
+
) => {
|
|
94
|
+
"worklet";
|
|
95
|
+
if (alwaysOn) return true;
|
|
96
|
+
return !!(options as NativeStackScreenTransitionConfig)?.enableTransitions;
|
|
97
|
+
};
|
|
98
|
+
|
|
69
99
|
export function _useScreenAnimation() {
|
|
70
100
|
const dimensions = useWindowDimensions();
|
|
71
101
|
const insets = useSafeAreaInsets();
|
|
102
|
+
const flags = useFlagsContext();
|
|
103
|
+
const transitionsAlwaysOn = flags?.TRANSITIONS_ALWAYS_ON ?? false;
|
|
72
104
|
|
|
73
105
|
const {
|
|
74
106
|
current: currentDescriptor,
|
|
@@ -85,15 +117,17 @@ export function _useScreenAnimation() {
|
|
|
85
117
|
>(() => {
|
|
86
118
|
"worklet";
|
|
87
119
|
|
|
88
|
-
const previous =
|
|
120
|
+
const previous = prevAnimation ? unwrapInto(prevAnimation) : undefined;
|
|
89
121
|
|
|
90
|
-
const next =
|
|
91
|
-
|
|
92
|
-
|
|
122
|
+
const next =
|
|
123
|
+
nextAnimation &&
|
|
124
|
+
hasTransitionsEnabled(nextDescriptor?.options, transitionsAlwaysOn)
|
|
125
|
+
? unwrapInto(nextAnimation)
|
|
126
|
+
: undefined;
|
|
93
127
|
|
|
94
|
-
const current =
|
|
95
|
-
|
|
96
|
-
DEFAULT_SCREEN_TRANSITION_STATE;
|
|
128
|
+
const current = currentAnimation
|
|
129
|
+
? unwrapInto(currentAnimation)
|
|
130
|
+
: DEFAULT_SCREEN_TRANSITION_STATE;
|
|
97
131
|
|
|
98
132
|
const helpers = derivations({
|
|
99
133
|
current,
|
|
@@ -26,7 +26,10 @@ import { useKeys } from "../../providers/keys.provider";
|
|
|
26
26
|
import { AnimationStore } from "../../stores/animation.store";
|
|
27
27
|
import { GestureStore, type GestureStoreMap } from "../../stores/gesture.store";
|
|
28
28
|
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
type GestureDirection,
|
|
31
|
+
GestureOffsetState,
|
|
32
|
+
} from "../../types/gesture.types";
|
|
30
33
|
import { startScreenTransition } from "../../utils/animation/start-screen-transition";
|
|
31
34
|
import { applyOffsetRules } from "../../utils/gesture/check-gesture-activation";
|
|
32
35
|
import { determineDismissal } from "../../utils/gesture/determine-dismissal";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import createProvider from "../utils/create-provider";
|
|
2
|
+
|
|
3
|
+
interface FlagsValue {
|
|
4
|
+
TRANSITIONS_ALWAYS_ON: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface FlagsProviderProps {
|
|
8
|
+
TRANSITIONS_ALWAYS_ON?: boolean;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { FlagsProvider, useFlagsContext } = createProvider("Flags", {
|
|
13
|
+
guarded: false,
|
|
14
|
+
})<FlagsProviderProps, FlagsValue>(
|
|
15
|
+
({ TRANSITIONS_ALWAYS_ON = false, children }) => ({
|
|
16
|
+
value: { TRANSITIONS_ALWAYS_ON },
|
|
17
|
+
children,
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export { FlagsProvider, useFlagsContext };
|
|
@@ -43,27 +43,26 @@ interface RegisterBoundsContextValue {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
* Returns
|
|
46
|
+
* Builds the full ancestor key chain for nested navigators.
|
|
47
|
+
* Returns an array of screen keys from immediate parent to root.
|
|
48
|
+
* [parentKey, grandparentKey, greatGrandparentKey, ...]
|
|
48
49
|
*/
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (!existsInParent && parentState.index !== undefined) {
|
|
63
|
-
return parentState.routes[parentState.index]?.key;
|
|
50
|
+
const getAncestorKeys = (current: TransitionDescriptor): string[] => {
|
|
51
|
+
const ancestors: string[] = [];
|
|
52
|
+
let nav = current.navigation.getParent();
|
|
53
|
+
|
|
54
|
+
while (nav) {
|
|
55
|
+
const state = nav.getState();
|
|
56
|
+
if (state?.routes && state.index !== undefined) {
|
|
57
|
+
const focusedRoute = state.routes[state.index];
|
|
58
|
+
if (focusedRoute?.key) {
|
|
59
|
+
ancestors.push(focusedRoute.key);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
nav = nav.getParent();
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
return
|
|
65
|
+
return ancestors;
|
|
67
66
|
};
|
|
68
67
|
|
|
69
68
|
/**
|
|
@@ -73,13 +72,13 @@ const getParentScreenKey = (current: TransitionDescriptor) => {
|
|
|
73
72
|
const useInitialLayoutHandler = (params: {
|
|
74
73
|
sharedBoundTag?: string;
|
|
75
74
|
currentScreenKey: string;
|
|
76
|
-
|
|
75
|
+
ancestorKeys: string[];
|
|
77
76
|
maybeMeasureAndStore: (options: MaybeMeasureAndStoreParams) => void;
|
|
78
77
|
}) => {
|
|
79
78
|
const {
|
|
80
79
|
sharedBoundTag,
|
|
81
80
|
currentScreenKey,
|
|
82
|
-
|
|
81
|
+
ancestorKeys,
|
|
83
82
|
maybeMeasureAndStore,
|
|
84
83
|
} = params;
|
|
85
84
|
|
|
@@ -87,57 +86,84 @@ const useInitialLayoutHandler = (params: {
|
|
|
87
86
|
currentScreenKey,
|
|
88
87
|
"animating",
|
|
89
88
|
);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
|
|
90
|
+
// Check if any ancestor is animating
|
|
91
|
+
const ancestorAnimations = ancestorKeys.map((key) =>
|
|
92
|
+
AnimationStore.getAnimation(key, "animating"),
|
|
93
|
+
);
|
|
93
94
|
|
|
94
95
|
const hasMeasuredOnLayout = useSharedValue(false);
|
|
95
96
|
|
|
96
97
|
return useCallback(() => {
|
|
97
98
|
"worklet";
|
|
98
|
-
if (!sharedBoundTag || hasMeasuredOnLayout.
|
|
99
|
-
|
|
99
|
+
if (!sharedBoundTag || hasMeasuredOnLayout.get()) return;
|
|
100
|
+
|
|
101
|
+
// Check if current or any ancestor is animating
|
|
102
|
+
let isAnyAnimating = isAnimating.get();
|
|
103
|
+
for (let i = 0; i < ancestorAnimations.length; i++) {
|
|
104
|
+
if (ancestorAnimations[i].get()) {
|
|
105
|
+
isAnyAnimating = 1;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!isAnyAnimating) return;
|
|
100
111
|
|
|
101
112
|
maybeMeasureAndStore({
|
|
102
113
|
shouldSetSource: false,
|
|
103
114
|
shouldSetDestination: true,
|
|
104
115
|
});
|
|
105
116
|
|
|
106
|
-
hasMeasuredOnLayout.
|
|
117
|
+
hasMeasuredOnLayout.set(true);
|
|
107
118
|
}, [
|
|
108
119
|
sharedBoundTag,
|
|
109
120
|
hasMeasuredOnLayout,
|
|
110
121
|
isAnimating,
|
|
111
|
-
|
|
122
|
+
ancestorAnimations,
|
|
112
123
|
maybeMeasureAndStore,
|
|
113
124
|
]);
|
|
114
125
|
};
|
|
115
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Measures non-pressable elements when screen becomes blurred.
|
|
129
|
+
* Captures bounds right before transition starts.
|
|
130
|
+
*/
|
|
116
131
|
/**
|
|
117
132
|
* Measures non-pressable elements when screen becomes blurred.
|
|
118
133
|
* Captures bounds right before transition starts.
|
|
119
134
|
*/
|
|
120
135
|
const useBlurMeasurement = (params: {
|
|
121
136
|
sharedBoundTag?: string;
|
|
137
|
+
ancestorKeys: string[];
|
|
122
138
|
maybeMeasureAndStore: (options: MaybeMeasureAndStoreParams) => void;
|
|
123
139
|
}) => {
|
|
124
|
-
const {
|
|
125
|
-
const
|
|
140
|
+
const { current } = useKeys();
|
|
141
|
+
const { sharedBoundTag, ancestorKeys, maybeMeasureAndStore } = params;
|
|
126
142
|
const hasCapturedSource = useRef(false);
|
|
127
143
|
|
|
144
|
+
const ancestorClosing = [current.route.key, ...ancestorKeys].map((key) =>
|
|
145
|
+
AnimationStore.getAnimation(key, "closing"),
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const maybeMeasureOnBlur = useStableCallbackValue(() => {
|
|
149
|
+
"worklet";
|
|
150
|
+
|
|
151
|
+
// Don't measure if current / any ancestor is closing
|
|
152
|
+
const isOneClosing = ancestorClosing.some((closing) => closing.get());
|
|
153
|
+
if (isOneClosing) return;
|
|
154
|
+
|
|
155
|
+
maybeMeasureAndStore({ shouldSetSource: true });
|
|
156
|
+
});
|
|
157
|
+
|
|
128
158
|
useFocusEffect(
|
|
129
159
|
useCallback(() => {
|
|
130
|
-
isFocused.current = true;
|
|
131
160
|
hasCapturedSource.current = false;
|
|
132
161
|
|
|
133
162
|
return () => {
|
|
134
|
-
if (!sharedBoundTag) return;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
isFocused.current = false;
|
|
138
|
-
runOnUI(maybeMeasureAndStore)({ shouldSetSource: true });
|
|
163
|
+
if (!sharedBoundTag || hasCapturedSource.current) return;
|
|
164
|
+
runOnUI(maybeMeasureOnBlur)();
|
|
139
165
|
};
|
|
140
|
-
}, [sharedBoundTag,
|
|
166
|
+
}, [sharedBoundTag, maybeMeasureOnBlur]),
|
|
141
167
|
);
|
|
142
168
|
|
|
143
169
|
return {
|
|
@@ -157,7 +183,7 @@ const useParentSyncReaction = (params: {
|
|
|
157
183
|
const { parentContext, maybeMeasureAndStore } = params;
|
|
158
184
|
|
|
159
185
|
useAnimatedReaction(
|
|
160
|
-
() => parentContext?.updateSignal.
|
|
186
|
+
() => parentContext?.updateSignal.get(),
|
|
161
187
|
(value) => {
|
|
162
188
|
"worklet";
|
|
163
189
|
if (value === 0 || value === undefined) return;
|
|
@@ -173,11 +199,12 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
173
199
|
({ style, onPress, sharedBoundTag, animatedRef, children }) => {
|
|
174
200
|
const { current } = useKeys();
|
|
175
201
|
const currentScreenKey = current.route.key;
|
|
176
|
-
const
|
|
202
|
+
const ancestorKeys = useMemo(() => getAncestorKeys(current), [current]);
|
|
177
203
|
|
|
178
204
|
// Context & signals
|
|
179
205
|
const parentContext: RegisterBoundsContextValue | null =
|
|
180
206
|
useRegisterBoundsContext();
|
|
207
|
+
|
|
181
208
|
const ownSignal = useSharedValue(0);
|
|
182
209
|
const updateSignal: SharedValue<number> =
|
|
183
210
|
parentContext?.updateSignal ?? ownSignal;
|
|
@@ -191,7 +218,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
191
218
|
const emitUpdate = useStableCallbackValue(() => {
|
|
192
219
|
"worklet";
|
|
193
220
|
const isRoot = !parentContext;
|
|
194
|
-
if (isRoot) updateSignal.
|
|
221
|
+
if (isRoot) updateSignal.set(updateSignal.get() + 1);
|
|
195
222
|
});
|
|
196
223
|
|
|
197
224
|
const maybeMeasureAndStore = useStableCallbackValue(
|
|
@@ -208,28 +235,31 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
208
235
|
|
|
209
236
|
emitUpdate();
|
|
210
237
|
|
|
211
|
-
|
|
212
|
-
BoundStore.registerOccurrence(
|
|
238
|
+
BoundStore.registerSnapshot(
|
|
213
239
|
sharedBoundTag,
|
|
214
240
|
currentScreenKey,
|
|
215
241
|
measured,
|
|
216
242
|
preparedStyles,
|
|
243
|
+
ancestorKeys,
|
|
217
244
|
);
|
|
218
245
|
|
|
219
|
-
// Set as source (on press or blur)
|
|
220
246
|
if (shouldSetSource) {
|
|
221
|
-
if (isAnimating.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
226
|
-
BoundStore.setLinkSource(
|
|
247
|
+
if (isAnimating.get()) {
|
|
248
|
+
// If animation is already in progress,
|
|
249
|
+
// lets use the existing measuremenets.
|
|
250
|
+
const existing = BoundStore.getSnapshot(
|
|
227
251
|
sharedBoundTag,
|
|
228
252
|
currentScreenKey,
|
|
229
|
-
existing.bounds,
|
|
230
|
-
preparedStyles,
|
|
231
|
-
parentScreenKey,
|
|
232
253
|
);
|
|
254
|
+
if (existing) {
|
|
255
|
+
BoundStore.setLinkSource(
|
|
256
|
+
sharedBoundTag,
|
|
257
|
+
currentScreenKey,
|
|
258
|
+
existing.bounds,
|
|
259
|
+
preparedStyles,
|
|
260
|
+
ancestorKeys,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
233
263
|
return;
|
|
234
264
|
}
|
|
235
265
|
BoundStore.setLinkSource(
|
|
@@ -237,7 +267,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
237
267
|
currentScreenKey,
|
|
238
268
|
measured,
|
|
239
269
|
preparedStyles,
|
|
240
|
-
|
|
270
|
+
ancestorKeys,
|
|
241
271
|
);
|
|
242
272
|
}
|
|
243
273
|
|
|
@@ -248,7 +278,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
248
278
|
currentScreenKey,
|
|
249
279
|
measured,
|
|
250
280
|
preparedStyles,
|
|
251
|
-
|
|
281
|
+
ancestorKeys,
|
|
252
282
|
);
|
|
253
283
|
}
|
|
254
284
|
|
|
@@ -259,7 +289,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
259
289
|
const handleInitialLayout = useInitialLayoutHandler({
|
|
260
290
|
sharedBoundTag,
|
|
261
291
|
currentScreenKey,
|
|
262
|
-
|
|
292
|
+
ancestorKeys,
|
|
263
293
|
maybeMeasureAndStore,
|
|
264
294
|
});
|
|
265
295
|
|
|
@@ -267,6 +297,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
267
297
|
const { markSourceCaptured } = useBlurMeasurement({
|
|
268
298
|
sharedBoundTag,
|
|
269
299
|
maybeMeasureAndStore,
|
|
300
|
+
ancestorKeys,
|
|
270
301
|
});
|
|
271
302
|
|
|
272
303
|
useParentSyncReaction({ parentContext, maybeMeasureAndStore });
|