react-native-screen-transitions 3.2.0-beta.0 → 3.2.0-beta.2
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.js +38 -0
- package/lib/commonjs/component-stack/components/component-screen.js.map +1 -0
- package/lib/commonjs/component-stack/components/stack-view.js +65 -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 +82 -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/components/root-transition-aware.js +5 -1
- package/lib/commonjs/shared/components/root-transition-aware.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/hooks/use-stack-pointer-events.js +23 -0
- package/lib/commonjs/shared/hooks/use-stack-pointer-events.js.map +1 -0
- package/lib/commonjs/shared/providers/gestures.provider.js +3 -0
- package/lib/commonjs/shared/providers/gestures.provider.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 +36 -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 +27 -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.js +32 -0
- package/lib/module/component-stack/components/component-screen.js.map +1 -0
- package/lib/module/component-stack/components/stack-view.js +60 -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 +77 -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/components/root-transition-aware.js +5 -1
- package/lib/module/shared/components/root-transition-aware.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/hooks/use-stack-pointer-events.js +20 -0
- package/lib/module/shared/hooks/use-stack-pointer-events.js.map +1 -0
- package/lib/module/shared/providers/gestures.provider.js +3 -0
- package/lib/module/shared/providers/gestures.provider.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 +35 -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 +31 -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.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 +23 -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/components/root-transition-aware.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/hooks/use-stack-pointer-events.d.ts +10 -0
- package/lib/typescript/shared/hooks/use-stack-pointer-events.d.ts.map +1 -0
- package/lib/typescript/shared/index.d.ts +13 -13
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/gestures.provider.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 +6 -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.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 +119 -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/components/root-transition-aware.tsx +7 -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/hooks/use-stack-pointer-events.ts +15 -0
- package/src/shared/index.ts +2 -1
- package/src/shared/providers/gestures.provider.tsx +5 -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 +56 -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 +7 -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
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
2
|
+
import { StyleSheet, type View } from "react-native";
|
|
3
3
|
import Animated, {
|
|
4
|
+
Extrapolation,
|
|
4
5
|
interpolate,
|
|
5
6
|
useAnimatedProps,
|
|
7
|
+
useAnimatedRef,
|
|
6
8
|
useDerivedValue,
|
|
7
9
|
useSharedValue,
|
|
8
10
|
} from "react-native-reanimated";
|
|
9
11
|
import { Screen as RNSScreen } from "react-native-screens";
|
|
12
|
+
import { useStack } from "../../shared/hooks/navigation/use-stack";
|
|
13
|
+
import { LayoutAnchorProvider } from "../../shared/providers/layout-anchor.provider";
|
|
10
14
|
import { useManagedStackContext } from "../../shared/providers/stack/managed.provider";
|
|
11
15
|
import { AnimationStore } from "../../shared/stores/animation.store";
|
|
12
16
|
|
|
@@ -25,10 +29,12 @@ enum ScreenActivity {
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
const EPSILON = 1e-5;
|
|
32
|
+
const POINT_NONE = "none" as const;
|
|
33
|
+
const POINT_BOX_NONE = "box-none" as const;
|
|
28
34
|
|
|
29
|
-
const
|
|
35
|
+
const AnimatedNativeScreen = Animated.createAnimatedComponent(RNSScreen);
|
|
30
36
|
|
|
31
|
-
export const
|
|
37
|
+
export const AdjustedScreen = ({
|
|
32
38
|
routeKey,
|
|
33
39
|
index,
|
|
34
40
|
isPreloaded,
|
|
@@ -36,8 +42,12 @@ export const Screen = ({
|
|
|
36
42
|
freezeOnBlur,
|
|
37
43
|
shouldFreeze,
|
|
38
44
|
}: ScreenProps) => {
|
|
45
|
+
const {
|
|
46
|
+
flags: { DISABLE_NATIVE_SCREENS = false },
|
|
47
|
+
} = useStack();
|
|
39
48
|
const { activeScreensLimit, routes } = useManagedStackContext();
|
|
40
49
|
const routesLength = routes.length;
|
|
50
|
+
const screenRef = useAnimatedRef<View>();
|
|
41
51
|
|
|
42
52
|
const sceneProgress = AnimationStore.getAnimation(routeKey, "progress");
|
|
43
53
|
const sceneClosing = AnimationStore.getAnimation(routeKey, "closing");
|
|
@@ -65,7 +75,7 @@ export const Screen = ({
|
|
|
65
75
|
sceneProgress.get(),
|
|
66
76
|
[0, 1 - EPSILON, 1],
|
|
67
77
|
[1, 1, outputValue],
|
|
68
|
-
|
|
78
|
+
Extrapolation.CLAMP,
|
|
69
79
|
);
|
|
70
80
|
|
|
71
81
|
const next = Math.trunc(v) ?? ScreenActivity.TRANSITIONING_OR_BELOW_TOP;
|
|
@@ -78,23 +88,34 @@ export const Screen = ({
|
|
|
78
88
|
|
|
79
89
|
const animatedProps = useAnimatedProps(() => {
|
|
80
90
|
const activity = screenActivity.get();
|
|
91
|
+
if (!DISABLE_NATIVE_SCREENS) {
|
|
92
|
+
return {
|
|
93
|
+
activityState: activity,
|
|
94
|
+
shouldFreeze: activity === ScreenActivity.INACTIVE && shouldFreeze,
|
|
95
|
+
pointerEvents: sceneClosing.get() ? POINT_NONE : POINT_BOX_NONE,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
81
99
|
return {
|
|
82
|
-
|
|
83
|
-
shouldFreeze: activity === ScreenActivity.INACTIVE && shouldFreeze,
|
|
84
|
-
pointerEvents: sceneClosing.get()
|
|
85
|
-
? ("none" as const)
|
|
86
|
-
: ("box-none" as const),
|
|
100
|
+
pointerEvents: sceneClosing.get() ? POINT_NONE : POINT_BOX_NONE,
|
|
87
101
|
};
|
|
88
102
|
});
|
|
89
103
|
|
|
104
|
+
const AdjustedScreenComponent = !DISABLE_NATIVE_SCREENS
|
|
105
|
+
? AnimatedNativeScreen
|
|
106
|
+
: Animated.View;
|
|
107
|
+
|
|
90
108
|
return (
|
|
91
|
-
<
|
|
109
|
+
<AdjustedScreenComponent
|
|
92
110
|
enabled
|
|
111
|
+
ref={screenRef}
|
|
93
112
|
style={StyleSheet.absoluteFill}
|
|
94
113
|
freezeOnBlur={freezeOnBlur}
|
|
95
114
|
animatedProps={animatedProps}
|
|
96
115
|
>
|
|
97
|
-
{
|
|
98
|
-
|
|
116
|
+
<LayoutAnchorProvider anchorRef={screenRef}>
|
|
117
|
+
{children}
|
|
118
|
+
</LayoutAnchorProvider>
|
|
119
|
+
</AdjustedScreenComponent>
|
|
99
120
|
);
|
|
100
121
|
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NavigationContext,
|
|
3
|
+
NavigationRouteContext,
|
|
4
|
+
} from "@react-navigation/native";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { Fragment } from "react";
|
|
7
|
+
import { Overlay } from "../../shared/components/overlay";
|
|
8
|
+
import { ManagedLifecycle } from "../../shared/controller/managed-lifecycle";
|
|
9
|
+
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
10
|
+
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
11
|
+
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
12
|
+
import type {
|
|
13
|
+
BlankStackDescriptor,
|
|
14
|
+
BlankStackNavigationHelpers,
|
|
15
|
+
} from "../types";
|
|
16
|
+
import { AdjustedScreen } from "./adjusted-screen";
|
|
17
|
+
import { AdjustedScreenContainer } from "./adjusted-screen-container";
|
|
18
|
+
|
|
19
|
+
function isFabric() {
|
|
20
|
+
return "nativeFabricUIManager" in global;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type SceneViewProps = {
|
|
24
|
+
descriptor: BlankStackDescriptor;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const SceneView = React.memo(function SceneView({
|
|
28
|
+
descriptor,
|
|
29
|
+
}: SceneViewProps) {
|
|
30
|
+
const { route, navigation, render } = descriptor;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<NavigationContext.Provider value={navigation}>
|
|
34
|
+
<NavigationRouteContext.Provider value={route}>
|
|
35
|
+
{descriptor.options.overlayMode === "screen" && <Overlay.Screen />}
|
|
36
|
+
{render()}
|
|
37
|
+
</NavigationRouteContext.Provider>
|
|
38
|
+
</NavigationContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const StackView = withStackCore(
|
|
43
|
+
{ TRANSITIONS_ALWAYS_ON: true, DISABLE_NATIVE_SCREENS: false },
|
|
44
|
+
withManagedStack<BlankStackDescriptor, BlankStackNavigationHelpers>(
|
|
45
|
+
({ descriptors, focusedIndex, scenes, shouldShowFloatOverlay }) => {
|
|
46
|
+
return (
|
|
47
|
+
<Fragment>
|
|
48
|
+
{shouldShowFloatOverlay ? <Overlay.Float /> : null}
|
|
49
|
+
|
|
50
|
+
<AdjustedScreenContainer>
|
|
51
|
+
{scenes.map((scene, sceneIndex) => {
|
|
52
|
+
const descriptor = scene.descriptor;
|
|
53
|
+
const route = scene.route;
|
|
54
|
+
const isFocused = focusedIndex === sceneIndex;
|
|
55
|
+
const isBelowFocused = focusedIndex - 1 === sceneIndex;
|
|
56
|
+
|
|
57
|
+
const previousDescriptor =
|
|
58
|
+
scenes[sceneIndex - 1]?.descriptor ?? undefined;
|
|
59
|
+
const nextDescriptor =
|
|
60
|
+
scenes[sceneIndex + 1]?.descriptor ?? undefined;
|
|
61
|
+
|
|
62
|
+
const isPreloaded = descriptors[route.key] === undefined;
|
|
63
|
+
|
|
64
|
+
// On Fabric, when screen is frozen, animated and reanimated values are not updated
|
|
65
|
+
// due to component being unmounted. To avoid this, we don't freeze the previous screen there
|
|
66
|
+
const shouldFreeze = isFabric()
|
|
67
|
+
? !isPreloaded && !isFocused && !isBelowFocused
|
|
68
|
+
: !isPreloaded && !isFocused;
|
|
69
|
+
return (
|
|
70
|
+
<AdjustedScreen
|
|
71
|
+
key={route.key}
|
|
72
|
+
isPreloaded={isPreloaded}
|
|
73
|
+
index={sceneIndex}
|
|
74
|
+
routeKey={route.key}
|
|
75
|
+
shouldFreeze={shouldFreeze}
|
|
76
|
+
freezeOnBlur={descriptor.options.freezeOnBlur}
|
|
77
|
+
>
|
|
78
|
+
<ScreenComposer
|
|
79
|
+
previous={previousDescriptor}
|
|
80
|
+
current={descriptor}
|
|
81
|
+
next={nextDescriptor}
|
|
82
|
+
LifecycleController={ManagedLifecycle}
|
|
83
|
+
>
|
|
84
|
+
<SceneView key={route.key} descriptor={descriptor} />
|
|
85
|
+
</ScreenComposer>
|
|
86
|
+
</AdjustedScreen>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
</AdjustedScreenContainer>
|
|
90
|
+
</Fragment>
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
),
|
|
94
|
+
);
|
|
@@ -4,18 +4,17 @@ import {
|
|
|
4
4
|
} from "@react-navigation/native";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { Fragment } from "react";
|
|
7
|
-
import { StyleSheet } from "react-native";
|
|
8
|
-
import { ScreenContainer } from "react-native-screens";
|
|
9
7
|
import { Overlay } from "../../shared/components/overlay";
|
|
8
|
+
import { ManagedLifecycle } from "../../shared/controller/managed-lifecycle";
|
|
10
9
|
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
11
10
|
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
12
11
|
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
13
|
-
import { BlankStackScreenLifecycleController } from "../controllers/blank-stack-lifecycle";
|
|
14
12
|
import type {
|
|
15
13
|
BlankStackDescriptor,
|
|
16
14
|
BlankStackNavigationHelpers,
|
|
17
15
|
} from "../types";
|
|
18
|
-
import {
|
|
16
|
+
import { AdjustedScreen } from "./adjusted-screen";
|
|
17
|
+
import { AdjustedScreenContainer } from "./adjusted-screen-container";
|
|
19
18
|
|
|
20
19
|
function isFabric() {
|
|
21
20
|
return "nativeFabricUIManager" in global;
|
|
@@ -41,60 +40,55 @@ const SceneView = React.memo(function SceneView({
|
|
|
41
40
|
});
|
|
42
41
|
|
|
43
42
|
export const StackView = withStackCore(
|
|
44
|
-
{ TRANSITIONS_ALWAYS_ON: true },
|
|
43
|
+
{ TRANSITIONS_ALWAYS_ON: true, DISABLE_NATIVE_SCREENS: true },
|
|
45
44
|
withManagedStack<BlankStackDescriptor, BlankStackNavigationHelpers>(
|
|
46
45
|
({ descriptors, focusedIndex, scenes, shouldShowFloatOverlay }) => {
|
|
47
46
|
return (
|
|
48
47
|
<Fragment>
|
|
49
48
|
{shouldShowFloatOverlay ? <Overlay.Float /> : null}
|
|
50
|
-
<Overlay.Container>
|
|
51
|
-
<ScreenContainer style={styles.container}>
|
|
52
|
-
{scenes.map((scene, sceneIndex) => {
|
|
53
|
-
const descriptor = scene.descriptor;
|
|
54
|
-
const route = scene.route;
|
|
55
|
-
const isFocused = focusedIndex === sceneIndex;
|
|
56
|
-
const isBelowFocused = focusedIndex - 1 === sceneIndex;
|
|
57
49
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
<AdjustedScreenContainer>
|
|
51
|
+
{scenes.map((scene, sceneIndex) => {
|
|
52
|
+
const descriptor = scene.descriptor;
|
|
53
|
+
const route = scene.route;
|
|
54
|
+
const isFocused = focusedIndex === sceneIndex;
|
|
55
|
+
const isBelowFocused = focusedIndex - 1 === sceneIndex;
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
const previousDescriptor =
|
|
58
|
+
scenes[sceneIndex - 1]?.descriptor ?? undefined;
|
|
59
|
+
const nextDescriptor =
|
|
60
|
+
scenes[sceneIndex + 1]?.descriptor ?? undefined;
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
const isPreloaded = descriptors[route.key] === undefined;
|
|
63
|
+
|
|
64
|
+
// On Fabric, when screen is frozen, animated and reanimated values are not updated
|
|
65
|
+
// due to component being unmounted. To avoid this, we don't freeze the previous screen there
|
|
66
|
+
const shouldFreeze = isFabric()
|
|
67
|
+
? !isPreloaded && !isFocused && !isBelowFocused
|
|
68
|
+
: !isPreloaded && !isFocused;
|
|
69
|
+
return (
|
|
70
|
+
<AdjustedScreen
|
|
71
|
+
key={route.key}
|
|
72
|
+
isPreloaded={isPreloaded}
|
|
73
|
+
index={sceneIndex}
|
|
74
|
+
routeKey={route.key}
|
|
75
|
+
shouldFreeze={shouldFreeze}
|
|
76
|
+
freezeOnBlur={descriptor.options.freezeOnBlur}
|
|
77
|
+
>
|
|
78
|
+
<ScreenComposer
|
|
79
|
+
previous={previousDescriptor}
|
|
80
|
+
current={descriptor}
|
|
81
|
+
next={nextDescriptor}
|
|
82
|
+
LifecycleController={ManagedLifecycle}
|
|
78
83
|
>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<SceneView key={route.key} descriptor={descriptor} />
|
|
86
|
-
</ScreenComposer>
|
|
87
|
-
</Screen>
|
|
88
|
-
);
|
|
89
|
-
})}
|
|
90
|
-
</ScreenContainer>
|
|
91
|
-
</Overlay.Container>
|
|
84
|
+
<SceneView key={route.key} descriptor={descriptor} />
|
|
85
|
+
</ScreenComposer>
|
|
86
|
+
</AdjustedScreen>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
</AdjustedScreenContainer>
|
|
92
90
|
</Fragment>
|
|
93
91
|
);
|
|
94
92
|
},
|
|
95
93
|
),
|
|
96
94
|
);
|
|
97
|
-
|
|
98
|
-
const styles = StyleSheet.create({
|
|
99
|
-
container: { flex: 1 },
|
|
100
|
-
});
|
package/src/blank-stack/types.ts
CHANGED
|
@@ -57,8 +57,9 @@ export type BlankStackScene = {
|
|
|
57
57
|
descriptor: BlankStackDescriptor;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
type BlankStackNavigationConfig = {
|
|
61
|
+
DISABLE_NATIVE_SCREENS?: boolean;
|
|
62
|
+
};
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
65
|
* Props passed to overlay components in blank-stack.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { StyleSheet, type View } from "react-native";
|
|
3
|
+
import Animated, {
|
|
4
|
+
useAnimatedProps,
|
|
5
|
+
useAnimatedRef,
|
|
6
|
+
} from "react-native-reanimated";
|
|
7
|
+
import { LayoutAnchorProvider } from "../../shared/providers/layout-anchor.provider";
|
|
8
|
+
import { AnimationStore } from "../../shared/stores/animation.store";
|
|
9
|
+
|
|
10
|
+
interface ScreenProps {
|
|
11
|
+
routeKey: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
const POINT_NONE = "none" as const;
|
|
15
|
+
const POINT_BOX_NONE = "box-none" as const;
|
|
16
|
+
|
|
17
|
+
export const ComponentScreen = ({ routeKey, children }: ScreenProps) => {
|
|
18
|
+
const sceneClosing = AnimationStore.getAnimation(routeKey, "closing");
|
|
19
|
+
const screenRef = useAnimatedRef<View>();
|
|
20
|
+
|
|
21
|
+
const animatedProps = useAnimatedProps(() => {
|
|
22
|
+
return {
|
|
23
|
+
pointerEvents: sceneClosing.get() ? POINT_NONE : POINT_BOX_NONE,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const ComponentScreenComponent = Animated.View;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ComponentScreenComponent
|
|
31
|
+
ref={screenRef}
|
|
32
|
+
style={StyleSheet.absoluteFill}
|
|
33
|
+
animatedProps={animatedProps}
|
|
34
|
+
>
|
|
35
|
+
<LayoutAnchorProvider anchorRef={screenRef}>
|
|
36
|
+
{children}
|
|
37
|
+
</LayoutAnchorProvider>
|
|
38
|
+
</ComponentScreenComponent>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NavigationContext,
|
|
3
|
+
NavigationRouteContext,
|
|
4
|
+
} from "@react-navigation/native";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { Fragment } from "react";
|
|
7
|
+
import { Overlay } from "../../shared/components/overlay";
|
|
8
|
+
import { ManagedLifecycle } from "../../shared/controller/managed-lifecycle";
|
|
9
|
+
import { ScreenComposer } from "../../shared/providers/screen/screen-composer";
|
|
10
|
+
import { withStackCore } from "../../shared/providers/stack/core.provider";
|
|
11
|
+
import { withManagedStack } from "../../shared/providers/stack/managed.provider";
|
|
12
|
+
import { StackType } from "../../shared/types/stack.types";
|
|
13
|
+
import type {
|
|
14
|
+
ComponentStackDescriptor,
|
|
15
|
+
ComponentStackNavigationHelpers,
|
|
16
|
+
} from "../types";
|
|
17
|
+
import { ComponentScreen } from "./component-screen";
|
|
18
|
+
|
|
19
|
+
type SceneViewProps = {
|
|
20
|
+
descriptor: ComponentStackDescriptor;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const SceneView = React.memo(function SceneView({
|
|
24
|
+
descriptor,
|
|
25
|
+
}: SceneViewProps) {
|
|
26
|
+
const { route, navigation, render } = descriptor;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<NavigationContext.Provider value={navigation}>
|
|
30
|
+
<NavigationRouteContext.Provider value={route}>
|
|
31
|
+
{descriptor.options.overlayMode === "screen" && <Overlay.Screen />}
|
|
32
|
+
{render()}
|
|
33
|
+
</NavigationRouteContext.Provider>
|
|
34
|
+
</NavigationContext.Provider>
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const StackView = withStackCore(
|
|
39
|
+
{ TRANSITIONS_ALWAYS_ON: true, STACK_TYPE: StackType.COMPONENT },
|
|
40
|
+
withManagedStack<ComponentStackDescriptor, ComponentStackNavigationHelpers>(
|
|
41
|
+
({ scenes, shouldShowFloatOverlay }) => {
|
|
42
|
+
return (
|
|
43
|
+
<Fragment>
|
|
44
|
+
{shouldShowFloatOverlay ? <Overlay.Float /> : null}
|
|
45
|
+
|
|
46
|
+
<Fragment>
|
|
47
|
+
{scenes.map((scene, sceneIndex) => {
|
|
48
|
+
const descriptor = scene.descriptor;
|
|
49
|
+
const route = scene.route;
|
|
50
|
+
|
|
51
|
+
const previousDescriptor =
|
|
52
|
+
scenes[sceneIndex - 1]?.descriptor ?? undefined;
|
|
53
|
+
const nextDescriptor =
|
|
54
|
+
scenes[sceneIndex + 1]?.descriptor ?? undefined;
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<ComponentScreen key={route.key} routeKey={route.key}>
|
|
58
|
+
<ScreenComposer
|
|
59
|
+
previous={previousDescriptor}
|
|
60
|
+
current={descriptor}
|
|
61
|
+
next={nextDescriptor}
|
|
62
|
+
LifecycleController={ManagedLifecycle}
|
|
63
|
+
>
|
|
64
|
+
<SceneView key={route.key} descriptor={descriptor} />
|
|
65
|
+
</ScreenComposer>
|
|
66
|
+
</ComponentScreen>
|
|
67
|
+
);
|
|
68
|
+
})}
|
|
69
|
+
</Fragment>
|
|
70
|
+
</Fragment>
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
),
|
|
74
|
+
);
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { createComponentNavigator } from "./navigators/create-component-navigator";
|
|
1
|
+
export { createComponentStackNavigator } from "../component-stack/navigators/create-component-stack-navigator";
|
|
3
2
|
export type {
|
|
4
|
-
|
|
5
|
-
ComponentNavigatorProps,
|
|
6
|
-
ComponentRoute,
|
|
7
|
-
ComponentScreenConfig,
|
|
8
|
-
ComponentScreenProps,
|
|
9
|
-
ComponentStackDescriptor,
|
|
3
|
+
ComponentStackNavigationEventMap,
|
|
10
4
|
ComponentStackNavigationOptions,
|
|
5
|
+
ComponentStackNavigationProp,
|
|
6
|
+
ComponentStackNavigatorProps,
|
|
7
|
+
ComponentStackOptionsArgs,
|
|
11
8
|
ComponentStackOverlayProps,
|
|
12
|
-
ComponentStackScene,
|
|
13
9
|
ComponentStackScreenProps,
|
|
14
|
-
|
|
15
|
-
ComponentStackState,
|
|
16
|
-
} from "./types";
|
|
10
|
+
} from "../component-stack/types";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createNavigatorFactory,
|
|
3
|
+
NavigationContainer,
|
|
4
|
+
NavigationIndependentTree,
|
|
5
|
+
type NavigatorTypeBagBase,
|
|
6
|
+
type ParamListBase,
|
|
7
|
+
type StackActionHelpers,
|
|
8
|
+
type StackNavigationState,
|
|
9
|
+
StackRouter,
|
|
10
|
+
type StackRouterOptions,
|
|
11
|
+
type StaticConfig,
|
|
12
|
+
type TypedNavigator,
|
|
13
|
+
useNavigationBuilder,
|
|
14
|
+
} from "@react-navigation/native";
|
|
15
|
+
import * as React from "react";
|
|
16
|
+
import { StackView } from "../components/stack-view";
|
|
17
|
+
import type {
|
|
18
|
+
ComponentStackNavigationEventMap,
|
|
19
|
+
ComponentStackNavigationOptions,
|
|
20
|
+
ComponentStackNavigationProp,
|
|
21
|
+
ComponentStackNavigatorProps,
|
|
22
|
+
} from "../types";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Context to detect if we're inside a ComponentStack.
|
|
26
|
+
* Used to avoid double-wrapping nested ComponentStacks in NavigationIndependentTree.
|
|
27
|
+
*/
|
|
28
|
+
const ComponentStackContext = React.createContext<boolean>(false);
|
|
29
|
+
ComponentStackContext.displayName = "ComponentStackContext";
|
|
30
|
+
|
|
31
|
+
const ComponentStackNavigatorInner = React.memo(
|
|
32
|
+
function ComponentStackNavigatorInner({
|
|
33
|
+
id,
|
|
34
|
+
initialRouteName,
|
|
35
|
+
children,
|
|
36
|
+
layout,
|
|
37
|
+
screenListeners,
|
|
38
|
+
screenOptions,
|
|
39
|
+
screenLayout,
|
|
40
|
+
...rest
|
|
41
|
+
}: ComponentStackNavigatorProps) {
|
|
42
|
+
const { state, describe, descriptors, navigation, NavigationContent } =
|
|
43
|
+
useNavigationBuilder<
|
|
44
|
+
StackNavigationState<ParamListBase>,
|
|
45
|
+
StackRouterOptions,
|
|
46
|
+
StackActionHelpers<ParamListBase>,
|
|
47
|
+
ComponentStackNavigationOptions,
|
|
48
|
+
ComponentStackNavigationEventMap
|
|
49
|
+
>(StackRouter, {
|
|
50
|
+
id,
|
|
51
|
+
initialRouteName,
|
|
52
|
+
children,
|
|
53
|
+
layout,
|
|
54
|
+
screenListeners,
|
|
55
|
+
screenOptions,
|
|
56
|
+
screenLayout,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<NavigationContent>
|
|
61
|
+
<StackView
|
|
62
|
+
{...rest}
|
|
63
|
+
state={state}
|
|
64
|
+
navigation={navigation}
|
|
65
|
+
descriptors={descriptors}
|
|
66
|
+
describe={describe}
|
|
67
|
+
/>
|
|
68
|
+
</NavigationContent>
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* ComponentStackNavigator conditionally wraps in NavigationIndependentTree.
|
|
75
|
+
* - If already inside a ComponentStack (nested), just render the inner navigator
|
|
76
|
+
* so it participates in the parent's navigation tree and goBack() works.
|
|
77
|
+
* - If top-level, wrap in NavigationIndependentTree + NavigationContainer
|
|
78
|
+
* to isolate from Expo Router / React Navigation.
|
|
79
|
+
*/
|
|
80
|
+
function IsolatedComponentStackNavigator(props: ComponentStackNavigatorProps) {
|
|
81
|
+
const isNested = React.useContext(ComponentStackContext);
|
|
82
|
+
|
|
83
|
+
if (isNested) {
|
|
84
|
+
return <ComponentStackNavigatorInner {...props} />;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<NavigationIndependentTree>
|
|
89
|
+
<NavigationContainer>
|
|
90
|
+
<ComponentStackContext.Provider value={true}>
|
|
91
|
+
<ComponentStackNavigatorInner {...props} />
|
|
92
|
+
</ComponentStackContext.Provider>
|
|
93
|
+
</NavigationContainer>
|
|
94
|
+
</NavigationIndependentTree>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function createComponentStackNavigator<
|
|
99
|
+
const ParamList extends ParamListBase,
|
|
100
|
+
const NavigatorID extends string | undefined = undefined,
|
|
101
|
+
const TypeBag extends NavigatorTypeBagBase = {
|
|
102
|
+
ParamList: ParamList;
|
|
103
|
+
NavigatorID: NavigatorID;
|
|
104
|
+
State: StackNavigationState<ParamList>;
|
|
105
|
+
ScreenOptions: ComponentStackNavigationOptions;
|
|
106
|
+
EventMap: ComponentStackNavigationEventMap;
|
|
107
|
+
NavigationList: {
|
|
108
|
+
[RouteName in keyof ParamList]: ComponentStackNavigationProp<
|
|
109
|
+
ParamList,
|
|
110
|
+
RouteName,
|
|
111
|
+
NavigatorID
|
|
112
|
+
>;
|
|
113
|
+
};
|
|
114
|
+
Navigator: typeof IsolatedComponentStackNavigator;
|
|
115
|
+
},
|
|
116
|
+
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
|
117
|
+
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
|
118
|
+
return createNavigatorFactory(IsolatedComponentStackNavigator)(config);
|
|
119
|
+
}
|