react-native-screen-transitions 2.4.1 → 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/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/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/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/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/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/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/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/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/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/lib/module/types/navigator.js +0 -4
- package/lib/typescript/types/navigator.d.ts.map +0 -1
|
@@ -4,30 +4,30 @@ import { RootTransitionAware } from "../components/root-transition-aware";
|
|
|
4
4
|
import { ScreenGestureProvider } from "../providers/gestures";
|
|
5
5
|
import { KeysProvider } from "../providers/keys";
|
|
6
6
|
import { TransitionStylesProvider } from "../providers/transition-styles";
|
|
7
|
-
import type { NativeStackDescriptor } from "../types/navigator";
|
|
7
|
+
import type { NativeStackDescriptor } from "../types/native-stack.navigator";
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
previous?: NativeStackDescriptor;
|
|
11
|
+
current: NativeStackDescriptor;
|
|
12
|
+
next?: NativeStackDescriptor;
|
|
13
|
+
children: React.ReactNode;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export function ScreenTransitionProvider({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
previous,
|
|
18
|
+
current,
|
|
19
|
+
next,
|
|
20
|
+
children,
|
|
21
21
|
}: Props) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
return (
|
|
23
|
+
<KeysProvider previous={previous} current={current} next={next}>
|
|
24
|
+
<ScreenGestureProvider>
|
|
25
|
+
<ScreenLifecycleController>
|
|
26
|
+
<TransitionStylesProvider>
|
|
27
|
+
<RootTransitionAware>{children}</RootTransitionAware>
|
|
28
|
+
</TransitionStylesProvider>
|
|
29
|
+
</ScreenLifecycleController>
|
|
30
|
+
</ScreenGestureProvider>
|
|
31
|
+
</KeysProvider>
|
|
32
|
+
);
|
|
33
33
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useDerivedValue } from "react-native-reanimated";
|
|
3
3
|
import { NO_STYLES } from "../constants";
|
|
4
4
|
import { _useScreenAnimation } from "../hooks/animation/use-screen-animation";
|
|
5
5
|
import type { TransitionInterpolatedStyle } from "../types/animation";
|
|
6
|
+
import { createBounds } from "../utils/bounds";
|
|
6
7
|
|
|
7
8
|
type Props = {
|
|
8
9
|
children: React.ReactNode;
|
|
@@ -18,21 +19,33 @@ export function TransitionStylesProvider({ children }: Props) {
|
|
|
18
19
|
const { screenInterpolatorProps, screenStyleInterpolator } =
|
|
19
20
|
_useScreenAnimation();
|
|
20
21
|
|
|
21
|
-
const isFunctionWorklet = isWorkletFunction(screenStyleInterpolator);
|
|
22
|
-
|
|
23
22
|
const stylesMap = useDerivedValue<TransitionInterpolatedStyle>(() => {
|
|
24
23
|
"worklet";
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
/**
|
|
26
|
+
* ### Maintainer note
|
|
27
|
+
*
|
|
28
|
+
* From my understanding, reanimated will serialize the DerivedValue result. Thus resulting in us receiving a `bounds is not a function, it is an object` error. We'll build the bounds function inside here (the final step) and pass it alongside the interpolator instead.
|
|
29
|
+
*/
|
|
30
|
+
const props = screenInterpolatorProps.value;
|
|
31
|
+
|
|
32
|
+
const bounds = createBounds(props);
|
|
33
|
+
try {
|
|
34
|
+
if (!screenStyleInterpolator) return NO_STYLES;
|
|
35
|
+
|
|
36
|
+
return screenStyleInterpolator({
|
|
37
|
+
...props,
|
|
38
|
+
bounds,
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (__DEV__) {
|
|
42
|
+
console.warn(
|
|
43
|
+
"[react-native-screen-transitions] screenStyleInterpolator must be a worklet",
|
|
44
|
+
err,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
30
47
|
return NO_STYLES;
|
|
31
48
|
}
|
|
32
|
-
|
|
33
|
-
return screenStyleInterpolator
|
|
34
|
-
? screenStyleInterpolator(screenInterpolatorProps.value)
|
|
35
|
-
: NO_STYLES;
|
|
36
49
|
});
|
|
37
50
|
|
|
38
51
|
const value = useMemo(() => {
|
package/src/stores/animations.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { makeMutable, type SharedValue } from "react-native-reanimated";
|
|
2
|
-
import type { ScreenKey } from "../types/navigator";
|
|
2
|
+
import type { ScreenKey } from "../types/native-stack.navigator";
|
|
3
3
|
|
|
4
4
|
export type AnimationMap = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
progress: SharedValue<number>;
|
|
6
|
+
closing: SharedValue<number>;
|
|
7
|
+
animating: SharedValue<number>;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const store: Record<ScreenKey, AnimationMap> = {};
|
|
11
11
|
|
|
12
12
|
const ensure = (key: ScreenKey) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
let bag = store[key];
|
|
14
|
+
if (!bag) {
|
|
15
|
+
bag = {
|
|
16
|
+
progress: makeMutable(0),
|
|
17
|
+
closing: makeMutable(0),
|
|
18
|
+
animating: makeMutable(0),
|
|
19
|
+
};
|
|
20
|
+
store[key] = bag;
|
|
21
|
+
}
|
|
22
|
+
return bag;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export function getAnimation(
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
key: ScreenKey,
|
|
27
|
+
type: "progress" | "closing" | "animating"
|
|
28
28
|
): SharedValue<number> {
|
|
29
|
-
|
|
29
|
+
return ensure(key)[type];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function getAll(key: ScreenKey) {
|
|
33
|
-
|
|
33
|
+
return ensure(key);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function clear(routeKey: ScreenKey) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
"worklet";
|
|
38
|
+
delete store[routeKey];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export const Animations = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
getAnimation,
|
|
43
|
+
clear,
|
|
44
|
+
getAll,
|
|
45
45
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type MeasuredDimensions,
|
|
3
|
+
makeMutable,
|
|
4
|
+
type StyleProps,
|
|
5
5
|
} from "react-native-reanimated";
|
|
6
6
|
import type { ScreenTransitionState } from "../../types/animation";
|
|
7
|
-
import type { ScreenKey } from "../../types/navigator";
|
|
7
|
+
import type { ScreenKey } from "../../types/native-stack.navigator";
|
|
8
8
|
import type { Any } from "../../types/utils";
|
|
9
9
|
import { pairKey, resolveActiveBound } from "./_utils";
|
|
10
10
|
|
|
11
11
|
type BoundsDict = Record<
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
string,
|
|
13
|
+
Record<string, { bounds: MeasuredDimensions; styles: StyleProps }>
|
|
14
14
|
>;
|
|
15
15
|
|
|
16
16
|
const registry = makeMutable<BoundsDict>({});
|
|
@@ -18,108 +18,108 @@ const pairCache = makeMutable<Record<string, string>>({});
|
|
|
18
18
|
const lastActiveByRoute = makeMutable<Record<string, string>>({});
|
|
19
19
|
|
|
20
20
|
function setBounds(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
screenId: string,
|
|
22
|
+
boundId: string,
|
|
23
|
+
bounds: MeasuredDimensions | null = null,
|
|
24
|
+
styles: StyleProps = {}
|
|
25
25
|
) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
"worklet";
|
|
27
|
+
registry.modify((state: Any) => {
|
|
28
|
+
"worklet";
|
|
29
|
+
if (!state[screenId]) {
|
|
30
|
+
state[screenId] = {};
|
|
31
|
+
}
|
|
32
|
+
state[screenId][boundId] = { bounds, styles };
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
return state;
|
|
35
|
+
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function getBounds(screenId: string) {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
"worklet";
|
|
40
|
+
return registry.value[screenId] ?? {};
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function setRouteActive(routeKey: string, boundId: string) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
"worklet";
|
|
45
|
+
lastActiveByRoute.modify((state: Any) => {
|
|
46
|
+
"worklet";
|
|
47
|
+
state[routeKey] = boundId;
|
|
48
|
+
return state;
|
|
49
|
+
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function getRouteActive(routeKey: string) {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
"worklet";
|
|
54
|
+
return lastActiveByRoute.value[routeKey] ?? null;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
function setPairCache(fromKey: string, toKey: string, boundId: string) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
"worklet";
|
|
59
|
+
const key = pairKey(fromKey, toKey);
|
|
60
|
+
if (!key) return;
|
|
61
|
+
pairCache.modify((state: Any) => {
|
|
62
|
+
"worklet";
|
|
63
|
+
state[key] = boundId;
|
|
64
|
+
return state;
|
|
65
|
+
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function getPairCache(fromKey: string, toKey: string) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
"worklet";
|
|
70
|
+
const key = pairKey(fromKey, toKey);
|
|
71
|
+
if (!key) return null;
|
|
72
|
+
return pairCache.value[key] ?? null;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function clear(routeKey: ScreenKey) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
"worklet";
|
|
77
|
+
registry.modify((state) => {
|
|
78
|
+
"worklet";
|
|
79
|
+
delete state[routeKey];
|
|
80
|
+
return state;
|
|
81
|
+
});
|
|
82
|
+
lastActiveByRoute.modify((state) => {
|
|
83
|
+
"worklet";
|
|
84
|
+
if (state[routeKey]) delete state[routeKey];
|
|
85
|
+
return state;
|
|
86
|
+
});
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
pairCache.modify((state) => {
|
|
89
|
+
"worklet";
|
|
90
|
+
const keys = Object.keys(state);
|
|
91
|
+
for (let i = 0; i < keys.length; i++) {
|
|
92
|
+
const k = keys[i];
|
|
93
|
+
const [from, to] = k.split("|");
|
|
94
|
+
if (from === routeKey || to === routeKey) {
|
|
95
|
+
delete state[k];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return state;
|
|
99
|
+
});
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
function getActiveBound(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
current: ScreenTransitionState,
|
|
104
|
+
next: ScreenTransitionState | undefined,
|
|
105
|
+
previous: ScreenTransitionState | undefined
|
|
106
106
|
) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
"worklet";
|
|
108
|
+
return resolveActiveBound({
|
|
109
|
+
current,
|
|
110
|
+
next,
|
|
111
|
+
previous,
|
|
112
|
+
getPairCache,
|
|
113
|
+
setPairCache,
|
|
114
|
+
getRouteActive,
|
|
115
|
+
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export const Bounds = {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
setBounds,
|
|
120
|
+
getBounds,
|
|
121
|
+
setRouteActive,
|
|
122
|
+
getRouteActive,
|
|
123
|
+
clear,
|
|
124
|
+
getActiveBound,
|
|
125
125
|
};
|
package/src/stores/gestures.ts
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import { makeMutable, type SharedValue } from "react-native-reanimated";
|
|
2
2
|
import type { GestureDirection } from "../types/gesture";
|
|
3
|
-
import type { ScreenKey } from "../types/navigator";
|
|
3
|
+
import type { ScreenKey } from "../types/native-stack.navigator";
|
|
4
4
|
|
|
5
5
|
export type GestureKey =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
| "x"
|
|
7
|
+
| "y"
|
|
8
|
+
| "normalizedX"
|
|
9
|
+
| "normalizedY"
|
|
10
|
+
| "isDismissing"
|
|
11
|
+
| "isDragging";
|
|
12
12
|
|
|
13
13
|
export type GestureMap = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
x: SharedValue<number>;
|
|
15
|
+
y: SharedValue<number>;
|
|
16
|
+
normalizedX: SharedValue<number>;
|
|
17
|
+
normalizedY: SharedValue<number>;
|
|
18
|
+
isDismissing: SharedValue<number>;
|
|
19
|
+
isDragging: SharedValue<number>;
|
|
20
|
+
direction: SharedValue<Omit<GestureDirection, "bidirectional"> | null>;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const store: Record<ScreenKey, GestureMap> = {};
|
|
24
24
|
|
|
25
25
|
function ensure(routeKey: ScreenKey): GestureMap {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
let bag = store[routeKey];
|
|
27
|
+
if (!bag) {
|
|
28
|
+
bag = {
|
|
29
|
+
x: makeMutable(0),
|
|
30
|
+
y: makeMutable(0),
|
|
31
|
+
normalizedX: makeMutable(0),
|
|
32
|
+
normalizedY: makeMutable(0),
|
|
33
|
+
isDismissing: makeMutable(0),
|
|
34
|
+
isDragging: makeMutable(0),
|
|
35
|
+
direction: makeMutable<Omit<GestureDirection, "bidirectional"> | null>(
|
|
36
|
+
null
|
|
37
|
+
),
|
|
38
|
+
};
|
|
39
|
+
store[routeKey] = bag;
|
|
40
|
+
}
|
|
41
|
+
return bag;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function getGesture(routeKey: ScreenKey, gestureKey: GestureKey) {
|
|
45
|
-
|
|
45
|
+
return ensure(routeKey)[gestureKey];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function getRouteGestures(routeKey: ScreenKey) {
|
|
49
|
-
|
|
49
|
+
return ensure(routeKey);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function clear(routeKey: ScreenKey) {
|
|
53
|
-
|
|
53
|
+
delete store[routeKey];
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export const Gestures = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
getGesture,
|
|
58
|
+
getRouteGestures,
|
|
59
|
+
clear,
|
|
60
60
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NativeStackDescriptor } from "../../types/navigator";
|
|
1
|
+
import type { NativeStackDescriptor } from "../../types/native-stack.navigator";
|
|
2
2
|
import { Animations } from "../animations";
|
|
3
3
|
import { Bounds } from "../bounds";
|
|
4
4
|
import { Gestures } from "../gestures";
|
|
@@ -7,7 +7,7 @@ import { Gestures } from "../gestures";
|
|
|
7
7
|
* Reset all stores for a given screen
|
|
8
8
|
*/
|
|
9
9
|
export const resetStoresForScreen = (current: NativeStackDescriptor) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
Animations.clear(current.route.key);
|
|
11
|
+
Gestures.clear(current.route.key);
|
|
12
|
+
Bounds.clear(current.route.key);
|
|
13
13
|
};
|
package/src/types/animation.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
import type { EdgeInsets } from "react-native-safe-area-context";
|
|
8
8
|
import type { BoundEntry, BoundsAccessor } from "./bounds";
|
|
9
9
|
import type { GestureValues } from "./gesture";
|
|
10
|
+
import type { Layout } from "./native-stack.navigator";
|
|
10
11
|
|
|
11
12
|
export type ScreenTransitionState = {
|
|
12
13
|
progress: number;
|
|
@@ -27,10 +28,7 @@ export interface ScreenInterpolationProps {
|
|
|
27
28
|
/** Layout measurements for the screen. */
|
|
28
29
|
layouts: {
|
|
29
30
|
/** The `width` and `height` of the screen container. */
|
|
30
|
-
screen:
|
|
31
|
-
width: number;
|
|
32
|
-
height: number;
|
|
33
|
-
};
|
|
31
|
+
screen: Layout;
|
|
34
32
|
};
|
|
35
33
|
/** The safe area insets for the screen. */
|
|
36
34
|
insets: EdgeInsets;
|