@applicaster/zapp-react-native-ui-components 17.0.0-rc.5 → 17.0.0-rc.6
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/Components/Screen/TV/hooks/__tests__/useResetScreenRevealManager.test.ts +29 -0
- package/Components/Screen/TV/hooks/index.ts +2 -0
- package/Components/Screen/TV/hooks/useResetScreenRevealManager.ts +14 -0
- package/Components/Screen/TV/index.web.tsx +7 -1
- package/Components/ScreenRevealManager/utils/__tests__/index.test.ts +50 -0
- package/Components/ScreenRevealManager/utils/index.ts +10 -1
- package/package.json +5 -5
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react-native";
|
|
2
|
+
|
|
3
|
+
import { useResetScreenRevealManager } from "../useResetScreenRevealManager";
|
|
4
|
+
|
|
5
|
+
const mockResetScreenRevealManagerSubject = jest.fn();
|
|
6
|
+
|
|
7
|
+
jest.mock(
|
|
8
|
+
"@applicaster/zapp-react-native-ui-components/Components/ScreenRevealManager/utils",
|
|
9
|
+
() => ({
|
|
10
|
+
resetScreenRevealManagerSubject: () =>
|
|
11
|
+
mockResetScreenRevealManagerSubject(),
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
describe("useResetScreenRevealManager", () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
mockResetScreenRevealManagerSubject.mockClear();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("recreates the reveal subject once per screen mount", () => {
|
|
21
|
+
const { rerender } = renderHook(() => useResetScreenRevealManager());
|
|
22
|
+
|
|
23
|
+
expect(mockResetScreenRevealManagerSubject).toHaveBeenCalledTimes(1);
|
|
24
|
+
|
|
25
|
+
rerender();
|
|
26
|
+
|
|
27
|
+
expect(mockResetScreenRevealManagerSubject).toHaveBeenCalledTimes(1);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { resetScreenRevealManagerSubject } from "@applicaster/zapp-react-native-ui-components/Components/ScreenRevealManager/utils";
|
|
4
|
+
|
|
5
|
+
// Once per screen mount, before useInitialFocus subscribes. A later reset
|
|
6
|
+
// would drop a transition already emitted for this screen.
|
|
7
|
+
export const useResetScreenRevealManager = (): void => {
|
|
8
|
+
const hasResetScreenReveal = React.useRef(false);
|
|
9
|
+
|
|
10
|
+
if (!hasResetScreenReveal.current) {
|
|
11
|
+
hasResetScreenReveal.current = true;
|
|
12
|
+
resetScreenRevealManagerSubject();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -21,7 +21,11 @@ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/he
|
|
|
21
21
|
|
|
22
22
|
import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
|
|
23
23
|
import { ScreenResolver } from "../../ScreenResolver";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
useInitialFocus,
|
|
26
|
+
useAfterPaint,
|
|
27
|
+
useResetScreenRevealManager,
|
|
28
|
+
} from "./hooks";
|
|
25
29
|
import { isPlayerPlugin } from "@applicaster/zapp-react-native-utils/pluginUtils";
|
|
26
30
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
27
31
|
import { FreezeWithCallback } from "../../FreezeWithCallback";
|
|
@@ -113,6 +117,8 @@ export const Screen = ({ route, Components }: Props) => {
|
|
|
113
117
|
|
|
114
118
|
const backgroundColor = useScreenBackgroundColor(screenId);
|
|
115
119
|
|
|
120
|
+
useResetScreenRevealManager();
|
|
121
|
+
|
|
116
122
|
useInitialFocus();
|
|
117
123
|
|
|
118
124
|
const activeRiver = getActiveRiver({
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
emitScreenRevealManagerIsNotReadyToShow,
|
|
3
|
+
emitScreenRevealManagerIsReadyToShow,
|
|
4
|
+
resetScreenRevealManagerSubject,
|
|
5
|
+
waitUntilScreenRevealManagerIsReady,
|
|
6
|
+
} from "../index";
|
|
7
|
+
|
|
8
|
+
const emitReadyTransition = () => {
|
|
9
|
+
emitScreenRevealManagerIsNotReadyToShow();
|
|
10
|
+
emitScreenRevealManagerIsReadyToShow();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe("screenRevealManagerSubject", () => {
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
resetScreenRevealManagerSubject();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("replays a ready transition to a subscriber that arrives after it", () => {
|
|
19
|
+
emitReadyTransition();
|
|
20
|
+
|
|
21
|
+
let emitted = false;
|
|
22
|
+
|
|
23
|
+
const subscription = waitUntilScreenRevealManagerIsReady().subscribe(() => {
|
|
24
|
+
emitted = true;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(emitted).toBe(true);
|
|
28
|
+
|
|
29
|
+
subscription.unsubscribe();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("does not replay the previous screen transition after the subject is recreated", () => {
|
|
33
|
+
emitReadyTransition();
|
|
34
|
+
resetScreenRevealManagerSubject();
|
|
35
|
+
|
|
36
|
+
let emitted = false;
|
|
37
|
+
|
|
38
|
+
const subscription = waitUntilScreenRevealManagerIsReady().subscribe(() => {
|
|
39
|
+
emitted = true;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(emitted).toBe(false);
|
|
43
|
+
|
|
44
|
+
emitReadyTransition();
|
|
45
|
+
|
|
46
|
+
expect(emitted).toBe(true);
|
|
47
|
+
|
|
48
|
+
subscription.unsubscribe();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -2,7 +2,16 @@ import { ReplaySubject } from "rxjs";
|
|
|
2
2
|
import { pairwise, filter, first } from "rxjs/operators";
|
|
3
3
|
|
|
4
4
|
// we are interested in last 2 events, because we wait transition from <false> to <true>
|
|
5
|
-
|
|
5
|
+
// Replaced on each screen mount. A shared buffer replays the previous
|
|
6
|
+
// screen's false→true pair to the next subscriber, and initial focus fires
|
|
7
|
+
// before that screen has anything to reveal.
|
|
8
|
+
let screenRevealManagerSubject$: ReplaySubject<boolean>;
|
|
9
|
+
|
|
10
|
+
export const resetScreenRevealManagerSubject = () => {
|
|
11
|
+
screenRevealManagerSubject$ = new ReplaySubject<boolean>(2);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
resetScreenRevealManagerSubject();
|
|
6
15
|
|
|
7
16
|
export const emitScreenRevealManagerIsReadyToShow = () => {
|
|
8
17
|
screenRevealManagerSubject$.next(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.6",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "17.0.0-rc.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "17.0.0-rc.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "17.0.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "17.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "17.0.0-rc.6",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "17.0.0-rc.6",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "17.0.0-rc.6",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "17.0.0-rc.6",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"react-native-sortables": "1.7.1",
|