react-native-screen-transitions 3.0.0-beta.0 → 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 +33 -7
- 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 +3 -7
- 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 +33 -7
- 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 +4 -8
- 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 +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 +11 -3
- 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 -8
- 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 +87 -99
- package/src/blank-stack/components/Overlay.tsx +40 -5
- 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 +6 -21
- 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 +11 -2
- 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 +8 -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
|
@@ -1,101 +1,89 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"targets": [
|
|
90
|
-
"commonjs",
|
|
91
|
-
"module",
|
|
92
|
-
[
|
|
93
|
-
"typescript",
|
|
94
|
-
{
|
|
95
|
-
"project": "tsconfig.build.json"
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
]
|
|
99
|
-
},
|
|
100
|
-
"gitHead": "888d4df9936ec0e3b8221bea7cd81115e6301693"
|
|
2
|
+
"name": "react-native-screen-transitions",
|
|
3
|
+
"version": "3.0.0-beta.10",
|
|
4
|
+
"description": "Easy screen transitions for React Native and Expo",
|
|
5
|
+
"author": "Ed",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/eds2002/react-native-screen-transitions.git",
|
|
10
|
+
"directory": "packages/react-native-screen-transitions"
|
|
11
|
+
},
|
|
12
|
+
"main": "lib/commonjs/shared/index.js",
|
|
13
|
+
"module": "lib/module/shared/index.js",
|
|
14
|
+
"types": "lib/typescript/shared/index.d.ts",
|
|
15
|
+
"react-native": "src/shared/index",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"react-native": "./src/shared/index.ts",
|
|
19
|
+
"import": "./lib/module/shared/index.js",
|
|
20
|
+
"require": "./lib/commonjs/shared/index.js",
|
|
21
|
+
"types": "./lib/typescript/shared/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./native-stack": {
|
|
24
|
+
"react-native": "./src/native-stack/index.ts",
|
|
25
|
+
"import": "./lib/module/native-stack/index.js",
|
|
26
|
+
"require": "./lib/commonjs/native-stack/index.js",
|
|
27
|
+
"types": "./lib/typescript/native-stack/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./blank-stack": {
|
|
30
|
+
"react-native": "./src/blank-stack/index.ts",
|
|
31
|
+
"import": "./lib/module/blank-stack/index.js",
|
|
32
|
+
"require": "./lib/commonjs/blank-stack/index.js",
|
|
33
|
+
"types": "./lib/typescript/blank-stack/index.d.ts"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "bob build",
|
|
38
|
+
"lint": "biome check ./src",
|
|
39
|
+
"prepublishOnly": "bun run build"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"react-native",
|
|
43
|
+
"transitions",
|
|
44
|
+
"animation",
|
|
45
|
+
"react-navigation",
|
|
46
|
+
"expo-router",
|
|
47
|
+
"reanimated"
|
|
48
|
+
],
|
|
49
|
+
"files": [
|
|
50
|
+
"lib",
|
|
51
|
+
"src",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@react-navigation/elements": ">=2.0.0",
|
|
57
|
+
"@react-navigation/native": ">=6.0.0",
|
|
58
|
+
"@react-navigation/native-stack": ">=7.0.0",
|
|
59
|
+
"@types/react": "*",
|
|
60
|
+
"@types/react-native": "*",
|
|
61
|
+
"react": "*",
|
|
62
|
+
"react-native": "*",
|
|
63
|
+
"react-native-gesture-handler": ">=2.16.1",
|
|
64
|
+
"react-native-reanimated": ">=3.16.0 || >=4.0.0-",
|
|
65
|
+
"react-native-safe-area-context": "*",
|
|
66
|
+
"react-native-screens": ">=4.4.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@testing-library/react-native": "^13.2.0",
|
|
70
|
+
"@types/react": "~19.1.10",
|
|
71
|
+
"react-native-builder-bob": "0.39.0",
|
|
72
|
+
"typescript": "catalog:"
|
|
73
|
+
},
|
|
74
|
+
"react-native-builder-bob": {
|
|
75
|
+
"source": "src",
|
|
76
|
+
"output": "lib",
|
|
77
|
+
"targets": [
|
|
78
|
+
"commonjs",
|
|
79
|
+
"module",
|
|
80
|
+
[
|
|
81
|
+
"typescript",
|
|
82
|
+
{
|
|
83
|
+
"project": "tsconfig.build.json"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"gitHead": "888d4df9936ec0e3b8221bea7cd81115e6301693"
|
|
101
89
|
}
|
|
@@ -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 {
|
|
@@ -20,7 +21,17 @@ type OverlayHostProps = {
|
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const getActiveFloatOverlay = (scenes: BlankStackScene[], index: number) => {
|
|
23
|
-
|
|
24
|
+
if (scenes.length === 0) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// When navigating back, closing scenes are kept at the top of the local stack
|
|
29
|
+
// while the focused index already points to the destination screen. We need to
|
|
30
|
+
// start scanning from the actual top of the stack so the overlay can animate
|
|
31
|
+
// out together with its closing screen instead of disappearing immediately.
|
|
32
|
+
const startIndex = Math.max(index, scenes.length - 1);
|
|
33
|
+
|
|
34
|
+
for (let i = startIndex; i >= 0; i--) {
|
|
24
35
|
const scene = scenes[i];
|
|
25
36
|
const options = scene?.descriptor?.options;
|
|
26
37
|
|
|
@@ -37,7 +48,30 @@ const OverlayHost = ({ scene, isFloating }: OverlayHostProps) => {
|
|
|
37
48
|
|
|
38
49
|
const OverlayComponent = scene.descriptor.options.overlay;
|
|
39
50
|
|
|
40
|
-
const {
|
|
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]);
|
|
73
|
+
|
|
74
|
+
const screenAnimation = useScreenAnimation();
|
|
41
75
|
|
|
42
76
|
if (!OverlayComponent) {
|
|
43
77
|
return null;
|
|
@@ -45,8 +79,10 @@ const OverlayHost = ({ scene, isFloating }: OverlayHostProps) => {
|
|
|
45
79
|
|
|
46
80
|
const overlayProps: BlankStackOverlayProps = {
|
|
47
81
|
route: scene.route,
|
|
82
|
+
focusedRoute,
|
|
48
83
|
navigation: scene.descriptor.navigation,
|
|
49
|
-
|
|
84
|
+
overlayAnimation,
|
|
85
|
+
screenAnimation,
|
|
50
86
|
focusedIndex: optimisticActiveIndex,
|
|
51
87
|
insets,
|
|
52
88
|
};
|
|
@@ -56,7 +92,7 @@ const OverlayHost = ({ scene, isFloating }: OverlayHostProps) => {
|
|
|
56
92
|
pointerEvents="box-none"
|
|
57
93
|
style={[
|
|
58
94
|
styles.container,
|
|
59
|
-
isFloating ? styles.floating :
|
|
95
|
+
isFloating ? styles.floating : { zIndex: 1 },
|
|
60
96
|
styles.absolute,
|
|
61
97
|
]}
|
|
62
98
|
>
|
|
@@ -97,7 +133,6 @@ const FloatOverlay = () => {
|
|
|
97
133
|
};
|
|
98
134
|
|
|
99
135
|
const ScreenOverlay = () => {
|
|
100
|
-
const { focusedIndex } = useStackNavigationContext();
|
|
101
136
|
const { current } = useKeys<BlankStackDescriptor>();
|
|
102
137
|
|
|
103
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
|
|
|
@@ -23,19 +14,13 @@ import { useStackNavigationContext } from "../utils/with-stack-navigation";
|
|
|
23
14
|
* drive animations that span multiple screens.
|
|
24
15
|
*/
|
|
25
16
|
export const useOverlayAnimation = (): {
|
|
26
|
-
|
|
17
|
+
overlayAnimation: DerivedValue<OverlayInterpolationProps>;
|
|
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 [];
|
|
@@ -86,7 +71,7 @@ export const useOverlayAnimation = (): {
|
|
|
86
71
|
|
|
87
72
|
const insets = useSafeAreaInsets();
|
|
88
73
|
|
|
89
|
-
const
|
|
74
|
+
const overlayAnimation = useDerivedValue<OverlayInterpolationProps>(() => ({
|
|
90
75
|
progress: accumulatedProgress.value,
|
|
91
76
|
layouts: {
|
|
92
77
|
screen,
|
|
@@ -95,7 +80,7 @@ export const useOverlayAnimation = (): {
|
|
|
95
80
|
}));
|
|
96
81
|
|
|
97
82
|
return {
|
|
98
|
-
|
|
83
|
+
overlayAnimation,
|
|
99
84
|
optimisticActiveIndex,
|
|
100
85
|
};
|
|
101
86
|
};
|
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";
|