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
|
@@ -1,209 +1,101 @@
|
|
|
1
|
-
import type { DerivedValue } from "react-native-reanimated";
|
|
2
|
-
import type { ScreenTransitionConfig } from "../shared";
|
|
3
1
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
DefaultNavigatorOptions,
|
|
3
|
+
Descriptor,
|
|
4
|
+
NavigationHelpers,
|
|
5
|
+
NavigationProp,
|
|
6
|
+
ParamListBase,
|
|
7
|
+
Route,
|
|
8
|
+
RouteProp,
|
|
9
|
+
StackActionHelpers,
|
|
10
|
+
StackNavigationState,
|
|
11
|
+
StackRouterOptions,
|
|
12
|
+
Theme,
|
|
13
|
+
} from "@react-navigation/native";
|
|
14
|
+
import type { ScreenTransitionConfig } from "../shared";
|
|
15
|
+
import type { OverlayProps } from "../shared/types/overlay.types";
|
|
8
16
|
|
|
9
|
-
|
|
10
|
-
* A synthetic route object for component navigation.
|
|
11
|
-
* Mimics React Navigation's Route type but without the navigation dependency.
|
|
12
|
-
*/
|
|
13
|
-
export interface ComponentRoute<Params = Record<string, unknown>> {
|
|
14
|
-
/** Unique identifier for this route instance */
|
|
15
|
-
key: string;
|
|
16
|
-
/** Name identifier for the screen */
|
|
17
|
-
name: string;
|
|
18
|
-
/** Optional parameters passed to the screen */
|
|
19
|
-
params?: Params;
|
|
20
|
-
}
|
|
17
|
+
export type ComponentStackNavigationEventMap = {};
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
export type ComponentStackNavigationProp<
|
|
20
|
+
ParamList extends ParamListBase,
|
|
21
|
+
RouteName extends keyof ParamList = string,
|
|
22
|
+
NavigatorID extends string | undefined = undefined,
|
|
23
|
+
> = NavigationProp<
|
|
24
|
+
ParamList,
|
|
25
|
+
RouteName,
|
|
26
|
+
NavigatorID,
|
|
27
|
+
StackNavigationState<ParamList>,
|
|
28
|
+
ComponentStackNavigationOptions,
|
|
29
|
+
ComponentStackNavigationEventMap
|
|
30
|
+
> &
|
|
31
|
+
StackActionHelpers<ParamList>;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
export type ComponentStackScreenProps<
|
|
34
|
+
ParamList extends ParamListBase,
|
|
35
|
+
RouteName extends keyof ParamList = string,
|
|
36
|
+
NavigatorID extends string | undefined = undefined,
|
|
37
|
+
> = {
|
|
38
|
+
navigation: ComponentStackNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
39
|
+
route: RouteProp<ParamList, RouteName>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type ComponentStackOptionsArgs<
|
|
43
|
+
ParamList extends ParamListBase,
|
|
44
|
+
RouteName extends keyof ParamList = keyof ParamList,
|
|
45
|
+
NavigatorID extends string | undefined = undefined,
|
|
46
|
+
> = ComponentStackScreenProps<ParamList, RouteName, NavigatorID> & {
|
|
47
|
+
theme: Theme;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type ComponentStackNavigationHelpers = NavigationHelpers<
|
|
51
|
+
ParamListBase,
|
|
52
|
+
ComponentStackNavigationEventMap
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
export type ComponentStackScene = {
|
|
56
|
+
route: Route<string>;
|
|
57
|
+
descriptor: ComponentStackDescriptor;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type ComponentStackNavigationConfig = {};
|
|
56
61
|
|
|
57
62
|
/**
|
|
58
|
-
*
|
|
63
|
+
* Props passed to overlay components in component-stack.
|
|
64
|
+
* Uses the shared OverlayProps type with component-stack's navigation type.
|
|
59
65
|
*/
|
|
60
|
-
export type
|
|
66
|
+
export type ComponentStackOverlayProps = OverlayProps<
|
|
67
|
+
ComponentStackNavigationProp<ParamListBase>
|
|
68
|
+
>;
|
|
69
|
+
|
|
70
|
+
type ComponentStackScreenTransitionConfig = ScreenTransitionConfig & {
|
|
61
71
|
/**
|
|
62
72
|
* Whether to detach the previous screen from the view hierarchy to save memory.
|
|
63
73
|
* Set it to `false` if you need the previous screen to be seen through the active screen.
|
|
74
|
+
* Only applicable if `detachInactiveScreens` isn't set to `false`.
|
|
64
75
|
*/
|
|
65
76
|
detachPreviousScreen?: boolean;
|
|
66
77
|
};
|
|
67
78
|
|
|
68
|
-
/**
|
|
69
|
-
* Props passed to overlay components.
|
|
70
|
-
*/
|
|
71
|
-
export type ComponentStackOverlayProps = {
|
|
72
|
-
/** Route of the currently focused screen in the stack. */
|
|
73
|
-
focusedRoute: ComponentRoute;
|
|
74
|
-
/** Index of the focused route in the stack. */
|
|
75
|
-
focusedIndex: number;
|
|
76
|
-
/** All routes currently in the stack. */
|
|
77
|
-
routes: ComponentRoute[];
|
|
78
|
-
/** Custom metadata from the focused screen's options. */
|
|
79
|
-
meta?: Record<string, unknown>;
|
|
80
|
-
/** Navigation object for the overlay. */
|
|
81
|
-
navigation: ComponentNavigation;
|
|
82
|
-
/** Animation values for the overlay. */
|
|
83
|
-
overlayAnimation: DerivedValue<OverlayInterpolationProps>;
|
|
84
|
-
/** Animation values for the screen. */
|
|
85
|
-
screenAnimation: DerivedValue<ScreenInterpolationProps>;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Props passed to container overlay components.
|
|
90
|
-
* Extends overlay props with children to wrap screen content.
|
|
91
|
-
*/
|
|
92
|
-
export type ComponentStackContainerOverlayProps = ComponentStackOverlayProps & {
|
|
93
|
-
/** The screen content to be wrapped by the container overlay. */
|
|
94
|
-
children: React.ReactNode;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Full navigation options for a component stack screen.
|
|
99
|
-
*/
|
|
100
79
|
export type ComponentStackNavigationOptions =
|
|
101
|
-
ComponentStackScreenTransitionConfig & {
|
|
102
|
-
/** Function that returns a React Element to display as overlay. */
|
|
103
|
-
overlay?:
|
|
104
|
-
| ((props: ComponentStackOverlayProps) => React.ReactNode)
|
|
105
|
-
| ((props: ComponentStackContainerOverlayProps) => React.ReactNode);
|
|
106
|
-
/**
|
|
107
|
-
* Layout: How the Overlay is positioned
|
|
108
|
-
* - 'float': Single persistent overlay above all screens (like iOS)
|
|
109
|
-
* - 'screen': Per-screen overlay that transitions with content
|
|
110
|
-
* - 'container': Wraps all screen content (for MaskedView, custom containers)
|
|
111
|
-
* @default 'screen'
|
|
112
|
-
*/
|
|
113
|
-
overlayMode?: OverlayMode;
|
|
114
|
-
/** Whether to show the overlay. Defaults to true when overlay is provided. */
|
|
115
|
-
overlayShown?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Whether inactive screens should be suspended from re-rendering.
|
|
118
|
-
* Defaults to `true` when `enableFreeze()` is run at the top of the application.
|
|
119
|
-
*/
|
|
120
|
-
freezeOnBlur?: boolean;
|
|
121
|
-
};
|
|
80
|
+
ComponentStackScreenTransitionConfig & {};
|
|
122
81
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
render: () => React.JSX.Element | null;
|
|
134
|
-
/** Screen options/configuration */
|
|
135
|
-
options: ComponentStackNavigationOptions;
|
|
136
|
-
}
|
|
82
|
+
export type ComponentStackNavigatorProps = DefaultNavigatorOptions<
|
|
83
|
+
ParamListBase,
|
|
84
|
+
string | undefined,
|
|
85
|
+
StackNavigationState<ParamListBase>,
|
|
86
|
+
ComponentStackNavigationOptions,
|
|
87
|
+
ComponentStackNavigationEventMap,
|
|
88
|
+
ComponentStackNavigationProp<ParamListBase>
|
|
89
|
+
> &
|
|
90
|
+
StackRouterOptions &
|
|
91
|
+
ComponentStackNavigationConfig;
|
|
137
92
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
descriptor: ComponentStackDescriptor;
|
|
144
|
-
}
|
|
93
|
+
export type ComponentStackDescriptor = Descriptor<
|
|
94
|
+
ComponentStackNavigationOptions,
|
|
95
|
+
ComponentStackNavigationProp<ParamListBase>,
|
|
96
|
+
RouteProp<ParamListBase>
|
|
97
|
+
>;
|
|
145
98
|
|
|
146
|
-
/**
|
|
147
|
-
* Map of route keys to descriptors.
|
|
148
|
-
*/
|
|
149
99
|
export type ComponentStackDescriptorMap = {
|
|
150
100
|
[key: string]: ComponentStackDescriptor;
|
|
151
101
|
};
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Props passed to screen components.
|
|
155
|
-
*/
|
|
156
|
-
export interface ComponentStackScreenProps<Params = Record<string, unknown>> {
|
|
157
|
-
/** Navigation object for controlling the stack */
|
|
158
|
-
navigation: ComponentNavigation;
|
|
159
|
-
/** Route object with params */
|
|
160
|
-
route: ComponentRoute<Params>;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* State of the component navigation stack.
|
|
165
|
-
*/
|
|
166
|
-
export interface ComponentStackState {
|
|
167
|
-
/** All routes in the stack */
|
|
168
|
-
routes: ComponentRoute[];
|
|
169
|
-
/** Index of the currently focused route */
|
|
170
|
-
index: number;
|
|
171
|
-
/** Unique key for this stack instance */
|
|
172
|
-
key: string;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Screen definition for the component navigator.
|
|
177
|
-
*/
|
|
178
|
-
export interface ComponentScreenConfig {
|
|
179
|
-
/** Unique name for this screen */
|
|
180
|
-
name: string;
|
|
181
|
-
/** Component to render for this screen */
|
|
182
|
-
component: React.ComponentType<ComponentStackScreenProps<any>>;
|
|
183
|
-
/** Screen-specific options */
|
|
184
|
-
options?: ComponentStackNavigationOptions;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Props for the ComponentNavigator component.
|
|
189
|
-
*/
|
|
190
|
-
export interface ComponentNavigatorProps {
|
|
191
|
-
/** Screen definitions */
|
|
192
|
-
children: React.ReactNode;
|
|
193
|
-
/** Initial screen name to display */
|
|
194
|
-
initialRouteName?: string;
|
|
195
|
-
/** Default options applied to all screens */
|
|
196
|
-
screenOptions?: ComponentStackNavigationOptions;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Props for the ComponentScreen component.
|
|
201
|
-
*/
|
|
202
|
-
export interface ComponentScreenProps {
|
|
203
|
-
/** Unique name for this screen */
|
|
204
|
-
name: string;
|
|
205
|
-
/** Component to render */
|
|
206
|
-
component: React.ComponentType<ComponentStackScreenProps<any>>;
|
|
207
|
-
/** Screen-specific options */
|
|
208
|
-
options?: ComponentStackNavigationOptions;
|
|
209
|
-
}
|
|
@@ -501,112 +501,110 @@ export const NativeStackView = withStackCore(
|
|
|
501
501
|
return (
|
|
502
502
|
<>
|
|
503
503
|
{shouldShowFloatOverlay ? <Overlay.Float /> : null}
|
|
504
|
-
<
|
|
505
|
-
|
|
506
|
-
{
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
</ScreenStack>
|
|
609
|
-
</Overlay.Container>
|
|
504
|
+
<ScreenStack style={styles.container}>
|
|
505
|
+
{scenes.map((scene, index) => {
|
|
506
|
+
const { route, descriptor, isPreloaded } = scene;
|
|
507
|
+
const isFocused = focusedIndex === index;
|
|
508
|
+
const isBelowFocused = focusedIndex - 1 === index;
|
|
509
|
+
|
|
510
|
+
// Get previous/next descriptors from state.routes (not scenes) for proper navigation
|
|
511
|
+
const previousKey = state.routes[index - 1]?.key;
|
|
512
|
+
const nextKey = state.routes[index + 1]?.key;
|
|
513
|
+
const previousDescriptor = previousKey
|
|
514
|
+
? descriptors[previousKey]
|
|
515
|
+
: undefined;
|
|
516
|
+
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
517
|
+
|
|
518
|
+
const isModal = modalRouteKeys.includes(route.key);
|
|
519
|
+
|
|
520
|
+
// On Fabric, when screen is frozen, animated and reanimated values are not updated
|
|
521
|
+
// due to component being unmounted. To avoid this, we don't freeze the previous screen there
|
|
522
|
+
const shouldFreeze = isFabric()
|
|
523
|
+
? !isPreloaded && !isFocused && !isBelowFocused
|
|
524
|
+
: !isPreloaded && !isFocused;
|
|
525
|
+
|
|
526
|
+
return (
|
|
527
|
+
<SceneView
|
|
528
|
+
key={route.key}
|
|
529
|
+
index={index}
|
|
530
|
+
focused={isFocused}
|
|
531
|
+
shouldFreeze={shouldFreeze}
|
|
532
|
+
descriptor={descriptor}
|
|
533
|
+
previousDescriptor={previousDescriptor}
|
|
534
|
+
nextDescriptor={nextDescriptor}
|
|
535
|
+
isPresentationModal={isModal}
|
|
536
|
+
isPreloaded={isPreloaded}
|
|
537
|
+
onWillDisappear={() => {
|
|
538
|
+
navigation.emit({
|
|
539
|
+
type: "transitionStart",
|
|
540
|
+
data: { closing: true },
|
|
541
|
+
target: route.key,
|
|
542
|
+
});
|
|
543
|
+
}}
|
|
544
|
+
onWillAppear={() => {
|
|
545
|
+
navigation.emit({
|
|
546
|
+
type: "transitionStart",
|
|
547
|
+
data: { closing: false },
|
|
548
|
+
target: route.key,
|
|
549
|
+
});
|
|
550
|
+
}}
|
|
551
|
+
onAppear={() => {
|
|
552
|
+
navigation.emit({
|
|
553
|
+
type: "transitionEnd",
|
|
554
|
+
data: { closing: false },
|
|
555
|
+
target: route.key,
|
|
556
|
+
});
|
|
557
|
+
}}
|
|
558
|
+
onDisappear={() => {
|
|
559
|
+
navigation.emit({
|
|
560
|
+
type: "transitionEnd",
|
|
561
|
+
data: { closing: true },
|
|
562
|
+
target: route.key,
|
|
563
|
+
});
|
|
564
|
+
}}
|
|
565
|
+
onDismissed={(event) => {
|
|
566
|
+
navigation.dispatch({
|
|
567
|
+
...StackActions.pop(event.nativeEvent.dismissCount),
|
|
568
|
+
source: route.key,
|
|
569
|
+
target: state.key,
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
setNextDismissedKey(route.key);
|
|
573
|
+
}}
|
|
574
|
+
onHeaderBackButtonClicked={() => {
|
|
575
|
+
navigation.dispatch({
|
|
576
|
+
...StackActions.pop(),
|
|
577
|
+
source: route.key,
|
|
578
|
+
target: state.key,
|
|
579
|
+
});
|
|
580
|
+
}}
|
|
581
|
+
onNativeDismissCancelled={(event) => {
|
|
582
|
+
navigation.dispatch({
|
|
583
|
+
...StackActions.pop(event.nativeEvent.dismissCount),
|
|
584
|
+
source: route.key,
|
|
585
|
+
target: state.key,
|
|
586
|
+
});
|
|
587
|
+
}}
|
|
588
|
+
onGestureCancel={() => {
|
|
589
|
+
navigation.emit({
|
|
590
|
+
type: "gestureCancel",
|
|
591
|
+
target: route.key,
|
|
592
|
+
});
|
|
593
|
+
}}
|
|
594
|
+
onSheetDetentChanged={(event) => {
|
|
595
|
+
navigation.emit({
|
|
596
|
+
type: "sheetDetentChange",
|
|
597
|
+
target: route.key,
|
|
598
|
+
data: {
|
|
599
|
+
index: event.nativeEvent.index,
|
|
600
|
+
stable: event.nativeEvent.isStable,
|
|
601
|
+
},
|
|
602
|
+
});
|
|
603
|
+
}}
|
|
604
|
+
/>
|
|
605
|
+
);
|
|
606
|
+
})}
|
|
607
|
+
</ScreenStack>
|
|
610
608
|
</>
|
|
611
609
|
);
|
|
612
610
|
}),
|
|
@@ -112,152 +112,6 @@ describe("syncRoutesWithRemoved", () => {
|
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
describe("mid-dismiss route reordering", () => {
|
|
116
|
-
it("moves mid-dismiss route to end when pushing while swiping (progress < 0.5)", () => {
|
|
117
|
-
const closingRouteKeys = createClosingRouteKeys();
|
|
118
|
-
|
|
119
|
-
setRouteState("a", { progress: 1 });
|
|
120
|
-
setRouteState("b-old", { progress: 0.3 }); // Mid-dismiss
|
|
121
|
-
setRouteState("b-new", { progress: 0 }); // Just pushed
|
|
122
|
-
|
|
123
|
-
const result = syncRoutesWithRemoved({
|
|
124
|
-
prevRoutes: [createRoute("a"), createRoute("b-old")],
|
|
125
|
-
prevDescriptors: { a: {}, "b-old": {} },
|
|
126
|
-
nextRoutes: [
|
|
127
|
-
createRoute("a"),
|
|
128
|
-
createRoute("b-old"),
|
|
129
|
-
createRoute("b-new"),
|
|
130
|
-
],
|
|
131
|
-
nextDescriptors: { a: {}, "b-old": {}, "b-new": {} },
|
|
132
|
-
closingRouteKeys,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
expect(result.routes.map((r) => r.key)).toEqual(["a", "b-new", "b-old"]);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("marks moved route as closing", () => {
|
|
139
|
-
const closingRouteKeys = createClosingRouteKeys();
|
|
140
|
-
|
|
141
|
-
setRouteState("a", { progress: 1 });
|
|
142
|
-
setRouteState("b-old", { progress: 0.3 });
|
|
143
|
-
setRouteState("b-new", { progress: 0 });
|
|
144
|
-
|
|
145
|
-
syncRoutesWithRemoved({
|
|
146
|
-
prevRoutes: [createRoute("a"), createRoute("b-old")],
|
|
147
|
-
prevDescriptors: { a: {}, "b-old": {} },
|
|
148
|
-
nextRoutes: [
|
|
149
|
-
createRoute("a"),
|
|
150
|
-
createRoute("b-old"),
|
|
151
|
-
createRoute("b-new"),
|
|
152
|
-
],
|
|
153
|
-
nextDescriptors: { a: {}, "b-old": {}, "b-new": {} },
|
|
154
|
-
closingRouteKeys,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
expect(closingRouteKeys.ref.current.has("b-old")).toBe(true);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("detects dismissing via isDragging flag", () => {
|
|
161
|
-
const closingRouteKeys = createClosingRouteKeys();
|
|
162
|
-
|
|
163
|
-
setRouteState("a", { progress: 1 });
|
|
164
|
-
setRouteState("b-old", { progress: 1, isDragging: 1 }); // Being dragged
|
|
165
|
-
setRouteState("b-new", { progress: 0 });
|
|
166
|
-
|
|
167
|
-
const result = syncRoutesWithRemoved({
|
|
168
|
-
prevRoutes: [createRoute("a"), createRoute("b-old")],
|
|
169
|
-
prevDescriptors: { a: {}, "b-old": {} },
|
|
170
|
-
nextRoutes: [
|
|
171
|
-
createRoute("a"),
|
|
172
|
-
createRoute("b-old"),
|
|
173
|
-
createRoute("b-new"),
|
|
174
|
-
],
|
|
175
|
-
nextDescriptors: { a: {}, "b-old": {}, "b-new": {} },
|
|
176
|
-
closingRouteKeys,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
expect(result.routes.map((r) => r.key)).toEqual(["a", "b-new", "b-old"]);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("detects dismissing via isDismissing flag", () => {
|
|
183
|
-
const closingRouteKeys = createClosingRouteKeys();
|
|
184
|
-
|
|
185
|
-
setRouteState("a", { progress: 1 });
|
|
186
|
-
setRouteState("b-old", { progress: 1, isDismissing: 1 });
|
|
187
|
-
setRouteState("b-new", { progress: 0 });
|
|
188
|
-
|
|
189
|
-
const result = syncRoutesWithRemoved({
|
|
190
|
-
prevRoutes: [createRoute("a"), createRoute("b-old")],
|
|
191
|
-
prevDescriptors: { a: {}, "b-old": {} },
|
|
192
|
-
nextRoutes: [
|
|
193
|
-
createRoute("a"),
|
|
194
|
-
createRoute("b-old"),
|
|
195
|
-
createRoute("b-new"),
|
|
196
|
-
],
|
|
197
|
-
nextDescriptors: { a: {}, "b-old": {}, "b-new": {} },
|
|
198
|
-
closingRouteKeys,
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
expect(result.routes.map((r) => r.key)).toEqual(["a", "b-new", "b-old"]);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("detects dismissing via closing flag", () => {
|
|
205
|
-
const closingRouteKeys = createClosingRouteKeys();
|
|
206
|
-
|
|
207
|
-
setRouteState("a", { progress: 1 });
|
|
208
|
-
setRouteState("b-old", { progress: 1, closing: 1 });
|
|
209
|
-
setRouteState("b-new", { progress: 0 });
|
|
210
|
-
|
|
211
|
-
const result = syncRoutesWithRemoved({
|
|
212
|
-
prevRoutes: [createRoute("a"), createRoute("b-old")],
|
|
213
|
-
prevDescriptors: { a: {}, "b-old": {} },
|
|
214
|
-
nextRoutes: [
|
|
215
|
-
createRoute("a"),
|
|
216
|
-
createRoute("b-old"),
|
|
217
|
-
createRoute("b-new"),
|
|
218
|
-
],
|
|
219
|
-
nextDescriptors: { a: {}, "b-old": {}, "b-new": {} },
|
|
220
|
-
closingRouteKeys,
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
expect(result.routes.map((r) => r.key)).toEqual(["a", "b-new", "b-old"]);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it("does not move first route even if dismissing", () => {
|
|
227
|
-
const closingRouteKeys = createClosingRouteKeys();
|
|
228
|
-
|
|
229
|
-
setRouteState("a", { progress: 0.3 }); // First route, low progress
|
|
230
|
-
setRouteState("b", { progress: 1 });
|
|
231
|
-
|
|
232
|
-
const result = syncRoutesWithRemoved({
|
|
233
|
-
prevRoutes: [createRoute("a")],
|
|
234
|
-
prevDescriptors: { a: {} },
|
|
235
|
-
nextRoutes: [createRoute("a"), createRoute("b")],
|
|
236
|
-
nextDescriptors: { a: {}, b: {} },
|
|
237
|
-
closingRouteKeys,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
expect(result.routes.map((r) => r.key)).toEqual(["a", "b"]);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it("does not move last route even if low progress (newly pushed)", () => {
|
|
244
|
-
const closingRouteKeys = createClosingRouteKeys();
|
|
245
|
-
|
|
246
|
-
setRouteState("a", { progress: 1 });
|
|
247
|
-
setRouteState("b", { progress: 1 });
|
|
248
|
-
setRouteState("c", { progress: 0.1 }); // Last route, low progress (just pushed)
|
|
249
|
-
|
|
250
|
-
const result = syncRoutesWithRemoved({
|
|
251
|
-
prevRoutes: [createRoute("a"), createRoute("b")],
|
|
252
|
-
prevDescriptors: { a: {}, b: {} },
|
|
253
|
-
nextRoutes: [createRoute("a"), createRoute("b"), createRoute("c")],
|
|
254
|
-
nextDescriptors: { a: {}, b: {}, c: {} },
|
|
255
|
-
closingRouteKeys,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
expect(result.routes.map((r) => r.key)).toEqual(["a", "b", "c"]);
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
115
|
|
|
262
116
|
describe("normal back navigation", () => {
|
|
263
117
|
it("keeps closing route at end for normal back (C -> B)", () => {
|