react-native-screen-transitions 2.4.0 → 2.4.2-beta.0
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/lib/commonjs/__configs__/presets.js.map +1 -1
- package/lib/commonjs/components/root-transition-aware.js.map +1 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/hooks/animation/use-screen-animation.js +9 -5
- package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/integrations/blank-stack/components/Header.js +142 -0
- package/lib/commonjs/integrations/blank-stack/components/Header.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/components/Screens.js +64 -0
- package/lib/commonjs/integrations/blank-stack/components/Screens.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/components/StackView.js +94 -0
- package/lib/commonjs/integrations/blank-stack/components/StackView.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/navigators/createBlankStackNavigator.js +74 -0
- package/lib/commonjs/integrations/blank-stack/navigators/createBlankStackNavigator.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js +66 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js +16 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js +208 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +1 -0
- package/lib/commonjs/{types/navigator.js → integrations/blank-stack/utils/with-stack-navigation/_types.js} +1 -1
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_types.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js +15 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js +23 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +15 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js +14 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js +13 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +1 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/index.js +71 -0
- package/lib/commonjs/integrations/blank-stack/utils/with-stack-navigation/index.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -1
- package/lib/commonjs/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -1
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -1
- package/lib/commonjs/providers/keys.js.map +1 -1
- package/lib/commonjs/providers/screen-transition-provider.js.map +1 -1
- package/lib/commonjs/providers/transition-styles.js +18 -4
- package/lib/commonjs/providers/transition-styles.js.map +1 -1
- package/lib/commonjs/stores/animations.js.map +1 -1
- package/lib/commonjs/stores/bounds/index.js.map +1 -1
- package/lib/commonjs/stores/gestures.js.map +1 -1
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/commonjs/types/blank-stack.navigator.js +6 -0
- package/lib/commonjs/types/{navigator.js.map → blank-stack.navigator.js.map} +1 -1
- package/lib/commonjs/types/native-stack.navigator.js +6 -0
- package/lib/commonjs/types/native-stack.navigator.js.map +1 -0
- package/lib/commonjs/utils/animation/derivations.js +1 -14
- package/lib/commonjs/utils/animation/derivations.js.map +1 -1
- package/lib/commonjs/utils/bounds/_utils/styles.js.map +1 -1
- package/lib/commonjs/utils/bounds/constants.js.map +1 -1
- package/lib/commonjs/utils/bounds/index.js +23 -90
- package/lib/commonjs/utils/bounds/index.js.map +1 -1
- package/lib/commonjs/utils/gesture/apply-offset-rules.js.map +1 -1
- package/lib/commonjs/utils/gesture/check-gesture-activation.js.map +1 -1
- package/lib/commonjs/utils/gesture/reset-gesture-values.js.map +1 -1
- package/lib/commonjs/utils/gesture/velocity.js +2 -2
- package/lib/commonjs/utils/gesture/velocity.js.map +1 -1
- package/lib/module/__configs__/presets.js.map +1 -1
- package/lib/module/components/root-transition-aware.js.map +1 -1
- package/lib/module/constants.js.map +1 -1
- package/lib/module/hooks/animation/use-screen-animation.js +9 -5
- package/lib/module/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/integrations/blank-stack/components/Header.js +138 -0
- package/lib/module/integrations/blank-stack/components/Header.js.map +1 -0
- package/lib/module/integrations/blank-stack/components/Screens.js +58 -0
- package/lib/module/integrations/blank-stack/components/Screens.js.map +1 -0
- package/lib/module/integrations/blank-stack/components/StackView.js +90 -0
- package/lib/module/integrations/blank-stack/components/StackView.js.map +1 -0
- package/lib/module/integrations/blank-stack/navigators/createBlankStackNavigator.js +68 -0
- package/lib/module/integrations/blank-stack/navigators/createBlankStackNavigator.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js +60 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js +11 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js +202 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_types.js +4 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_types.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js +10 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js +19 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js +10 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js +9 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js +8 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.js.map +1 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/index.js +65 -0
- package/lib/module/integrations/blank-stack/utils/with-stack-navigation/index.js.map +1 -0
- package/lib/module/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -1
- package/lib/module/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -1
- package/lib/module/integrations/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/integrations/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -1
- package/lib/module/providers/keys.js.map +1 -1
- package/lib/module/providers/screen-transition-provider.js.map +1 -1
- package/lib/module/providers/transition-styles.js +19 -5
- package/lib/module/providers/transition-styles.js.map +1 -1
- package/lib/module/stores/animations.js.map +1 -1
- package/lib/module/stores/bounds/index.js.map +1 -1
- package/lib/module/stores/gestures.js.map +1 -1
- package/lib/module/stores/utils/reset-stores-for-screen.js.map +1 -1
- package/lib/module/types/blank-stack.navigator.js +4 -0
- package/lib/module/types/{navigator.js.map → blank-stack.navigator.js.map} +1 -1
- package/lib/module/types/native-stack.navigator.js +4 -0
- package/lib/module/types/native-stack.navigator.js.map +1 -0
- package/lib/module/utils/animation/derivations.js +1 -14
- package/lib/module/utils/animation/derivations.js.map +1 -1
- package/lib/module/utils/bounds/_utils/styles.js.map +1 -1
- package/lib/module/utils/bounds/constants.js.map +1 -1
- package/lib/module/utils/bounds/index.js +24 -91
- package/lib/module/utils/bounds/index.js.map +1 -1
- package/lib/module/utils/gesture/apply-offset-rules.js.map +1 -1
- package/lib/module/utils/gesture/check-gesture-activation.js.map +1 -1
- package/lib/module/utils/gesture/reset-gesture-values.js.map +1 -1
- package/lib/module/utils/gesture/velocity.js +2 -2
- package/lib/module/utils/gesture/velocity.js.map +1 -1
- package/lib/typescript/__configs__/index.d.ts +9 -9
- package/lib/typescript/__configs__/index.d.ts.map +1 -1
- package/lib/typescript/__configs__/presets.d.ts +1 -1
- package/lib/typescript/__configs__/presets.d.ts.map +1 -1
- package/lib/typescript/components/root-transition-aware.d.ts.map +1 -1
- package/lib/typescript/constants.d.ts +2 -2
- package/lib/typescript/constants.d.ts.map +1 -1
- package/lib/typescript/hooks/animation/use-screen-animation.d.ts +1 -1
- package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +20 -18
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/integrations/blank-stack/components/Header.d.ts +5 -0
- package/lib/typescript/integrations/blank-stack/components/Header.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/components/Screens.d.ts +15 -0
- package/lib/typescript/integrations/blank-stack/components/Screens.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/components/StackView.d.ts +2 -0
- package/lib/typescript/integrations/blank-stack/components/StackView.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/navigators/createBlankStackNavigator.d.ts +109 -0
- package/lib/typescript/integrations/blank-stack/navigators/createBlankStackNavigator.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.d.ts +8 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.d.ts +2 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.d.ts +20 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_types.d.ts +23 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_types.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.d.ts +3 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.d.ts +4 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.d.ts +4 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.d.ts +3 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.d.ts +3 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.d.ts.map +1 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/index.d.ts +6 -0
- package/lib/typescript/integrations/blank-stack/utils/with-stack-navigation/index.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts +1 -1
- package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -1
- package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts +1 -1
- package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts.map +1 -1
- package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts +1 -1
- package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts.map +1 -1
- package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts +1 -1
- package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts.map +1 -1
- package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts +1 -1
- package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts +1 -1
- package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts.map +1 -1
- package/lib/typescript/providers/keys.d.ts +1 -1
- package/lib/typescript/providers/keys.d.ts.map +1 -1
- package/lib/typescript/providers/screen-transition-provider.d.ts +1 -1
- package/lib/typescript/providers/screen-transition-provider.d.ts.map +1 -1
- package/lib/typescript/providers/transition-styles.d.ts.map +1 -1
- package/lib/typescript/stores/animations.d.ts +1 -1
- package/lib/typescript/stores/animations.d.ts.map +1 -1
- package/lib/typescript/stores/bounds/index.d.ts +1 -1
- package/lib/typescript/stores/bounds/index.d.ts.map +1 -1
- package/lib/typescript/stores/gestures.d.ts +1 -1
- package/lib/typescript/stores/gestures.d.ts.map +1 -1
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts +1 -1
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts.map +1 -1
- package/lib/typescript/types/animation.d.ts +2 -4
- package/lib/typescript/types/animation.d.ts.map +1 -1
- package/lib/typescript/types/blank-stack.navigator.d.ts +219 -0
- package/lib/typescript/types/blank-stack.navigator.d.ts.map +1 -0
- package/lib/typescript/types/bounds.d.ts +0 -57
- package/lib/typescript/types/bounds.d.ts.map +1 -1
- package/lib/typescript/types/{navigator.d.ts → native-stack.navigator.d.ts} +5 -1
- package/lib/typescript/types/native-stack.navigator.d.ts.map +1 -0
- package/lib/typescript/types/utils.d.ts.map +1 -1
- package/lib/typescript/utils/animation/derivations.d.ts +1 -4
- package/lib/typescript/utils/animation/derivations.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_types/builder.d.ts +2 -2
- package/lib/typescript/utils/bounds/_types/builder.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_utils/geometry.d.ts +2 -2
- package/lib/typescript/utils/bounds/_utils/geometry.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/_utils/styles.d.ts +2 -1
- package/lib/typescript/utils/bounds/_utils/styles.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/constants.d.ts +2 -2
- package/lib/typescript/utils/bounds/constants.d.ts.map +1 -1
- package/lib/typescript/utils/bounds/index.d.ts +4 -4
- package/lib/typescript/utils/bounds/index.d.ts.map +1 -1
- package/lib/typescript/utils/gesture/apply-offset-rules.d.ts +2 -2
- package/lib/typescript/utils/gesture/apply-offset-rules.d.ts.map +1 -1
- package/lib/typescript/utils/gesture/check-gesture-activation.d.ts +2 -2
- package/lib/typescript/utils/gesture/check-gesture-activation.d.ts.map +1 -1
- package/lib/typescript/utils/gesture/reset-gesture-values.d.ts.map +1 -1
- package/lib/typescript/utils/gesture/velocity.d.ts +1 -1
- package/lib/typescript/utils/gesture/velocity.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__configs__/presets.ts +590 -590
- package/src/components/root-transition-aware.tsx +27 -27
- package/src/constants.ts +47 -47
- package/src/hooks/animation/use-screen-animation.tsx +52 -47
- package/src/index.ts +33 -22
- package/src/integrations/blank-stack/components/Header.tsx +143 -0
- package/src/integrations/blank-stack/components/Screens.tsx +96 -0
- package/src/integrations/blank-stack/components/StackView.tsx +106 -0
- package/src/integrations/blank-stack/navigators/createBlankStackNavigator.tsx +122 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-closing-route-keys.tsx +62 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-previous.tsx +11 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_hooks/use-stack-navigation-state.tsx +280 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_types.ts +36 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/are-descriptors-equal.ts +15 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/calculateActiveScreensLimit.ts +29 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/compose-descriptors.ts +17 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/have-same-route-keys.ts +12 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.ts +11 -0
- package/src/integrations/blank-stack/utils/with-stack-navigation/index.tsx +93 -0
- package/src/integrations/native-stack/navigators/createNativeStackNavigator.tsx +95 -95
- package/src/integrations/native-stack/utils/getModalRoutesKeys.ts +14 -14
- package/src/integrations/native-stack/utils/useInvalidPreventRemoveError.tsx +23 -23
- package/src/integrations/native-stack/views/NativeStackView.native.tsx +608 -608
- package/src/integrations/native-stack/views/NativeStackView.tsx +188 -188
- package/src/integrations/native-stack/views/useHeaderConfigProps.tsx +260 -260
- package/src/providers/keys.tsx +22 -22
- package/src/providers/screen-transition-provider.tsx +20 -20
- package/src/providers/transition-styles.tsx +24 -11
- package/src/stores/animations.ts +23 -23
- package/src/stores/bounds/index.ts +82 -82
- package/src/stores/gestures.ts +36 -36
- package/src/stores/utils/reset-stores-for-screen.ts +4 -4
- package/src/types/animation.ts +2 -4
- package/src/types/blank-stack.navigator.ts +271 -0
- package/src/types/bounds.ts +0 -64
- package/src/types/{navigator.ts → native-stack.navigator.ts} +5 -0
- package/src/types/utils.ts +1 -0
- package/src/utils/animation/derivations.ts +3 -20
- package/src/utils/bounds/_types/builder.ts +111 -111
- package/src/utils/bounds/_utils/geometry.ts +2 -2
- package/src/utils/bounds/_utils/styles.ts +2 -1
- package/src/utils/bounds/constants.ts +29 -29
- package/src/utils/bounds/index.ts +35 -105
- package/src/utils/gesture/apply-offset-rules.ts +271 -271
- package/src/utils/gesture/check-gesture-activation.ts +260 -260
- package/src/utils/gesture/reset-gesture-values.ts +1 -0
- package/src/utils/gesture/velocity.ts +1 -2
- package/lib/module/types/navigator.js +0 -4
- package/lib/typescript/types/navigator.d.ts.map +0 -1
package/src/integrations/blank-stack/utils/with-stack-navigation/_utils/routes-are-identical.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Route } from "@react-navigation/native";
|
|
2
|
+
|
|
3
|
+
export const routesAreIdentical = (
|
|
4
|
+
a: Route<string>[],
|
|
5
|
+
b: Route<string>[],
|
|
6
|
+
): boolean => {
|
|
7
|
+
if (a === b) return true;
|
|
8
|
+
if (a.length !== b.length) return false;
|
|
9
|
+
|
|
10
|
+
return a.every((route, index) => route === b[index]);
|
|
11
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComponentType,
|
|
3
|
+
createContext,
|
|
4
|
+
memo,
|
|
5
|
+
useContext,
|
|
6
|
+
useMemo,
|
|
7
|
+
} from "react";
|
|
8
|
+
import { Header } from "../../components/Header";
|
|
9
|
+
import type { BlankStackScene } from "../../../../types/blank-stack.navigator";
|
|
10
|
+
import { useStackNavigationState } from "./_hooks/use-stack-navigation-state";
|
|
11
|
+
import type {
|
|
12
|
+
StackNavigationContextProps,
|
|
13
|
+
StackNavigationContextValue,
|
|
14
|
+
} from "./_types";
|
|
15
|
+
import { calculateActiveScreensLimit } from "./_utils/calculateActiveScreensLimit";
|
|
16
|
+
|
|
17
|
+
export const StackNavigationContext =
|
|
18
|
+
createContext<StackNavigationContextValue | null>(null);
|
|
19
|
+
|
|
20
|
+
export function withStackNavigationProvider(
|
|
21
|
+
Component: ComponentType<StackNavigationContextValue>
|
|
22
|
+
) {
|
|
23
|
+
return function StackNavigationWrapper(props: StackNavigationContextProps) {
|
|
24
|
+
const { state, handleCloseRoute, closingRouteKeys } =
|
|
25
|
+
useStackNavigationState(props);
|
|
26
|
+
|
|
27
|
+
const scenes = useMemo(() => {
|
|
28
|
+
return state.routes.reduce((acc, route) => {
|
|
29
|
+
acc.push({
|
|
30
|
+
route,
|
|
31
|
+
descriptor: state.descriptors[route.key],
|
|
32
|
+
});
|
|
33
|
+
return acc;
|
|
34
|
+
}, [] as BlankStackScene[]);
|
|
35
|
+
}, [state.routes, state.descriptors]);
|
|
36
|
+
|
|
37
|
+
const activeScreensLimit = useMemo(() => {
|
|
38
|
+
return calculateActiveScreensLimit(state.routes, state.descriptors);
|
|
39
|
+
}, [state.routes, state.descriptors]);
|
|
40
|
+
|
|
41
|
+
const FloatHeader = memo(() => {
|
|
42
|
+
const shouldShowFloatHeader = props.state.routes.some((route) => {
|
|
43
|
+
const options = props.descriptors[route.key]?.options;
|
|
44
|
+
return options?.headerMode === "float" && options?.headerShown;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
if (!shouldShowFloatHeader) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return <Header.Float />;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const contextValue = useMemo<StackNavigationContextValue>(() => {
|
|
55
|
+
return {
|
|
56
|
+
routes: state.routes,
|
|
57
|
+
focusedIndex: props.state.index,
|
|
58
|
+
descriptors: state.descriptors,
|
|
59
|
+
closingRouteKeysShared: closingRouteKeys.shared,
|
|
60
|
+
activeScreensLimit,
|
|
61
|
+
handleCloseRoute,
|
|
62
|
+
scenes,
|
|
63
|
+
FloatHeader,
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
state,
|
|
67
|
+
scenes,
|
|
68
|
+
activeScreensLimit,
|
|
69
|
+
closingRouteKeys,
|
|
70
|
+
handleCloseRoute,
|
|
71
|
+
props.state.index,
|
|
72
|
+
FloatHeader,
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<StackNavigationContext.Provider value={contextValue}>
|
|
77
|
+
<Component {...contextValue} />
|
|
78
|
+
</StackNavigationContext.Provider>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const useStackNavigationContext = () => {
|
|
84
|
+
const context = useContext(StackNavigationContext);
|
|
85
|
+
|
|
86
|
+
if (!context) {
|
|
87
|
+
throw new Error(
|
|
88
|
+
"StackNavigationContext.Provider is missing in the component tree."
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return context;
|
|
93
|
+
};
|
|
@@ -1,112 +1,112 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
createNavigatorFactory,
|
|
3
|
+
type EventArg,
|
|
4
|
+
type NavigatorTypeBagBase,
|
|
5
|
+
type ParamListBase,
|
|
6
|
+
type StackActionHelpers,
|
|
7
|
+
StackActions,
|
|
8
|
+
type StackNavigationState,
|
|
9
|
+
StackRouter,
|
|
10
|
+
type StackRouterOptions,
|
|
11
|
+
type StaticConfig,
|
|
12
|
+
type TypedNavigator,
|
|
13
|
+
useNavigationBuilder,
|
|
14
14
|
} from "@react-navigation/native";
|
|
15
15
|
import * as React from "react";
|
|
16
16
|
|
|
17
17
|
import type {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} from "../../../types/navigator";
|
|
18
|
+
NativeStackNavigationEventMap,
|
|
19
|
+
NativeStackNavigationOptions,
|
|
20
|
+
NativeStackNavigationProp,
|
|
21
|
+
NativeStackNavigatorProps,
|
|
22
|
+
} from "../../../types/native-stack.navigator";
|
|
23
23
|
import { NativeStackView } from "../views/NativeStackView";
|
|
24
24
|
|
|
25
25
|
function NativeStackNavigator({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
id,
|
|
27
|
+
initialRouteName,
|
|
28
|
+
children,
|
|
29
|
+
layout,
|
|
30
|
+
screenListeners,
|
|
31
|
+
screenOptions,
|
|
32
|
+
screenLayout,
|
|
33
|
+
...rest
|
|
34
34
|
}: NativeStackNavigatorProps) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
const { state, describe, descriptors, navigation, NavigationContent } =
|
|
36
|
+
useNavigationBuilder<
|
|
37
|
+
StackNavigationState<ParamListBase>,
|
|
38
|
+
StackRouterOptions,
|
|
39
|
+
StackActionHelpers<ParamListBase>,
|
|
40
|
+
NativeStackNavigationOptions,
|
|
41
|
+
NativeStackNavigationEventMap
|
|
42
|
+
>(StackRouter, {
|
|
43
|
+
id,
|
|
44
|
+
initialRouteName,
|
|
45
|
+
children,
|
|
46
|
+
layout,
|
|
47
|
+
screenListeners,
|
|
48
|
+
screenOptions,
|
|
49
|
+
screenLayout,
|
|
50
|
+
});
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
React.useEffect(
|
|
53
|
+
() =>
|
|
54
|
+
// @ts-expect-error: there may not be a tab navigator in parent
|
|
55
|
+
navigation?.addListener?.("tabPress", (e: any) => {
|
|
56
|
+
const isFocused = navigation.isFocused();
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
58
|
+
// Run the operation in the next frame so we're sure all listeners have been run
|
|
59
|
+
// This is necessary to know if preventDefault() has been called
|
|
60
|
+
requestAnimationFrame(() => {
|
|
61
|
+
if (
|
|
62
|
+
state.index > 0 &&
|
|
63
|
+
isFocused &&
|
|
64
|
+
!(e as EventArg<"tabPress", true>).defaultPrevented
|
|
65
|
+
) {
|
|
66
|
+
// When user taps on already focused tab and we're inside the tab,
|
|
67
|
+
// reset the stack to replicate native behaviour
|
|
68
|
+
navigation.dispatch({
|
|
69
|
+
...StackActions.popToTop(),
|
|
70
|
+
target: state.key,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}),
|
|
75
|
+
[navigation, state.index, state.key]
|
|
76
|
+
);
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
78
|
+
return (
|
|
79
|
+
<NavigationContent>
|
|
80
|
+
<NativeStackView
|
|
81
|
+
{...rest}
|
|
82
|
+
state={state}
|
|
83
|
+
navigation={navigation}
|
|
84
|
+
descriptors={descriptors}
|
|
85
|
+
describe={describe}
|
|
86
|
+
/>
|
|
87
|
+
</NavigationContent>
|
|
88
|
+
);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export function createNativeStackNavigator<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
92
|
+
const ParamList extends ParamListBase,
|
|
93
|
+
const NavigatorID extends string | undefined = undefined,
|
|
94
|
+
const TypeBag extends NavigatorTypeBagBase = {
|
|
95
|
+
ParamList: ParamList;
|
|
96
|
+
NavigatorID: NavigatorID;
|
|
97
|
+
State: StackNavigationState<ParamList>;
|
|
98
|
+
ScreenOptions: NativeStackNavigationOptions;
|
|
99
|
+
EventMap: NativeStackNavigationEventMap;
|
|
100
|
+
NavigationList: {
|
|
101
|
+
[RouteName in keyof ParamList]: NativeStackNavigationProp<
|
|
102
|
+
ParamList,
|
|
103
|
+
RouteName,
|
|
104
|
+
NavigatorID
|
|
105
|
+
>;
|
|
106
|
+
};
|
|
107
|
+
Navigator: typeof NativeStackNavigator;
|
|
108
|
+
},
|
|
109
|
+
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>
|
|
110
110
|
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
|
111
|
-
|
|
111
|
+
return createNavigatorFactory(NativeStackNavigator)(config);
|
|
112
112
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { Route } from "@react-navigation/native";
|
|
2
2
|
|
|
3
|
-
import type { NativeStackDescriptorMap } from "../../../types/navigator";
|
|
3
|
+
import type { NativeStackDescriptorMap } from "../../../types/native-stack.navigator";
|
|
4
4
|
|
|
5
5
|
export const getModalRouteKeys = (
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
routes: Route<string>[],
|
|
7
|
+
descriptors: NativeStackDescriptorMap
|
|
8
8
|
) =>
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
routes.reduce<string[]>((acc, route) => {
|
|
10
|
+
const { presentation } = descriptors[route.key]?.options ?? {};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (
|
|
13
|
+
(acc.length && !presentation) ||
|
|
14
|
+
presentation === "modal" ||
|
|
15
|
+
presentation === "transparentModal"
|
|
16
|
+
) {
|
|
17
|
+
acc.push(route.key);
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
return acc;
|
|
21
|
+
}, []);
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { usePreventRemoveContext } from "@react-navigation/native";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
import type { NativeStackDescriptorMap } from "../../../types/navigator";
|
|
4
|
+
import type { NativeStackDescriptorMap } from "../../../types/native-stack.navigator";
|
|
5
5
|
|
|
6
6
|
export function useInvalidPreventRemoveError(
|
|
7
|
-
|
|
7
|
+
descriptors: NativeStackDescriptorMap
|
|
8
8
|
) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const { preventedRoutes } = usePreventRemoveContext();
|
|
10
|
+
const preventedRouteKey = Object.keys(preventedRoutes)[0];
|
|
11
|
+
const preventedDescriptor = descriptors[preventedRouteKey];
|
|
12
|
+
const isHeaderBackButtonMenuEnabledOnPreventedScreen =
|
|
13
|
+
preventedDescriptor?.options?.headerBackButtonMenuEnabled;
|
|
14
|
+
const preventedRouteName = preventedDescriptor?.route?.name;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (
|
|
18
|
+
preventedRouteKey != null &&
|
|
19
|
+
isHeaderBackButtonMenuEnabledOnPreventedScreen
|
|
20
|
+
) {
|
|
21
|
+
const message =
|
|
22
|
+
`The screen ${preventedRouteName} uses 'usePreventRemove' hook alongside 'headerBackButtonMenuEnabled: true', which is not supported. \n\n` +
|
|
23
|
+
`Consider removing 'headerBackButtonMenuEnabled: true' from ${preventedRouteName} screen to get rid of this error.`;
|
|
24
|
+
console.error(message);
|
|
25
|
+
}
|
|
26
|
+
}, [
|
|
27
|
+
preventedRouteKey,
|
|
28
|
+
isHeaderBackButtonMenuEnabledOnPreventedScreen,
|
|
29
|
+
preventedRouteName,
|
|
30
|
+
]);
|
|
31
31
|
}
|