@applicaster/zapp-react-native-ui-components 13.0.0-alpha.3755455151 → 13.0.0-alpha.3829509172
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/AppContainer/__tests__/AppContainer.test.js +4 -6
- package/Components/AudioPlayer/AudioPlayer.tsx +7 -0
- package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
- package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
- package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
- package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
- package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
- package/Components/AudioPlayer/__tests__/title.test.js +3 -5
- package/Components/AudioPlayer/helpers.tsx +1 -0
- package/Components/BaseFocusable/index.ios.ts +1 -1
- package/Components/BaseFocusable/index.tsx +2 -3
- package/Components/Cell/Cell.tsx +8 -3
- package/Components/Cell/CellWithFocusable.tsx +44 -59
- package/Components/Cell/TvOSCellComponent.tsx +20 -26
- package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
- package/Components/Cell/index.js +3 -1
- package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
- package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
- package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
- package/Components/ErrorScreen/index.tsx +6 -6
- package/Components/Focusable/Focusable.tsx +1 -0
- package/Components/Focusable/FocusableTvOS.tsx +6 -2
- package/Components/Focusable/Touchable.tsx +19 -20
- package/Components/Focusable/index.android.tsx +10 -3
- package/Components/FocusableCell/index.tsx +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
- package/Components/FocusableGroup/index.tsx +0 -3
- package/Components/FocusableList/index.tsx +26 -10
- package/Components/FocusableScrollView/index.tsx +43 -13
- package/Components/HandlePlayable/HandlePlayable.tsx +14 -27
- package/Components/Layout/TV/NavBarContainer.tsx +19 -23
- package/Components/Layout/TV/ScreenContainer.tsx +8 -1
- package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
- package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
- package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
- package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
- package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
- package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
- package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
- package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
- package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
- package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
- package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
- package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
- package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
- package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
- package/Components/MasterCell/utils/index.ts +9 -135
- package/Components/ModalComponent/Button/index.tsx +6 -6
- package/Components/ModalComponent/Header/index.tsx +3 -3
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
- package/Components/PlayerContainer/PlayerContainer.tsx +20 -20
- package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
- package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
- package/Components/PlayerImageBackground/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +42 -65
- package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
- package/Components/River/RiverFooter.tsx +39 -9
- package/Components/River/RiverItem.tsx +37 -2
- package/Components/River/TV/index.tsx +6 -1
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
- package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
- package/Components/River/__tests__/componentsMap.test.js +17 -5
- package/Components/River/__tests__/river.test.js +75 -40
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
- package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
- package/Components/RouteManager/__tests__/testId.test.js +8 -6
- package/Components/Screen/TV/index.web.tsx +5 -6
- package/Components/Screen/hooks.ts +53 -0
- package/Components/Screen/index.tsx +16 -42
- package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
- package/Components/Tabs/Tab.tsx +11 -9
- package/Components/TextInputTv/index.tsx +4 -3
- package/Components/TrackedView/index.tsx +1 -0
- package/Components/Transitioner/AnimationManager.js +15 -15
- package/Components/Transitioner/Scene.tsx +53 -24
- package/Components/Transitioner/Transitioner.tsx +3 -3
- package/Components/Transitioner/__tests__/Scene.test.js +25 -14
- package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -49
- package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
- package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
- package/Components/Transitioner/index.js +8 -4
- package/Components/VideoLive/LiveImageManager.ts +27 -1
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +51 -1
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -5
- package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
- package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +49 -31
- package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +8 -4
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +32 -18
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -5
- package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
- package/Components/VideoModal/OpaqueLayer.tsx +33 -0
- package/Components/VideoModal/PlayerDetails.tsx +9 -6
- package/Components/VideoModal/PlayerWrapper.tsx +17 -36
- package/Components/VideoModal/VideoModal.tsx +16 -25
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -1
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +0 -90
- package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
- package/Components/VideoModal/hooks/index.ts +7 -0
- package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
- package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
- package/Components/VideoModal/hooks/utils/index.ts +33 -0
- package/Components/VideoModal/utils.ts +1 -1
- package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
- package/Components/Viewport/__tests__/utils.test.js +5 -4
- package/Components/ZappUIComponent/Placeholder.tsx +3 -1
- package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
- package/Components/ZappUIComponent/index.tsx +3 -16
- package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
- package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
- package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
- package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
- package/Contexts/HeaderOffsetContext/index.tsx +4 -6
- package/Contexts/ScreenContext/index.tsx +6 -12
- package/Contexts/ScreenLayoutContext/index.tsx +5 -3
- package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
- package/Decorators/Navigator/index.tsx +1 -1
- package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
- package/Decorators/RiverResolver/index.tsx +6 -8
- package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
- package/Decorators/ZappPipesDataConnector/index.tsx +6 -2
- package/package.json +7 -12
- package/tsconfig.json +2 -3
- package/.babelrc +0 -8
- package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
- package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
- package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
- package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
- package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
- package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
- package/Decorators/Navigator/__tests__/react-router-native-mock.js +0 -11
- package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import { StyleSheet,
|
|
2
|
+
import { equals } from "ramda";
|
|
3
|
+
import { StyleSheet, StatusBar } from "react-native";
|
|
4
4
|
|
|
5
5
|
import { HandlePlayable } from "@applicaster/zapp-react-native-ui-components/Components/HandlePlayable";
|
|
6
6
|
import {
|
|
@@ -17,17 +17,20 @@ import {
|
|
|
17
17
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
|
|
18
18
|
|
|
19
19
|
import { withModalNavigationContextProvider } from "../../Contexts/ModalNavigationContext";
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import {
|
|
21
|
+
useModalSize,
|
|
22
|
+
useBackgroundColor,
|
|
23
|
+
useInitialPlayerState,
|
|
24
|
+
} from "./hooks";
|
|
25
|
+
|
|
23
26
|
import { APP_EVENTS } from "@applicaster/zapp-react-native-utils/appUtils/events";
|
|
24
|
-
import { Spinner } from "../Spinner";
|
|
25
27
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
26
28
|
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
27
29
|
import { useSubscriberFor } from "@applicaster/zapp-react-native-utils/reactHooks/useSubscriberFor";
|
|
28
30
|
import { requiresAuthentication } from "@applicaster/zapp-react-native-utils/configurationUtils";
|
|
29
31
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
30
32
|
import { ScreenContextProvider } from "../../Contexts/ScreenContext";
|
|
33
|
+
import { OpaqueLayer } from "./OpaqueLayer";
|
|
31
34
|
|
|
32
35
|
import { AnimatedPlayerModalWrapper } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
33
36
|
|
|
@@ -39,17 +42,6 @@ const styles = StyleSheet.create({
|
|
|
39
42
|
bottom: 0,
|
|
40
43
|
position: "absolute",
|
|
41
44
|
},
|
|
42
|
-
// eslint-disable-next-line react-native/no-color-literals
|
|
43
|
-
loaderContainer: {
|
|
44
|
-
top: 0,
|
|
45
|
-
left: 0,
|
|
46
|
-
right: 0,
|
|
47
|
-
bottom: 0,
|
|
48
|
-
position: "absolute",
|
|
49
|
-
alignItems: "center",
|
|
50
|
-
justifyContent: "center",
|
|
51
|
-
backgroundColor: "rgba(64,64,64,.5)",
|
|
52
|
-
},
|
|
53
45
|
});
|
|
54
46
|
|
|
55
47
|
const VideoModalComponent = () => {
|
|
@@ -100,7 +92,7 @@ const VideoModalComponent = () => {
|
|
|
100
92
|
|
|
101
93
|
const onHooksSuccess = ({ payload }) => {
|
|
102
94
|
// set new modified entry
|
|
103
|
-
if (!
|
|
95
|
+
if (!equals(payload, item)) {
|
|
104
96
|
onVideoModalHookSuccessAnalyticsEvent();
|
|
105
97
|
setVideoModalItem(payload);
|
|
106
98
|
}
|
|
@@ -136,27 +128,26 @@ const VideoModalComponent = () => {
|
|
|
136
128
|
|
|
137
129
|
<PathnameContext.Provider value={pathname}>
|
|
138
130
|
<ScreenContextProvider pathname={pathname}>
|
|
139
|
-
{
|
|
131
|
+
{/* Hide content underneath when we switch to next video in fullscreen mode */}
|
|
132
|
+
{mode === "FULLSCREEN" && <OpaqueLayer />}
|
|
133
|
+
|
|
134
|
+
{itemIdHooksFinished === item?.id && (
|
|
140
135
|
<AnimatedPlayerModalWrapper
|
|
141
136
|
style={[
|
|
142
137
|
styles.container,
|
|
143
138
|
{
|
|
144
139
|
backgroundColor,
|
|
140
|
+
width: modalSize.width,
|
|
141
|
+
height: modalSize.height,
|
|
145
142
|
},
|
|
146
143
|
]}
|
|
147
144
|
>
|
|
148
145
|
<HandlePlayable
|
|
149
146
|
item={item}
|
|
150
147
|
isModal={mode !== "PIP"}
|
|
151
|
-
modalHeight={modalSize.height}
|
|
152
|
-
modalWidth={modalSize.width}
|
|
153
148
|
mode={mode}
|
|
154
149
|
/>
|
|
155
150
|
</AnimatedPlayerModalWrapper>
|
|
156
|
-
) : (
|
|
157
|
-
<View style={styles.loaderContainer}>
|
|
158
|
-
<Spinner />
|
|
159
|
-
</View>
|
|
160
151
|
)}
|
|
161
152
|
</ScreenContextProvider>
|
|
162
153
|
</PathnameContext.Provider>
|
|
@@ -62,7 +62,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
62
62
|
})),
|
|
63
63
|
}));
|
|
64
64
|
|
|
65
|
-
jest.mock("../utils", () => ({
|
|
65
|
+
jest.mock("../utils", () => ({ playerDimensionsHack: {} }));
|
|
66
66
|
|
|
67
67
|
const { PlayerWrapper } = require("../PlayerWrapper");
|
|
68
68
|
|
|
@@ -71,36 +71,6 @@ exports[`PlayerWrapper renders inline 1`] = `
|
|
|
71
71
|
}
|
|
72
72
|
testID="test-player-container"
|
|
73
73
|
/>
|
|
74
|
-
<View
|
|
75
|
-
animationType="componentFade"
|
|
76
|
-
style={
|
|
77
|
-
{
|
|
78
|
-
"flex": 1,
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
>
|
|
82
|
-
<View
|
|
83
|
-
configuration={
|
|
84
|
-
{
|
|
85
|
-
"tablet_landscape_player_container_background_color": "red",
|
|
86
|
-
"tablet_landscape_sidebar_width": "35%",
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
entry={
|
|
90
|
-
{
|
|
91
|
-
"id": "test",
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
isTablet={false}
|
|
95
|
-
isTabletLandscape={false}
|
|
96
|
-
style={
|
|
97
|
-
{
|
|
98
|
-
"flex": 1,
|
|
99
|
-
"paddingTop": 20,
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/>
|
|
103
|
-
</View>
|
|
104
74
|
</View>
|
|
105
75
|
</RNCSafeAreaView>
|
|
106
76
|
</RNCSafeAreaProvider>
|
|
@@ -177,36 +147,6 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
|
177
147
|
}
|
|
178
148
|
testID="test-player-container"
|
|
179
149
|
/>
|
|
180
|
-
<View
|
|
181
|
-
animationType="componentFade"
|
|
182
|
-
style={
|
|
183
|
-
{
|
|
184
|
-
"flex": 1,
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
>
|
|
188
|
-
<View
|
|
189
|
-
configuration={
|
|
190
|
-
{
|
|
191
|
-
"tablet_landscape_player_container_background_color": "red",
|
|
192
|
-
"tablet_landscape_sidebar_width": "35%",
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
entry={
|
|
196
|
-
{
|
|
197
|
-
"id": "test",
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
isTablet={false}
|
|
201
|
-
isTabletLandscape={false}
|
|
202
|
-
style={
|
|
203
|
-
{
|
|
204
|
-
"flex": 1,
|
|
205
|
-
"paddingTop": 20,
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
/>
|
|
209
|
-
</View>
|
|
210
150
|
</View>
|
|
211
151
|
</RNCSafeAreaView>
|
|
212
152
|
</RNCSafeAreaProvider>
|
|
@@ -299,36 +239,6 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
|
|
|
299
239
|
}
|
|
300
240
|
/>
|
|
301
241
|
</View>
|
|
302
|
-
<View
|
|
303
|
-
animationType="componentFade"
|
|
304
|
-
style={
|
|
305
|
-
{
|
|
306
|
-
"flex": 1,
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
>
|
|
310
|
-
<View
|
|
311
|
-
configuration={
|
|
312
|
-
{
|
|
313
|
-
"tablet_landscape_player_container_background_color": "red",
|
|
314
|
-
"tablet_landscape_sidebar_width": "35%",
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
entry={
|
|
318
|
-
{
|
|
319
|
-
"id": "test",
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
isTablet={true}
|
|
323
|
-
isTabletLandscape={true}
|
|
324
|
-
style={
|
|
325
|
-
{
|
|
326
|
-
"flex": 1,
|
|
327
|
-
"paddingTop": 20,
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
/>
|
|
331
|
-
</View>
|
|
332
242
|
</View>
|
|
333
243
|
</RNCSafeAreaView>
|
|
334
244
|
</RNCSafeAreaProvider>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react-hooks";
|
|
2
|
+
import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
|
|
3
|
+
import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
|
|
4
|
+
import { showDetails } from "../utils";
|
|
5
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
|
+
|
|
7
|
+
jest.mock("@applicaster/zapp-react-native-utils/idleUtils", () => ({
|
|
8
|
+
withTimeout$: jest.fn(),
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
jest.mock("../utils", () => ({
|
|
12
|
+
showDetails: jest.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
16
|
+
useIsTablet: jest.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
describe("useDelayedPlayerDetails", () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should return false initially", () => {
|
|
25
|
+
(withTimeout$ as jest.Mock).mockReturnValue({
|
|
26
|
+
subscribe: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const { result } = renderHook(() =>
|
|
30
|
+
useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(result.current).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should return true if showDetails returns true", () => {
|
|
37
|
+
(withTimeout$ as jest.Mock).mockReturnValue({
|
|
38
|
+
subscribe: (callback) => {
|
|
39
|
+
callback.next();
|
|
40
|
+
|
|
41
|
+
return { unsubscribe: jest.fn() };
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
(showDetails as jest.Mock).mockReturnValue(true);
|
|
46
|
+
(useIsTablet as jest.Mock).mockReturnValue(false);
|
|
47
|
+
|
|
48
|
+
const { result } = renderHook(() =>
|
|
49
|
+
useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
expect(result.current).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("should return false if showDetails returns false", () => {
|
|
56
|
+
(withTimeout$ as jest.Mock).mockReturnValue({
|
|
57
|
+
subscribe: (callback) => {
|
|
58
|
+
callback.next();
|
|
59
|
+
|
|
60
|
+
return { unsubscribe: jest.fn() };
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
(showDetails as jest.Mock).mockReturnValue(false);
|
|
65
|
+
(useIsTablet as jest.Mock).mockReturnValue(false);
|
|
66
|
+
|
|
67
|
+
const { result } = renderHook(() =>
|
|
68
|
+
useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(result.current).toBe(false);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should unsubscribe on unmount", () => {
|
|
75
|
+
const unsubscribeMock = jest.fn();
|
|
76
|
+
|
|
77
|
+
(withTimeout$ as jest.Mock).mockReturnValue({
|
|
78
|
+
subscribe: jest.fn().mockReturnValue({ unsubscribe: unsubscribeMock }),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const { unmount } = renderHook(() =>
|
|
82
|
+
useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
unmount();
|
|
86
|
+
|
|
87
|
+
expect(unsubscribeMock).toHaveBeenCalled();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
3
|
+
import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
|
|
4
|
+
|
|
5
|
+
import { showDetails } from "./utils";
|
|
6
|
+
|
|
7
|
+
const TIMEOUT = 100; // ms
|
|
8
|
+
|
|
9
|
+
type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Custom hook to determine whether to show player details with a delay.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} params - The parameters object.
|
|
15
|
+
* @param {boolean} params.isInline - Indicates if the player is inline.
|
|
16
|
+
* @param {boolean} params.isDocked - Indicates if the player is docked.
|
|
17
|
+
* @param {boolean} params.isPip - Indicates if the player is in PIP mode.
|
|
18
|
+
* @returns {boolean} - Returns true if player details should be shown, otherwise false.
|
|
19
|
+
*/
|
|
20
|
+
export const useDelayedPlayerDetails = ({
|
|
21
|
+
isInline,
|
|
22
|
+
isDocked,
|
|
23
|
+
isPip,
|
|
24
|
+
}: Props): boolean => {
|
|
25
|
+
const [shouldShowDetails, setShouldShowDetails] = React.useState(false);
|
|
26
|
+
|
|
27
|
+
const isTablet = useIsTablet();
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
const subscription = withTimeout$(TIMEOUT).subscribe({
|
|
31
|
+
next: () => {
|
|
32
|
+
setShouldShowDetails(() => {
|
|
33
|
+
return showDetails({
|
|
34
|
+
isMobile: !isTablet,
|
|
35
|
+
isInline,
|
|
36
|
+
isDocked,
|
|
37
|
+
isPip,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
subscription.unsubscribe();
|
|
45
|
+
};
|
|
46
|
+
}, [isDocked, isTablet, isInline, isPip]);
|
|
47
|
+
|
|
48
|
+
return shouldShowDetails;
|
|
49
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { showDetails } from "..";
|
|
2
|
+
|
|
3
|
+
describe("showDetails", () => {
|
|
4
|
+
it("should return false if isPip is true", () => {
|
|
5
|
+
const result = showDetails({
|
|
6
|
+
isMobile: true,
|
|
7
|
+
isInline: true,
|
|
8
|
+
isDocked: false,
|
|
9
|
+
isPip: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
expect(result).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should return false if isDocked is true", () => {
|
|
16
|
+
const result = showDetails({
|
|
17
|
+
isMobile: true,
|
|
18
|
+
isInline: true,
|
|
19
|
+
isDocked: true,
|
|
20
|
+
isPip: false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
expect(result).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should return true if isMobile is true and isInline is true", () => {
|
|
27
|
+
const result = showDetails({
|
|
28
|
+
isMobile: true,
|
|
29
|
+
isInline: true,
|
|
30
|
+
isDocked: false,
|
|
31
|
+
isPip: false,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(result).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should return false if isMobile is true and isInline is false", () => {
|
|
38
|
+
const result = showDetails({
|
|
39
|
+
isMobile: true,
|
|
40
|
+
isInline: false,
|
|
41
|
+
isDocked: false,
|
|
42
|
+
isPip: false,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(result).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should return true if isMobile is false", () => {
|
|
49
|
+
const result = showDetails({
|
|
50
|
+
isMobile: false,
|
|
51
|
+
isInline: true,
|
|
52
|
+
isDocked: false,
|
|
53
|
+
isPip: false,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(result).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("should return true if isMobile is false and isInline is false", () => {
|
|
60
|
+
const result = showDetails({
|
|
61
|
+
isMobile: false,
|
|
62
|
+
isInline: false,
|
|
63
|
+
isDocked: false,
|
|
64
|
+
isPip: false,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(result).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("should return false if all properties are false except isMobile", () => {
|
|
71
|
+
const result = showDetails({
|
|
72
|
+
isMobile: true,
|
|
73
|
+
isInline: false,
|
|
74
|
+
isDocked: false,
|
|
75
|
+
isPip: false,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(result).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("should return true if all properties are false except isInline", () => {
|
|
82
|
+
const result = showDetails({
|
|
83
|
+
isMobile: false,
|
|
84
|
+
isInline: true,
|
|
85
|
+
isDocked: false,
|
|
86
|
+
isPip: false,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(result).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -35,3 +35,36 @@ export const orientationWasChangedFromPortraitToLandscape = ({
|
|
|
35
35
|
isOrientationLandscape(toOrientation)
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
|
+
|
|
39
|
+
export const showDetails = ({
|
|
40
|
+
isMobile,
|
|
41
|
+
isInline,
|
|
42
|
+
isDocked,
|
|
43
|
+
isPip,
|
|
44
|
+
}: {
|
|
45
|
+
isMobile: boolean;
|
|
46
|
+
isInline: boolean;
|
|
47
|
+
isDocked: boolean;
|
|
48
|
+
isPip: boolean;
|
|
49
|
+
}): boolean => {
|
|
50
|
+
if (isPip) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (isDocked) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// for mobile with inline mode(rotation is portrait) we always show details.
|
|
59
|
+
if (isMobile && isInline) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// for mobile with landscape rotation(player is fullscreen) we always hide details. Mounting of it is very heavy operation.
|
|
64
|
+
if (isMobile && !isInline) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// for tablets we always show details
|
|
69
|
+
return true;
|
|
70
|
+
};
|
package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap
CHANGED
|
@@ -33,45 +33,33 @@ exports[`<ViewportAware /> invokes the onViewportLeave function when leaving the
|
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
35
|
exports[`<ViewportAware /> passes the correct view port flag 1`] = `
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
<RCTScrollView
|
|
37
|
+
onContentSizeChange={[Function]}
|
|
38
|
+
onLayout={[Function]}
|
|
39
|
+
onScroll={[Function]}
|
|
40
40
|
>
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
<View>
|
|
42
|
+
<RCTScrollView
|
|
43
|
+
testID="test-component-false"
|
|
44
|
+
>
|
|
45
|
+
<View />
|
|
46
|
+
</RCTScrollView>
|
|
47
|
+
</View>
|
|
48
|
+
</RCTScrollView>
|
|
45
49
|
`;
|
|
46
50
|
|
|
47
51
|
exports[`<ViewportAware /> renders its children correctly 1`] = `
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"lastEvent": null,
|
|
53
|
-
"listeners": [],
|
|
54
|
-
"notify": [Function],
|
|
55
|
-
}
|
|
56
|
-
}
|
|
52
|
+
<RCTScrollView
|
|
53
|
+
onContentSizeChange={[Function]}
|
|
54
|
+
onLayout={[Function]}
|
|
55
|
+
onScroll={[Function]}
|
|
57
56
|
>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
>
|
|
68
|
-
<ScrollView>
|
|
69
|
-
<TestComponent
|
|
70
|
-
onViewportEnter={[MockFunction]}
|
|
71
|
-
onViewportLeave={[MockFunction]}
|
|
72
|
-
preTriggerRatio={0.1}
|
|
73
|
-
/>
|
|
74
|
-
</ScrollView>
|
|
75
|
-
</ViewportTracker>
|
|
76
|
-
</ContextProvider>
|
|
57
|
+
<View>
|
|
58
|
+
<RCTScrollView
|
|
59
|
+
testID="test-component-false"
|
|
60
|
+
>
|
|
61
|
+
<View />
|
|
62
|
+
</RCTScrollView>
|
|
63
|
+
</View>
|
|
64
|
+
</RCTScrollView>
|
|
77
65
|
`;
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
5
|
+
import { act, create as render } from "react-test-renderer";
|
|
6
|
+
|
|
7
|
+
import { ViewportAware } from "../";
|
|
8
|
+
import { ViewportTracker } from "../../ViewportTracker";
|
|
8
9
|
|
|
9
10
|
import { ViewportEvents } from "../../ViewportEvents";
|
|
11
|
+
import ReactNative from "react-native";
|
|
10
12
|
|
|
11
13
|
jest.useFakeTimers();
|
|
12
14
|
|
|
@@ -24,17 +26,10 @@ jest.mock("react-native/Libraries/Renderer/shims/ReactNative", () => ({
|
|
|
24
26
|
findNodeHandle: () => 1234,
|
|
25
27
|
}));
|
|
26
28
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const { Animated, ScrollView } = ReactNative;
|
|
30
|
-
|
|
31
|
-
Animated.timing = jest.fn(() => ({ start: jest.fn() }));
|
|
29
|
+
const { ScrollView } = ReactNative;
|
|
32
30
|
|
|
33
31
|
const viewportEventsManager = new ViewportEvents(true);
|
|
34
32
|
|
|
35
|
-
const { ViewportAware } = require("../");
|
|
36
|
-
const { ViewportTracker } = require("../../ViewportTracker");
|
|
37
|
-
|
|
38
33
|
const TestComponent = (props) => {
|
|
39
34
|
const {
|
|
40
35
|
preTriggerRatio,
|
|
@@ -90,7 +85,7 @@ describe("<ViewportAware />", () => {
|
|
|
90
85
|
});
|
|
91
86
|
|
|
92
87
|
it("renders its children correctly", () => {
|
|
93
|
-
const wrapper =
|
|
88
|
+
const wrapper = render(
|
|
94
89
|
getWrapper(() => (
|
|
95
90
|
<TestComponent
|
|
96
91
|
preTriggerRatio={0.1}
|
|
@@ -100,11 +95,11 @@ describe("<ViewportAware />", () => {
|
|
|
100
95
|
))
|
|
101
96
|
);
|
|
102
97
|
|
|
103
|
-
expect(
|
|
98
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
104
99
|
});
|
|
105
100
|
|
|
106
101
|
it("passes the correct view port flag", () => {
|
|
107
|
-
const wrapper =
|
|
102
|
+
const wrapper = render(
|
|
108
103
|
getWrapper(() => (
|
|
109
104
|
<TestComponent
|
|
110
105
|
preTriggerRatio={0.1}
|
|
@@ -114,12 +109,11 @@ describe("<ViewportAware />", () => {
|
|
|
114
109
|
))
|
|
115
110
|
);
|
|
116
111
|
|
|
117
|
-
|
|
118
|
-
expect(shallowToJson(testComponentWrapper.shallow())).toMatchSnapshot();
|
|
112
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
119
113
|
});
|
|
120
114
|
|
|
121
115
|
it("invokes the onViewportEnter function when entering the viewport", () => {
|
|
122
|
-
const wrapper =
|
|
116
|
+
const wrapper = render(
|
|
123
117
|
getWrapper(() => (
|
|
124
118
|
<TestComponent
|
|
125
119
|
preTriggerRatio={0.1}
|
|
@@ -156,7 +150,7 @@ describe("<ViewportAware />", () => {
|
|
|
156
150
|
});
|
|
157
151
|
|
|
158
152
|
it("invokes the onViewportLeave function when leaving the viewport", () => {
|
|
159
|
-
const wrapper =
|
|
153
|
+
const wrapper = render(
|
|
160
154
|
getWrapper(() => (
|
|
161
155
|
<TestComponent
|
|
162
156
|
preTriggerRatio={0.1}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
|
-
import {
|
|
4
|
+
import { render } from "@testing-library/react-native";
|
|
5
5
|
import { callOnChildren, isInViewport } from "../utils";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// IDK what this is doing
|
|
8
|
+
describe.skip("callOnChildren", () => {
|
|
8
9
|
const arg1 = "arg1";
|
|
9
10
|
const arg2 = "arg2";
|
|
10
11
|
|
|
@@ -28,7 +29,7 @@ describe("callOnChildren", () => {
|
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
it("calls the method on the child component's props if it exists", () => {
|
|
31
|
-
|
|
32
|
+
render(
|
|
32
33
|
<TestComponent
|
|
33
34
|
isMounted={() => {
|
|
34
35
|
expect(testMethod).toHaveBeenCalledWith(arg1, arg2);
|
|
@@ -40,7 +41,7 @@ describe("callOnChildren", () => {
|
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
it("fails silently if the child component doesn't have any prop", () => {
|
|
43
|
-
|
|
44
|
+
render(
|
|
44
45
|
<TestComponent
|
|
45
46
|
isMounted={() => {
|
|
46
47
|
expect(testMethod).not.toHaveBeenCalled();
|
|
@@ -30,5 +30,7 @@ export const Placeholder = ({ readyToBeDisplayed }: Props) => {
|
|
|
30
30
|
|
|
31
31
|
if (readyToBeDisplayed && !isTV()) return null;
|
|
32
32
|
|
|
33
|
-
return
|
|
33
|
+
return (
|
|
34
|
+
<View testID="ZappUIComponent-placeholder" style={styles.placeholder} />
|
|
35
|
+
);
|
|
34
36
|
};
|