react-native-screen-transitions 3.2.0-beta.0 → 3.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -8
- package/lib/commonjs/blank-stack/components/adjusted-screen-container.js +36 -0
- package/lib/commonjs/blank-stack/components/adjusted-screen-container.js.map +1 -0
- package/lib/commonjs/blank-stack/components/{screens.js → adjusted-screen.js} +31 -11
- package/lib/commonjs/blank-stack/components/adjusted-screen.js.map +1 -0
- package/lib/commonjs/blank-stack/components/stack-view.js +33 -41
- package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/blank-stack/components/stack-view.native.js +81 -0
- package/lib/commonjs/blank-stack/components/stack-view.native.js.map +1 -0
- package/lib/commonjs/component-stack/components/component-screen-container.js +23 -0
- package/lib/commonjs/component-stack/components/component-screen-container.js.map +1 -0
- package/lib/commonjs/component-stack/components/component-screen.js +36 -0
- package/lib/commonjs/component-stack/components/component-screen.js.map +1 -0
- package/lib/commonjs/component-stack/components/stack-view.js +64 -0
- package/lib/commonjs/component-stack/components/stack-view.js.map +1 -0
- package/lib/commonjs/component-stack/index.js +3 -10
- package/lib/commonjs/component-stack/index.js.map +1 -1
- package/lib/commonjs/component-stack/navigators/create-component-stack-navigator.js +52 -0
- package/lib/commonjs/component-stack/navigators/create-component-stack-navigator.js.map +1 -0
- package/lib/commonjs/native-stack/views/NativeStackView.native.js +103 -105
- package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/helpers/get-active-overlay.js +0 -25
- package/lib/commonjs/shared/components/overlay/helpers/get-active-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/index.js +1 -3
- package/lib/commonjs/shared/components/overlay/index.js.map +1 -1
- package/lib/commonjs/shared/constants.js +3 -1
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/{blank-stack/controllers/blank-stack-lifecycle.js → shared/controller/managed-lifecycle.js} +16 -19
- package/lib/commonjs/shared/controller/managed-lifecycle.js.map +1 -0
- package/lib/commonjs/shared/hooks/animation/use-high-refresh-rate.js +7 -1
- package/lib/commonjs/shared/hooks/animation/use-high-refresh-rate.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js +2 -2
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +3 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/navigation/use-stack.js.map +1 -1
- package/lib/commonjs/shared/hooks/reanimated/use-shared-value-state.js +5 -0
- package/lib/commonjs/shared/hooks/reanimated/use-shared-value-state.js.map +1 -1
- package/lib/commonjs/shared/providers/layout-anchor.provider.js +73 -0
- package/lib/commonjs/shared/providers/layout-anchor.provider.js.map +1 -0
- package/lib/commonjs/shared/providers/register-bounds.provider.js +9 -4
- package/lib/commonjs/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/keys.provider.js +2 -2
- package/lib/commonjs/shared/providers/screen/styles.provider.js +38 -4
- package/lib/commonjs/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/core.provider.js +35 -12
- package/lib/commonjs/shared/providers/stack/core.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/direct.provider.js +6 -4
- package/lib/commonjs/shared/providers/stack/direct.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/stack/managed.provider.js +7 -5
- package/lib/commonjs/shared/providers/stack/managed.provider.js.map +1 -1
- package/lib/commonjs/shared/types/index.js.map +1 -1
- package/lib/commonjs/shared/types/stack.types.js +26 -0
- package/lib/commonjs/shared/types/stack.types.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/index.js +13 -1
- package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
- package/lib/commonjs/shared/utils/navigation/sync-routes-with-removed.js +20 -45
- package/lib/commonjs/shared/utils/navigation/sync-routes-with-removed.js.map +1 -1
- package/lib/module/blank-stack/components/adjusted-screen-container.js +31 -0
- package/lib/module/blank-stack/components/adjusted-screen-container.js.map +1 -0
- package/lib/module/blank-stack/components/{screens.js → adjusted-screen.js} +30 -10
- package/lib/module/blank-stack/components/adjusted-screen.js.map +1 -0
- package/lib/module/blank-stack/components/stack-view.js +33 -41
- package/lib/module/blank-stack/components/stack-view.js.map +1 -1
- package/lib/module/blank-stack/components/stack-view.native.js +76 -0
- package/lib/module/blank-stack/components/stack-view.native.js.map +1 -0
- package/lib/module/component-stack/components/component-screen-container.js +18 -0
- package/lib/module/component-stack/components/component-screen-container.js.map +1 -0
- package/lib/module/component-stack/components/component-screen.js +30 -0
- package/lib/module/component-stack/components/component-screen.js.map +1 -0
- package/lib/module/component-stack/components/stack-view.js +59 -0
- package/lib/module/component-stack/components/stack-view.js.map +1 -0
- package/lib/module/component-stack/index.js +1 -2
- package/lib/module/component-stack/index.js.map +1 -1
- package/lib/module/component-stack/navigators/create-component-stack-navigator.js +48 -0
- package/lib/module/component-stack/navigators/create-component-stack-navigator.js.map +1 -0
- package/lib/module/native-stack/views/NativeStackView.native.js +103 -105
- package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/shared/components/overlay/helpers/get-active-overlay.js +0 -24
- package/lib/module/shared/components/overlay/helpers/get-active-overlay.js.map +1 -1
- package/lib/module/shared/components/overlay/index.js +1 -3
- package/lib/module/shared/components/overlay/index.js.map +1 -1
- package/lib/module/shared/constants.js +2 -0
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/{blank-stack/controllers/blank-stack-lifecycle.js → shared/controller/managed-lifecycle.js} +14 -17
- package/lib/module/shared/controller/managed-lifecycle.js.map +1 -0
- package/lib/module/shared/hooks/animation/use-high-refresh-rate.js +8 -1
- package/lib/module/shared/hooks/animation/use-high-refresh-rate.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js +2 -2
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js +4 -2
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/navigation/use-stack.js.map +1 -1
- package/lib/module/shared/hooks/reanimated/use-shared-value-state.js +5 -0
- package/lib/module/shared/hooks/reanimated/use-shared-value-state.js.map +1 -1
- package/lib/module/shared/providers/layout-anchor.provider.js +67 -0
- package/lib/module/shared/providers/layout-anchor.provider.js.map +1 -0
- package/lib/module/shared/providers/register-bounds.provider.js +9 -4
- package/lib/module/shared/providers/register-bounds.provider.js.map +1 -1
- package/lib/module/shared/providers/screen/keys.provider.js +2 -2
- package/lib/module/shared/providers/screen/styles.provider.js +39 -5
- package/lib/module/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/module/shared/providers/stack/core.provider.js +34 -11
- package/lib/module/shared/providers/stack/core.provider.js.map +1 -1
- package/lib/module/shared/providers/stack/direct.provider.js +6 -4
- package/lib/module/shared/providers/stack/direct.provider.js.map +1 -1
- package/lib/module/shared/providers/stack/managed.provider.js +7 -5
- package/lib/module/shared/providers/stack/managed.provider.js.map +1 -1
- package/lib/module/shared/types/index.js.map +1 -1
- package/lib/module/shared/types/stack.types.js +30 -1
- package/lib/module/shared/types/stack.types.js.map +1 -1
- package/lib/module/shared/utils/bounds/index.js +13 -1
- package/lib/module/shared/utils/bounds/index.js.map +1 -1
- package/lib/module/shared/utils/navigation/sync-routes-with-removed.js +20 -45
- package/lib/module/shared/utils/navigation/sync-routes-with-removed.js.map +1 -1
- package/lib/typescript/blank-stack/components/adjusted-screen-container.d.ts +6 -0
- package/lib/typescript/blank-stack/components/adjusted-screen-container.d.ts.map +1 -0
- package/lib/typescript/blank-stack/components/{screens.d.ts → adjusted-screen.d.ts} +2 -2
- package/lib/typescript/blank-stack/components/adjusted-screen.d.ts.map +1 -0
- package/lib/typescript/blank-stack/components/stack-view.d.ts +1 -1
- package/lib/typescript/blank-stack/components/stack-view.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/stack-view.native.d.ts +4 -0
- package/lib/typescript/blank-stack/components/stack-view.native.d.ts.map +1 -0
- package/lib/typescript/blank-stack/types.d.ts +3 -1
- package/lib/typescript/blank-stack/types.d.ts.map +1 -1
- package/lib/typescript/component-stack/components/component-screen-container.d.ts +6 -0
- package/lib/typescript/component-stack/components/component-screen-container.d.ts.map +1 -0
- package/lib/typescript/component-stack/components/component-screen.d.ts +8 -0
- package/lib/typescript/component-stack/components/component-screen.d.ts.map +1 -0
- package/lib/typescript/component-stack/components/stack-view.d.ts +4 -0
- package/lib/typescript/component-stack/components/stack-view.d.ts.map +1 -0
- package/lib/typescript/component-stack/index.d.ts +2 -3
- package/lib/typescript/component-stack/index.d.ts.map +1 -1
- package/lib/typescript/component-stack/navigators/create-component-stack-navigator.d.ts +16 -0
- package/lib/typescript/component-stack/navigators/create-component-stack-navigator.d.ts.map +1 -0
- package/lib/typescript/component-stack/types.d.ts +24 -191
- package/lib/typescript/component-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.native.d.ts +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/helpers/get-active-overlay.d.ts +0 -9
- package/lib/typescript/shared/components/overlay/helpers/get-active-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/index.d.ts +0 -2
- package/lib/typescript/shared/components/overlay/index.d.ts.map +1 -1
- package/lib/typescript/shared/constants.d.ts +1 -0
- package/lib/typescript/shared/constants.d.ts.map +1 -1
- package/lib/typescript/shared/controller/managed-lifecycle.d.ts +9 -0
- package/lib/typescript/shared/controller/managed-lifecycle.d.ts.map +1 -0
- package/lib/typescript/shared/hooks/animation/use-high-refresh-rate.d.ts +7 -0
- package/lib/typescript/shared/hooks/animation/use-high-refresh-rate.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts +2 -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/hooks/navigation/use-stack.d.ts +4 -9
- package/lib/typescript/shared/hooks/navigation/use-stack.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/reanimated/use-shared-value-state.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +13 -13
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/layout-anchor.provider.d.ts +34 -0
- package/lib/typescript/shared/providers/layout-anchor.provider.d.ts.map +1 -0
- package/lib/typescript/shared/providers/register-bounds.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/keys.provider.d.ts +2 -2
- package/lib/typescript/shared/providers/screen/styles.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/core.provider.d.ts +15 -4
- package/lib/typescript/shared/providers/stack/core.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/direct.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/stack/managed.provider.d.ts +1 -1
- package/lib/typescript/shared/providers/stack/managed.provider.d.ts.map +1 -1
- package/lib/typescript/shared/types/bounds.types.d.ts +1 -0
- package/lib/typescript/shared/types/bounds.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/index.d.ts +1 -1
- package/lib/typescript/shared/types/index.d.ts.map +1 -1
- package/lib/typescript/shared/types/overlay.types.d.ts +1 -12
- package/lib/typescript/shared/types/overlay.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/screen.types.d.ts +2 -2
- package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/stack.types.d.ts +5 -2
- package/lib/typescript/shared/types/stack.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
- package/lib/typescript/shared/utils/navigation/sync-routes-with-removed.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blank-stack/components/adjusted-screen-container.tsx +25 -0
- package/src/blank-stack/components/{screens.tsx → adjusted-screen.tsx} +33 -12
- package/src/blank-stack/components/stack-view.native.tsx +94 -0
- package/src/blank-stack/components/stack-view.tsx +41 -47
- package/src/blank-stack/types.ts +3 -2
- package/src/component-stack/components/component-screen-container.tsx +15 -0
- package/src/component-stack/components/component-screen.tsx +40 -0
- package/src/component-stack/components/stack-view.tsx +74 -0
- package/src/component-stack/index.ts +6 -12
- package/src/component-stack/navigators/create-component-stack-navigator.tsx +88 -0
- package/src/component-stack/types.ts +80 -188
- package/src/native-stack/views/NativeStackView.native.tsx +104 -106
- package/src/shared/__tests__/sync-routes-with-removed.test.ts +0 -146
- package/src/shared/components/overlay/helpers/get-active-overlay.ts +0 -26
- package/src/shared/components/overlay/index.ts +0 -2
- package/src/shared/constants.ts +3 -0
- package/src/{blank-stack/controllers/blank-stack-lifecycle.tsx → shared/controller/managed-lifecycle.tsx} +14 -18
- package/src/shared/hooks/animation/use-high-refresh-rate.tsx +7 -1
- package/src/shared/hooks/animation/use-screen-animation.tsx +5 -3
- package/src/shared/hooks/gestures/use-build-gestures.tsx +9 -1
- package/src/shared/hooks/navigation/use-stack.tsx +4 -15
- package/src/shared/hooks/reanimated/use-shared-value-state.ts +5 -0
- package/src/shared/index.ts +2 -1
- package/src/shared/providers/layout-anchor.provider.tsx +81 -0
- package/src/shared/providers/register-bounds.provider.tsx +11 -4
- package/src/shared/providers/screen/keys.provider.tsx +2 -2
- package/src/shared/providers/screen/styles.provider.tsx +50 -5
- package/src/shared/providers/stack/core.provider.tsx +51 -28
- package/src/shared/providers/stack/direct.provider.tsx +4 -1
- package/src/shared/providers/stack/managed.provider.tsx +5 -2
- package/src/shared/types/bounds.types.ts +5 -0
- package/src/shared/types/index.ts +0 -1
- package/src/shared/types/overlay.types.ts +1 -14
- package/src/shared/types/screen.types.ts +2 -8
- package/src/shared/types/stack.types.ts +6 -2
- package/src/shared/utils/bounds/index.ts +18 -1
- package/src/shared/utils/navigation/sync-routes-with-removed.ts +28 -58
- package/lib/commonjs/blank-stack/components/screens.js.map +0 -1
- package/lib/commonjs/blank-stack/controllers/blank-stack-lifecycle.js.map +0 -1
- package/lib/commonjs/component-stack/components/component-view.js +0 -63
- package/lib/commonjs/component-stack/components/component-view.js.map +0 -1
- package/lib/commonjs/component-stack/components/screens.js +0 -64
- package/lib/commonjs/component-stack/components/screens.js.map +0 -1
- package/lib/commonjs/component-stack/controllers/component-stack-lifecycle.js +0 -82
- package/lib/commonjs/component-stack/controllers/component-stack-lifecycle.js.map +0 -1
- package/lib/commonjs/component-stack/hooks/use-component-navigation-builder.js +0 -321
- package/lib/commonjs/component-stack/hooks/use-component-navigation-builder.js.map +0 -1
- package/lib/commonjs/component-stack/hooks/use-component-navigation.js +0 -28
- package/lib/commonjs/component-stack/hooks/use-component-navigation.js.map +0 -1
- package/lib/commonjs/component-stack/navigators/create-component-navigator.js +0 -97
- package/lib/commonjs/component-stack/navigators/create-component-navigator.js.map +0 -1
- package/lib/commonjs/shared/components/overlay/variations/container-overlay.js +0 -99
- package/lib/commonjs/shared/components/overlay/variations/container-overlay.js.map +0 -1
- package/lib/module/blank-stack/components/screens.js.map +0 -1
- package/lib/module/blank-stack/controllers/blank-stack-lifecycle.js.map +0 -1
- package/lib/module/component-stack/components/component-view.js +0 -58
- package/lib/module/component-stack/components/component-view.js.map +0 -1
- package/lib/module/component-stack/components/screens.js +0 -58
- package/lib/module/component-stack/components/screens.js.map +0 -1
- package/lib/module/component-stack/controllers/component-stack-lifecycle.js +0 -76
- package/lib/module/component-stack/controllers/component-stack-lifecycle.js.map +0 -1
- package/lib/module/component-stack/hooks/use-component-navigation-builder.js +0 -316
- package/lib/module/component-stack/hooks/use-component-navigation-builder.js.map +0 -1
- package/lib/module/component-stack/hooks/use-component-navigation.js +0 -25
- package/lib/module/component-stack/hooks/use-component-navigation.js.map +0 -1
- package/lib/module/component-stack/navigators/create-component-navigator.js +0 -91
- package/lib/module/component-stack/navigators/create-component-navigator.js.map +0 -1
- package/lib/module/shared/components/overlay/variations/container-overlay.js +0 -97
- package/lib/module/shared/components/overlay/variations/container-overlay.js.map +0 -1
- package/lib/typescript/blank-stack/components/screens.d.ts.map +0 -1
- package/lib/typescript/blank-stack/controllers/blank-stack-lifecycle.d.ts +0 -9
- package/lib/typescript/blank-stack/controllers/blank-stack-lifecycle.d.ts.map +0 -1
- package/lib/typescript/component-stack/components/component-view.d.ts +0 -4
- package/lib/typescript/component-stack/components/component-view.d.ts.map +0 -1
- package/lib/typescript/component-stack/components/screens.d.ts +0 -9
- package/lib/typescript/component-stack/components/screens.d.ts.map +0 -1
- package/lib/typescript/component-stack/controllers/component-stack-lifecycle.d.ts +0 -10
- package/lib/typescript/component-stack/controllers/component-stack-lifecycle.d.ts.map +0 -1
- package/lib/typescript/component-stack/hooks/use-component-navigation-builder.d.ts +0 -19
- package/lib/typescript/component-stack/hooks/use-component-navigation-builder.d.ts.map +0 -1
- package/lib/typescript/component-stack/hooks/use-component-navigation.d.ts +0 -19
- package/lib/typescript/component-stack/hooks/use-component-navigation.d.ts.map +0 -1
- package/lib/typescript/component-stack/navigators/create-component-navigator.d.ts +0 -35
- package/lib/typescript/component-stack/navigators/create-component-navigator.d.ts.map +0 -1
- package/lib/typescript/shared/components/overlay/variations/container-overlay.d.ts +0 -8
- package/lib/typescript/shared/components/overlay/variations/container-overlay.d.ts.map +0 -1
- package/src/component-stack/components/component-view.tsx +0 -72
- package/src/component-stack/components/screens.tsx +0 -86
- package/src/component-stack/controllers/component-stack-lifecycle.tsx +0 -80
- package/src/component-stack/hooks/use-component-navigation-builder.tsx +0 -388
- package/src/component-stack/hooks/use-component-navigation.tsx +0 -22
- package/src/component-stack/navigators/create-component-navigator.tsx +0 -104
- package/src/shared/components/overlay/variations/container-overlay.tsx +0 -98
|
@@ -36,29 +36,3 @@ export function getActiveFloatOverlay(
|
|
|
36
36
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Find the active container overlay from scenes.
|
|
42
|
-
* Scans from the bottom of the stack upward to find the first screen
|
|
43
|
-
* with overlayMode="container" and overlayShown=true.
|
|
44
|
-
*/
|
|
45
|
-
export function getActiveContainerOverlay(
|
|
46
|
-
scenes: StackScene[],
|
|
47
|
-
transitionsAlwaysOn: boolean,
|
|
48
|
-
): { scene: StackScene; overlayIndex: number } | null {
|
|
49
|
-
for (let i = 0; i < scenes.length; i++) {
|
|
50
|
-
const scene = scenes[i];
|
|
51
|
-
const options = scene?.descriptor?.options;
|
|
52
|
-
|
|
53
|
-
// Skip screens without enableTransitions (native-stack only)
|
|
54
|
-
if (!transitionsAlwaysOn && !options?.enableTransitions) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (options?.overlayMode === "container" && options?.overlayShown) {
|
|
59
|
-
return { scene, overlayIndex: i };
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { ContainerOverlay } from "./variations/container-overlay";
|
|
2
1
|
import { FloatOverlay } from "./variations/float-overlay";
|
|
3
2
|
import { ScreenOverlay } from "./variations/screen-overlay";
|
|
4
3
|
|
|
5
4
|
export const Overlay = {
|
|
6
5
|
Float: FloatOverlay,
|
|
7
6
|
Screen: ScreenOverlay,
|
|
8
|
-
Container: ContainerOverlay,
|
|
9
7
|
};
|
package/src/shared/constants.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ParamListBase, RouteProp } from "@react-navigation/native";
|
|
2
|
+
import { Platform } from "react-native";
|
|
2
3
|
import type { MeasuredDimensions } from "react-native-reanimated";
|
|
3
4
|
import type { ScreenTransitionState } from "./types/animation.types";
|
|
4
5
|
import type { ActivationArea } from "./types/gesture.types";
|
|
@@ -73,3 +74,5 @@ export const DEFAULT_GESTURE_DIRECTION = "horizontal";
|
|
|
73
74
|
export const DEFAULT_GESTURE_ENABLED = false;
|
|
74
75
|
export const DEFAULT_GESTURE_DRIVES_PROGRESS = true;
|
|
75
76
|
export const DEFAULT_GESTURE_ACTIVATION_AREA: ActivationArea = "screen";
|
|
77
|
+
|
|
78
|
+
export const IS_WEB = Platform.OS === "web";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useLayoutEffect } from "react";
|
|
2
2
|
import { runOnJS, useAnimatedReaction } from "react-native-reanimated";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
3
|
+
import type { BlankStackDescriptor } from "../../blank-stack/types";
|
|
4
|
+
import { useHighRefreshRate } from "../hooks/animation/use-high-refresh-rate";
|
|
5
|
+
import useStableCallback from "../hooks/use-stable-callback";
|
|
6
|
+
import { useKeys } from "../providers/screen/keys.provider";
|
|
7
|
+
import { useManagedStackContext } from "../providers/stack/managed.provider";
|
|
8
|
+
import { AnimationStore } from "../stores/animation.store";
|
|
9
|
+
import { startScreenTransition } from "../utils/animation/start-screen-transition";
|
|
10
|
+
import { resetStoresForScreen } from "../utils/reset-stores-for-screen";
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
children: React.ReactNode;
|
|
@@ -16,7 +16,7 @@ interface Props {
|
|
|
16
16
|
/**
|
|
17
17
|
* Lifecycle controller built out for Blank Stack implementation.
|
|
18
18
|
*/
|
|
19
|
-
export const
|
|
19
|
+
export const ManagedLifecycle = ({ children }: Props) => {
|
|
20
20
|
const { current } = useKeys<BlankStackDescriptor>();
|
|
21
21
|
const { handleCloseRoute, closingRouteKeysShared } = useManagedStackContext();
|
|
22
22
|
|
|
@@ -35,16 +35,15 @@ export const BlankStackScreenLifecycleController = ({ children }: Props) => {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
const handleCleanup = useStableCallback(() => {
|
|
39
|
-
resetStoresForScreen(current);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
38
|
const handleCloseEnd = useStableCallback((finished: boolean) => {
|
|
43
|
-
deactivateHighRefreshRate();
|
|
44
39
|
if (!finished) {
|
|
45
40
|
return;
|
|
46
41
|
}
|
|
47
42
|
handleCloseRoute({ route: current.route });
|
|
43
|
+
requestAnimationFrame(() => {
|
|
44
|
+
deactivateHighRefreshRate();
|
|
45
|
+
resetStoresForScreen(current);
|
|
46
|
+
});
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
useAnimatedReaction(
|
|
@@ -68,10 +67,7 @@ export const BlankStackScreenLifecycleController = ({ children }: Props) => {
|
|
|
68
67
|
|
|
69
68
|
useLayoutEffect(() => {
|
|
70
69
|
handleInitialize();
|
|
71
|
-
|
|
72
|
-
handleCleanup();
|
|
73
|
-
};
|
|
74
|
-
}, [handleInitialize, handleCleanup]);
|
|
70
|
+
}, [handleInitialize]);
|
|
75
71
|
|
|
76
72
|
return children;
|
|
77
73
|
};
|
|
@@ -2,8 +2,14 @@ import { useFrameCallback } from "react-native-reanimated";
|
|
|
2
2
|
import type { BaseDescriptor } from "../../providers/screen/keys.provider";
|
|
3
3
|
import useStableCallback from "../use-stable-callback";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Maintainer Notes:
|
|
7
|
+
* Marking as experimental for now since, I'll be honest, I'm not sure if this does much. This was taken
|
|
8
|
+
* right from this https://github.com/software-mansion/react-native-reanimated/issues/4738
|
|
9
|
+
*
|
|
10
|
+
* Not noticing much of a difference in prod.
|
|
11
|
+
*/
|
|
5
12
|
export const useHighRefreshRate = (current: BaseDescriptor) => {
|
|
6
|
-
// Force display to run at max refresh rate during transitions only
|
|
7
13
|
const enableHighRefreshRate =
|
|
8
14
|
current.options.experimental_enableHighRefreshRate ?? false;
|
|
9
15
|
|
|
@@ -164,9 +164,11 @@ export function _useScreenAnimation() {
|
|
|
164
164
|
const currentInterpolator =
|
|
165
165
|
currentDescriptor?.options.screenStyleInterpolator;
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
return {
|
|
168
|
+
screenInterpolatorProps,
|
|
169
|
+
nextInterpolator,
|
|
170
|
+
currentInterpolator,
|
|
171
|
+
};
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
export function useScreenAnimation() {
|
|
@@ -35,6 +35,7 @@ import { determineDismissal } from "../../utils/gesture/determine-dismissal";
|
|
|
35
35
|
import { mapGestureToProgress } from "../../utils/gesture/map-gesture-to-progress";
|
|
36
36
|
import { resetGestureValues } from "../../utils/gesture/reset-gesture-values";
|
|
37
37
|
import { velocity } from "../../utils/gesture/velocity";
|
|
38
|
+
import { useStack } from "../navigation/use-stack";
|
|
38
39
|
import useStableCallbackValue from "../use-stable-callback-value";
|
|
39
40
|
|
|
40
41
|
interface BuildGesturesHookProps {
|
|
@@ -52,7 +53,11 @@ export const useBuildGestures = ({
|
|
|
52
53
|
gestureAnimationValues: GestureStoreMap;
|
|
53
54
|
} => {
|
|
54
55
|
const dimensions = useWindowDimensions();
|
|
56
|
+
|
|
55
57
|
const { current } = useKeys();
|
|
58
|
+
const navState = current.navigation.getState();
|
|
59
|
+
const isFirstScreen =
|
|
60
|
+
navState.routes.findIndex((r) => r.key === current.route.key) === 0;
|
|
56
61
|
|
|
57
62
|
const initialTouch = useSharedValue({
|
|
58
63
|
x: 0,
|
|
@@ -73,7 +78,6 @@ export const useBuildGestures = ({
|
|
|
73
78
|
|
|
74
79
|
const {
|
|
75
80
|
gestureDirection = DEFAULT_GESTURE_DIRECTION,
|
|
76
|
-
gestureEnabled = DEFAULT_GESTURE_ENABLED,
|
|
77
81
|
gestureVelocityImpact = GESTURE_VELOCITY_IMPACT,
|
|
78
82
|
gestureDrivesProgress = DEFAULT_GESTURE_DRIVES_PROGRESS,
|
|
79
83
|
gestureActivationArea = DEFAULT_GESTURE_ACTIVATION_AREA,
|
|
@@ -81,6 +85,10 @@ export const useBuildGestures = ({
|
|
|
81
85
|
transitionSpec,
|
|
82
86
|
} = current.options;
|
|
83
87
|
|
|
88
|
+
const gestureEnabled = Boolean(
|
|
89
|
+
isFirstScreen ? false : current.options.gestureEnabled,
|
|
90
|
+
);
|
|
91
|
+
|
|
84
92
|
const directions = useMemo(() => {
|
|
85
93
|
const directionsArray = Array.isArray(gestureDirection)
|
|
86
94
|
? gestureDirection
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { Route } from "@react-navigation/native";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
import type { DerivedValue } from "react-native-reanimated";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
OverlayMode,
|
|
7
|
-
OverlayProps,
|
|
8
|
-
} from "../../types/overlay.types";
|
|
4
|
+
import type { StackCoreContextValue } from "../../providers/stack/core.provider";
|
|
5
|
+
import type { OverlayMode, OverlayProps } from "../../types/overlay.types";
|
|
9
6
|
import type {
|
|
10
7
|
BaseStackDescriptor,
|
|
11
8
|
BaseStackNavigation,
|
|
@@ -22,9 +19,7 @@ export interface StackDescriptor<
|
|
|
22
19
|
TNavigation extends BaseStackNavigation = BaseStackNavigation,
|
|
23
20
|
> extends BaseStackDescriptor<TRoute, TNavigation> {
|
|
24
21
|
options: BaseStackDescriptor["options"] & {
|
|
25
|
-
overlay?:
|
|
26
|
-
| ((props: OverlayProps) => React.ReactNode)
|
|
27
|
-
| ((props: ContainerOverlayProps) => React.ReactNode);
|
|
22
|
+
overlay?: (props: OverlayProps) => React.ReactNode;
|
|
28
23
|
overlayMode?: OverlayMode;
|
|
29
24
|
overlayShown?: boolean;
|
|
30
25
|
meta?: Record<string, unknown>;
|
|
@@ -42,13 +37,7 @@ export type StackScene<TDescriptor extends StackDescriptor = StackDescriptor> =
|
|
|
42
37
|
* Common stack context value that both managed and direct stack providers populate.
|
|
43
38
|
* Used by overlays and shared components that need stack progress info.
|
|
44
39
|
*/
|
|
45
|
-
export interface StackContextValue {
|
|
46
|
-
/**
|
|
47
|
-
* Stack flags.
|
|
48
|
-
*/
|
|
49
|
-
flags: {
|
|
50
|
-
TRANSITIONS_ALWAYS_ON: boolean;
|
|
51
|
-
};
|
|
40
|
+
export interface StackContextValue extends StackCoreContextValue {
|
|
52
41
|
/**
|
|
53
42
|
* Route keys for all routes in the stack.
|
|
54
43
|
*/
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type SharedValue,
|
|
6
6
|
useAnimatedReaction,
|
|
7
7
|
} from "react-native-reanimated";
|
|
8
|
+
import { IS_WEB } from "../../constants";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Derives React state from a Reanimated SharedValue.
|
|
@@ -12,6 +13,10 @@ import {
|
|
|
12
13
|
*/
|
|
13
14
|
export function useSharedValueState<T>(sharedValue: SharedValue<T>): T {
|
|
14
15
|
const [state, setState] = useState<T>(() => {
|
|
16
|
+
if (IS_WEB) {
|
|
17
|
+
// Web fallback - executeOnUIRuntimeSync not available
|
|
18
|
+
return sharedValue.value;
|
|
19
|
+
}
|
|
15
20
|
const readOnUI = executeOnUIRuntimeSync((sv: SharedValue<T>) => {
|
|
16
21
|
"worklet";
|
|
17
22
|
return sv.value;
|
package/src/shared/index.ts
CHANGED
|
@@ -25,11 +25,12 @@ export type {
|
|
|
25
25
|
AnimationConfig,
|
|
26
26
|
BoundEntry,
|
|
27
27
|
BoundsLink,
|
|
28
|
-
ContainerOverlayProps,
|
|
29
28
|
OverlayInterpolationProps,
|
|
30
29
|
OverlayMode,
|
|
31
30
|
OverlayProps,
|
|
32
31
|
ScreenInterpolationProps,
|
|
33
32
|
ScreenStyleInterpolator,
|
|
34
33
|
ScreenTransitionConfig,
|
|
34
|
+
TransitionInterpolatedStyle,
|
|
35
|
+
TransitionSpec,
|
|
35
36
|
} from "./types";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { useWindowDimensions, type View } from "react-native";
|
|
3
|
+
import {
|
|
4
|
+
type AnimatedRef,
|
|
5
|
+
type MeasuredDimensions,
|
|
6
|
+
measure,
|
|
7
|
+
} from "react-native-reanimated";
|
|
8
|
+
import createProvider from "../utils/create-provider";
|
|
9
|
+
|
|
10
|
+
interface LayoutAnchorProviderProps {
|
|
11
|
+
anchorRef: AnimatedRef<View>;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface LayoutAnchorContextValue {
|
|
16
|
+
/**
|
|
17
|
+
* Corrects measured dimensions for parent transforms (translation and scale).
|
|
18
|
+
* The anchor should be at (0, 0) with full screen dimensions - any difference
|
|
19
|
+
* is from parent transforms. This function reverses those transforms to yield
|
|
20
|
+
* the true layout position and dimensions.
|
|
21
|
+
*/
|
|
22
|
+
correctMeasurement: (measured: MeasuredDimensions) => MeasuredDimensions;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Provides a reference point for correcting bounds measurements.
|
|
27
|
+
*
|
|
28
|
+
* When a parent view has transforms applied (e.g., during screen transitions),
|
|
29
|
+
* `measure()` returns visual positions that include those transforms. This provider
|
|
30
|
+
* establishes an anchor point (typically the screen container at 0,0) and exposes
|
|
31
|
+
* a `correctMeasurement` function that reverses translation and scale transforms
|
|
32
|
+
* to yield the true layout position and dimensions.
|
|
33
|
+
*
|
|
34
|
+
* ## How it works
|
|
35
|
+
*
|
|
36
|
+
* 1. **Translation**: Subtract anchor's pageX/pageY offset
|
|
37
|
+
* 2. **Scale**: Compare anchor's measured size to expected (screen) size to compute
|
|
38
|
+
* scale factor, then divide positions and dimensions by that factor
|
|
39
|
+
*/
|
|
40
|
+
const { LayoutAnchorProvider, useLayoutAnchorContext } = createProvider(
|
|
41
|
+
"LayoutAnchor",
|
|
42
|
+
{ guarded: false },
|
|
43
|
+
)<LayoutAnchorProviderProps, LayoutAnchorContextValue>(
|
|
44
|
+
({ anchorRef, children }) => {
|
|
45
|
+
const { width: screenWidth, height: screenHeight } = useWindowDimensions();
|
|
46
|
+
|
|
47
|
+
const correctMeasurement = (
|
|
48
|
+
measured: MeasuredDimensions,
|
|
49
|
+
): MeasuredDimensions => {
|
|
50
|
+
"worklet";
|
|
51
|
+
const anchor = measure(anchorRef);
|
|
52
|
+
if (!anchor) return measured;
|
|
53
|
+
|
|
54
|
+
// Compute scale factor by comparing anchor size to expected screen size.
|
|
55
|
+
// Anchor should be full-screen (absoluteFill), so any difference is from scale.
|
|
56
|
+
const scaleX = anchor.width > 0 ? anchor.width / screenWidth : 1;
|
|
57
|
+
const scaleY = anchor.height > 0 ? anchor.height / screenHeight : 1;
|
|
58
|
+
|
|
59
|
+
// Get element position relative to anchor (removes translation)
|
|
60
|
+
const relativeX = measured.pageX - anchor.pageX;
|
|
61
|
+
const relativeY = measured.pageY - anchor.pageY;
|
|
62
|
+
|
|
63
|
+
// Reverse scale: divide relative position and dimensions by scale factor
|
|
64
|
+
return {
|
|
65
|
+
x: measured.x,
|
|
66
|
+
y: measured.y,
|
|
67
|
+
width: scaleX !== 1 ? measured.width / scaleX : measured.width,
|
|
68
|
+
height: scaleY !== 1 ? measured.height / scaleY : measured.height,
|
|
69
|
+
pageX: scaleX !== 1 ? relativeX / scaleX : relativeX,
|
|
70
|
+
pageY: scaleY !== 1 ? relativeY / scaleY : relativeY,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
value: { correctMeasurement },
|
|
76
|
+
children,
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export { LayoutAnchorProvider, useLayoutAnchorContext };
|
|
@@ -17,6 +17,7 @@ import { AnimationStore } from "../stores/animation.store";
|
|
|
17
17
|
import { BoundStore } from "../stores/bounds.store";
|
|
18
18
|
import { prepareStyleForBounds } from "../utils/bounds/helpers/styles";
|
|
19
19
|
import createProvider from "../utils/create-provider";
|
|
20
|
+
import { useLayoutAnchorContext } from "./layout-anchor.provider";
|
|
20
21
|
import { type BaseDescriptor, useKeys } from "./screen/keys.provider";
|
|
21
22
|
|
|
22
23
|
interface MaybeMeasureAndStoreParams {
|
|
@@ -51,7 +52,7 @@ const getAncestorKeys = (current: BaseDescriptor): string[] => {
|
|
|
51
52
|
const ancestors: string[] = [];
|
|
52
53
|
const nav = current.navigation as any;
|
|
53
54
|
|
|
54
|
-
// Safety check for
|
|
55
|
+
// Safety check for navigators without getParent
|
|
55
56
|
if (typeof nav?.getParent !== "function") {
|
|
56
57
|
return ancestors;
|
|
57
58
|
}
|
|
@@ -208,6 +209,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
208
209
|
const { current } = useKeys();
|
|
209
210
|
const currentScreenKey = current.route.key;
|
|
210
211
|
const ancestorKeys = useMemo(() => getAncestorKeys(current), [current]);
|
|
212
|
+
const layoutAnchor = useLayoutAnchorContext();
|
|
211
213
|
|
|
212
214
|
// Context & signals
|
|
213
215
|
const parentContext: RegisterBoundsContextValue | null =
|
|
@@ -241,12 +243,17 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
241
243
|
const measured = measure(animatedRef);
|
|
242
244
|
if (!measured) return;
|
|
243
245
|
|
|
246
|
+
// Correct for parent transforms (e.g., when parent screen is animating)
|
|
247
|
+
const correctedMeasured = layoutAnchor
|
|
248
|
+
? layoutAnchor.correctMeasurement(measured)
|
|
249
|
+
: measured;
|
|
250
|
+
|
|
244
251
|
emitUpdate();
|
|
245
252
|
|
|
246
253
|
BoundStore.registerSnapshot(
|
|
247
254
|
sharedBoundTag,
|
|
248
255
|
currentScreenKey,
|
|
249
|
-
|
|
256
|
+
correctedMeasured,
|
|
250
257
|
preparedStyles,
|
|
251
258
|
ancestorKeys,
|
|
252
259
|
);
|
|
@@ -273,7 +280,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
273
280
|
BoundStore.setLinkSource(
|
|
274
281
|
sharedBoundTag,
|
|
275
282
|
currentScreenKey,
|
|
276
|
-
|
|
283
|
+
correctedMeasured,
|
|
277
284
|
preparedStyles,
|
|
278
285
|
ancestorKeys,
|
|
279
286
|
);
|
|
@@ -284,7 +291,7 @@ const { RegisterBoundsProvider, useRegisterBoundsContext } = createProvider(
|
|
|
284
291
|
BoundStore.setLinkDestination(
|
|
285
292
|
sharedBoundTag,
|
|
286
293
|
currentScreenKey,
|
|
287
|
-
|
|
294
|
+
correctedMeasured,
|
|
288
295
|
preparedStyles,
|
|
289
296
|
ancestorKeys,
|
|
290
297
|
);
|
|
@@ -18,8 +18,8 @@ export type { BaseStackRoute as BaseRoute };
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Base descriptor interface - minimal contract for all stack types.
|
|
21
|
-
* This allows
|
|
22
|
-
*
|
|
21
|
+
* This allows blank-stack and native-stack to work with the shared
|
|
22
|
+
* providers without tight coupling to React Navigation.
|
|
23
23
|
*/
|
|
24
24
|
export type BaseDescriptor = BaseStackDescriptor;
|
|
25
25
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type SharedValue,
|
|
4
|
+
useDerivedValue,
|
|
5
|
+
useSharedValue,
|
|
6
|
+
} from "react-native-reanimated";
|
|
3
7
|
import { NO_STYLES } from "../../constants";
|
|
4
8
|
import { _useScreenAnimation } from "../../hooks/animation/use-screen-animation";
|
|
5
9
|
import type { TransitionInterpolatedStyle } from "../../types/animation.types";
|
|
@@ -21,17 +25,58 @@ const ScreenStylesContext = createContext<ScreenStylesContextValue | null>(
|
|
|
21
25
|
export function ScreenStylesProvider({ children }: Props) {
|
|
22
26
|
const parentCtx = useContext(ScreenStylesContext);
|
|
23
27
|
|
|
24
|
-
const { screenInterpolatorProps,
|
|
28
|
+
const { screenInterpolatorProps, nextInterpolator, currentInterpolator } =
|
|
25
29
|
_useScreenAnimation();
|
|
26
30
|
|
|
31
|
+
// Track when a gesture is triggered while another screen is closing
|
|
32
|
+
const hasTriggeredGestureWhileInFlight = useSharedValue(false);
|
|
33
|
+
|
|
27
34
|
const stylesMap = useDerivedValue<TransitionInterpolatedStyle>(() => {
|
|
28
35
|
"worklet";
|
|
29
36
|
const props = screenInterpolatorProps.value;
|
|
30
37
|
const bounds = createBounds(props);
|
|
38
|
+
|
|
39
|
+
// Detect when user starts gesture on current screen while next screen is closing
|
|
40
|
+
if (props.current.gesture.isDragging && props.next?.closing) {
|
|
41
|
+
hasTriggeredGestureWhileInFlight.value = true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Reset the flag when no longer dragging and next screen is done closing
|
|
45
|
+
if (
|
|
46
|
+
!props.current.gesture.isDragging &&
|
|
47
|
+
!props.next?.closing &&
|
|
48
|
+
hasTriggeredGestureWhileInFlight.value
|
|
49
|
+
) {
|
|
50
|
+
hasTriggeredGestureWhileInFlight.value = false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Use current interpolator when gesture triggered while in-flight,
|
|
54
|
+
// otherwise use next interpolator if available (normal case)
|
|
55
|
+
const shouldUseCurrentInterpolator =
|
|
56
|
+
props.current.gesture.isDragging ||
|
|
57
|
+
hasTriggeredGestureWhileInFlight.value;
|
|
58
|
+
|
|
59
|
+
const interpolator = shouldUseCurrentInterpolator
|
|
60
|
+
? currentInterpolator
|
|
61
|
+
: (nextInterpolator ?? currentInterpolator);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Maintainer Note:
|
|
65
|
+
* To avoid unnecessary jumps in off directions, we have to snap back to the currents progress.
|
|
66
|
+
* While this still introduces a 'snap back' animation, it's still very rare that a user would encounter this unless
|
|
67
|
+
* they're spamming things out. Not ideal, but this is the best way to go about dealing with fast rapid gestures.
|
|
68
|
+
*
|
|
69
|
+
* The alternative was preventing users from actually being able to drag back while animation was still in flight. But there was a significant delay
|
|
70
|
+
* when waiting for gestures to register again.
|
|
71
|
+
*/
|
|
72
|
+
const effectiveProps = shouldUseCurrentInterpolator
|
|
73
|
+
? { ...props, progress: props.current.progress, next: undefined }
|
|
74
|
+
: props;
|
|
75
|
+
|
|
31
76
|
try {
|
|
32
|
-
if (!
|
|
33
|
-
return
|
|
34
|
-
...
|
|
77
|
+
if (!interpolator) return NO_STYLES;
|
|
78
|
+
return interpolator({
|
|
79
|
+
...effectiveProps,
|
|
35
80
|
bounds,
|
|
36
81
|
});
|
|
37
82
|
} catch (err) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { SafeAreaProviderCompat } from "@react-navigation/elements";
|
|
2
|
-
import * as React from "react";
|
|
2
|
+
import type * as React from "react";
|
|
3
3
|
import { StyleSheet } from "react-native";
|
|
4
4
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
5
|
+
import { StackType } from "../../types/stack.types";
|
|
5
6
|
import createProvider from "../../utils/create-provider";
|
|
6
7
|
|
|
7
|
-
interface StackCoreConfig {
|
|
8
|
+
export interface StackCoreConfig {
|
|
8
9
|
TRANSITIONS_ALWAYS_ON?: boolean;
|
|
10
|
+
STACK_TYPE?: StackType;
|
|
11
|
+
DISABLE_NATIVE_SCREENS?: boolean;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
interface StackCoreProviderProps {
|
|
@@ -13,47 +16,65 @@ interface StackCoreProviderProps {
|
|
|
13
16
|
children: React.ReactNode;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
interface StackCoreContextValue {
|
|
19
|
+
export interface StackCoreContextValue {
|
|
17
20
|
flags: {
|
|
18
21
|
TRANSITIONS_ALWAYS_ON: boolean;
|
|
22
|
+
STACK_TYPE?: StackType;
|
|
23
|
+
DISABLE_NATIVE_SCREENS: boolean;
|
|
19
24
|
};
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
const { StackCoreProvider: InternalStackCoreProvider } =
|
|
23
|
-
"StackCore",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const { StackCoreProvider: InternalStackCoreProvider, useStackCoreContext } =
|
|
28
|
+
createProvider("StackCore", { guarded: true })<
|
|
29
|
+
StackCoreProviderProps,
|
|
30
|
+
StackCoreContextValue
|
|
31
|
+
>(({ config, children }) => {
|
|
32
|
+
const {
|
|
33
|
+
TRANSITIONS_ALWAYS_ON = false,
|
|
34
|
+
DISABLE_NATIVE_SCREENS = false,
|
|
35
|
+
STACK_TYPE = StackType.BLANK,
|
|
36
|
+
} = config;
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
43
|
-
});
|
|
38
|
+
return {
|
|
39
|
+
value: {
|
|
40
|
+
flags: {
|
|
41
|
+
TRANSITIONS_ALWAYS_ON,
|
|
42
|
+
STACK_TYPE,
|
|
43
|
+
DISABLE_NATIVE_SCREENS,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
children: (
|
|
47
|
+
<GestureHandlerRootView style={styles.container}>
|
|
48
|
+
<SafeAreaProviderCompat>{children}</SafeAreaProviderCompat>
|
|
49
|
+
</GestureHandlerRootView>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
44
53
|
|
|
45
54
|
/**
|
|
46
55
|
* HOC that wraps a component with the StackCore provider.
|
|
47
56
|
* Just a simple open gate
|
|
48
57
|
*/
|
|
49
58
|
export function withStackCore<TProps extends object>(
|
|
50
|
-
|
|
59
|
+
defaultConfig: StackCoreConfig,
|
|
51
60
|
Component: React.ComponentType<TProps>,
|
|
52
|
-
): React.FC<TProps> {
|
|
53
|
-
return function StackCoreWrapper(
|
|
61
|
+
): React.FC<TProps & StackCoreConfig> {
|
|
62
|
+
return function StackCoreWrapper({
|
|
63
|
+
DISABLE_NATIVE_SCREENS,
|
|
64
|
+
TRANSITIONS_ALWAYS_ON,
|
|
65
|
+
STACK_TYPE,
|
|
66
|
+
...props
|
|
67
|
+
}: TProps & StackCoreConfig) {
|
|
68
|
+
// User props first, then defaultConfig overrides (config takes priority)
|
|
69
|
+
const config: StackCoreConfig = {
|
|
70
|
+
...(DISABLE_NATIVE_SCREENS !== undefined && { DISABLE_NATIVE_SCREENS }),
|
|
71
|
+
...(TRANSITIONS_ALWAYS_ON !== undefined && { TRANSITIONS_ALWAYS_ON }),
|
|
72
|
+
...(STACK_TYPE !== undefined && { STACK_TYPE }),
|
|
73
|
+
...defaultConfig,
|
|
74
|
+
};
|
|
54
75
|
return (
|
|
55
76
|
<InternalStackCoreProvider config={config}>
|
|
56
|
-
<Component {...props} />
|
|
77
|
+
<Component {...(props as TProps)} />
|
|
57
78
|
</InternalStackCoreProvider>
|
|
58
79
|
);
|
|
59
80
|
};
|
|
@@ -62,3 +83,5 @@ export function withStackCore<TProps extends object>(
|
|
|
62
83
|
const styles = StyleSheet.create({
|
|
63
84
|
container: { flex: 1 },
|
|
64
85
|
});
|
|
86
|
+
|
|
87
|
+
export { useStackCoreContext };
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
type StackContextValue,
|
|
17
17
|
} from "../../hooks/navigation/use-stack";
|
|
18
18
|
import { AnimationStore } from "../../stores/animation.store";
|
|
19
|
+
import { useStackCoreContext } from "./core.provider";
|
|
19
20
|
|
|
20
21
|
export interface DirectStackScene {
|
|
21
22
|
route: StackNavigationState<ParamListBase>["routes"][number];
|
|
@@ -67,6 +68,7 @@ function useDirectStackValue(
|
|
|
67
68
|
props: DirectStackProps,
|
|
68
69
|
): DirectStackContextValue & { stackContextValue: StackContextValue } {
|
|
69
70
|
const { state, navigation, descriptors, describe } = props;
|
|
71
|
+
const { flags } = useStackCoreContext();
|
|
70
72
|
|
|
71
73
|
const preloadedDescriptors = useMemo(() => {
|
|
72
74
|
return state.preloadedRoutes.reduce<NativeStackDescriptorMap>(
|
|
@@ -156,7 +158,7 @@ function useDirectStackValue(
|
|
|
156
158
|
|
|
157
159
|
const stackContextValue = useMemo<StackContextValue>(
|
|
158
160
|
() => ({
|
|
159
|
-
flags
|
|
161
|
+
flags,
|
|
160
162
|
routeKeys,
|
|
161
163
|
routes: allRoutes,
|
|
162
164
|
descriptors: allDescriptors,
|
|
@@ -173,6 +175,7 @@ function useDirectStackValue(
|
|
|
173
175
|
focusedIndex,
|
|
174
176
|
stackProgress,
|
|
175
177
|
optimisticFocusedIndex,
|
|
178
|
+
flags,
|
|
176
179
|
],
|
|
177
180
|
);
|
|
178
181
|
|