react-native-screen-transitions 3.0.0-beta.1 → 3.0.0-beta.10
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/blank-stack/components/Overlay.js +19 -5
- package/lib/commonjs/blank-stack/components/Overlay.js.map +1 -1
- package/lib/commonjs/blank-stack/components/Screens.js +3 -3
- package/lib/commonjs/blank-stack/components/Screens.js.map +1 -1
- package/lib/commonjs/blank-stack/components/StackView.js +49 -40
- package/lib/commonjs/blank-stack/components/StackView.js.map +1 -1
- package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js +1 -5
- package/lib/commonjs/blank-stack/hooks/use-overlay-animation.js.map +1 -1
- package/lib/commonjs/blank-stack/index.js +14 -0
- package/lib/commonjs/blank-stack/index.js.map +1 -1
- package/lib/commonjs/blank-stack/providers/blank-stack-state.js +65 -0
- package/lib/commonjs/blank-stack/providers/blank-stack-state.js.map +1 -0
- package/lib/commonjs/native-stack/views/NativeStackView.native.js +2 -1
- package/lib/commonjs/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/commonjs/shared/components/controllers/screen-lifecycle.js +20 -6
- package/lib/commonjs/shared/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/commonjs/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/commonjs/shared/hooks/bounds/use-bound-registry.js +21 -0
- package/lib/commonjs/shared/hooks/bounds/use-bound-registry.js.map +1 -1
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js +40 -28
- package/lib/commonjs/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/commonjs/shared/hooks/use-derived-value-state.js +33 -0
- package/lib/commonjs/shared/hooks/use-derived-value-state.js.map +1 -0
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js +7 -1
- package/lib/commonjs/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/commonjs/shared/providers/gestures.js +6 -3
- package/lib/commonjs/shared/providers/gestures.js.map +1 -1
- package/lib/commonjs/shared/providers/utils/create-provider.js +41 -29
- package/lib/commonjs/shared/providers/utils/create-provider.js.map +1 -1
- package/lib/commonjs/shared/stores/animation-store.js +12 -3
- package/lib/commonjs/shared/stores/animation-store.js.map +1 -1
- package/lib/commonjs/shared/stores/bound-store/index.js +12 -1
- package/lib/commonjs/shared/stores/bound-store/index.js.map +1 -1
- package/lib/commonjs/shared/stores/gesture-store.js +10 -0
- package/lib/commonjs/shared/stores/gesture-store.js.map +1 -1
- package/lib/module/blank-stack/components/Overlay.js +19 -5
- package/lib/module/blank-stack/components/Overlay.js.map +1 -1
- package/lib/module/blank-stack/components/Screens.js +3 -3
- package/lib/module/blank-stack/components/Screens.js.map +1 -1
- package/lib/module/blank-stack/components/StackView.js +48 -40
- package/lib/module/blank-stack/components/StackView.js.map +1 -1
- package/lib/module/blank-stack/hooks/use-overlay-animation.js +2 -6
- package/lib/module/blank-stack/hooks/use-overlay-animation.js.map +1 -1
- package/lib/module/blank-stack/index.js +2 -0
- package/lib/module/blank-stack/index.js.map +1 -1
- package/lib/module/blank-stack/providers/blank-stack-state.js +59 -0
- package/lib/module/blank-stack/providers/blank-stack-state.js.map +1 -0
- package/lib/module/native-stack/views/NativeStackView.native.js +2 -1
- package/lib/module/native-stack/views/NativeStackView.native.js.map +1 -1
- package/lib/module/shared/components/controllers/screen-lifecycle.js +20 -6
- package/lib/module/shared/components/controllers/screen-lifecycle.js.map +1 -1
- package/lib/module/shared/hooks/animation/use-screen-animation.js.map +1 -1
- package/lib/module/shared/hooks/bounds/use-bound-registry.js +22 -1
- package/lib/module/shared/hooks/bounds/use-bound-registry.js.map +1 -1
- package/lib/module/shared/hooks/gestures/use-build-gestures.js +42 -30
- package/lib/module/shared/hooks/gestures/use-build-gestures.js.map +1 -1
- package/lib/module/shared/hooks/use-derived-value-state.js +30 -0
- package/lib/module/shared/hooks/use-derived-value-state.js.map +1 -0
- package/lib/module/shared/hooks/use-stable-callback-value.js +8 -2
- package/lib/module/shared/hooks/use-stable-callback-value.js.map +1 -1
- package/lib/module/shared/providers/gestures.js +6 -3
- package/lib/module/shared/providers/gestures.js.map +1 -1
- package/lib/module/shared/providers/utils/create-provider.js +40 -27
- package/lib/module/shared/providers/utils/create-provider.js.map +1 -1
- package/lib/module/shared/stores/animation-store.js +15 -4
- package/lib/module/shared/stores/animation-store.js.map +1 -1
- package/lib/module/shared/stores/bound-store/index.js +12 -1
- package/lib/module/shared/stores/bound-store/index.js.map +1 -1
- package/lib/module/shared/stores/gesture-store.js +11 -1
- package/lib/module/shared/stores/gesture-store.js.map +1 -1
- package/lib/typescript/blank-stack/components/Overlay.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/Screens.d.ts +2 -3
- package/lib/typescript/blank-stack/components/Screens.d.ts.map +1 -1
- package/lib/typescript/blank-stack/components/StackView.d.ts.map +1 -1
- package/lib/typescript/blank-stack/hooks/use-overlay-animation.d.ts.map +1 -1
- package/lib/typescript/blank-stack/index.d.ts +2 -0
- package/lib/typescript/blank-stack/index.d.ts.map +1 -1
- package/lib/typescript/blank-stack/providers/blank-stack-state.d.ts +13 -0
- package/lib/typescript/blank-stack/providers/blank-stack-state.d.ts.map +1 -0
- package/lib/typescript/blank-stack/types.d.ts +4 -0
- package/lib/typescript/blank-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/controllers/screen-lifecycle.d.ts.map +1 -1
- package/lib/typescript/shared/configs/index.d.ts +9 -9
- package/lib/typescript/shared/hooks/animation/use-screen-animation.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/bounds/use-bound-registry.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts +5 -2
- package/lib/typescript/shared/hooks/gestures/use-build-gestures.d.ts.map +1 -1
- package/lib/typescript/shared/hooks/use-derived-value-state.d.ts +9 -0
- package/lib/typescript/shared/hooks/use-derived-value-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 +10 -9
- package/lib/typescript/shared/index.d.ts.map +1 -1
- package/lib/typescript/shared/providers/gestures.d.ts +4 -2
- package/lib/typescript/shared/providers/gestures.d.ts.map +1 -1
- package/lib/typescript/shared/providers/utils/create-provider.d.ts +11 -29
- package/lib/typescript/shared/providers/utils/create-provider.d.ts.map +1 -1
- package/lib/typescript/shared/stores/animation-store.d.ts +4 -2
- package/lib/typescript/shared/stores/animation-store.d.ts.map +1 -1
- package/lib/typescript/shared/stores/bound-store/index.d.ts +2 -0
- package/lib/typescript/shared/stores/bound-store/index.d.ts.map +1 -1
- package/lib/typescript/shared/stores/gesture-store.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/blank-stack/components/Overlay.tsx +24 -4
- package/src/blank-stack/components/Screens.tsx +5 -5
- package/src/blank-stack/components/StackView.tsx +55 -46
- package/src/blank-stack/hooks/use-overlay-animation.tsx +3 -18
- package/src/blank-stack/index.ts +2 -0
- package/src/blank-stack/providers/blank-stack-state.tsx +90 -0
- package/src/blank-stack/types.ts +4 -0
- package/src/native-stack/views/NativeStackView.native.tsx +3 -1
- package/src/shared/components/controllers/screen-lifecycle.tsx +20 -7
- package/src/shared/hooks/animation/use-screen-animation.tsx +1 -1
- package/src/shared/hooks/bounds/use-bound-registry.tsx +32 -1
- package/src/shared/hooks/gestures/use-build-gestures.tsx +63 -35
- package/src/shared/hooks/use-derived-value-state.ts +41 -0
- package/src/shared/hooks/use-stable-callback-value.tsx +10 -1
- package/src/shared/index.ts +3 -0
- package/src/shared/providers/gestures.tsx +17 -8
- package/src/shared/providers/utils/create-provider.tsx +77 -0
- package/src/shared/stores/animation-store.ts +19 -3
- package/src/shared/stores/bound-store/index.ts +23 -0
- package/src/shared/stores/gesture-store.ts +15 -1
- package/lib/commonjs/shared/stores/navigator-dismiss-state.js +0 -23
- package/lib/commonjs/shared/stores/navigator-dismiss-state.js.map +0 -1
- package/lib/module/shared/stores/navigator-dismiss-state.js +0 -19
- package/lib/module/shared/stores/navigator-dismiss-state.js.map +0 -1
- package/lib/typescript/shared/stores/navigator-dismiss-state.d.ts +0 -7
- package/lib/typescript/shared/stores/navigator-dismiss-state.d.ts.map +0 -1
- package/src/shared/providers/utils/create-provider.ts +0 -64
- package/src/shared/stores/navigator-dismiss-state.ts +0 -17
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* https://github.com/
|
|
2
|
+
* THANK YOU @MatiPl01
|
|
3
|
+
* https://github.com/MatiPl01/react-native-sortables/blob/main/packages/react-native-sortables/src/providers/utils/createProvider.tsx
|
|
4
|
+
* SUPER COOL AMAZING UTILITY
|
|
4
5
|
*/
|
|
5
|
-
import
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Error message to throw if the context is `undefined`
|
|
14
|
-
*/
|
|
15
|
-
errorMessage?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The display name of the context
|
|
18
|
-
*/
|
|
19
|
-
name?: string;
|
|
20
|
-
}
|
|
21
|
-
export type CreateContextReturn<T> = [
|
|
22
|
-
React.Provider<T>,
|
|
23
|
-
() => T,
|
|
24
|
-
React.Context<T>
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* Creates a named context, provider, and hook.
|
|
28
|
-
*
|
|
29
|
-
* @param options create context options
|
|
30
|
-
*/
|
|
31
|
-
export declare function createContext<ContextType>(options?: CreateContextOptions): CreateContextReturn<ContextType>;
|
|
6
|
+
import { type PropsWithChildren, type ReactNode } from "react";
|
|
7
|
+
export default function createProvider<ProviderName extends string, Guarded extends boolean = true>(name: ProviderName, options?: {
|
|
8
|
+
guarded?: Guarded;
|
|
9
|
+
}): <ProviderProps extends PropsWithChildren<object>, ContextValue>(factory: (props: ProviderProps) => {
|
|
10
|
+
value?: ContextValue;
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}) => { [P in ProviderName as `${P}Context`]: React.Context<ContextValue>; } & { [P in ProviderName as `${P}Provider`]: React.FC<ProviderProps>; } & { [P in ProviderName as `use${P}Context`]: () => Guarded extends true ? ContextValue : ContextValue | null; };
|
|
32
14
|
//# sourceMappingURL=create-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../../../../src/shared/providers/utils/create-provider.
|
|
1
|
+
{"version":3,"file":"create-provider.d.ts","sourceRoot":"","sources":["../../../../../src/shared/providers/utils/create-provider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAGd,MAAM,OAAO,CAAC;AAEf,MAAM,CAAC,OAAO,UAAU,cAAc,CACrC,YAAY,SAAS,MAAM,EAC3B,OAAO,SAAS,OAAO,GAAG,IAAI,EAC7B,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,IAC5C,aAAa,SAAS,iBAAiB,CAAC,MAAM,CAAC,EAAE,YAAY,EACpE,SAAS,CAAC,KAAK,EAAE,aAAa,KAAK;IAClC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB,KA4CI,GACH,CAAC,IAAI,YAAY,IAAI,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,GACjE,GAAG,GACF,CAAC,IAAI,YAAY,IAAI,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,GAC9D,GAAG,GACF,CAAC,IAAI,YAAY,IAAI,MAAM,CAAC,SAAS,GAAG,MAAM,OAAO,SAAS,IAAI,GAChE,YAAY,GACZ,YAAY,GAAG,IAAI,GACtB,CAEF"}
|
|
@@ -5,13 +5,15 @@ export type AnimationStoreMap = {
|
|
|
5
5
|
closing: SharedValue<number>;
|
|
6
6
|
animating: SharedValue<number>;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
declare function getAnimation(key: ScreenKey, type: "progress" | "closing" | "animating"): SharedValue<number>;
|
|
9
|
+
declare function getAll(key: ScreenKey): AnimationStoreMap;
|
|
10
10
|
declare function clear(routeKey: ScreenKey): void;
|
|
11
|
+
declare function debugStoreSize(): void;
|
|
11
12
|
export declare const AnimationStore: {
|
|
12
13
|
getAnimation: typeof getAnimation;
|
|
13
14
|
clear: typeof clear;
|
|
14
15
|
getAll: typeof getAll;
|
|
16
|
+
debugStoreSize: typeof debugStoreSize;
|
|
15
17
|
};
|
|
16
18
|
export {};
|
|
17
19
|
//# sourceMappingURL=animation-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-store.d.ts","sourceRoot":"","sources":["../../../../src/shared/stores/animation-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"animation-store.d.ts","sourceRoot":"","sources":["../../../../src/shared/stores/animation-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAiBF,iBAAS,YAAY,CACpB,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,GACxC,WAAW,CAAC,MAAM,CAAC,CAErB;AAED,iBAAS,MAAM,CAAC,GAAG,EAAE,SAAS,qBAE7B;AAED,iBAAS,KAAK,CAAC,QAAQ,EAAE,SAAS,QASjC;AAED,iBAAS,cAAc,SAGtB;AAED,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC"}
|
|
@@ -9,6 +9,7 @@ declare function getBounds(screenId: string): Record<string, {
|
|
|
9
9
|
declare function setRouteActive(routeKey: string, boundId: string): void;
|
|
10
10
|
declare function getRouteActive(routeKey: string): string;
|
|
11
11
|
declare function clear(routeKey: ScreenKey): void;
|
|
12
|
+
declare function debugBoundStore(): void;
|
|
12
13
|
declare function getActiveBound(current: ScreenTransitionState, next: ScreenTransitionState | undefined, previous: ScreenTransitionState | undefined): string;
|
|
13
14
|
export declare const BoundStore: {
|
|
14
15
|
setBounds: typeof setBounds;
|
|
@@ -17,6 +18,7 @@ export declare const BoundStore: {
|
|
|
17
18
|
getRouteActive: typeof getRouteActive;
|
|
18
19
|
clear: typeof clear;
|
|
19
20
|
getActiveBound: typeof getActiveBound;
|
|
21
|
+
debugBoundStore: typeof debugBoundStore;
|
|
20
22
|
};
|
|
21
23
|
export {};
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/shared/stores/bound-store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EAEvB,KAAK,UAAU,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAalD,iBAAS,SAAS,CACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,kBAAkB,GAAG,IAAW,EACxC,MAAM,GAAE,UAAe,QAYvB;AAED,iBAAS,SAAS,CAAC,QAAQ,EAAE,MAAM;YAzBT,kBAAkB;YAAU,UAAU;GA4B/D;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAOxD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,MAAM,UAGvC;AAoBD,iBAAS,KAAK,CAAC,QAAQ,EAAE,SAAS,QAyBjC;AAED,iBAAS,cAAc,CACtB,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE,qBAAqB,GAAG,SAAS,EACvC,QAAQ,EAAE,qBAAqB,GAAG,SAAS,UAW3C;AAED,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/shared/stores/bound-store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,kBAAkB,EAEvB,KAAK,UAAU,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAalD,iBAAS,SAAS,CACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,kBAAkB,GAAG,IAAW,EACxC,MAAM,GAAE,UAAe,QAYvB;AAED,iBAAS,SAAS,CAAC,QAAQ,EAAE,MAAM;YAzBT,kBAAkB;YAAU,UAAU;GA4B/D;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAOxD;AAED,iBAAS,cAAc,CAAC,QAAQ,EAAE,MAAM,UAGvC;AAoBD,iBAAS,KAAK,CAAC,QAAQ,EAAE,SAAS,QAyBjC;AAED,iBAAS,eAAe,SAoBvB;AAED,iBAAS,cAAc,CACtB,OAAO,EAAE,qBAAqB,EAC9B,IAAI,EAAE,qBAAqB,GAAG,SAAS,EACvC,QAAQ,EAAE,qBAAqB,GAAG,SAAS,UAW3C;AAED,eAAO,MAAM,UAAU;;;;;;;;CAQtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gesture-store.d.ts","sourceRoot":"","sources":["../../../../src/shared/stores/gesture-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"gesture-store.d.ts","sourceRoot":"","sources":["../../../../src/shared/stores/gesture-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,WAAW,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,MAAM,UAAU,GACnB,GAAG,GACH,GAAG,GACH,aAAa,GACb,aAAa,GACb,cAAc,GACd,YAAY,CAAC;AAEhB,MAAM,MAAM,eAAe,GAAG;IAC7B,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;CACvE,CAAC;AAuBF,iBAAS,UAAU,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,uBAE9D;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,SAAS,mBAE5C;AAED,iBAAS,KAAK,CAAC,QAAQ,EAAE,SAAS,QAYjC;AAED,eAAO,MAAM,YAAY;;;;CAIxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { Animated, StyleSheet, View } from "react-native";
|
|
7
7
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
8
|
+
import { useScreenAnimation } from "../../shared/hooks/animation/use-screen-animation";
|
|
8
9
|
import { KeysProvider, useKeys } from "../../shared/providers/keys";
|
|
9
10
|
import { useOverlayAnimation } from "../hooks/use-overlay-animation";
|
|
10
11
|
import type {
|
|
@@ -13,7 +14,6 @@ import type {
|
|
|
13
14
|
BlankStackScene,
|
|
14
15
|
} from "../types";
|
|
15
16
|
import { useStackNavigationContext } from "../utils/with-stack-navigation";
|
|
16
|
-
import { useScreenAnimation } from "../../shared/hooks/animation/use-screen-animation";
|
|
17
17
|
|
|
18
18
|
type OverlayHostProps = {
|
|
19
19
|
scene: BlankStackScene;
|
|
@@ -43,13 +43,33 @@ const getActiveFloatOverlay = (scenes: BlankStackScene[], index: number) => {
|
|
|
43
43
|
return null;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
|
|
47
46
|
const OverlayHost = ({ scene, isFloating }: OverlayHostProps) => {
|
|
48
47
|
const insets = useSafeAreaInsets();
|
|
49
48
|
|
|
50
49
|
const OverlayComponent = scene.descriptor.options.overlay;
|
|
51
50
|
|
|
52
51
|
const { overlayAnimation, optimisticActiveIndex } = useOverlayAnimation();
|
|
52
|
+
const { scenes } = useStackNavigationContext();
|
|
53
|
+
|
|
54
|
+
const overlaySceneIndex = useMemo(() => {
|
|
55
|
+
return scenes.findIndex(
|
|
56
|
+
(stackScene) => stackScene.route.key === scene.route.key,
|
|
57
|
+
);
|
|
58
|
+
}, [scenes, scene.route.key]);
|
|
59
|
+
|
|
60
|
+
const focusedRoute = useMemo(() => {
|
|
61
|
+
if (overlaySceneIndex === -1) {
|
|
62
|
+
return scene.route;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const maxOffset = Math.max(scenes.length - overlaySceneIndex - 1, 0);
|
|
66
|
+
const normalizedIndex = Math.min(
|
|
67
|
+
Math.max(optimisticActiveIndex, 0),
|
|
68
|
+
maxOffset,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return scenes[overlaySceneIndex + normalizedIndex]?.route ?? scene.route;
|
|
72
|
+
}, [overlaySceneIndex, optimisticActiveIndex, scenes, scene.route]);
|
|
53
73
|
|
|
54
74
|
const screenAnimation = useScreenAnimation();
|
|
55
75
|
|
|
@@ -59,6 +79,7 @@ const OverlayHost = ({ scene, isFloating }: OverlayHostProps) => {
|
|
|
59
79
|
|
|
60
80
|
const overlayProps: BlankStackOverlayProps = {
|
|
61
81
|
route: scene.route,
|
|
82
|
+
focusedRoute,
|
|
62
83
|
navigation: scene.descriptor.navigation,
|
|
63
84
|
overlayAnimation,
|
|
64
85
|
screenAnimation,
|
|
@@ -71,7 +92,7 @@ const OverlayHost = ({ scene, isFloating }: OverlayHostProps) => {
|
|
|
71
92
|
pointerEvents="box-none"
|
|
72
93
|
style={[
|
|
73
94
|
styles.container,
|
|
74
|
-
isFloating ? styles.floating :
|
|
95
|
+
isFloating ? styles.floating : { zIndex: 1 },
|
|
75
96
|
styles.absolute,
|
|
76
97
|
]}
|
|
77
98
|
>
|
|
@@ -112,7 +133,6 @@ const FloatOverlay = () => {
|
|
|
112
133
|
};
|
|
113
134
|
|
|
114
135
|
const ScreenOverlay = () => {
|
|
115
|
-
const { focusedIndex } = useStackNavigationContext();
|
|
116
136
|
const { current } = useKeys<BlankStackDescriptor>();
|
|
117
137
|
|
|
118
138
|
const options = current.options;
|
|
@@ -13,7 +13,7 @@ import { AnimationStore } from "../../shared/stores/animation-store";
|
|
|
13
13
|
interface ScreenProps {
|
|
14
14
|
routeKey: string;
|
|
15
15
|
index: number;
|
|
16
|
-
|
|
16
|
+
routesLength: number;
|
|
17
17
|
isPreloaded: boolean;
|
|
18
18
|
children: React.ReactNode;
|
|
19
19
|
freezeOnBlur?: boolean;
|
|
@@ -32,7 +32,7 @@ const AnimatedScreen = Animated.createAnimatedComponent(RNSScreen);
|
|
|
32
32
|
export const Screen = ({
|
|
33
33
|
routeKey,
|
|
34
34
|
index,
|
|
35
|
-
|
|
35
|
+
routesLength,
|
|
36
36
|
isPreloaded,
|
|
37
37
|
activeScreensLimit,
|
|
38
38
|
children,
|
|
@@ -48,13 +48,13 @@ export const Screen = ({
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
if (index <
|
|
51
|
+
if (index < routesLength - activeScreensLimit - 1 || isPreloaded) {
|
|
52
52
|
screenActivity.value = STATE_INACTIVE;
|
|
53
53
|
} else {
|
|
54
54
|
const outputValue =
|
|
55
|
-
index ===
|
|
55
|
+
index === routesLength - 1
|
|
56
56
|
? STATE_ON_TOP
|
|
57
|
-
: index >=
|
|
57
|
+
: index >= routesLength - activeScreensLimit
|
|
58
58
|
? STATE_TRANSITIONING_OR_BELOW_TOP
|
|
59
59
|
: STATE_INACTIVE;
|
|
60
60
|
|
|
@@ -3,9 +3,12 @@ import {
|
|
|
3
3
|
NavigationContext,
|
|
4
4
|
NavigationRouteContext,
|
|
5
5
|
} from "@react-navigation/native";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { StyleSheet } from "react-native";
|
|
6
8
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
7
9
|
import { ScreenContainer } from "react-native-screens";
|
|
8
10
|
import { BlankStackScreenLifecycleController } from "../../shared/components/controllers/screen-lifecycle";
|
|
11
|
+
import { BlankStackStateProvider } from "../providers/blank-stack-state";
|
|
9
12
|
import { ScreenTransitionProvider } from "../../shared/providers/screen-transition-provider";
|
|
10
13
|
import type { BlankStackDescriptor } from "../types";
|
|
11
14
|
import { withStackNavigationProvider } from "../utils/with-stack-navigation";
|
|
@@ -22,7 +25,7 @@ type SceneViewProps = {
|
|
|
22
25
|
sceneIndex: number;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
|
-
const SceneView = ({ descriptor }: SceneViewProps) => {
|
|
28
|
+
const SceneView = React.memo(({ descriptor }: SceneViewProps) => {
|
|
26
29
|
const { route, navigation, render } = descriptor;
|
|
27
30
|
|
|
28
31
|
return (
|
|
@@ -33,7 +36,7 @@ const SceneView = ({ descriptor }: SceneViewProps) => {
|
|
|
33
36
|
</NavigationRouteContext.Provider>
|
|
34
37
|
</NavigationContext.Provider>
|
|
35
38
|
);
|
|
36
|
-
};
|
|
39
|
+
});
|
|
37
40
|
|
|
38
41
|
export const StackView = withStackNavigationProvider(
|
|
39
42
|
({
|
|
@@ -47,56 +50,62 @@ export const StackView = withStackNavigationProvider(
|
|
|
47
50
|
return (
|
|
48
51
|
<GestureHandlerRootView>
|
|
49
52
|
<SafeAreaProviderCompat>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
<BlankStackStateProvider>
|
|
54
|
+
{shouldShowFloatOverlay ? <Overlay.Float /> : null}
|
|
55
|
+
<ScreenContainer style={styles.container}>
|
|
56
|
+
{scenes.map((scene, sceneIndex) => {
|
|
57
|
+
const descriptor = scene.descriptor;
|
|
58
|
+
const route = scene.route;
|
|
59
|
+
const isFocused = focusedIndex === sceneIndex;
|
|
60
|
+
const isBelowFocused = focusedIndex - 1 === sceneIndex;
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
const previousDescriptor =
|
|
63
|
+
scenes[sceneIndex - 1]?.descriptor ?? undefined;
|
|
64
|
+
const nextDescriptor =
|
|
65
|
+
scenes[sceneIndex + 1]?.descriptor ?? undefined;
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
const isPreloaded = descriptors[route.key] === undefined;
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
>
|
|
81
|
-
<ScreenTransitionProvider
|
|
82
|
-
previous={previousDescriptor}
|
|
83
|
-
current={descriptor}
|
|
84
|
-
next={nextDescriptor}
|
|
85
|
-
LifecycleController={BlankStackScreenLifecycleController}
|
|
69
|
+
// On Fabric, when screen is frozen, animated and reanimated values are not updated
|
|
70
|
+
// due to component being unmounted. To avoid this, we don't freeze the previous screen there
|
|
71
|
+
const shouldFreeze = isFabric()
|
|
72
|
+
? !isPreloaded && !isFocused && !isBelowFocused
|
|
73
|
+
: !isPreloaded && !isFocused;
|
|
74
|
+
return (
|
|
75
|
+
<Screen
|
|
76
|
+
key={route.key}
|
|
77
|
+
isPreloaded={isPreloaded}
|
|
78
|
+
index={sceneIndex}
|
|
79
|
+
activeScreensLimit={activeScreensLimit}
|
|
80
|
+
routeKey={route.key}
|
|
81
|
+
routesLength={routes.length}
|
|
82
|
+
shouldFreeze={shouldFreeze}
|
|
83
|
+
freezeOnBlur={descriptor.options.freezeOnBlur}
|
|
86
84
|
>
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
<ScreenTransitionProvider
|
|
86
|
+
previous={previousDescriptor}
|
|
87
|
+
current={descriptor}
|
|
88
|
+
next={nextDescriptor}
|
|
89
|
+
LifecycleController={BlankStackScreenLifecycleController}
|
|
90
|
+
>
|
|
91
|
+
<SceneView
|
|
92
|
+
key={route.key}
|
|
93
|
+
isFocused={isFocused}
|
|
94
|
+
sceneIndex={sceneIndex}
|
|
95
|
+
descriptor={descriptor}
|
|
96
|
+
/>
|
|
97
|
+
</ScreenTransitionProvider>
|
|
98
|
+
</Screen>
|
|
99
|
+
);
|
|
100
|
+
})}
|
|
101
|
+
</ScreenContainer>
|
|
102
|
+
</BlankStackStateProvider>
|
|
98
103
|
</SafeAreaProviderCompat>
|
|
99
104
|
</GestureHandlerRootView>
|
|
100
105
|
);
|
|
101
106
|
},
|
|
102
107
|
);
|
|
108
|
+
|
|
109
|
+
const styles = StyleSheet.create({
|
|
110
|
+
container: { flex: 1 },
|
|
111
|
+
});
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
2
|
import { useWindowDimensions } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
type DerivedValue,
|
|
5
|
-
type SharedValue,
|
|
6
|
-
useDerivedValue,
|
|
7
|
-
useSharedValue,
|
|
8
|
-
} from "react-native-reanimated";
|
|
3
|
+
import { type DerivedValue, useDerivedValue } from "react-native-reanimated";
|
|
9
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
10
5
|
import { useSharedValueState } from "../../shared/hooks/use-shared-value-state";
|
|
11
6
|
import { useKeys } from "../../shared/providers/keys";
|
|
12
|
-
import {
|
|
13
|
-
AnimationStore,
|
|
14
|
-
type AnimationStoreMap,
|
|
15
|
-
} from "../../shared/stores/animation-store";
|
|
16
|
-
import { GestureStore } from "../../shared/stores/gesture-store";
|
|
7
|
+
import { AnimationStore } from "../../shared/stores/animation-store";
|
|
17
8
|
import type { OverlayInterpolationProps } from "../../shared/types/animation";
|
|
18
9
|
import { useStackNavigationContext } from "../utils/with-stack-navigation";
|
|
19
10
|
|
|
@@ -27,15 +18,9 @@ export const useOverlayAnimation = (): {
|
|
|
27
18
|
optimisticActiveIndex: number;
|
|
28
19
|
} => {
|
|
29
20
|
const { current } = useKeys();
|
|
30
|
-
const { scenes
|
|
21
|
+
const { scenes } = useStackNavigationContext();
|
|
31
22
|
const routeKey = current?.route?.key;
|
|
32
23
|
|
|
33
|
-
const gestureState = routeKey
|
|
34
|
-
? GestureStore.getRouteGestures(routeKey)
|
|
35
|
-
: null;
|
|
36
|
-
|
|
37
|
-
const fallbackIsDismissing = useSharedValue(0);
|
|
38
|
-
|
|
39
24
|
const progressValues = useMemo(() => {
|
|
40
25
|
if (!routeKey) {
|
|
41
26
|
return [];
|
package/src/blank-stack/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { useOverlayAnimation } from "../blank-stack/hooks/use-overlay-animation";
|
|
1
2
|
export { createBlankStackNavigator } from "../blank-stack/navigators/createBlankStackNavigator";
|
|
2
3
|
export type {
|
|
3
4
|
BlankStackNavigationEventMap,
|
|
@@ -8,3 +9,4 @@ export type {
|
|
|
8
9
|
BlankStackOverlayProps,
|
|
9
10
|
BlankStackScreenProps,
|
|
10
11
|
} from "../blank-stack/types";
|
|
12
|
+
export { useBlankStackState } from "./providers/blank-stack-state";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { NavigationRoute, ParamListBase } from "@react-navigation/native";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { useDerivedValue } from "react-native-reanimated";
|
|
4
|
+
import { useSharedValueState } from "../../shared/hooks/use-shared-value-state";
|
|
5
|
+
import createProvider from "../../shared/providers/utils/create-provider";
|
|
6
|
+
import { AnimationStore } from "../../shared/stores/animation-store";
|
|
7
|
+
import { useStackNavigationContext } from "../utils/with-stack-navigation";
|
|
8
|
+
|
|
9
|
+
interface BlankStackStateProviderProps {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type BlankStackStateProviderContext = {
|
|
14
|
+
parentIndex: number;
|
|
15
|
+
parentRoutes: NavigationRoute<ParamListBase, string>[];
|
|
16
|
+
index: number;
|
|
17
|
+
routes: NavigationRoute<ParamListBase, string>[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
useBlankStackStateContext: useBlankStackState,
|
|
22
|
+
BlankStackStateProvider,
|
|
23
|
+
} = createProvider("BlankStackState", { guarded: false })<
|
|
24
|
+
BlankStackStateProviderProps,
|
|
25
|
+
BlankStackStateProviderContext
|
|
26
|
+
>(() => {
|
|
27
|
+
const { focusedIndex, routes: stackRoutes } = useStackNavigationContext();
|
|
28
|
+
const [index, setIndex] = useState(0);
|
|
29
|
+
const [routes, setRoutes] = useState<
|
|
30
|
+
NavigationRoute<ParamListBase, string>[]
|
|
31
|
+
>([]);
|
|
32
|
+
|
|
33
|
+
const progressValues = useMemo(
|
|
34
|
+
() => stackRoutes.map((route) => AnimationStore.getAll(route.key)),
|
|
35
|
+
[stackRoutes],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const parentIndex = useDerivedValue(() => {
|
|
39
|
+
"worklet";
|
|
40
|
+
|
|
41
|
+
const activeIndex = progressValues.length - 1;
|
|
42
|
+
const isOneDismissing = Number(
|
|
43
|
+
progressValues.some((value) => value.closing.value > 0),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const optimisticIndex = activeIndex - isOneDismissing;
|
|
47
|
+
|
|
48
|
+
return optimisticIndex;
|
|
49
|
+
}, [focusedIndex, progressValues]);
|
|
50
|
+
|
|
51
|
+
const parentIndexValue = useSharedValueState(parentIndex);
|
|
52
|
+
|
|
53
|
+
const _registerNested = useCallback(
|
|
54
|
+
(
|
|
55
|
+
nestedIndex: number,
|
|
56
|
+
nestedRoutes: NavigationRoute<ParamListBase, string>[],
|
|
57
|
+
) => {
|
|
58
|
+
if (nestedIndex !== index) {
|
|
59
|
+
setIndex(nestedIndex);
|
|
60
|
+
}
|
|
61
|
+
if (nestedRoutes.length !== routes.length) {
|
|
62
|
+
setRoutes(nestedRoutes);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
[routes.length, index],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const context = useBlankStackState();
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
//@ts-expect-error Internally used
|
|
72
|
+
if (context?._registerNested) {
|
|
73
|
+
//@ts-expect-error Internally used
|
|
74
|
+
context._registerNested(parentIndexValue, stackRoutes);
|
|
75
|
+
}
|
|
76
|
+
//@ts-expect-error Internally used
|
|
77
|
+
}, [parentIndexValue, context?._registerNested, stackRoutes]);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
value: {
|
|
81
|
+
parentIndex: parentIndexValue,
|
|
82
|
+
parentRoutes: stackRoutes,
|
|
83
|
+
index,
|
|
84
|
+
routes,
|
|
85
|
+
_registerNested,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export { useBlankStackState, BlankStackStateProvider };
|
package/src/blank-stack/types.ts
CHANGED
|
@@ -107,6 +107,10 @@ export type BlankStackOverlayProps = {
|
|
|
107
107
|
* Route object for the current screen.
|
|
108
108
|
*/
|
|
109
109
|
route: Route<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Route object for the currently focused screen in the stack.
|
|
112
|
+
*/
|
|
113
|
+
focusedRoute: Route<string>;
|
|
110
114
|
/**
|
|
111
115
|
* Navigation prop for the overlay.
|
|
112
116
|
*/
|
|
@@ -513,11 +513,13 @@ export function NativeStackView({
|
|
|
513
513
|
return acc;
|
|
514
514
|
}, {});
|
|
515
515
|
|
|
516
|
+
const routes = state.routes.concat(state.preloadedRoutes);
|
|
517
|
+
|
|
516
518
|
return (
|
|
517
519
|
<GestureHandlerRootView>
|
|
518
520
|
<SafeAreaProviderCompat>
|
|
519
521
|
<ScreenStack style={styles.container}>
|
|
520
|
-
{
|
|
522
|
+
{routes.map((route, index) => {
|
|
521
523
|
const descriptor =
|
|
522
524
|
descriptors[route.key] ?? preloadedDescriptors[route.key];
|
|
523
525
|
const isFocused = state.index === index;
|
|
@@ -4,10 +4,11 @@ import type { BlankStackDescriptor } from "../../../blank-stack/types";
|
|
|
4
4
|
import { useStackNavigationContext } from "../../../blank-stack/utils/with-stack-navigation";
|
|
5
5
|
import type { NativeStackDescriptor } from "../../../native-stack/types";
|
|
6
6
|
import { useParentGestureRegistry } from "../../hooks/gestures/use-parent-gesture-registry";
|
|
7
|
+
import { useDerivedValueState } from "../../hooks/use-derived-value-state";
|
|
7
8
|
import useStableCallback from "../../hooks/use-stable-callback";
|
|
9
|
+
import { useGestureContext } from "../../providers/gestures";
|
|
8
10
|
import { useKeys } from "../../providers/keys";
|
|
9
11
|
import { AnimationStore } from "../../stores/animation-store";
|
|
10
|
-
import { NavigatorDismissState } from "../../stores/navigator-dismiss-state";
|
|
11
12
|
import { resetStoresForScreen } from "../../stores/utils/reset-stores-for-screen";
|
|
12
13
|
import { startScreenTransition } from "../../utils/animation/start-screen-transition";
|
|
13
14
|
|
|
@@ -22,19 +23,22 @@ export const NativeStackScreenLifecycleController = ({
|
|
|
22
23
|
children,
|
|
23
24
|
}: ScreenLifecycleProps) => {
|
|
24
25
|
const { current } = useKeys<NativeStackDescriptor>();
|
|
26
|
+
const { parentContext } = useGestureContext();
|
|
27
|
+
|
|
28
|
+
const isParentDismissingViaGesture = useDerivedValueState(() => {
|
|
29
|
+
"worklet";
|
|
30
|
+
return parentContext?.gestureAnimationValues.isDismissing?.value ?? false;
|
|
31
|
+
});
|
|
25
32
|
|
|
26
33
|
const animations = AnimationStore.getAll(current.route.key);
|
|
27
34
|
|
|
28
35
|
const handleBeforeRemove = useStableCallback((e: any) => {
|
|
29
|
-
const key = current.navigation.getParent()?.getState().key;
|
|
30
|
-
const requestedDismissOnNavigator = NavigatorDismissState.get(key);
|
|
31
|
-
|
|
32
36
|
const isEnabled = current.options.enableTransitions;
|
|
33
|
-
|
|
37
|
+
|
|
34
38
|
const isFirstScreen = current.navigation.getState().index === 0;
|
|
35
39
|
|
|
36
40
|
// If transitions are disabled, or the dismissal was on the local root, or this is the first screen of the stack, reset the stores
|
|
37
|
-
if (!isEnabled ||
|
|
41
|
+
if (!isEnabled || isParentDismissingViaGesture || isFirstScreen) {
|
|
38
42
|
resetStoresForScreen(current);
|
|
39
43
|
return;
|
|
40
44
|
}
|
|
@@ -105,6 +109,10 @@ export const BlankStackScreenLifecycleController = ({
|
|
|
105
109
|
});
|
|
106
110
|
});
|
|
107
111
|
|
|
112
|
+
const handleCleanup = useStableCallback(() => {
|
|
113
|
+
resetStoresForScreen(current);
|
|
114
|
+
});
|
|
115
|
+
|
|
108
116
|
const handleCloseEnd = useStableCallback((finished: boolean) => {
|
|
109
117
|
if (!finished) {
|
|
110
118
|
return;
|
|
@@ -130,7 +138,12 @@ export const BlankStackScreenLifecycleController = ({
|
|
|
130
138
|
},
|
|
131
139
|
);
|
|
132
140
|
|
|
133
|
-
useLayoutEffect(
|
|
141
|
+
useLayoutEffect(() => {
|
|
142
|
+
handleInitialize();
|
|
143
|
+
return () => {
|
|
144
|
+
handleCleanup();
|
|
145
|
+
};
|
|
146
|
+
}, [handleInitialize, handleCleanup]);
|
|
134
147
|
|
|
135
148
|
// important for t.a scrollviews inside nested navigators.
|
|
136
149
|
useParentGestureRegistry();
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
NO_BOUNDS_MAP,
|
|
10
10
|
} from "../../constants";
|
|
11
11
|
import { type TransitionDescriptor, useKeys } from "../../providers/keys";
|
|
12
|
+
|
|
12
13
|
import { AnimationStore } from "../../stores/animation-store";
|
|
13
14
|
import { BoundStore } from "../../stores/bound-store";
|
|
14
15
|
import { GestureStore, type GestureStoreMap } from "../../stores/gesture-store";
|
|
@@ -121,7 +122,6 @@ export function _useScreenAnimation() {
|
|
|
121
122
|
focused,
|
|
122
123
|
activeBoundId,
|
|
123
124
|
progress,
|
|
124
|
-
|
|
125
125
|
active,
|
|
126
126
|
isActiveTransitioning,
|
|
127
127
|
isDismissing,
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
Fragment,
|
|
4
|
+
useContext,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
} from "react";
|
|
2
9
|
import type { View } from "react-native";
|
|
3
10
|
import {
|
|
4
11
|
type AnimatedRef,
|
|
@@ -132,6 +139,30 @@ export const useBoundsRegistry = ({
|
|
|
132
139
|
);
|
|
133
140
|
}, [IS_ROOT, sharedBoundTag, ROOT_SIGNAL]);
|
|
134
141
|
|
|
142
|
+
const prevNextRef = useRef(next);
|
|
143
|
+
/**
|
|
144
|
+
* Measure non-pressable elements when the screen goes from focused to blurred
|
|
145
|
+
* (or when a new `next` descriptor appears) so we capture final bounds
|
|
146
|
+
* right before the transition starts.
|
|
147
|
+
*/
|
|
148
|
+
useLayoutEffect(() => {
|
|
149
|
+
if (!sharedBoundTag || onPress) return;
|
|
150
|
+
|
|
151
|
+
const hadNext = !!prevNextRef.current;
|
|
152
|
+
const hasNext = !!next;
|
|
153
|
+
|
|
154
|
+
if (!hadNext && hasNext) {
|
|
155
|
+
runOnUI(maybeMeasureAndStore)({});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
prevNextRef.current = next;
|
|
159
|
+
}, [next, sharedBoundTag, onPress, maybeMeasureAndStore]);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Signal child shared elements (nested under this provider) to refresh their
|
|
163
|
+
* measurements when the root updates, while preventing them from marking
|
|
164
|
+
* themselves active during that sync.
|
|
165
|
+
*/
|
|
135
166
|
useAnimatedReaction(
|
|
136
167
|
() => ROOT_MEASUREMENT_SIGNAL?.updateSignal.value,
|
|
137
168
|
(current) => {
|