react-native-screen-transitions 3.2.0-beta.2 → 3.2.0-beta.3
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 +108 -37
- package/lib/commonjs/blank-stack/components/stack-view.js +0 -2
- package/lib/commonjs/blank-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/blank-stack/components/stack-view.native.js +0 -2
- package/lib/commonjs/blank-stack/components/stack-view.native.js.map +1 -1
- package/lib/commonjs/component-stack/components/stack-view.js +16 -20
- package/lib/commonjs/component-stack/components/stack-view.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.native.js +3 -3
- package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/float-overlay.js +1 -6
- package/lib/commonjs/shared/components/overlay/variations/float-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/overlay-host.js +16 -64
- package/lib/commonjs/shared/components/overlay/variations/overlay-host.js.map +1 -1
- package/lib/commonjs/shared/components/overlay/variations/screen-overlay.js +5 -8
- package/lib/commonjs/shared/components/overlay/variations/screen-overlay.js.map +1 -1
- package/lib/commonjs/shared/components/screen-lifecycle.js +153 -0
- package/lib/commonjs/shared/components/screen-lifecycle.js.map +1 -0
- package/lib/commonjs/shared/constants.js +3 -2
- package/lib/commonjs/shared/constants.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js +45 -0
- package/lib/commonjs/shared/hooks/navigation/use-screen-state.js.map +1 -0
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js +0 -2
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/commonjs/shared/index.js +7 -0
- package/lib/commonjs/shared/index.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/keys.provider.js +0 -2
- package/lib/commonjs/shared/providers/screen/keys.provider.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/screen-composer.js +3 -3
- package/lib/commonjs/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/commonjs/shared/providers/screen/styles.provider.js +1 -1
- package/lib/commonjs/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/commonjs/shared/types/index.js +3 -3
- package/lib/commonjs/shared/types/index.js.map +1 -1
- package/lib/commonjs/shared/types/stack.types.js +4 -0
- package/lib/commonjs/shared/types/stack.types.js.map +1 -1
- package/lib/commonjs/shared/utils/animation/start-screen-transition.js +5 -5
- package/lib/commonjs/shared/utils/animation/start-screen-transition.js.map +1 -1
- package/lib/commonjs/shared/utils/bounds/index.js.map +1 -1
- package/lib/module/blank-stack/components/stack-view.js +0 -2
- package/lib/module/blank-stack/components/stack-view.js.map +1 -1
- package/lib/module/blank-stack/components/stack-view.native.js +0 -2
- package/lib/module/blank-stack/components/stack-view.native.js.map +1 -1
- package/lib/module/component-stack/components/stack-view.js +16 -20
- package/lib/module/component-stack/components/stack-view.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.native.js +3 -3
- package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/float-overlay.js +1 -6
- package/lib/module/shared/components/overlay/variations/float-overlay.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/overlay-host.js +16 -64
- package/lib/module/shared/components/overlay/variations/overlay-host.js.map +1 -1
- package/lib/module/shared/components/overlay/variations/screen-overlay.js +5 -8
- package/lib/module/shared/components/overlay/variations/screen-overlay.js.map +1 -1
- package/lib/module/shared/components/screen-lifecycle.js +147 -0
- package/lib/module/shared/components/screen-lifecycle.js.map +1 -0
- package/lib/module/shared/constants.js +2 -1
- package/lib/module/shared/constants.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/navigation/use-screen-state.js +41 -0
- package/lib/module/shared/hooks/navigation/use-screen-state.js.map +1 -0
- package/lib/module/shared/hooks/use-stable-callback-value.js +0 -3
- package/lib/module/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/module/shared/index.js +1 -0
- package/lib/module/shared/index.js.map +1 -1
- package/lib/module/shared/providers/screen/keys.provider.js +0 -2
- package/lib/module/shared/providers/screen/keys.provider.js.map +1 -1
- package/lib/module/shared/providers/screen/screen-composer.js +3 -3
- package/lib/module/shared/providers/screen/screen-composer.js.map +1 -1
- package/lib/module/shared/providers/screen/styles.provider.js +1 -1
- package/lib/module/shared/providers/screen/styles.provider.js.map +1 -1
- package/lib/module/shared/types/index.js +1 -1
- package/lib/module/shared/types/index.js.map +1 -1
- package/lib/module/shared/types/stack.types.js +5 -0
- package/lib/module/shared/types/stack.types.js.map +1 -1
- package/lib/module/shared/utils/animation/start-screen-transition.js +1 -1
- package/lib/module/shared/utils/animation/start-screen-transition.js.map +1 -1
- package/lib/module/shared/utils/bounds/index.js.map +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.map +1 -1
- package/lib/typescript/blank-stack/types.d.ts +4 -8
- package/lib/typescript/blank-stack/types.d.ts.map +1 -1
- package/lib/typescript/component-stack/components/stack-view.d.ts.map +1 -1
- package/lib/typescript/component-stack/types.d.ts +4 -8
- package/lib/typescript/component-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/types.d.ts +2 -3
- package/lib/typescript/native-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/float-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/overlay-host.d.ts +1 -6
- package/lib/typescript/shared/components/overlay/variations/overlay-host.d.ts.map +1 -1
- package/lib/typescript/shared/components/overlay/variations/screen-overlay.d.ts +4 -0
- package/lib/typescript/shared/components/overlay/variations/screen-overlay.d.ts.map +1 -1
- package/lib/typescript/shared/components/screen-lifecycle.d.ts +9 -0
- package/lib/typescript/shared/components/screen-lifecycle.d.ts.map +1 -0
- package/lib/typescript/shared/constants.d.ts +2 -1
- package/lib/typescript/shared/constants.d.ts.map +1 -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-screen-state.d.ts +40 -0
- package/lib/typescript/shared/hooks/navigation/use-screen-state.d.ts.map +1 -0
- package/lib/typescript/shared/hooks/use-stable-callback-value.d.ts.map +1 -1
- package/lib/typescript/shared/index.d.ts +21 -20
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/keys.provider.d.ts +2 -3
- package/lib/typescript/shared/providers/screen/keys.provider.d.ts.map +1 -1
- package/lib/typescript/shared/providers/screen/screen-composer.d.ts +1 -3
- package/lib/typescript/shared/providers/screen/screen-composer.d.ts.map +1 -1
- package/lib/typescript/shared/types/animation.types.d.ts +2 -6
- package/lib/typescript/shared/types/animation.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/index.d.ts +2 -2
- package/lib/typescript/shared/types/index.d.ts.map +1 -1
- package/lib/typescript/shared/types/overlay.types.d.ts +21 -0
- package/lib/typescript/shared/types/overlay.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/screen.types.d.ts +5 -4
- package/lib/typescript/shared/types/screen.types.d.ts.map +1 -1
- package/lib/typescript/shared/types/stack.types.d.ts +9 -0
- package/lib/typescript/shared/types/stack.types.d.ts.map +1 -1
- package/lib/typescript/shared/utils/animation/start-screen-transition.d.ts.map +1 -1
- package/lib/typescript/shared/utils/bounds/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blank-stack/components/stack-view.native.tsx +0 -2
- package/src/blank-stack/components/stack-view.tsx +0 -2
- package/src/blank-stack/types.ts +6 -8
- package/src/component-stack/components/stack-view.tsx +19 -23
- package/src/component-stack/types.ts +7 -8
- package/src/native-stack/types.ts +2 -3
- package/src/native-stack/views/NativeStackView.native.tsx +2 -3
- package/src/shared/components/overlay/variations/float-overlay.tsx +2 -8
- package/src/shared/components/overlay/variations/overlay-host.tsx +18 -84
- package/src/shared/components/overlay/variations/screen-overlay.tsx +6 -15
- package/src/shared/components/screen-lifecycle.tsx +168 -0
- package/src/shared/constants.ts +3 -1
- package/src/shared/hooks/animation/use-screen-animation.tsx +3 -3
- package/src/shared/hooks/gestures/use-build-gestures.tsx +0 -2
- package/src/shared/hooks/navigation/use-screen-state.tsx +99 -0
- package/src/shared/hooks/use-stable-callback-value.ts +0 -1
- package/src/shared/index.ts +4 -0
- package/src/shared/providers/screen/keys.provider.tsx +1 -9
- package/src/shared/providers/screen/screen-composer.tsx +3 -5
- package/src/shared/providers/screen/styles.provider.tsx +1 -1
- package/src/shared/types/animation.types.ts +2 -6
- package/src/shared/types/index.ts +2 -7
- package/src/shared/types/overlay.types.ts +23 -0
- package/src/shared/types/screen.types.ts +5 -4
- package/src/shared/types/stack.types.ts +16 -1
- package/src/shared/utils/animation/start-screen-transition.ts +1 -1
- package/src/shared/utils/bounds/index.ts +6 -1
- package/lib/commonjs/native-stack/controllers/native-stack-lifecycle.js +0 -90
- package/lib/commonjs/native-stack/controllers/native-stack-lifecycle.js.map +0 -1
- package/lib/commonjs/shared/controller/managed-lifecycle.js +0 -78
- package/lib/commonjs/shared/controller/managed-lifecycle.js.map +0 -1
- package/lib/commonjs/shared/types/state.types.js +0 -9
- package/lib/commonjs/shared/types/state.types.js.map +0 -1
- package/lib/module/native-stack/controllers/native-stack-lifecycle.js +0 -83
- package/lib/module/native-stack/controllers/native-stack-lifecycle.js.map +0 -1
- package/lib/module/shared/controller/managed-lifecycle.js +0 -72
- package/lib/module/shared/controller/managed-lifecycle.js.map +0 -1
- package/lib/module/shared/types/state.types.js +0 -5
- package/lib/module/shared/types/state.types.js.map +0 -1
- package/lib/typescript/native-stack/controllers/native-stack-lifecycle.d.ts +0 -8
- package/lib/typescript/native-stack/controllers/native-stack-lifecycle.d.ts.map +0 -1
- package/lib/typescript/shared/controller/managed-lifecycle.d.ts +0 -9
- package/lib/typescript/shared/controller/managed-lifecycle.d.ts.map +0 -1
- package/lib/typescript/shared/types/state.types.d.ts +0 -3
- package/lib/typescript/shared/types/state.types.d.ts.map +0 -1
- package/src/native-stack/controllers/native-stack-lifecycle.tsx +0 -96
- package/src/shared/controller/managed-lifecycle.tsx +0 -73
- package/src/shared/types/state.types.ts +0 -2
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/** biome-ignore-all lint/style/noNonNullAssertion: <Lifecycles are rendered right under the gesture provider> */
|
|
4
|
-
import { useEffect, useLayoutEffect } from "react";
|
|
5
|
-
import { useDerivedValue } from "react-native-reanimated";
|
|
6
|
-
import { useHighRefreshRate } from "../../shared/hooks/animation/use-high-refresh-rate";
|
|
7
|
-
import { useSharedValueState } from "../../shared/hooks/reanimated/use-shared-value-state";
|
|
8
|
-
import useStableCallback from "../../shared/hooks/use-stable-callback";
|
|
9
|
-
import { useGestureContext } from "../../shared/providers/gestures.provider";
|
|
10
|
-
import { useKeys } from "../../shared/providers/screen/keys.provider";
|
|
11
|
-
import { AnimationStore } from "../../shared/stores/animation.store";
|
|
12
|
-
import { TRUE } from "../../shared/types/state.types";
|
|
13
|
-
import { startScreenTransition } from "../../shared/utils/animation/start-screen-transition";
|
|
14
|
-
import { resetStoresForScreen } from "../../shared/utils/reset-stores-for-screen";
|
|
15
|
-
/**
|
|
16
|
-
* Lifecycle controller built out for Native Stack implementation.
|
|
17
|
-
*/
|
|
18
|
-
export const NativeStackScreenLifecycleController = ({
|
|
19
|
-
children
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
current
|
|
23
|
-
} = useKeys();
|
|
24
|
-
const {
|
|
25
|
-
ancestorContext
|
|
26
|
-
} = useGestureContext();
|
|
27
|
-
const isAncestorDismissingViaGesture = useSharedValueState(useDerivedValue(() => {
|
|
28
|
-
"worklet";
|
|
29
|
-
|
|
30
|
-
return ancestorContext?.gestureAnimationValues.isDismissing?.value ?? false;
|
|
31
|
-
}));
|
|
32
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
33
|
-
const {
|
|
34
|
-
deactivateHighRefreshRate,
|
|
35
|
-
activateHighRefreshRate
|
|
36
|
-
} = useHighRefreshRate(current);
|
|
37
|
-
const handleBeforeRemove = useStableCallback(e => {
|
|
38
|
-
const isEnabled = current.options.enableTransitions;
|
|
39
|
-
const isFirstScreen = current.navigation.getState().index === 0;
|
|
40
|
-
|
|
41
|
-
// If transitions are disabled, or an ancestor is dismissing via gesture, or this is the first screen of the stack, reset the stores
|
|
42
|
-
if (!isEnabled || isAncestorDismissingViaGesture || isFirstScreen) {
|
|
43
|
-
animations.closing.set(TRUE);
|
|
44
|
-
resetStoresForScreen(current);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
activateHighRefreshRate();
|
|
49
|
-
const onAnimationFinish = finished => {
|
|
50
|
-
deactivateHighRefreshRate();
|
|
51
|
-
if (finished) {
|
|
52
|
-
current.navigation.dispatch(e.data.action);
|
|
53
|
-
|
|
54
|
-
// we'll ensure the dispatch is complete before resetting stores
|
|
55
|
-
requestAnimationFrame(() => {
|
|
56
|
-
resetStoresForScreen(current);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
startScreenTransition({
|
|
61
|
-
target: "close",
|
|
62
|
-
spec: current.options.transitionSpec,
|
|
63
|
-
onAnimationFinish,
|
|
64
|
-
animations
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
const handleInitialize = useStableCallback(() => {
|
|
68
|
-
activateHighRefreshRate();
|
|
69
|
-
startScreenTransition({
|
|
70
|
-
target: "open",
|
|
71
|
-
spec: current.options.transitionSpec,
|
|
72
|
-
animations,
|
|
73
|
-
onAnimationFinish: deactivateHighRefreshRate
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
const unsubscribe = current.navigation.addListener("beforeRemove", handleBeforeRemove);
|
|
78
|
-
return unsubscribe;
|
|
79
|
-
}, [current.navigation, handleBeforeRemove]);
|
|
80
|
-
useLayoutEffect(handleInitialize, []);
|
|
81
|
-
return children;
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=native-stack-lifecycle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useDerivedValue","useHighRefreshRate","useSharedValueState","useStableCallback","useGestureContext","useKeys","AnimationStore","TRUE","startScreenTransition","resetStoresForScreen","NativeStackScreenLifecycleController","children","current","ancestorContext","isAncestorDismissingViaGesture","gestureAnimationValues","isDismissing","value","animations","getAll","route","key","deactivateHighRefreshRate","activateHighRefreshRate","handleBeforeRemove","e","isEnabled","options","enableTransitions","isFirstScreen","navigation","getState","index","closing","set","preventDefault","onAnimationFinish","finished","dispatch","data","action","requestAnimationFrame","target","spec","transitionSpec","handleInitialize","unsubscribe","addListener"],"sourceRoot":"../../../../src","sources":["native-stack/controllers/native-stack-lifecycle.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { useLayoutEffect } from "react";
|
|
4
|
-
import { runOnJS, useAnimatedReaction } from "react-native-reanimated";
|
|
5
|
-
import { useHighRefreshRate } from "../hooks/animation/use-high-refresh-rate";
|
|
6
|
-
import useStableCallback from "../hooks/use-stable-callback";
|
|
7
|
-
import { useKeys } from "../providers/screen/keys.provider";
|
|
8
|
-
import { useManagedStackContext } from "../providers/stack/managed.provider";
|
|
9
|
-
import { AnimationStore } from "../stores/animation.store";
|
|
10
|
-
import { startScreenTransition } from "../utils/animation/start-screen-transition";
|
|
11
|
-
import { resetStoresForScreen } from "../utils/reset-stores-for-screen";
|
|
12
|
-
/**
|
|
13
|
-
* Lifecycle controller built out for Blank Stack implementation.
|
|
14
|
-
*/
|
|
15
|
-
export const ManagedLifecycle = ({
|
|
16
|
-
children
|
|
17
|
-
}) => {
|
|
18
|
-
const {
|
|
19
|
-
current
|
|
20
|
-
} = useKeys();
|
|
21
|
-
const {
|
|
22
|
-
handleCloseRoute,
|
|
23
|
-
closingRouteKeysShared
|
|
24
|
-
} = useManagedStackContext();
|
|
25
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
26
|
-
const {
|
|
27
|
-
deactivateHighRefreshRate,
|
|
28
|
-
activateHighRefreshRate
|
|
29
|
-
} = useHighRefreshRate(current);
|
|
30
|
-
const handleInitialize = useStableCallback(() => {
|
|
31
|
-
activateHighRefreshRate();
|
|
32
|
-
startScreenTransition({
|
|
33
|
-
target: "open",
|
|
34
|
-
spec: current.options.transitionSpec,
|
|
35
|
-
animations,
|
|
36
|
-
onAnimationFinish: deactivateHighRefreshRate
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
const handleCloseEnd = useStableCallback(finished => {
|
|
40
|
-
if (!finished) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
handleCloseRoute({
|
|
44
|
-
route: current.route
|
|
45
|
-
});
|
|
46
|
-
requestAnimationFrame(() => {
|
|
47
|
-
deactivateHighRefreshRate();
|
|
48
|
-
resetStoresForScreen(current);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
useAnimatedReaction(() => ({
|
|
52
|
-
keys: closingRouteKeysShared.value
|
|
53
|
-
}), ({
|
|
54
|
-
keys
|
|
55
|
-
}) => {
|
|
56
|
-
if (!keys.includes(current.route.key)) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
runOnJS(activateHighRefreshRate)();
|
|
60
|
-
startScreenTransition({
|
|
61
|
-
target: "close",
|
|
62
|
-
spec: current.options.transitionSpec,
|
|
63
|
-
animations,
|
|
64
|
-
onAnimationFinish: handleCloseEnd
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
useLayoutEffect(() => {
|
|
68
|
-
handleInitialize();
|
|
69
|
-
}, [handleInitialize]);
|
|
70
|
-
return children;
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=managed-lifecycle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useLayoutEffect","runOnJS","useAnimatedReaction","useHighRefreshRate","useStableCallback","useKeys","useManagedStackContext","AnimationStore","startScreenTransition","resetStoresForScreen","ManagedLifecycle","children","current","handleCloseRoute","closingRouteKeysShared","animations","getAll","route","key","deactivateHighRefreshRate","activateHighRefreshRate","handleInitialize","target","spec","options","transitionSpec","onAnimationFinish","handleCloseEnd","finished","requestAnimationFrame","keys","value","includes"],"sourceRoot":"../../../../src","sources":["shared/controller/managed-lifecycle.tsx"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,OAAO;AACvC,SAASC,OAAO,EAAEC,mBAAmB,QAAQ,yBAAyB;AAEtE,SAASC,kBAAkB,QAAQ,0CAA0C;AAC7E,OAAOC,iBAAiB,MAAM,8BAA8B;AAC5D,SAASC,OAAO,QAAQ,mCAAmC;AAC3D,SAASC,sBAAsB,QAAQ,qCAAqC;AAC5E,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,SAASC,qBAAqB,QAAQ,4CAA4C;AAClF,SAASC,oBAAoB,QAAQ,kCAAkC;AAMvE;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC;AAAgB,CAAC,KAAK;EACxD,MAAM;IAAEC;EAAQ,CAAC,GAAGP,OAAO,CAAuB,CAAC;EACnD,MAAM;IAAEQ,gBAAgB;IAAEC;EAAuB,CAAC,GAAGR,sBAAsB,CAAC,CAAC;EAE7E,MAAMS,UAAU,GAAGR,cAAc,CAACS,MAAM,CAACJ,OAAO,CAACK,KAAK,CAACC,GAAG,CAAC;EAE3D,MAAM;IAAEC,yBAAyB;IAAEC;EAAwB,CAAC,GAC3DjB,kBAAkB,CAACS,OAAO,CAAC;EAE5B,MAAMS,gBAAgB,GAAGjB,iBAAiB,CAAC,MAAM;IAChDgB,uBAAuB,CAAC,CAAC;IACzBZ,qBAAqB,CAAC;MACrBc,MAAM,EAAE,MAAM;MACdC,IAAI,EAAEX,OAAO,CAACY,OAAO,CAACC,cAAc;MACpCV,UAAU;MACVW,iBAAiB,EAAEP;IACpB,CAAC,CAAC;EACH,CAAC,CAAC;EAEF,MAAMQ,cAAc,GAAGvB,iBAAiB,CAAEwB,QAAiB,IAAK;IAC/D,IAAI,CAACA,QAAQ,EAAE;MACd;IACD;IACAf,gBAAgB,CAAC;MAAEI,KAAK,EAAEL,OAAO,CAACK;IAAM,CAAC,CAAC;IAC1CY,qBAAqB,CAAC,MAAM;MAC3BV,yBAAyB,CAAC,CAAC;MAC3BV,oBAAoB,CAACG,OAAO,CAAC;IAC9B,CAAC,CAAC;EACH,CAAC,CAAC;EAEFV,mBAAmB,CAClB,OAAO;IACN4B,IAAI,EAAEhB,sBAAsB,CAACiB;EAC9B,CAAC,CAAC,EACF,CAAC;IAAED;EAAK,CAAC,KAAK;IACb,IAAI,CAACA,IAAI,CAACE,QAAQ,CAACpB,OAAO,CAACK,KAAK,CAACC,GAAG,CAAC,EAAE;MACtC;IACD;IAEAjB,OAAO,CAACmB,uBAAuB,CAAC,CAAC,CAAC;IAClCZ,qBAAqB,CAAC;MACrBc,MAAM,EAAE,OAAO;MACfC,IAAI,EAAEX,OAAO,CAACY,OAAO,CAACC,cAAc;MACpCV,UAAU;MACVW,iBAAiB,EAAEC;IACpB,CAAC,CAAC;EACH,CACD,CAAC;EAED3B,eAAe,CAAC,MAAM;IACrBqB,gBAAgB,CAAC,CAAC;EACnB,CAAC,EAAE,CAACA,gBAAgB,CAAC,CAAC;EAEtB,OAAOV,QAAQ;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TRUE","FALSE"],"sourceRoot":"../../../../src","sources":["shared/types/state.types.ts"],"mappings":";;AAAA,OAAO,MAAMA,IAAI,GAAG,CAAC;AACrB,OAAO,MAAMC,KAAK,GAAG,CAAC","ignoreList":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface Props {
|
|
2
|
-
children: React.ReactNode;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Lifecycle controller built out for Native Stack implementation.
|
|
6
|
-
*/
|
|
7
|
-
export declare const NativeStackScreenLifecycleController: ({ children }: Props) => import("react").ReactNode;
|
|
8
|
-
//# sourceMappingURL=native-stack-lifecycle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"native-stack-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/native-stack/controllers/native-stack-lifecycle.tsx"],"names":[],"mappings":"AAcA,MAAM,WAAW,KAAK;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,oCAAoC,GAAI,cAAc,KAAK,8BA0EvE,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
interface Props {
|
|
2
|
-
children: React.ReactNode;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Lifecycle controller built out for Blank Stack implementation.
|
|
6
|
-
*/
|
|
7
|
-
export declare const ManagedLifecycle: ({ children }: Props) => import("react").ReactNode;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=managed-lifecycle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"managed-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/shared/controller/managed-lifecycle.tsx"],"names":[],"mappings":"AAWA,UAAU,KAAK;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,cAAc,KAAK,8BAsDnD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.types.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/state.types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,IAAI,CAAC;AACtB,eAAO,MAAM,KAAK,IAAI,CAAC"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/** biome-ignore-all lint/style/noNonNullAssertion: <Lifecycles are rendered right under the gesture provider> */
|
|
2
|
-
import { useEffect, useLayoutEffect } from "react";
|
|
3
|
-
import { useDerivedValue } from "react-native-reanimated";
|
|
4
|
-
import { useHighRefreshRate } from "../../shared/hooks/animation/use-high-refresh-rate";
|
|
5
|
-
import { useSharedValueState } from "../../shared/hooks/reanimated/use-shared-value-state";
|
|
6
|
-
import useStableCallback from "../../shared/hooks/use-stable-callback";
|
|
7
|
-
import { useGestureContext } from "../../shared/providers/gestures.provider";
|
|
8
|
-
import { useKeys } from "../../shared/providers/screen/keys.provider";
|
|
9
|
-
import { AnimationStore } from "../../shared/stores/animation.store";
|
|
10
|
-
import { TRUE } from "../../shared/types/state.types";
|
|
11
|
-
import { startScreenTransition } from "../../shared/utils/animation/start-screen-transition";
|
|
12
|
-
import { resetStoresForScreen } from "../../shared/utils/reset-stores-for-screen";
|
|
13
|
-
import type { NativeStackDescriptor } from "../types";
|
|
14
|
-
|
|
15
|
-
export interface Props {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Lifecycle controller built out for Native Stack implementation.
|
|
21
|
-
*/
|
|
22
|
-
export const NativeStackScreenLifecycleController = ({ children }: Props) => {
|
|
23
|
-
const { current } = useKeys<NativeStackDescriptor>();
|
|
24
|
-
const { ancestorContext } = useGestureContext()!;
|
|
25
|
-
|
|
26
|
-
const isAncestorDismissingViaGesture = useSharedValueState(
|
|
27
|
-
useDerivedValue(() => {
|
|
28
|
-
"worklet";
|
|
29
|
-
return (
|
|
30
|
-
ancestorContext?.gestureAnimationValues.isDismissing?.value ?? false
|
|
31
|
-
);
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
36
|
-
|
|
37
|
-
const { deactivateHighRefreshRate, activateHighRefreshRate } =
|
|
38
|
-
useHighRefreshRate(current);
|
|
39
|
-
|
|
40
|
-
const handleBeforeRemove = useStableCallback((e: any) => {
|
|
41
|
-
const isEnabled = current.options.enableTransitions;
|
|
42
|
-
|
|
43
|
-
const isFirstScreen = current.navigation.getState().index === 0;
|
|
44
|
-
|
|
45
|
-
// If transitions are disabled, or an ancestor is dismissing via gesture, or this is the first screen of the stack, reset the stores
|
|
46
|
-
if (!isEnabled || isAncestorDismissingViaGesture || isFirstScreen) {
|
|
47
|
-
animations.closing.set(TRUE);
|
|
48
|
-
resetStoresForScreen(current);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
e.preventDefault();
|
|
53
|
-
activateHighRefreshRate();
|
|
54
|
-
const onAnimationFinish = (finished: boolean) => {
|
|
55
|
-
deactivateHighRefreshRate();
|
|
56
|
-
if (finished) {
|
|
57
|
-
current.navigation.dispatch(e.data.action);
|
|
58
|
-
|
|
59
|
-
// we'll ensure the dispatch is complete before resetting stores
|
|
60
|
-
requestAnimationFrame(() => {
|
|
61
|
-
resetStoresForScreen(current);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
startScreenTransition({
|
|
67
|
-
target: "close",
|
|
68
|
-
spec: current.options.transitionSpec,
|
|
69
|
-
onAnimationFinish,
|
|
70
|
-
animations,
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const handleInitialize = useStableCallback(() => {
|
|
75
|
-
activateHighRefreshRate();
|
|
76
|
-
startScreenTransition({
|
|
77
|
-
target: "open",
|
|
78
|
-
spec: current.options.transitionSpec,
|
|
79
|
-
animations,
|
|
80
|
-
onAnimationFinish: deactivateHighRefreshRate,
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
const unsubscribe = current.navigation.addListener(
|
|
86
|
-
"beforeRemove",
|
|
87
|
-
handleBeforeRemove,
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
return unsubscribe;
|
|
91
|
-
}, [current.navigation, handleBeforeRemove]);
|
|
92
|
-
|
|
93
|
-
useLayoutEffect(handleInitialize, []);
|
|
94
|
-
|
|
95
|
-
return children;
|
|
96
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect } from "react";
|
|
2
|
-
import { runOnJS, useAnimatedReaction } from "react-native-reanimated";
|
|
3
|
-
import type { BlankStackDescriptor } from "../../blank-stack/types";
|
|
4
|
-
import { useHighRefreshRate } from "../hooks/animation/use-high-refresh-rate";
|
|
5
|
-
import useStableCallback from "../hooks/use-stable-callback";
|
|
6
|
-
import { useKeys } from "../providers/screen/keys.provider";
|
|
7
|
-
import { useManagedStackContext } from "../providers/stack/managed.provider";
|
|
8
|
-
import { AnimationStore } from "../stores/animation.store";
|
|
9
|
-
import { startScreenTransition } from "../utils/animation/start-screen-transition";
|
|
10
|
-
import { resetStoresForScreen } from "../utils/reset-stores-for-screen";
|
|
11
|
-
|
|
12
|
-
interface Props {
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Lifecycle controller built out for Blank Stack implementation.
|
|
18
|
-
*/
|
|
19
|
-
export const ManagedLifecycle = ({ children }: Props) => {
|
|
20
|
-
const { current } = useKeys<BlankStackDescriptor>();
|
|
21
|
-
const { handleCloseRoute, closingRouteKeysShared } = useManagedStackContext();
|
|
22
|
-
|
|
23
|
-
const animations = AnimationStore.getAll(current.route.key);
|
|
24
|
-
|
|
25
|
-
const { deactivateHighRefreshRate, activateHighRefreshRate } =
|
|
26
|
-
useHighRefreshRate(current);
|
|
27
|
-
|
|
28
|
-
const handleInitialize = useStableCallback(() => {
|
|
29
|
-
activateHighRefreshRate();
|
|
30
|
-
startScreenTransition({
|
|
31
|
-
target: "open",
|
|
32
|
-
spec: current.options.transitionSpec,
|
|
33
|
-
animations,
|
|
34
|
-
onAnimationFinish: deactivateHighRefreshRate,
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const handleCloseEnd = useStableCallback((finished: boolean) => {
|
|
39
|
-
if (!finished) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
handleCloseRoute({ route: current.route });
|
|
43
|
-
requestAnimationFrame(() => {
|
|
44
|
-
deactivateHighRefreshRate();
|
|
45
|
-
resetStoresForScreen(current);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
useAnimatedReaction(
|
|
50
|
-
() => ({
|
|
51
|
-
keys: closingRouteKeysShared.value,
|
|
52
|
-
}),
|
|
53
|
-
({ keys }) => {
|
|
54
|
-
if (!keys.includes(current.route.key)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
runOnJS(activateHighRefreshRate)();
|
|
59
|
-
startScreenTransition({
|
|
60
|
-
target: "close",
|
|
61
|
-
spec: current.options.transitionSpec,
|
|
62
|
-
animations,
|
|
63
|
-
onAnimationFinish: handleCloseEnd,
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
useLayoutEffect(() => {
|
|
69
|
-
handleInitialize();
|
|
70
|
-
}, [handleInitialize]);
|
|
71
|
-
|
|
72
|
-
return children;
|
|
73
|
-
};
|